Пример #1
0
  @Override
  public ArrayList<ItemStack> getBlockDropped(
      World world, int x, int y, int z, int metadata, int fortune) {
    ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
    if (!world.isRemote) {
      TileEntity te = world.getBlockTileEntity(x, y, z);
      if (te instanceof TileCapacitorBank) {
        TileCapacitorBank cb = (TileCapacitorBank) te;
        cb.onBreakBlock();

        ItemStack itemStack =
            BlockItemCapacitorBank.createItemStackWithPower(cb.doGetEnergyStored());
        ret.add(itemStack);
      }
    }
    return ret;
  }
Пример #2
0
  @Override
  public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) {
    if (!world.isRemote) {
      TileEntity te = world.getBlockTileEntity(x, y, z);
      if (te instanceof TileCapacitorBank) {
        TileCapacitorBank cb = (TileCapacitorBank) te;
        cb.onBreakBlock();

        ItemStack itemStack =
            BlockItemCapacitorBank.createItemStackWithPower(cb.doGetEnergyStored());
        float f = 0.7F;
        double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack);
        entityitem.delayBeforeCanPickup = 10;
        world.spawnEntityInWorld(entityitem);
      }
    }
    return super.removeBlockByPlayer(world, player, x, y, z);
  }