diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java index 6e2e9f3d9..519505c26 100644 --- a/src/main/java/techreborn/api/recipe/RecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -136,7 +136,7 @@ public class RecipeCrafter { setCurrentRecipe(recipe);//Sets the current recipe then syncs this.currentNeededTicks = (int) (currentRecipe.tickTime() * (1.0 - speedMultiplier)); this.currentTickTime = -1; - syncIsActive(); + setIsActive(); } else { this.currentTickTime = -0; } @@ -146,7 +146,7 @@ public class RecipeCrafter { if (inventory.hasChanged && !hasAllInputs()) {//If it doesn't have all the inputs reset currentRecipe = null; currentTickTime = 0; - syncIsActive(); + setIsActive(); } if (currentRecipe != null && currentTickTime >= currentNeededTicks) {//If it has reached the recipe tick time boolean canGiveInvAll = true; @@ -166,7 +166,7 @@ public class RecipeCrafter { useAllInputs();//this uses all the inputs currentRecipe = null;//resets currentTickTime = 0; - syncIsActive(); + setIsActive(); } } else if (currentRecipe != null && currentTickTime < currentNeededTicks) { if (energy.canUseEnergy(getEuPerTick())) {//This uses the power @@ -325,18 +325,13 @@ public class RecipeCrafter { } - public void syncIsActive() { - if (!parentTile.getWorldObj().isRemote) { - PacketHandler.sendPacketToAllPlayers(getSyncPacket(), - parentTile.getWorldObj()); - } - } - - public Packet getSyncPacket() { - NBTTagCompound nbtTag = new NBTTagCompound(); - writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.parentTile.xCoord, this.parentTile.yCoord, - this.parentTile.zCoord, 1, nbtTag); + public void setIsActive() { + if(isActiveServer()){ + parentTile.getWorldObj().setBlockMetadataWithNotify(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord, 1, 2); + } else { + parentTile.getWorldObj().setBlockMetadataWithNotify(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord, 0, 2); + } + parentTile.getWorldObj().markBlockForUpdate(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord); } public void setCurrentRecipe(IBaseRecipeType recipe) { diff --git a/src/main/java/techreborn/blocks/BlockChunkLoader.java b/src/main/java/techreborn/blocks/BlockChunkLoader.java index 7c751e475..f995819fd 100644 --- a/src/main/java/techreborn/blocks/BlockChunkLoader.java +++ b/src/main/java/techreborn/blocks/BlockChunkLoader.java @@ -7,6 +7,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.client.GuiHandler; @@ -51,14 +52,13 @@ public class BlockChunkLoader extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/BlockComputerCube.java b/src/main/java/techreborn/blocks/BlockComputerCube.java index 05ef11bd2..286b6ed49 100644 --- a/src/main/java/techreborn/blocks/BlockComputerCube.java +++ b/src/main/java/techreborn/blocks/BlockComputerCube.java @@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockComputerCube extends BlockMachineBase { @@ -31,14 +33,13 @@ public class BlockComputerCube extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/computer_cube"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } \ No newline at end of file diff --git a/src/main/java/techreborn/blocks/BlockDigitalChest.java b/src/main/java/techreborn/blocks/BlockDigitalChest.java index 8e13fed37..5b8a83d3e 100644 --- a/src/main/java/techreborn/blocks/BlockDigitalChest.java +++ b/src/main/java/techreborn/blocks/BlockDigitalChest.java @@ -7,6 +7,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.client.GuiHandler; @@ -51,13 +52,12 @@ public class BlockDigitalChest extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/BlockElectricCraftingTable.java b/src/main/java/techreborn/blocks/BlockElectricCraftingTable.java index d4c356f16..6a44d4205 100644 --- a/src/main/java/techreborn/blocks/BlockElectricCraftingTable.java +++ b/src/main/java/techreborn/blocks/BlockElectricCraftingTable.java @@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockElectricCraftingTable extends BlockMachineBase { @@ -31,14 +33,13 @@ public class BlockElectricCraftingTable extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/BlockFusionCoil.java b/src/main/java/techreborn/blocks/BlockFusionCoil.java index 4667295c6..43f28f799 100644 --- a/src/main/java/techreborn/blocks/BlockFusionCoil.java +++ b/src/main/java/techreborn/blocks/BlockFusionCoil.java @@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockFusionCoil extends BlockMachineBase { @@ -31,14 +33,13 @@ public class BlockFusionCoil extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/fusion_coil"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/BlockFusionControlComputer.java b/src/main/java/techreborn/blocks/BlockFusionControlComputer.java index 5aaaf1078..14e0031fd 100644 --- a/src/main/java/techreborn/blocks/BlockFusionControlComputer.java +++ b/src/main/java/techreborn/blocks/BlockFusionControlComputer.java @@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockFusionControlComputer extends BlockMachineBase { @@ -31,14 +33,13 @@ public class BlockFusionControlComputer extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/plasma_generator_side_off"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/BlockHighlyAdvancedMachine.java b/src/main/java/techreborn/blocks/BlockHighlyAdvancedMachine.java index 07cdf4038..c88170c2a 100644 --- a/src/main/java/techreborn/blocks/BlockHighlyAdvancedMachine.java +++ b/src/main/java/techreborn/blocks/BlockHighlyAdvancedMachine.java @@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockHighlyAdvancedMachine extends BlockMachineBase { @@ -31,14 +33,13 @@ public class BlockHighlyAdvancedMachine extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/highlyadvancedmachine"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/BlockMachineBase.java b/src/main/java/techreborn/blocks/BlockMachineBase.java index 408a23bac..7f990bae5 100644 --- a/src/main/java/techreborn/blocks/BlockMachineBase.java +++ b/src/main/java/techreborn/blocks/BlockMachineBase.java @@ -11,8 +11,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; +import net.minecraft.world.ChunkCache; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.client.TechRebornCreativeTab; +import techreborn.tiles.TileMachineBase; import java.util.Random; @@ -61,6 +64,7 @@ public class BlockMachineBase extends BlockContainer { } world.setBlockMetadataWithNotify(x, y, z, b, 2); + setTileMeta(world, x, y, z, b); } @@ -73,16 +77,16 @@ public class BlockMachineBase extends BlockContainer { .floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; if (l == 0) { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); + setTileMeta(world, x, y, z, 2); } if (l == 1) { - world.setBlockMetadataWithNotify(x, y, z, 5, 2); + setTileMeta(world, x, y, z, 5); } if (l == 2) { - world.setBlockMetadataWithNotify(x, y, z, 3, 2); + setTileMeta(world, x, y, z, 3); } if (l == 3) { - world.setBlockMetadataWithNotify(x, y, z, 4, 2); + setTileMeta(world, x, y, z, 4); } super.onBlockPlacedBy(world, x, y, z, player, itemstack); } @@ -137,4 +141,21 @@ public class BlockMachineBase extends BlockContainer { } } } + + public void setTileMeta(World world, int x, int y, int z, int meta){ + if(world.getTileEntity(x, y, z) instanceof TileMachineBase){ + ((TileMachineBase) world.getTileEntity(x, y, z)).setMeta(meta); + } + } + + public int getTileMeta(World world, int x, int y, int z){ + if(world.getTileEntity(x, y, z) instanceof TileMachineBase){ + return ((TileMachineBase) world.getTileEntity(x, y, z)).getMeta(); + } + return 0; + } + + public int getTileMeta(IBlockAccess blockAccess, int x, int y, int z){ + return getTileMeta(blockAccess.getTileEntity(x, y,z).getWorldObj(), x, y, z); + } } diff --git a/src/main/java/techreborn/blocks/BlockMetalShelf.java b/src/main/java/techreborn/blocks/BlockMetalShelf.java index 77d82284c..526dedd45 100644 --- a/src/main/java/techreborn/blocks/BlockMetalShelf.java +++ b/src/main/java/techreborn/blocks/BlockMetalShelf.java @@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockMetalShelf extends BlockMachineBase { @@ -40,13 +42,13 @@ public class BlockMetalShelf extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFrontEmpty : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFrontEmpty : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/BlockSupercondensator.java b/src/main/java/techreborn/blocks/BlockSupercondensator.java index b1cd59acb..0354f8ec5 100644 --- a/src/main/java/techreborn/blocks/BlockSupercondensator.java +++ b/src/main/java/techreborn/blocks/BlockSupercondensator.java @@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockSupercondensator extends BlockMachineBase { @@ -31,14 +33,13 @@ public class BlockSupercondensator extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/supercondensator_side"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/BlockWoodenshelf.java b/src/main/java/techreborn/blocks/BlockWoodenshelf.java index 2a7ce2baf..5916d5b08 100644 --- a/src/main/java/techreborn/blocks/BlockWoodenshelf.java +++ b/src/main/java/techreborn/blocks/BlockWoodenshelf.java @@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class BlockWoodenshelf extends BlockMachineBase { @@ -31,14 +33,13 @@ public class BlockWoodenshelf extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/wood_shelf_side"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/machine/BlockAlloyFurnace.java b/src/main/java/techreborn/blocks/machine/BlockAlloyFurnace.java index 832017689..4653de5bf 100644 --- a/src/main/java/techreborn/blocks/machine/BlockAlloyFurnace.java +++ b/src/main/java/techreborn/blocks/machine/BlockAlloyFurnace.java @@ -7,6 +7,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.blocks.BlockMachineBase; @@ -56,13 +57,17 @@ public class BlockAlloyFurnace extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/alloy_furnace_bottom"); } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { + return this.iconFrontOn; + } return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/machine/BlockAlloySmelter.java b/src/main/java/techreborn/blocks/machine/BlockAlloySmelter.java index 818af393a..ec327ab88 100644 --- a/src/main/java/techreborn/blocks/machine/BlockAlloySmelter.java +++ b/src/main/java/techreborn/blocks/machine/BlockAlloySmelter.java @@ -62,10 +62,10 @@ public class BlockAlloySmelter extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileAlloySmelter tileAlloySmelter = (TileAlloySmelter) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tileAlloySmelter.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } return metadata == 0 && side == 3 ? this.iconFront @@ -74,14 +74,6 @@ public class BlockAlloySmelter extends BlockMachineBase { : (side == metadata ? this.iconFront : this.blockIcon)); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - - } @Override public Item getItemDropped(int meta, Random random, int fortune) { diff --git a/src/main/java/techreborn/blocks/machine/BlockAssemblingMachine.java b/src/main/java/techreborn/blocks/machine/BlockAssemblingMachine.java index e38b42fb8..92490bcdd 100644 --- a/src/main/java/techreborn/blocks/machine/BlockAssemblingMachine.java +++ b/src/main/java/techreborn/blocks/machine/BlockAssemblingMachine.java @@ -62,26 +62,16 @@ public class BlockAssemblingMachine extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileAssemblingMachine tileAssemblingMachine = (TileAssemblingMachine) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tileAssemblingMachine.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockBlastFurnace.java b/src/main/java/techreborn/blocks/machine/BlockBlastFurnace.java index ae5c94fd1..0d00c8945 100644 --- a/src/main/java/techreborn/blocks/machine/BlockBlastFurnace.java +++ b/src/main/java/techreborn/blocks/machine/BlockBlastFurnace.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.blocks.BlockMachineBase; @@ -60,14 +61,17 @@ public class BlockBlastFurnace extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/advanced_machine_side"); } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { + return this.iconFrontOn; + } return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockCentrifuge.java b/src/main/java/techreborn/blocks/machine/BlockCentrifuge.java index 04892d4db..03a675392 100644 --- a/src/main/java/techreborn/blocks/machine/BlockCentrifuge.java +++ b/src/main/java/techreborn/blocks/machine/BlockCentrifuge.java @@ -65,32 +65,16 @@ public class BlockCentrifuge extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileCentrifuge tileCentrifuge = (TileCentrifuge) blockAccess.getTileEntity(x, y, z); - if (side >= 2 && tileCentrifuge.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } - - if (side == 1 && tileCentrifuge.crafter.isActive()) { - return this.iconTopOn; - } - - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.iconFront)); - - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.iconFront)); - + : (side == metadata ? this.iconFront : this.blockIcon)); } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockChargeBench.java b/src/main/java/techreborn/blocks/machine/BlockChargeBench.java index abef33e4d..561a3a839 100644 --- a/src/main/java/techreborn/blocks/machine/BlockChargeBench.java +++ b/src/main/java/techreborn/blocks/machine/BlockChargeBench.java @@ -7,6 +7,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.blocks.BlockMachineBase; @@ -55,13 +56,17 @@ public class BlockChargeBench extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { + return this.iconFrontOn; + } return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } } diff --git a/src/main/java/techreborn/blocks/machine/BlockChemicalReactor.java b/src/main/java/techreborn/blocks/machine/BlockChemicalReactor.java index 8d6a30a17..6bd839d7e 100644 --- a/src/main/java/techreborn/blocks/machine/BlockChemicalReactor.java +++ b/src/main/java/techreborn/blocks/machine/BlockChemicalReactor.java @@ -62,27 +62,16 @@ public class BlockChemicalReactor extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileChemicalReactor tileChemicalReactor = (TileChemicalReactor) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tileChemicalReactor.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockDistillationTower.java b/src/main/java/techreborn/blocks/machine/BlockDistillationTower.java index 14d84c185..f0ca95693 100644 --- a/src/main/java/techreborn/blocks/machine/BlockDistillationTower.java +++ b/src/main/java/techreborn/blocks/machine/BlockDistillationTower.java @@ -7,6 +7,8 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; import techreborn.blocks.BlockMachineBase; import java.util.Random; @@ -36,14 +38,14 @@ public class BlockDistillationTower extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/advanced_machine_side"); } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta(blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockGrinder.java b/src/main/java/techreborn/blocks/machine/BlockGrinder.java index 5032db7be..3ed6979b6 100644 --- a/src/main/java/techreborn/blocks/machine/BlockGrinder.java +++ b/src/main/java/techreborn/blocks/machine/BlockGrinder.java @@ -66,32 +66,16 @@ public class BlockGrinder extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileGrinder tileGrinder = (TileGrinder) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tileGrinder.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } - - if (side == 1 && tileGrinder.crafter.isActive()) { - return this.iconTopOn; - } - - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockImplosionCompressor.java b/src/main/java/techreborn/blocks/machine/BlockImplosionCompressor.java index f3345fc13..2663c077e 100644 --- a/src/main/java/techreborn/blocks/machine/BlockImplosionCompressor.java +++ b/src/main/java/techreborn/blocks/machine/BlockImplosionCompressor.java @@ -62,28 +62,18 @@ public class BlockImplosionCompressor extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileImplosionCompressor tileImplosionCompressor = (TileImplosionCompressor) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tileImplosionCompressor.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - - } - @Override public Item getItemDropped(int meta, Random random, int fortune) { return IC2Items.getItem("advancedMachine").getItem(); diff --git a/src/main/java/techreborn/blocks/machine/BlockIndustrialElectrolyzer.java b/src/main/java/techreborn/blocks/machine/BlockIndustrialElectrolyzer.java index 49602ce7d..9edabf489 100644 --- a/src/main/java/techreborn/blocks/machine/BlockIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/blocks/machine/BlockIndustrialElectrolyzer.java @@ -63,28 +63,16 @@ public class BlockIndustrialElectrolyzer extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileIndustrialElectrolyzer tileIndustrialElectrolyzer = (TileIndustrialElectrolyzer) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tileIndustrialElectrolyzer.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockIndustrialSawmill.java b/src/main/java/techreborn/blocks/machine/BlockIndustrialSawmill.java index 08d9ed015..8670372a1 100644 --- a/src/main/java/techreborn/blocks/machine/BlockIndustrialSawmill.java +++ b/src/main/java/techreborn/blocks/machine/BlockIndustrialSawmill.java @@ -62,28 +62,16 @@ public class BlockIndustrialSawmill extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileIndustrialSawmill tileIndustrialSawmill = (TileIndustrialSawmill) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tileIndustrialSawmill.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockLathe.java b/src/main/java/techreborn/blocks/machine/BlockLathe.java index c7eabc2d6..5506ef0c5 100644 --- a/src/main/java/techreborn/blocks/machine/BlockLathe.java +++ b/src/main/java/techreborn/blocks/machine/BlockLathe.java @@ -62,27 +62,16 @@ public class BlockLathe extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TileLathe tileLathe = (TileLathe) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tileLathe.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockMatterFabricator.java b/src/main/java/techreborn/blocks/machine/BlockMatterFabricator.java index 18485b2d5..9d8a2b7e0 100644 --- a/src/main/java/techreborn/blocks/machine/BlockMatterFabricator.java +++ b/src/main/java/techreborn/blocks/machine/BlockMatterFabricator.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.blocks.BlockMachineBase; @@ -52,24 +53,16 @@ public class BlockMatterFabricator extends BlockMachineBase { @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister icon) { - this.blockIcon = icon.registerIcon("techreborn:machine/matterfab_off"); - this.iconFront = icon.registerIcon("techreborn:machine/matterfab_off"); - this.iconFrontOn = icon.registerIcon("techreborn:machine/matterfab_on"); - this.iconTop = icon.registerIcon("techreborn:machine/matterfab_off"); - this.iconBottom = icon.registerIcon("techreborn:machine/matterfab_off"); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { + return this.iconFrontOn; + } return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } - @Override public Item getItemDropped(int meta, Random random, int fortune) { return IC2Items.getItem("advancedMachine").getItem(); diff --git a/src/main/java/techreborn/blocks/machine/BlockPlateCuttingMachine.java b/src/main/java/techreborn/blocks/machine/BlockPlateCuttingMachine.java index b8b34e204..2573711f2 100644 --- a/src/main/java/techreborn/blocks/machine/BlockPlateCuttingMachine.java +++ b/src/main/java/techreborn/blocks/machine/BlockPlateCuttingMachine.java @@ -62,26 +62,16 @@ public class BlockPlateCuttingMachine extends BlockMachineBase { } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - int metadata = blockAccess.getBlockMetadata(x, y, z); - TilePlateCuttingMachine tilePlateCuttingMachine = (TilePlateCuttingMachine) blockAccess.getTileEntity(x, y, z); - if (side == metadata && tilePlateCuttingMachine.crafter.isActive()) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFrontOn; } return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront - : side == 1 ? this.iconTop : - side == 0 ? this.iconBottom : (side == 0 ? this.iconTop - : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockRollingMachine.java b/src/main/java/techreborn/blocks/machine/BlockRollingMachine.java index 338440e41..2ddb7303c 100644 --- a/src/main/java/techreborn/blocks/machine/BlockRollingMachine.java +++ b/src/main/java/techreborn/blocks/machine/BlockRollingMachine.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.blocks.BlockMachineBase; @@ -56,13 +57,14 @@ public class BlockRollingMachine extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom"); } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta(blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/machine/BlockVacuumFreezer.java b/src/main/java/techreborn/blocks/machine/BlockVacuumFreezer.java index f0db9780e..1b5e3d17e 100644 --- a/src/main/java/techreborn/blocks/machine/BlockVacuumFreezer.java +++ b/src/main/java/techreborn/blocks/machine/BlockVacuumFreezer.java @@ -7,6 +7,8 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; import techreborn.blocks.BlockMachineBase; import java.util.Random; @@ -36,14 +38,14 @@ public class BlockVacuumFreezer extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom"); } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta(blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/storage/BlockAesu.java b/src/main/java/techreborn/blocks/storage/BlockAesu.java index 1dabe7855..ddcf2a9b8 100644 --- a/src/main/java/techreborn/blocks/storage/BlockAesu.java +++ b/src/main/java/techreborn/blocks/storage/BlockAesu.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.blocks.BlockMachineBase; @@ -55,10 +56,13 @@ public class BlockAesu extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/aesu_side"); } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - if (side == metadata) + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta(blockAccess, x, y, z); + if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) { return this.iconFront; + } return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop diff --git a/src/main/java/techreborn/blocks/storage/BlockIDSU.java b/src/main/java/techreborn/blocks/storage/BlockIDSU.java index 3e610e643..4e6764aa5 100644 --- a/src/main/java/techreborn/blocks/storage/BlockIDSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockIDSU.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.blocks.BlockMachineBase; @@ -40,13 +41,13 @@ public class BlockIDSU extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/idsu_side"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/blocks/storage/BlockLesu.java b/src/main/java/techreborn/blocks/storage/BlockLesu.java index 84e63915b..aa2d09e5b 100644 --- a/src/main/java/techreborn/blocks/storage/BlockLesu.java +++ b/src/main/java/techreborn/blocks/storage/BlockLesu.java @@ -7,6 +7,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.Core; import techreborn.blocks.BlockMachineBase; @@ -38,10 +39,9 @@ public class BlockLesu extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/lesu_side"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - if (side == metadata) - return this.iconFront; + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop diff --git a/src/main/java/techreborn/blocks/storage/BlockLesuStorage.java b/src/main/java/techreborn/blocks/storage/BlockLesuStorage.java index bbbbffe55..4cbb100f0 100644 --- a/src/main/java/techreborn/blocks/storage/BlockLesuStorage.java +++ b/src/main/java/techreborn/blocks/storage/BlockLesuStorage.java @@ -9,6 +9,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import techreborn.blocks.BlockMachineBase; import techreborn.tiles.lesu.TileLesuStorage; @@ -38,14 +39,13 @@ public class BlockLesuStorage extends BlockMachineBase { this.iconBottom = icon.registerIcon("techreborn:machine/lesu_block"); } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - + @Override + public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = getTileMeta((World) blockAccess, x, y, z); return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : side == 0 ? this.iconBottom : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); - } @Override diff --git a/src/main/java/techreborn/tiles/TileMachineBase.java b/src/main/java/techreborn/tiles/TileMachineBase.java index 10107a3b8..c47c1dd63 100644 --- a/src/main/java/techreborn/tiles/TileMachineBase.java +++ b/src/main/java/techreborn/tiles/TileMachineBase.java @@ -13,6 +13,8 @@ import java.util.List; public abstract class TileMachineBase extends TileEntity { + int meta; + public void syncWithAll() { if (!worldObj.isRemote) { PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(), @@ -39,4 +41,27 @@ public abstract class TileMachineBase extends TileEntity { readFromNBT(packet.func_148857_g()); } + public int getMeta() { + return meta; + } + + public void setMeta(int meta) { + this.meta = meta; + syncWithAll(); + worldObj.notifyBlockChange(xCoord, yCoord, zCoord, blockType); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); + } + + @Override + public void readFromNBT(NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + meta = tagCompound.getInteger("meta"); + } + + @Override + public void writeToNBT(NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setInteger("meta", meta); + } }