Java Code Examples for net.minecraft.entity.player.InventoryPlayer#isHotbar()
The following examples show how to use
net.minecraft.entity.player.InventoryPlayer#isHotbar() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObsidianReplaceModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
private int findObsidianInHotbar(final EntityPlayerSP player) { for (int index = 0; InventoryPlayer.isHotbar(index); index++) if (isItemStackObsidian(player.inventory.getStackInSlot(index))) return index; return -1; }
Example 2
Source File: ToroQuestCommand.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
private List<ItemStack> pullHotbarItems(EntityPlayer player) { List<ItemStack> items = new ArrayList<ItemStack>(); InventoryPlayer inv = player.inventory; for (int i = 0; i < inv.getSizeInventory(); i++) { if (inv.getStackInSlot(i) != null && InventoryPlayer.isHotbar(i)) { ItemStack stack = inv.getStackInSlot(i); inv.setInventorySlotContents(i, ItemStack.EMPTY); items.add(stack); } } return items; }
Example 3
Source File: InventoryUtils.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
public static boolean switchItemToHand(ItemStack stack, boolean ignoreNbt, Minecraft mc) { if (PICK_BLOCKABLE_SLOTS.size() == 0) { return false; } EntityPlayer player = mc.player; InventoryPlayer inventory = player.inventory; boolean isCreativeMode = player.capabilities.isCreativeMode; int slotWithItem = fi.dy.masa.malilib.util.InventoryUtils.findSlotWithItemToPickBlock(player.openContainer, stack, ignoreNbt); // No item or no place to put it if (slotWithItem == -1 && isCreativeMode == false) { return false; } if (slotWithItem >= 36 && slotWithItem < 45) { inventory.currentItem = slotWithItem - 36; return true; } int hotbarSlot = getEmptyPickBlockableHotbarSlot(inventory); if (hotbarSlot == -1) { hotbarSlot = getNextPickBlockableHotbarSlot(inventory); } if (slotWithItem != -1) { fi.dy.masa.malilib.util.InventoryUtils.swapSlots(player.openContainer, slotWithItem, hotbarSlot); inventory.currentItem = hotbarSlot; return true; } else if (isCreativeMode && InventoryPlayer.isHotbar(hotbarSlot)) { int slotNum = hotbarSlot + 36; // First try to put the current hotbar item into an empty slot in the player's inventory if (inventory.getStackInSlot(hotbarSlot).isEmpty() == false) { // Shift click the stack mc.playerController.windowClick(player.openContainer.windowId, slotNum, 0, ClickType.QUICK_MOVE, player); // Wasn't able to move the items out if (inventory.getStackInSlot(hotbarSlot).isEmpty() == false) { // TODO try to combine partial stacks // The off-hand slot is empty, move the current stack to it if (player.getHeldItemOffhand().isEmpty()) { fi.dy.masa.malilib.util.InventoryUtils.swapSlots(player.openContainer, slotNum, 0); fi.dy.masa.malilib.util.InventoryUtils.swapSlots(player.openContainer, 45, 0); fi.dy.masa.malilib.util.InventoryUtils.swapSlots(player.openContainer, slotNum, 0); } } } inventory.currentItem = hotbarSlot; inventory.mainInventory.set(hotbarSlot, stack.copy()); mc.playerController.sendSlotPacket(stack.copy(), slotNum); return true; } return false; }