本文整理汇总了Java中org.spongepowered.api.item.inventory.entity.Hotbar类的典型用法代码示例。如果您正苦于以下问题:Java Hotbar类的具体用法?Java Hotbar怎么用?Java Hotbar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hotbar类属于org.spongepowered.api.item.inventory.entity包,在下文中一共展示了Hotbar类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onItemDrop
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
@Listener
public void onItemDrop(DropItemEvent event, @Root Entity entity) {
if (entity.getType() != EntityTypes.PLAYER)
return;
IActiveCharacter character = characterService.getCharacter(entity.getUniqueId());
if (character.isStub())
return;
if (character.hasOpenInventory()) {
return;
}
Hotbar hotbar = character.getPlayer().getInventory().query(Hotbar.class);
HotbarObject hotbarObject = character.getHotbar()[hotbar.getSelectedSlotIndex()];
if (hotbarObject == HotbarObject.EMPTYHAND_OR_CONSUMABLE) {
return;
}
inventoryService.initializeHotbar(character, hotbar.getSelectedSlotIndex());
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:19,代码来源:InventoryListener.java
示例2: giveItem
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
/**
* Ajouter un item dans l'inventaire du joueur
* @param itemstack L'itemstack
*/
public Optional<ItemStack> giveItem(final ItemStack itemstack) {
InventoryTransactionResult transaction = this.getInventory().query(Hotbar.class).offer(itemstack);
if (!transaction.getRejectedItems().isEmpty()) {
transaction = this.getInventory().query(GridInventory.class).offer(transaction.getRejectedItems().iterator().next().createStack());
if (!transaction.getRejectedItems().isEmpty()) {
return Optional.of(transaction.getRejectedItems().iterator().next().createStack());
}
}
return Optional.empty();
}
开发者ID:EverCraft,项目名称:EverAPI,代码行数:15,代码来源:EPlayer.java
示例3: commandRepairHotBar
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
private CompletableFuture<Boolean> commandRepairHotBar(final EPlayer player) {
UtilsInventory.repair(player.getInventory().query(Hotbar.class));
UtilsInventory.repair(player.getInventory().query(Slot.class));
EEMessages.REPAIR_HOTBAR_PLAYER.sendTo(player);
return CompletableFuture.completedFuture(true);
}
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:8,代码来源:EERepairHotBar.java
示例4: commandRepairAll
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
private CompletableFuture<Boolean> commandRepairAll(final EPlayer player) {
UtilsInventory.repair(player.getInventory().query(Hotbar.class));
UtilsInventory.repair(player.getInventory().query(GridInventory.class));
UtilsInventory.repair(player.getInventory().query(EquipmentInventory.class));
UtilsInventory.repair(player.getInventory().query(Slot.class));
EEMessages.REPAIR_ALL_PLAYER.sendTo(player);
return CompletableFuture.completedFuture(true);
}
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:10,代码来源:EERepairAll.java
示例5: initializeHotbar
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
public void initializeHotbar(IActiveCharacter character) {
if (character.isStub())
return;
Hotbar hotbar = character.getPlayer().getInventory().query(Hotbar.class);
int slot = 0;
for (Inventory inventory : hotbar) {
initializeHotbar(character, slot, null, (Slot) inventory, hotbar);
slot++;
}
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:12,代码来源:InventoryService.java
示例6: changeEquipedWeapon
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
protected void changeEquipedWeapon(IActiveCharacter character, Weapon changeTo) {
unEquipWeapon(character);
int slot = ((Hotbar) character.getPlayer().getInventory().query(Hotbar.class)).getSelectedSlotIndex();
character.setHotbarSlot(slot, changeTo);
changeTo.current = true;
changeTo.setSlot(slot);
character.setMainHand(changeTo);
changeTo.onEquip(character);
damageService.recalculateCharacterWeaponDamage(character, changeTo.getItemType());
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:12,代码来源:InventoryService.java
示例7: startSocketing
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
public void startSocketing(IActiveCharacter character) {
Optional<ItemStack> itemInHand = character.getPlayer().getItemInHand(HandTypes.MAIN_HAND);
if (itemInHand.isPresent()) {
Hotbar h = character.getPlayer().getInventory().query(Hotbar.class);
int selectedSlotIndex = h.getSelectedSlotIndex();
HotbarObject o = character.getHotbar()[selectedSlotIndex];
if (o.getHotbarObjectType() == HotbarObjectTypes.RUNE) {
character.setCurrentRune(selectedSlotIndex);
Gui.sendMessage(character, Localization.SOCKET_HELP);
}
}
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:13,代码来源:InventoryService.java
示例8: onAttack
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
@Listener(order = Order.BEFORE_POST)
public void onAttack(InteractEntityEvent.Primary event) {
if (event.isCancelled())
return;
if (!Utils.isLivingEntity(event.getTargetEntity()))
return;
Optional<Player> first = event.getCause().first(Player.class);
IActiveCharacter character = null;
if (first.isPresent()) {
character = characterService.getCharacter(first.get().getUniqueId());
if (character.isStub())
return;
Hotbar query = first.get().getInventory().query(Hotbar.class);
inventoryService.onLeftClick(character, query.getSelectedSlotIndex());
}
IEntity entity = entityService.get(event.getTargetEntity());
if (entity.getType() == IEntityType.CHARACTER) {
IActiveCharacter target = characterService.getCharacter(event.getTargetEntity().getUniqueId());
if (target.isStub() && !PluginConfig.ALLOW_COMBAT_FOR_CHARACTERLESS_PLAYERS) {
event.setCancelled(true);
return;
}
if (first.isPresent()) {
if (character.getParty() == target.getParty() && !character.getParty().isFriendlyfire()) {
event.setCancelled(true);
}
}
}
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:32,代码来源:BasicListener.java
示例9: onBlockClick
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
@Listener
public void onBlockClick(InteractBlockEvent.Primary event) {
Optional<Player> first = event.getCause().first(Player.class);
if (first.isPresent()) {
Player pl = first.get();
IActiveCharacter character = characterService.getCharacter(pl.getUniqueId());
if (character.isStub())
return;
Hotbar h = pl.getInventory().query(Hotbar.class);
inventoryService.onLeftClick(character, h.getSelectedSlotIndex());
}
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:13,代码来源:BasicListener.java
示例10: onBlockRightClick
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
@Listener
public void onBlockRightClick(InteractBlockEvent.Secondary event, @First(typeFilter = Player.class) Player pl) {
IActiveCharacter character = characterService.getCharacter(pl.getUniqueId());
Optional<ItemStack> itemInHand = pl.getItemInHand(HandTypes.MAIN_HAND);
if (itemInHand.isPresent() && ItemStackUtils.any_armor.contains(itemInHand.get().getItem())) {
event.setCancelled(true); //restrict armor equip on rightclick
return;
}
if (character.isStub())
return;
Hotbar h = pl.getInventory().query(Hotbar.class);
inventoryService.onRightClick(character, h.getSelectedSlotIndex());
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:15,代码来源:BasicListener.java
示例11: applyFromPlayer
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
public void applyFromPlayer(Player player)
{
Inventory playerInventory = player.getInventory();
this.heldItemSlot = ((Hotbar)playerInventory.query(QueryOperationTypes.INVENTORY_TYPE.of(Hotbar.class))).getSelectedSlotIndex();
this.maxHealth = player.get(Keys.MAX_HEALTH).get();
this.health = player.get(Keys.HEALTH).get();
this.foodLevel = player.get(Keys.FOOD_LEVEL).get();
this.saturation = player.get(Keys.SATURATION).get();
this.exhaustion = player.get(Keys.EXHAUSTION).get();
this.exp = player.get(Keys.TOTAL_EXPERIENCE).get();
this.fireTicks = player.get(Keys.FIRE_TICKS).orElse(0);
this.activePotionEffects = player.get(Keys.POTION_EFFECTS).orElse(emptyList());
this.inventory = new HashMap<>();
int i = 0;
for (Inventory slot : playerInventory.slots())
{
Optional<ItemStack> item = slot.peek();
if (item.isPresent())
{
this.inventory.put(i, item.get());
}
i++;
}
this.enderChest = new HashMap<>();
/* TODO EnderChest
i = 0;
for (Inventory slot : player.getEnderChest().slots())
{
Optional<ItemStack> item = slot.peek();
if (item.isPresent())
{
this.enderChest.put(i, item.get());
}
i++;
}
*/
this.gameMode = player.get(Keys.GAME_MODE).get();
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:41,代码来源:PlayerData.java
示例12: getItemInHand
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
@Override
public ItemStack getItemInHand() {
Hotbar hotbar = this.getHandle().getHotbar();
Optional<Slot> slot = hotbar.getSlot(new SlotIndex(hotbar.getSelectedSlotIndex()));
if (slot.isPresent()) {
Optional<org.spongepowered.api.item.inventory.ItemStack> stack = slot.get().peek();
if (stack.isPresent()) {
return ItemStackConverter.of(stack.get());
}
}
return null;
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:13,代码来源:PorePlayerInventory.java
示例13: setItemInHand
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
@Override
public void setItemInHand(ItemStack stack) {
Hotbar hotbar = this.getHandle().getHotbar();
Optional<Slot> slot = hotbar.getSlot(new SlotIndex(hotbar.getSelectedSlotIndex()));
if (slot.isPresent()) {
slot.get().set(ItemStackConverter.of(stack));
}
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:9,代码来源:PorePlayerInventory.java
示例14: getHotbar
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
private static Hotbar getHotbar(Player player) {
return ((PlayerInventory) player.getInventory()).getHotbar();
}
开发者ID:AuraDevelopmentTeam,项目名称:InvSync,代码行数:4,代码来源:PlayerSerializer.java
示例15: updateSelectedHotbarSlot
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
@Override
public void updateSelectedHotbarSlot() {
Hotbar hotbar = getPlayer().getInventory().query(Hotbar.class);
selected = hotbar.getSelectedSlotIndex();
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:6,代码来源:ActiveCharacter.java
示例16: applyToPlayer
import org.spongepowered.api.item.inventory.entity.Hotbar; //导入依赖的package包/类
public void applyToPlayer(Player player)
{
Inventory inv = player.getInventory();
((Hotbar)inv.query(QueryOperationTypes.INVENTORY_TYPE.of(Hotbar.class))).setSelectedSlotIndex(heldItemSlot);
player.offer(Keys.MAX_HEALTH, maxHealth);
player.offer(Keys.HEALTH, health);
player.offer(Keys.FOOD_LEVEL, foodLevel);
player.offer(Keys.SATURATION, saturation);
player.offer(Keys.EXHAUSTION, exhaustion);
player.offer(Keys.TOTAL_EXPERIENCE, exp);
if (fireTicks != 0)
{
player.offer(Keys.FIRE_TICKS, fireTicks);
}
player.remove(Keys.POTION_EFFECTS);
player.offer(Keys.POTION_EFFECTS, activePotionEffects);
int i = 0;
for (Inventory slot : inv.slots())
{
ItemStack item = inventory.get(i);
if (item != null)
{
slot.set(item);
}
else
{
slot.clear();
}
i++;
}
/* TODO EnderChet
i = 0;
for (Inventory slot : player.getEnderChest().slots())
{
ItemStack item = enderChest.get(i);
if (item != null)
{
slot.set(item);
}
else
{
slot.clear();
}
i++;
}
*/
player.offer(Keys.GAME_MODE, gameMode);
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:53,代码来源:PlayerData.java
注:本文中的org.spongepowered.api.item.inventory.entity.Hotbar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论