Java Code Examples for net.minecraft.inventory.EntityEquipmentSlot#getIndex()
The following examples show how to use
net.minecraft.inventory.EntityEquipmentSlot#getIndex() .
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: CraftEntityEquipment.java From Kettle with GNU General Public License v3.0 | 5 votes |
private void setDropChance(EntityEquipmentSlot slot, float chance) { if (slot == EntityEquipmentSlot.MAINHAND || slot == EntityEquipmentSlot.OFFHAND) { ((EntityLiving) entity.getHandle()).inventoryHandsDropChances[slot.getIndex()] = chance - 0.1F; } else { ((EntityLiving) entity.getHandle()).inventoryArmorDropChances[slot.getIndex()] = chance - 0.1F; } }
Example 2
Source File: CraftEntityEquipment.java From Kettle with GNU General Public License v3.0 | 5 votes |
private float getDropChance(EntityEquipmentSlot slot) { if (slot == EntityEquipmentSlot.MAINHAND || slot == EntityEquipmentSlot.OFFHAND) { return ((EntityLiving) entity.getHandle()).inventoryHandsDropChances[slot.getIndex()] + 0.1F; } else { return ((EntityLiving) entity.getHandle()).inventoryArmorDropChances[slot.getIndex()] + 0.1F; } }
Example 3
Source File: ItemInventorySwapper.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
private void swapRegularSlot(InventoryItemModular swapperInv, final int slot, final int mainInvSize, final int invMax, EntityPlayer player) { ItemStack stackInSwapper = swapperInv.getStackInSlot(slot); // Check if the stack from the swapper can fit and is valid to be put into the player's inventory if (stackInSwapper.isEmpty() || (stackInSwapper.getCount() <= Math.min(stackInSwapper.getMaxStackSize(), invMax) && player.inventory.isItemValidForSlot(slot, stackInSwapper))) { // Armor slots if (slot >= mainInvSize && slot < (mainInvSize + 4)) { int pos = -1; // Armor present in the swappers's inventory slot, get the corresponding armor slot if (stackInSwapper.isEmpty() == false) { EntityEquipmentSlot equipmentSlot = EntityLiving.getSlotForItemStack(stackInSwapper); if (stackInSwapper.getCount() == 1 && equipmentSlot.getSlotType() == EntityEquipmentSlot.Type.ARMOR) { pos = equipmentSlot.getIndex(); } } else if (player.inventory.getStackInSlot(slot).isEmpty() == false) { pos = slot - mainInvSize; } if (pos >= 0 && pos == (slot - mainInvSize)) { swapperInv.setStackInSlot(slot, player.inventory.getStackInSlot(slot)); player.inventory.setInventorySlotContents(slot, stackInSwapper); } } // Main inventory and Off Hand slot else { swapperInv.setStackInSlot(slot, player.inventory.getStackInSlot(slot)); player.inventory.setInventorySlotContents(slot, stackInSwapper); } } }