@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)); } }
@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; }