diff --git a/common/mekanism/induction/client/render/RenderPartWire.java b/common/mekanism/induction/client/render/RenderPartWire.java index c514e6555..fe4d31d8f 100644 --- a/common/mekanism/induction/client/render/RenderPartWire.java +++ b/common/mekanism/induction/client/render/RenderPartWire.java @@ -41,7 +41,7 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderPartWire { - private static final ResourceLocation WIRE_SHINE = new ResourceLocation(MekanismInduction.DOMAIN, MekanismInduction.MODEL_TEXTURE_DIRECTORY + "white.png"); + private static final ResourceLocation WIRE_SHINE = MekanismUtils.getResource(ResourceType.RENDER, "white.png"); public static final Map models; public static final Map shinyModels; public static Icon wireIcon; @@ -108,7 +108,7 @@ public class RenderPartWire GL11.glEnable(GL11.GL_LIGHT3); GL11.glLight(GL11.GL_LIGHT3, GL11.GL_POSITION, location); - GL11.glTranslatef((float) x, (float) y, (float) z); + GL11.glTranslatef((float)x, (float)y, (float)z); GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, zero); CCRenderState.reset(); @@ -144,9 +144,9 @@ public class RenderPartWire public static void registerIcons(IconRegister iconReg) { - wireIcon = iconReg.registerIcon(MekanismInduction.PREFIX + MekanismInduction.MODEL_TEXTURE_DIRECTORY + "Wire"); - insulationIcon = iconReg.registerIcon(MekanismInduction.PREFIX + MekanismInduction.MODEL_TEXTURE_DIRECTORY + "Insulation" + (MekanismInduction.LO_FI_INSULATION ? "Tiny" : "")); - breakIcon = iconReg.registerIcon(MekanismInduction.PREFIX + "wire"); + wireIcon = iconReg.registerIcon("mekanism:render/Wire"); + insulationIcon = iconReg.registerIcon("mekanism:render/" + "Insulation" + (MekanismInduction.LO_FI_INSULATION ? "Tiny" : "")); + breakIcon = iconReg.registerIcon("mekanism:wire"); } public void renderStatic(PartWire wire) diff --git a/common/mekanism/induction/client/render/RenderWire.java b/common/mekanism/induction/client/render/RenderWire.java index 4988fb2ad..e95584cec 100644 --- a/common/mekanism/induction/client/render/RenderWire.java +++ b/common/mekanism/induction/client/render/RenderWire.java @@ -1,5 +1,7 @@ package mekanism.induction.client.render; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.induction.client.model.ModelInsulation; import mekanism.induction.client.model.ModelWire; import mekanism.induction.common.MekanismInduction; @@ -25,55 +27,56 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderWire extends TileEntitySpecialRenderer { - private static final ResourceLocation WIRE_TEXTURE = new ResourceLocation(MekanismInduction.DOMAIN, "textures/blocks/" + MekanismInduction.MODEL_TEXTURE_DIRECTORY + "WireSimple.png"); - private static final ResourceLocation INSULATION_TEXTURE = new ResourceLocation(MekanismInduction.DOMAIN, "textures/blocks/" + MekanismInduction.MODEL_TEXTURE_DIRECTORY + "InsulationSimple.png"); + private static final ResourceLocation WIRE_TEXTURE = MekanismUtils.getResource(ResourceType.RENDER, "WireSimple.png"); + private static final ResourceLocation INSULATION_TEXTURE = MekanismUtils.getResource(ResourceType.RENDER, "InsulationSimple.png"); + public static final ModelWire WIRE_MODEL = new ModelWire(); public static final ModelInsulation INSULATION_MODEL = new ModelInsulation(); public void renderModelAt(TileEntityWire tileEntity, double x, double y, double z, float f) { - if (tileEntity != null) + if(tileEntity != null) { GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glScalef(1, -1, -1); EnumWireMaterial material = tileEntity.getMaterial(); - // Texture file + //Texture file FMLClientHandler.instance().getClient().renderEngine.bindTexture(WIRE_TEXTURE); GL11.glColor4d(material.color.x, material.color.y, material.color.z, 1); tileEntity.adjacentConnections = null; TileEntity[] adjacentConnections = tileEntity.getAdjacentConnections(); - if (adjacentConnections != null) + if(adjacentConnections != null) { - if (adjacentConnections[0] != null) + if(adjacentConnections[0] != null) { WIRE_MODEL.renderBottom(); } - if (adjacentConnections[1] != null) + if(adjacentConnections[1] != null) { WIRE_MODEL.renderTop(); } - if (adjacentConnections[2] != null) + if(adjacentConnections[2] != null) { WIRE_MODEL.renderBack(); } - if (adjacentConnections[3] != null) + if(adjacentConnections[3] != null) { WIRE_MODEL.renderFront(); } - if (adjacentConnections[4] != null) + if(adjacentConnections[4] != null) { WIRE_MODEL.renderLeft(); } - if (adjacentConnections[5] != null) + if(adjacentConnections[5] != null) { WIRE_MODEL.renderRight(); } @@ -81,41 +84,40 @@ public class RenderWire extends TileEntitySpecialRenderer WIRE_MODEL.renderMiddle(); - if (tileEntity.isInsulated) + if(tileEntity.isInsulated) { - // Texture file FMLClientHandler.instance().getClient().renderEngine.bindTexture(INSULATION_TEXTURE); Vector3 insulationColor = MekanismInduction.DYE_COLORS[tileEntity.dyeID]; GL11.glColor4d(insulationColor.x, insulationColor.y, insulationColor.z, 1); - if (adjacentConnections != null) + if(adjacentConnections != null) { - if (adjacentConnections[0] != null) + if(adjacentConnections[0] != null) { INSULATION_MODEL.renderBottom(0.0625f); } - if (adjacentConnections[1] != null) + if(adjacentConnections[1] != null) { INSULATION_MODEL.renderTop(0.0625f); } - if (adjacentConnections[2] != null) + if(adjacentConnections[2] != null) { INSULATION_MODEL.renderBack(0.0625f); } - if (adjacentConnections[3] != null) + if(adjacentConnections[3] != null) { INSULATION_MODEL.renderFront(0.0625f); } - if (adjacentConnections[4] != null) + if(adjacentConnections[4] != null) { INSULATION_MODEL.renderLeft(0.0625f); } - if (adjacentConnections[5] != null) + if(adjacentConnections[5] != null) { INSULATION_MODEL.renderRight(0.0625f); } @@ -131,6 +133,6 @@ public class RenderWire extends TileEntitySpecialRenderer @Override public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) { - this.renderModelAt((TileEntityWire) tileEntity, var2, var4, var6, var8); + renderModelAt((TileEntityWire)tileEntity, var2, var4, var6, var8); } } \ No newline at end of file diff --git a/common/mekanism/induction/common/block/BlockWire.java b/common/mekanism/induction/common/block/BlockWire.java index 1e12dae86..cbdf68d6f 100644 --- a/common/mekanism/induction/common/block/BlockWire.java +++ b/common/mekanism/induction/common/block/BlockWire.java @@ -15,6 +15,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import universalelectricity.core.block.IConductor; import universalelectricity.prefab.block.BlockConductor; /** @@ -27,31 +28,45 @@ public class BlockWire extends BlockConductor public BlockWire(int id) { super(Mekanism.configuration.getBlock("wire", id).getInt(id), Material.cloth); - this.setUnlocalizedName(MekanismInduction.PREFIX + "wire"); - this.setStepSound(soundClothFootstep); - this.setResistance(0.2F); - this.setHardness(0.1f); - this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f); - this.setCreativeTab(CreativeTabs.tabRedstone); - Block.setBurnProperties(this.blockID, 30, 60); - this.setTextureName(MekanismInduction.PREFIX + "wire"); - this.setCreativeTab(Mekanism.tabMekanism); + + setUnlocalizedName(MekanismInduction.PREFIX + "wire"); + setStepSound(soundClothFootstep); + setResistance(0.2F); + setHardness(0.1f); + setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f); + setCreativeTab(CreativeTabs.tabRedstone); + Block.setBurnProperties(blockID, 30, 60); + setTextureName(MekanismInduction.PREFIX + "wire"); + setCreativeTab(Mekanism.tabMekanism); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) + { + super.onNeighborBlockChange(world, x, y, z, blockID); + + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + if(tileEntity instanceof IConductor) + { + world.markBlockForUpdate(x, y, z); + } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { TileEntity t = world.getBlockTileEntity(x, y, z); - TileEntityWire tileEntity = (TileEntityWire) t; + TileEntityWire tileEntity = (TileEntityWire)t; - if (entityPlayer.getCurrentEquippedItem() != null) + if(entityPlayer.getCurrentEquippedItem() != null) { - if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID) + if(entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID) { tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage()); return true; } - else if (entityPlayer.getCurrentEquippedItem().itemID == Block.cloth.blockID && !tileEntity.isInsulated) + else if(entityPlayer.getCurrentEquippedItem().itemID == Block.cloth.blockID && !tileEntity.isInsulated) { tileEntity.setInsulated(); tileEntity.setDye(BlockColored.getDyeFromBlock(entityPlayer.getCurrentEquippedItem().getItemDamage())); @@ -63,30 +78,18 @@ public class BlockWire extends BlockConductor return false; } - /** - * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the - * shared face of two adjacent blocks and also whether the player can attach torches, redstone - * wire, etc to this block. - */ @Override public boolean isOpaqueCube() { return false; } - /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, - * buttons, stairs, etc) - */ @Override public boolean renderAsNormalBlock() { return false; } - /** - * The type of render function that is called for this block - */ @Override public int getRenderType() { @@ -100,17 +103,17 @@ public class BlockWire extends BlockConductor } @Override - public int damageDropped(int par1) + public int damageDropped(int i) { - return par1; + return i; } @Override - public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) + public void getSubBlocks(int i, CreativeTabs par2CreativeTabs, List list) { - for (int i = 0; i < EnumWireMaterial.values().length; i++) + for(EnumWireMaterial material : EnumWireMaterial.values()) { - par3List.add(new ItemStack(par1, 1, i)); + list.add(new ItemStack(i, 1, material.ordinal())); } } @@ -119,16 +122,13 @@ public class BlockWire extends BlockConductor { TileEntity t = world.getBlockTileEntity(x, y, z); - /** - * Drop wool insulation if the wire is insulated. - */ - if (t instanceof TileEntityWire) + if(t instanceof TileEntityWire) { TileEntityWire tileEntity = (TileEntityWire) t; - if (tileEntity.isInsulated) + if(tileEntity.isInsulated) { - this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(tileEntity.dyeID))); + dropBlockAsItem_do(world, x, y, z, new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(tileEntity.dyeID))); } } diff --git a/common/mekanism/induction/common/tileentity/TileEntityWire.java b/common/mekanism/induction/common/tileentity/TileEntityWire.java index f473df4fa..8020a05c5 100644 --- a/common/mekanism/induction/common/tileentity/TileEntityWire.java +++ b/common/mekanism/induction/common/tileentity/TileEntityWire.java @@ -28,28 +28,29 @@ public class TileEntityWire extends TileEntityUniversalConductor implements ITil @Override public boolean canConnect(ForgeDirection direction) { - if (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) + if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { return false; } Vector3 connectPos = new Vector3(this).modifyPositionFromSide(direction); - TileEntity connectTile = connectPos.getTileEntity(this.worldObj); - if (connectTile instanceof IWireMaterial) + TileEntity connectTile = connectPos.getTileEntity(worldObj); + + if(connectTile instanceof IWireMaterial) { IWireMaterial wireTile = (IWireMaterial) connectTile; - if (wireTile.getMaterial() != this.getMaterial()) + if(wireTile.getMaterial() != getMaterial()) { return false; } } - if (this.isInsulated() && connectTile instanceof IInsulation) + if(isInsulated() && connectTile instanceof IInsulation) { IInsulation insulatedTile = (IInsulation) connectTile; - if ((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != this.getInsulationColor() && this.getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR)) + if((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != getInsulationColor() && getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR)) { return false; } @@ -61,27 +62,27 @@ public class TileEntityWire extends TileEntityUniversalConductor implements ITil @Override public void refresh() { - if (!this.worldObj.isRemote) + if(!worldObj.isRemote) { - this.adjacentConnections = null; + adjacentConnections = null; - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if (this.canConnect(side.getOpposite())) + if(canConnect(side.getOpposite())) { - TileEntity tileEntity = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), side); + TileEntity tileEntity = VectorHelper.getConnectorFromSide(worldObj, new Vector3(this), side); - if (tileEntity != null) + if(tileEntity != null) { - if (tileEntity instanceof INetworkProvider) + if(tileEntity instanceof INetworkProvider) { - this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork()); + getNetwork().merge(((INetworkProvider)tileEntity).getNetwork()); } } } } - this.getNetwork().refresh(); + getNetwork().refresh(); } } @@ -100,29 +101,35 @@ public class TileEntityWire extends TileEntityUniversalConductor implements ITil @Override public EnumWireMaterial getMaterial() { - return EnumWireMaterial.values()[this.getTypeID()]; + return EnumWireMaterial.values()[getTypeID()]; } public int getTypeID() { - return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); + return worldObj.getBlockMetadata(xCoord, yCoord, zCoord); } /** * @param dyeID */ - public void setDye(int dyeID) + public void setDye(int dye) { - this.dyeID = dyeID; - this.refresh(); - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + dyeID = dye; + refresh(); + + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID); } public void setInsulated() { - this.isInsulated = true; - this.refresh(); - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + isInsulated = true; + refresh(); + + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID); } @Override @@ -135,46 +142,40 @@ public class TileEntityWire extends TileEntityUniversalConductor implements ITil } @Override - public void handlePacketData(ByteArrayDataInput input) + public void handlePacketData(ByteArrayDataInput dataStream) { - try - { - this.isInsulated = input.readBoolean(); - this.dyeID = input.readInt(); - } - catch (Exception e) - { + try { + isInsulated = dataStream.readBoolean(); + dyeID = dataStream.readInt(); + } catch(Exception e) { e.printStackTrace(); } } - /** - * Reads a tile entity from NBT. - */ @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - this.dyeID = nbt.getInteger("dyeID"); - this.isInsulated = nbt.getBoolean("isInsulated"); + + dyeID = nbt.getInteger("dyeID"); + isInsulated = nbt.getBoolean("isInsulated"); } - /** - * Writes a tile entity to NBT. - */ @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setInteger("dyeID", this.dyeID); - nbt.setBoolean("isInsulated", this.isInsulated); + + nbt.setInteger("dyeID", dyeID); + nbt.setBoolean("isInsulated", isInsulated); } @Override public void doWork(PowerHandler workProvider) { - this.buildcraftBuffer = Compatibility.BC3_RATIO * 25 * this.getMaterial().maxAmps; - this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2); + buildcraftBuffer = Compatibility.BC3_RATIO * 25 * getMaterial().maxAmps; + powerHandler.configure(0, buildcraftBuffer, buildcraftBuffer, buildcraftBuffer * 2); + super.doWork(workProvider); } @@ -187,9 +188,10 @@ public class TileEntityWire extends TileEntityUniversalConductor implements ITil @Override public void setInsulated(boolean insulated) { - if (insulated && !isInsulated()) + if(insulated && !isInsulated()) + { setInsulated(); - + } } @Override diff --git a/common/mekanism/induction/common/wire/PartUniversalConductor.java b/common/mekanism/induction/common/wire/PartUniversalConductor.java index 73e3f1ae2..0fc7a72b1 100644 --- a/common/mekanism/induction/common/wire/PartUniversalConductor.java +++ b/common/mekanism/induction/common/wire/PartUniversalConductor.java @@ -59,7 +59,7 @@ public abstract class PartUniversalConductor extends PartConductor implements IE { if(tile instanceof IEnergyHandler) { - return !((IEnergyHandler) tile).canInterface(side); + return !((IEnergyHandler)tile).canInterface(side); } return super.isConnectionPrevented(tile, side); diff --git a/common/mekanism/induction/common/wire/PartWire.java b/common/mekanism/induction/common/wire/PartWire.java index b173e2e11..52248c4cd 100644 --- a/common/mekanism/induction/common/wire/PartWire.java +++ b/common/mekanism/induction/common/wire/PartWire.java @@ -178,6 +178,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN dyeID = dye; refresh(); world().markBlockForUpdate(x(), y(), z()); + tile().notifyPartChange(this); } public void setMaterialFromID(int id) @@ -347,6 +348,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN { tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID)))); } + setInsulated(BlockColored.getDyeFromBlock(item.getItemDamage())); player.inventory.decrStackSize(player.inventory.currentItem, 1); return true; @@ -399,8 +401,10 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN public void setInsulationColor(int dye) { dyeID = dye; + refresh(); world().markBlockForUpdate(x(), y(), z()); + tile().notifyPartChange(this); } @Override @@ -408,6 +412,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN { isInsulated = insulated; dyeID = DEFAULT_COLOR; + refresh(); world().markBlockForUpdate(x(), y(), z()); tile().notifyPartChange(this); @@ -417,6 +422,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN { isInsulated = true; dyeID = dyeColour; + refresh(); world().markBlockForUpdate(x(), y(), z()); tile().notifyPartChange(this);