Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
- ItemStack lockKey = new ItemStack(SecureItMod.lockAndKeyItem ,1);
- if (SecureItMod.instance.isLocked(world, x, y, z)) {
- if (SecureItMod.instance.isKey(world, x, y, z, getKey(stack))) {
- if (player.isSneaking()) {
- SecureItMod.instance.unlock(world, x, y, z);
- stack.stackSize--;
- player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy());
- if (!player.inventory.addItemStackToInventory(lockKey.copy()))
- player.dropItem(SecureItMod.lockAndKeyItem, 1);
- MessageUtil.sendMessage(player, "Unlocked chest.");
- player.inventory.markDirty();
- }
- return false;
- } else {
- MessageUtil.sendMessage(player, "Wrong key...");
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment