@Override
 public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) {
   if (world.isRemote) {
     return;
   }
   TileCapacitorBank te = (TileCapacitorBank) world.getBlockTileEntity(x, y, z);
   te.onNeighborBlockChange(blockId);
 }
 @Override
 public void onBlockAdded(World world, int x, int y, int z) {
   if (world.isRemote) {
     return;
   }
   TileCapacitorBank tr = (TileCapacitorBank) world.getBlockTileEntity(x, y, z);
   tr.onBlockAdded();
 }
 @Override
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
   if (world.isRemote) {
     return;
   }
   TileEntity te = world.getBlockTileEntity(x, y, z);
   if (te instanceof TileCapacitorBank) {
     TileCapacitorBank cb = (TileCapacitorBank) te;
     cb.addEnergy(PowerHandlerUtil.getStoredEnergyForItem(stack));
   }
   world.markBlockForUpdate(x, y, z);
 }
Example #4
0
 @Override
 public boolean renderWorldBlock(
     IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
   TileEntity te = world.getBlockTileEntity(x, y, z);
   if (te instanceof TileCapacitorBank) {
     TileCapacitorBank cb = ((TileCapacitorBank) te);
     cb.energyAtLastRender = cb.getEnergyStored();
   }
   connectedTexRenderer.setEdgeTexture(
       EnderIO.blockAlloySmelter.getBlockTextureFromSide(
           3)); // can't do in constructor as texture not loaded yet
   CustomCubeRenderer.instance.renderBlock(world, block, x, y, z, renderers);
   return true;
 }
  @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;
  }
  @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);
  }
  @Override
  @SideOnly(Side.CLIENT)
  public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
    TileEntity te = world.getBlockTileEntity(x, y, z);
    if (!(te instanceof TileCapacitorBank)) {
      return super.getSelectedBoundingBoxFromPool(world, x, y, z);
    }
    TileCapacitorBank tr = (TileCapacitorBank) te;
    if (!tr.isMultiblock()) {
      return super.getSelectedBoundingBoxFromPool(world, x, y, z);
    }

    Vector3d min = new Vector3d(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
    Vector3d max = new Vector3d(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
    for (BlockCoord bc : tr.multiblock) {
      min.x = Math.min(min.x, bc.x);
      max.x = Math.max(max.x, bc.x + 1);
      min.y = Math.min(min.y, bc.y);
      max.y = Math.max(max.y, bc.y + 1);
      min.z = Math.min(min.z, bc.z);
      max.z = Math.max(max.z, bc.z + 1);
    }
    return AxisAlignedBB.getAABBPool().getAABB(min.x, min.y, min.z, max.x, max.y, max.z);
  }