示例#1
0
  @Override
  public void onBlockPlacedBy(
      World world, int i, int j, int k, EntityLivingBase player, ItemStack is) {
    super.onBlockPlacedBy(world, i, j, k, player, is);
    TECrucible te = (TECrucible) world.getBlockTileEntity(i, j, k);

    if (te != null && is.hasTagCompound()) {
      te.readFromItemNBT(is.getTagCompound());
    }
  }
示例#2
0
  @Override
  public void breakBlock(World world, int i, int j, int k, int par5, int par6) {
    TECrucible te = (TECrucible) world.getBlockTileEntity(i, j, k);

    if (te != null) {
      ItemStack is = new ItemStack(Block.blocksList[par5], 1);
      NBTTagCompound nbt = writeCrucibleToNBT(te);
      is.setTagCompound(nbt);
      EntityItem ei = new EntityItem(world, i, j, k, is);
      world.spawnEntityInWorld(ei);

      for (int s = 0; s < te.getSizeInventory(); ++s) {
        te.setInventorySlotContents(s, null);
      }
    }
    super.breakBlock(world, i, j, k, par5, par6);
  }