/** Locks the chest with the item the player is currently holding, if possible. */ public boolean lockChest(EntityPlayer player) { ItemStack lock = player.getHeldItem(); if (!canLock(lock)) return false; setLock(lock); player.inventory.setInventorySlotContents(player.inventory.currentItem, null); return true; }
/** Unlocks the chest with the item the player is currently holding, if possible. */ public boolean unlockChest(EntityPlayer player) { ItemStack key = player.getHeldItem(); if (!canUnlock(key)) return false; ItemStack lock = getLock(); setLock(null); EntityItem item = player.dropPlayerItem(lock); item.delayBeforeCanPickup = 0; return true; }
public void dropLock() { ItemStack lock = getLock(); if (lock == null) return; dropItemStack(lock); setLock(null); }