Added ability to split wires via redstone
This commit is contained in:
parent
267c598b7f
commit
0231e7ab68
1 changed files with 35 additions and 0 deletions
|
@ -1,14 +1,22 @@
|
||||||
package resonantinduction.wire;
|
package resonantinduction.wire;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.compatibility.TileEntityUniversalConductor;
|
import universalelectricity.compatibility.TileEntityUniversalConductor;
|
||||||
|
import universalelectricity.core.block.INetworkProvider;
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
|
import universalelectricity.core.vector.VectorHelper;
|
||||||
|
|
||||||
public class TileEntityWire extends TileEntityUniversalConductor
|
public class TileEntityWire extends TileEntityUniversalConductor
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection direction)
|
public boolean canConnect(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
|
if (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Vector3 connectPos = new Vector3(this).modifyPositionFromSide(direction);
|
Vector3 connectPos = new Vector3(this).modifyPositionFromSide(direction);
|
||||||
|
|
||||||
if (connectPos.getTileEntity(this.worldObj) instanceof TileEntityWire && connectPos.getBlockMetadata(this.worldObj) != this.getTypeID())
|
if (connectPos.getTileEntity(this.worldObj) instanceof TileEntityWire && connectPos.getBlockMetadata(this.worldObj) != this.getTypeID())
|
||||||
|
@ -19,6 +27,33 @@ public class TileEntityWire extends TileEntityUniversalConductor
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refresh()
|
||||||
|
{
|
||||||
|
if (!this.worldObj.isRemote)
|
||||||
|
{
|
||||||
|
this.adjacentConnections = null;
|
||||||
|
|
||||||
|
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||||
|
{
|
||||||
|
if (this.canConnect(side.getOpposite()))
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), side);
|
||||||
|
|
||||||
|
if (tileEntity != null)
|
||||||
|
{
|
||||||
|
if (tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider)
|
||||||
|
{
|
||||||
|
this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getNetwork().refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getResistance()
|
public float getResistance()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue