コード例 #1
0
 /** 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;
 }
コード例 #2
0
 /** 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;
 }
コード例 #3
0
 public void dropLock() {
   ItemStack lock = getLock();
   if (lock == null) return;
   dropItemStack(lock);
   setLock(null);
 }