| package assets.city01.Blocks; |
| |
| import net.minecraft.block.BlockContainer; |
| import net.minecraft.block.material.Material; |
| import net.minecraft.client.renderer.texture.IconRegister; |
| import net.minecraft.entity.EntityLivingBase; |
| import net.minecraft.item.ItemStack; |
| import net.minecraft.tileentity.TileEntity; |
| import net.minecraft.util.AxisAlignedBB; |
| import net.minecraft.util.Icon; |
| import net.minecraft.util.MathHelper; |
| import net.minecraft.world.IBlockAccess; |
| import net.minecraft.world.World; |
| import assets.city01.Data.ClientProxy; |
| import assets.city01.Data.HL2; |
| import assets.city01.TileEntity.TileEntityPanneau; |
| import cpw.mods.fml.relauncher.Side; |
| import cpw.mods.fml.relauncher.SideOnly; |
| |
| public class B_Panneau extends BlockContainer { |
| private Icon icontop, iconbottom, iconfront; |
| private Icon[] Icon1 = new Icon[6]; |
| private Icon[] Icon2 = new Icon[5]; |
| private Icon[] Icon3 = new Icon[4]; |
| private Icon[] Icon4 = new Icon[3]; |
| private Icon[] Icon5 = new Icon[2]; |
| private Icon[] Icon6 = new Icon[2]; |
| private Icon Icon7, Icon8; |
| |
| public B_Panneau(int par1) { |
| super(par1, Material.wood); |
| this.setCreativeTab(HL2.Tab); |
| |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public void registerIcons(IconRegister iconregister) { |
| Icon1[0] = iconregister.registerIcon("city01:nope"); |
| Icon1[1] = iconregister.registerIcon("city01:nope"); |
| Icon1[2] = iconregister.registerIcon("city01:nope"); |
| Icon1[3] = iconregister.registerIcon("city01:a"); |
| Icon1[4] = iconregister.registerIcon("city01:a"); |
| Icon1[5] = iconregister.registerIcon("city01:a"); |
| |
| Icon2[0] = iconregister.registerIcon("city01:nope"); |
| Icon2[1] = iconregister.registerIcon("city01:nope"); |
| Icon2[2] = iconregister.registerIcon("city01:nope"); |
| Icon2[3] = iconregister.registerIcon("city01:a"); |
| Icon2[4] = iconregister.registerIcon("city01:a"); |
| |
| Icon3[0] = iconregister.registerIcon("city01:nope"); |
| Icon3[1] = iconregister.registerIcon("city01:nope"); |
| Icon3[2] = iconregister.registerIcon("city01:a"); |
| Icon3[3] = iconregister.registerIcon("city01:a"); |
| |
| Icon4[0] = iconregister.registerIcon("city01:nope"); |
| Icon4[1] = iconregister.registerIcon("city01:nope"); |
| Icon4[2] = iconregister.registerIcon("city01:a"); |
| |
| Icon5[0] = iconregister.registerIcon("city01:nope"); |
| Icon5[1] = iconregister.registerIcon("city01:a"); |
| |
| Icon6[0] = iconregister.registerIcon("city01:nope"); |
| Icon6[1] = iconregister.registerIcon("city01:a"); |
| |
| Icon7 = iconregister.registerIcon("city01:nope"); |
| Icon8 = iconregister.registerIcon("city01:a"); |
| } |
| |
| public void onBlockPlacedBy(World world, int x, int y, int z, |
| EntityLivingBase living, ItemStack stack) { |
| int direction = MathHelper |
| .floor_double((double) (living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; |
| TileEntity te = world.getBlockTileEntity(x, y, z); |
| if (te != null && stack.getItemDamage() == 2 |
| && te instanceof TileEntityPanneau) { |
| ((TileEntityPanneau) te).setDirection((byte) direction); |
| world.markBlockForUpdate(x, y, z); |
| } |
| } |
| |
| @SideOnly(Side.CLIENT) |
| public Icon getIcon(int side, int metadata) { |
| |
| |
| |
| |
| |
| |
| |
| switch (metadata) { |
| case 0: |
| return Icon1[side]; |
| case 1: |
| return side > 1 ? Icon2[side - 1] : Icon2[0]; |
| case 2: |
| return side < 4 ? Icon3[side] : Icon3[3]; |
| case 3: |
| return side < 3 ? Icon4[side] : Icon4[2]; |
| case 4: |
| return side < 2 ? Icon5[0] : Icon5[1]; |
| case 5: |
| return side == 1 ? Icon6[0] : Icon6[1]; |
| case 6: |
| return Icon7; |
| case 7: |
| return Icon8; |
| default: |
| return blockIcon; |
| } |
| } |
| |
| @Override |
| public TileEntity createNewTileEntity(World world) { |
| return new TileEntityPanneau(); |
| } |
| |
| public boolean renderAsNormalBlock() { |
| return false; |
| } |
| |
| public boolean isOpaqueCube() { |
| return false; |
| } |
| |
| @SideOnly(Side.CLIENT) |
| public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, |
| int y, int z) { |
| return AxisAlignedBB.getAABBPool().getAABB( |
| (double) x + this.minX + 0.0D, (double) y + this.minY, |
| (double) z + this.minZ + 0.6D, (double) x + this.maxX + 1.0D, |
| (double) y + this.maxY + 1.0D, (double) z + this.maxZ - 0.6D); |
| } |
| |
| public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, |
| int y, int z) { |
| return AxisAlignedBB.getAABBPool().getAABB( |
| (double) x + this.minX + 0.0D, (double) y + this.minY, |
| (double) z + this.minZ + 0.6D, (double) x + this.maxX + 2.0D, |
| (double) y + this.maxY + 1.0D, (double) z + this.maxZ - 0.6D); |
| } |
| |
| @SideOnly(Side.CLIENT) |
| public int getRenderType() { |
| return ClientProxy.renderInventoryTESRId; |
| } |
| |
| @SideOnly(Side.CLIENT) |
| public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, |
| int side) { |
| TileEntity te = blockAccess.getBlockTileEntity(x, y, z); |
| if (te != null && te instanceof TileEntityPanneau) { |
| TileEntityPanneau panneau = (TileEntityPanneau) te; |
| int direction = panneau.getDirection(); |
| return side == 1 ? Icon3[0] : (side == 0 ? Icon3[1] |
| : (direction == 2 && side == 2 ? Icon3[2] : (direction == 3 |
| && side == 5 ? Icon3[2] : (direction == 0 |
| && side == 3 ? Icon3[2] : (direction == 1 |
| && side == 4 ? Icon3[2] : Icon3[3]))))); |
| } |
| return this.getIcon(side, blockAccess.getBlockMetadata(x, y, z)); |
| } |
| |
| } |