From 267c598b7f9c093a986770b05a217e68a29b7af8 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Tue, 6 Aug 2013 19:51:50 -0400 Subject: [PATCH] Wires will not connect with different material ones --- .../wire/TileEntityWire.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/resonantinduction/wire/TileEntityWire.java b/src/resonantinduction/wire/TileEntityWire.java index 98e3e735..45e78bc6 100644 --- a/src/resonantinduction/wire/TileEntityWire.java +++ b/src/resonantinduction/wire/TileEntityWire.java @@ -1,24 +1,43 @@ package resonantinduction.wire; +import net.minecraftforge.common.ForgeDirection; import universalelectricity.compatibility.TileEntityUniversalConductor; +import universalelectricity.core.vector.Vector3; public class TileEntityWire extends TileEntityUniversalConductor { - /** - * Changed this if your mod wants to nerf Basic Component's copper wire. - */ - public static float RESISTANCE = 0.05F; - public static float MAX_AMPS = 200; + @Override + public boolean canConnect(ForgeDirection direction) + { + Vector3 connectPos = new Vector3(this).modifyPositionFromSide(direction); + + if (connectPos.getTileEntity(this.worldObj) instanceof TileEntityWire && connectPos.getBlockMetadata(this.worldObj) != this.getTypeID()) + { + return false; + } + + return true; + } @Override public float getResistance() { - return RESISTANCE; + return getMaterial().resistance; } @Override public float getCurrentCapacity() { - return MAX_AMPS; + return getMaterial().maxAmps; + } + + public EnumWire getMaterial() + { + return EnumWire.values()[this.getTypeID()]; + } + + public int getTypeID() + { + return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); } }