package pneumaticCraft.common.block; import java.util.List; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemBlock; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import pneumaticCraft.PneumaticCraft; import pneumaticCraft.client.render.block.RenderChargingStationPad; import pneumaticCraft.common.item.ItemMachineUpgrade; import pneumaticCraft.common.tileentity.TileEntityChargingStation; import pneumaticCraft.lib.BBConstants; import pneumaticCraft.proxy.CommonProxy.EnumGuiId; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockChargingStation extends BlockPneumaticCraftModeled{ public BlockChargingStation(Material par2Material){ super(par2Material); } @Override public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ if(((TileEntityChargingStation)world.getTileEntity(x, y, z)).getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0) { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { setBlockBounds(BBConstants.CHARGING_STATION_MIN_POS, 0F, BBConstants.CHARGING_STATION_MIN_POS, BBConstants.CHARGING_STATION_MAX_POS, BBConstants.CHARGING_STATION_MAX_POS_TOP, BBConstants.CHARGING_STATION_MAX_POS); } } @Override public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity){ setBlockBoundsBasedOnState(world, i, j, k); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } @Override protected Class<? extends TileEntity> getTileEntityClass(){ return TileEntityChargingStation.class; } @Override public EnumGuiId getGuiID(){ return EnumGuiId.CHARGING_STATION; } @Override public boolean isRotatable(){ return true; } /** * Returns true if the block is emitting direct/strong redstone power on the * specified side. Args: World, X, Y, Z, side. Note that the side is * reversed - eg it is 1 (up) when checking the bottom of the block. */ @Override public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5){ return 0; } /** * Returns true if the block is emitting indirect/weak redstone power on the * specified side. If isBlockNormalCube returns true, standard redstone * propagation rules will apply instead and this will not be called. Args: * World, X, Y, Z, side. Note that the side is reversed - eg it is 1 (up) * when checking the bottom of the block. */ @Override public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5){ TileEntity te = par1IBlockAccess.getTileEntity(par2, par3, par4); if(te instanceof TileEntityChargingStation) { TileEntityChargingStation teCs = (TileEntityChargingStation)te; return teCs.shouldEmitRedstone() ? 15 : 0; } return 0; } @Override public boolean canProvidePower(){ return true; } @Override protected int getInventoryDropEndSlot(IInventory inventory){ return 5; } @Override @SideOnly(Side.CLIENT) public int getRenderType(){ return PneumaticCraft.proxy.getRenderIdForRenderer(RenderChargingStationPad.class); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ if(!world.isRemote && player.isSneaking()) { TileEntityChargingStation station = (TileEntityChargingStation)world.getTileEntity(x, y, z); station.setCamoStack(player.getCurrentEquippedItem()); return player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemBlock; } else return super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9); } }