コード例 #1
0
 @Override
 public boolean onItemUseFirst(
     ItemStack stack, EntityPlayer player, World world, int X, int Y, int Z, int side) {
   TileEntity te = world.getBlockTileEntity(X, Y, Z);
   if (te != null && te instanceof TileEntityIronChest) {
     TileEntityIronChest ironchest = (TileEntityIronChest) te;
     TileEntityIronChest newchest = ironchest.applyUpgradeItem(this);
     if (newchest == null) {
       return false;
     }
     world.setBlockTileEntity(X, Y, Z, newchest);
     world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal());
     world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z));
     world.markBlockNeedsUpdate(X, Y, Z);
     stack.stackSize = 0;
     return true;
   } else {
     return false;
   }
 }