diff --git a/electrical/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java b/electrical/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java index 765c7ffd4..44f75fcda 100644 --- a/electrical/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java +++ b/electrical/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java @@ -36,263 +36,262 @@ import codechicken.multipart.MultiPartRegistry; import codechicken.multipart.PartMap; import codechicken.multipart.TSlottedPart; import codechicken.multipart.TileMultipart; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class PartFramedWire extends PartFramedConnection implements IConductor, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects { - public PartFramedWire() - { - super(); - breakIcon = RenderFramedWire.breakIcon; - } + public PartFramedWire() + { + super(); + if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) + breakIcon = RenderFramedWire.breakIcon; + } - public PartFramedWire(EnumWireMaterial type) - { - super(); - breakIcon = RenderFramedWire.breakIcon; - material = type; - } + public PartFramedWire(EnumWireMaterial type) + { + this(); + material = type; + } - public PartFramedWire(int typeID) - { - this(EnumWireMaterial.values()[typeID]); - } + public PartFramedWire(int typeID) + { + this(EnumWireMaterial.values()[typeID]); + } - @Override - public String getType() - { - return "resonant_induction_wire"; - } + @Override + public String getType() + { + return "resonant_induction_wire"; + } - @Override - public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item) - { - if (item != null) - { - if (item.getItem().itemID == Block.lever.blockID) - { - TileMultipart tile = tile(); - World w = world(); + @Override + public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item) + { + if (item != null) + { + if (item.getItem().itemID == Block.lever.blockID) + { + TileMultipart tile = tile(); + World w = world(); - if (!w.isRemote) - { - PartFramedSwitchWire wire = (PartFramedSwitchWire) MultiPartRegistry.createPart("resonant_induction_switch_wire", false); - wire.copyFrom(this); + if (!w.isRemote) + { + PartFramedSwitchWire wire = (PartFramedSwitchWire) MultiPartRegistry.createPart("resonant_induction_switch_wire", false); + wire.copyFrom(this); - if (tile.canReplacePart(this, wire)) - { - tile.remPart(this); - TileMultipart.addPart(w, new BlockCoord(tile), wire); + if (tile.canReplacePart(this, wire)) + { + tile.remPart(this); + TileMultipart.addPart(w, new BlockCoord(tile), wire); - if (!player.capabilities.isCreativeMode) - { - player.inventory.decrStackSize(player.inventory.currentItem, 1); - } - } - } - return true; - } - } + if (!player.capabilities.isCreativeMode) + { + player.inventory.decrStackSize(player.inventory.currentItem, 1); + } + } + } + return true; + } + } - return super.activate(player, part, item); - } + return super.activate(player, part, item); + } - @Override - public void preparePlacement(int meta) - { - this.setMaterial(meta); - } + @Override + public void preparePlacement(int meta) + { + this.setMaterial(meta); + } - @Override - public Iterable getCollisionBoxes() - { - Set collisionBoxes = new HashSet(); - collisionBoxes.addAll((Collection) getSubParts()); + @Override + public Iterable getCollisionBoxes() + { + Set collisionBoxes = new HashSet(); + collisionBoxes.addAll((Collection) getSubParts()); - return collisionBoxes; - } + return collisionBoxes; + } - @Override - public float getStrength(MovingObjectPosition hit, EntityPlayer player) - { - return 10F; - } + @Override + public float getStrength(MovingObjectPosition hit, EntityPlayer player) + { + return 10F; + } - @Override - @SideOnly(Side.CLIENT) - public void renderStatic(codechicken.lib.vec.Vector3 pos, LazyLightMatrix olm, int pass) - { - if (pass == 0) - { - RenderFramedWire.INSTANCE.renderStatic(this); - } - } + @Override + @SideOnly(Side.CLIENT) + public void renderStatic(codechicken.lib.vec.Vector3 pos, LazyLightMatrix olm, int pass) + { + if (pass == 0) + { + RenderFramedWire.INSTANCE.renderStatic(this); + } + } - @Override - @SideOnly(Side.CLIENT) - public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass) - { - if (getMaterial() == EnumWireMaterial.SILVER) - { - RenderFramedWire.INSTANCE.renderShine(this, pos.x, pos.y, pos.z, frame); - } - } + @Override + @SideOnly(Side.CLIENT) + public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass) + { + if (getMaterial() == EnumWireMaterial.SILVER) + { + RenderFramedWire.INSTANCE.renderShine(this, pos.x, pos.y, pos.z, frame); + } + } - @Override - public void drawBreaking(RenderBlocks renderBlocks) - { - CCRenderState.reset(); - RenderUtils.renderBlock(sides[6], 0, new Translation(x(), y(), z()), new IconTransformation(renderBlocks.overrideBlockTexture), null); - } + @Override + public void drawBreaking(RenderBlocks renderBlocks) + { + CCRenderState.reset(); + RenderUtils.renderBlock(sides[6], 0, new Translation(x(), y(), z()), new IconTransformation(renderBlocks.overrideBlockTexture), null); + } - @Override - public Iterable getOcclusionBoxes() - { - return getCollisionBoxes(); - } + @Override + public Iterable getOcclusionBoxes() + { + return getCollisionBoxes(); + } - @Override - public int getSlotMask() - { - return PartMap.CENTER.mask; - } + @Override + public int getSlotMask() + { + return PartMap.CENTER.mask; + } - @Override - public int getHollowSize() - { - return isInsulated ? 8 : 6; - } + @Override + public int getHollowSize() + { + return isInsulated ? 8 : 6; + } - @Override - public Cuboid6 getBounds() - { - return new Cuboid6(0.375, 0.375, 0.375, 0.625, 0.625, 0.625); - } + @Override + public Cuboid6 getBounds() + { + return new Cuboid6(0.375, 0.375, 0.375, 0.625, 0.625, 0.625); + } - @Override - public Icon getBreakingIcon(Object subPart, int side) - { - return RenderFramedWire.breakIcon; - } + @Override + public Icon getBreakingIcon(Object subPart, int side) + { + return RenderFramedWire.breakIcon; + } - @Override - protected boolean canConnectTo(TileEntity tile) - { - return tile instanceof IConductor || this.canConnectToObj(tile); - } + @Override + protected boolean canConnectTo(TileEntity tile) + { + return tile instanceof IConductor || this.canConnectToObj(tile); + } - public boolean canConnectToObj(Object obj) - { - if (obj != null && (obj.getClass().isAssignableFrom(this.getClass()) || this.getClass().isAssignableFrom(obj.getClass()))) - { - PartAdvancedWire wire = (PartAdvancedWire) obj; + public boolean canConnectToObj(Object obj) + { + if (obj != null && (obj.getClass().isAssignableFrom(this.getClass()) || this.getClass().isAssignableFrom(obj.getClass()))) + { + PartAdvancedWire wire = (PartAdvancedWire) obj; - if (this.getMaterial() == wire.getMaterial()) - { - if (this.isInsulated() && wire.isInsulated()) - { - return this.getColor() == wire.getColor() || (this.getColor() == DEFAULT_COLOR || wire.getColor() == DEFAULT_COLOR); - } + if (this.getMaterial() == wire.getMaterial()) + { + if (this.isInsulated() && wire.isInsulated()) + { + return this.getColor() == wire.getColor() || (this.getColor() == DEFAULT_COLOR || wire.getColor() == DEFAULT_COLOR); + } - return true; - } - } - else if (!(obj instanceof IConductor)) - { - return CompatibilityModule.isHandler(obj); - } + return true; + } + } + else if (!(obj instanceof IConductor)) + { + return CompatibilityModule.isHandler(obj); + } - return false; - } + return false; + } - @Override - public IConductor getConnector(TileEntity tile) - { - if (tile instanceof IConductor) - return (IConductor) ((IConductor) tile).getInstance(ForgeDirection.UNKNOWN); + @Override + public IConductor getConnector(TileEntity tile) + { + if (tile instanceof IConductor) + return (IConductor) ((IConductor) tile).getInstance(ForgeDirection.UNKNOWN); - return null; - } + return null; + } - /** - * Shouldn't need to be overridden. Override connectionPrevented instead - */ - @Override - public boolean canConnect(ForgeDirection direction, Object obj) - { - if (obj instanceof PartFramedWire) - { - if (world().isBlockIndirectlyGettingPowered(x(), y(), z())) - { - return false; - } + /** Shouldn't need to be overridden. Override connectionPrevented instead */ + @Override + public boolean canConnect(ForgeDirection direction, Object obj) + { + if (obj instanceof PartFramedWire) + { + if (world().isBlockIndirectlyGettingPowered(x(), y(), z())) + { + return false; + } - Vector3 connectPos = new Vector3(tile()).translate(direction); - TileEntity connectTile = connectPos.getTileEntity(world()); - return !isConnectionPrevented(connectTile, direction); - } + Vector3 connectPos = new Vector3(tile()).translate(direction); + TileEntity connectTile = connectPos.getTileEntity(world()); + return !isConnectionPrevented(connectTile, direction); + } - return false; - } + return false; + } - @Override - public float getResistance() - { - return this.getMaterial().resistance; - } + @Override + public float getResistance() + { + return this.getMaterial().resistance; + } - public void copyFrom(PartFramedWire otherCable) - { - this.isInsulated = otherCable.isInsulated; - this.color = otherCable.color; - this.connections = otherCable.connections; - this.material = otherCable.material; - this.currentWireConnections = otherCable.currentWireConnections; - this.currentAcceptorConnections = otherCable.currentAcceptorConnections; - this.setNetwork(otherCable.getNetwork()); - this.getNetwork().setBufferFor(this, otherCable.getInstance(ForgeDirection.UNKNOWN).getNetwork().getBufferOf(otherCable)); - } + public void copyFrom(PartFramedWire otherCable) + { + this.isInsulated = otherCable.isInsulated; + this.color = otherCable.color; + this.connections = otherCable.connections; + this.material = otherCable.material; + this.currentWireConnections = otherCable.currentWireConnections; + this.currentAcceptorConnections = otherCable.currentAcceptorConnections; + this.setNetwork(otherCable.getNetwork()); + this.getNetwork().setBufferFor(this, otherCable.getInstance(ForgeDirection.UNKNOWN).getNetwork().getBufferOf(otherCable)); + } - @Override - public IEnergyNetwork getNetwork() - { - if (network == null) - { - setNetwork(EnergyNetworkLoader.getNewNetwork(this)); - } + @Override + public IEnergyNetwork getNetwork() + { + if (network == null) + { + setNetwork(EnergyNetworkLoader.getNewNetwork(this)); + } - return network; - } + return network; + } - @Override - public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive) - { - return this.getNetwork().produce(this, from.getOpposite(), receive, doReceive); - } + @Override + public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive) + { + return this.getNetwork().produce(this, from.getOpposite(), receive, doReceive); + } - @Override - public long onExtractEnergy(ForgeDirection from, long request, boolean doExtract) - { - return 0; - } + @Override + public long onExtractEnergy(ForgeDirection from, long request, boolean doExtract) + { + return 0; + } - @Override - public long getCurrentCapacity() - { - return this.getMaterial().maxAmps; - } + @Override + public long getCurrentCapacity() + { + return this.getMaterial().maxAmps; + } - @Override - public void setMaterial(int i) - { - setMaterial(EnumWireMaterial.values()[i]); - } + @Override + public void setMaterial(int i) + { + setMaterial(EnumWireMaterial.values()[i]); + } - @Override - protected ItemStack getItem() - { - return new ItemStack(Electrical.itemWire); - } + @Override + protected ItemStack getItem() + { + return new ItemStack(Electrical.itemWire); + } } \ No newline at end of file diff --git a/src/main/java/resonantinduction/core/prefab/part/PartFramedConnection.java b/src/main/java/resonantinduction/core/prefab/part/PartFramedConnection.java index 32136bad7..fe3ed3f25 100644 --- a/src/main/java/resonantinduction/core/prefab/part/PartFramedConnection.java +++ b/src/main/java/resonantinduction/core/prefab/part/PartFramedConnection.java @@ -32,6 +32,8 @@ import codechicken.multipart.PartMap; import codechicken.multipart.TMultiPart; import codechicken.multipart.TSlottedPart; import codechicken.multipart.TileMultipart; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class PartFramedConnection, N extends INodeNetwork> extends PartColorableMaterial implements IConnector, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects { @@ -69,6 +71,8 @@ public abstract class PartFramedConnection other) - { - this.isInsulated = other.isInsulated; - this.color = other.color; - this.connections = other.connections; - this.material = other.material; - this.currentWireConnections = other.currentWireConnections; - this.currentAcceptorConnections = other.currentAcceptorConnections; - this.setNetwork(other.getNetwork()); - } + public void copyFrom(PartFramedConnection other) + { + this.isInsulated = other.isInsulated; + this.color = other.color; + this.connections = other.connections; + this.material = other.material; + this.currentWireConnections = other.currentWireConnections; + this.currentAcceptorConnections = other.currentAcceptorConnections; + this.setNetwork(other.getNetwork()); + } - /** - * Packet Methods - */ - public void sendConnectionUpdate() - { - tile().getWriteStream(this).writeByte(0).writeByte(this.currentWireConnections).writeByte(this.currentAcceptorConnections); - } + /** Packet Methods */ + public void sendConnectionUpdate() + { + tile().getWriteStream(this).writeByte(0).writeByte(this.currentWireConnections).writeByte(this.currentAcceptorConnections); + } - @Override - public void readDesc(MCDataInput packet) - { - super.readDesc(packet); - this.currentWireConnections = packet.readByte(); - this.currentAcceptorConnections = packet.readByte(); - } + @Override + public void readDesc(MCDataInput packet) + { + super.readDesc(packet); + this.currentWireConnections = packet.readByte(); + this.currentAcceptorConnections = packet.readByte(); + } - @Override - public void writeDesc(MCDataOutput packet) - { - super.writeDesc(packet); - packet.writeByte(this.currentWireConnections); - packet.writeByte(this.currentAcceptorConnections); - } + @Override + public void writeDesc(MCDataOutput packet) + { + super.writeDesc(packet); + packet.writeByte(this.currentWireConnections); + packet.writeByte(this.currentAcceptorConnections); + } - @Override - public void read(MCDataInput packet) - { - read(packet, packet.readUByte()); - } + @Override + public void read(MCDataInput packet) + { + read(packet, packet.readUByte()); + } - @Override - public void read(MCDataInput packet, int packetID) - { - if (packetID == 0) - { - this.currentWireConnections = packet.readByte(); - this.currentAcceptorConnections = packet.readByte(); - tile().markRender(); - } - else - { - super.read(packet, packetID); - } - } + @Override + public void read(MCDataInput packet, int packetID) + { + if (packetID == 0) + { + this.currentWireConnections = packet.readByte(); + this.currentAcceptorConnections = packet.readByte(); + tile().markRender(); + } + else + { + super.read(packet, packetID); + } + } - /** - * Network Methods - */ - @Override - public void setNetwork(N network) - { - this.network = network; - } + /** Network Methods */ + @Override + public void setNetwork(N network) + { + this.network = network; + } - @Override - public IConnector getInstance(ForgeDirection dir) - { - return this; - } + @Override + public IConnector getInstance(ForgeDirection dir) + { + return this; + } } \ No newline at end of file