coaster3000

Untitled

May 17th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. @Override
  2.     public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
  3.        
  4.         ItemStack lockKey = new ItemStack(SecureItMod.lockAndKeyItem ,1);
  5.        
  6.         if (SecureItMod.instance.isLocked(world, x, y, z)) {
  7.             if (SecureItMod.instance.isKey(world, x, y, z, getKey(stack))) {
  8.                 if (player.isSneaking()) {
  9.                     SecureItMod.instance.unlock(world, x, y, z);
  10.                    
  11.                     stack.stackSize--;
  12.                     player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy());
  13.                    
  14.                     if (!player.inventory.addItemStackToInventory(lockKey.copy()))
  15.                         player.dropItem(SecureItMod.lockAndKeyItem, 1);
  16.                    
  17.                     MessageUtil.sendMessage(player, "Unlocked chest.");
  18.                     player.inventory.markDirty();
  19.                 }
  20.                 return false;
  21.             } else {
  22.                 MessageUtil.sendMessage(player, "Wrong key...");
  23.             }
  24.         }
  25.        
  26.         return true;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment