Fixed wires causing TE conduits to malfunction
This commit is contained in:
parent
2f42329173
commit
662837fb3d
3 changed files with 78 additions and 7 deletions
|
@ -1 +1 @@
|
|||
Subproject commit efbdc74c82b31b476f5ece15bb379dfa9f98200a
|
||||
Subproject commit c26937ca337d8cf3b96f2b647be1a005c6c00d34
|
|
@ -30,8 +30,6 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
@Override
|
||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||
{
|
||||
// new
|
||||
// Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world())
|
||||
return this.getNetwork().produce(this, from.getOpposite(), receive, doReceive);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,14 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.wire.PartConductor;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
||||
{
|
||||
public Set<PartConductor> teConductorInterfaces = new HashSet<PartConductor>();
|
||||
public Set<IEnergyHandler> teInterfaces = new HashSet<IEnergyHandler>();
|
||||
|
||||
@Override
|
||||
|
@ -19,6 +21,7 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
|||
|
||||
if (that instanceof TraitEnergyHandler)
|
||||
{
|
||||
this.teConductorInterfaces = ((TraitEnergyHandler) that).teConductorInterfaces;
|
||||
this.teInterfaces = ((TraitEnergyHandler) that).teInterfaces;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +33,14 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
|||
|
||||
if (part instanceof IEnergyHandler)
|
||||
{
|
||||
this.teInterfaces.add((IEnergyHandler) part);
|
||||
if (part instanceof PartConductor)
|
||||
{
|
||||
this.teConductorInterfaces.add((PartConductor) part);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.teInterfaces.add((IEnergyHandler) part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +51,14 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
|||
|
||||
if (part instanceof IEnergyHandler)
|
||||
{
|
||||
this.teInterfaces.remove(part);
|
||||
if (part instanceof PartConductor)
|
||||
{
|
||||
this.teConductorInterfaces.remove((PartConductor) part);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.teInterfaces.remove(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +67,7 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
|||
{
|
||||
super.clearParts();
|
||||
this.teInterfaces.clear();
|
||||
this.teConductorInterfaces.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +84,7 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
|||
{
|
||||
TMultiPart part = this.partMap(dir.ordinal());
|
||||
|
||||
if (this.teInterfaces.contains(part))
|
||||
if (this.teConductorInterfaces.contains(part))
|
||||
{
|
||||
return ((IEnergyHandler) part).receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
@ -74,6 +92,14 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed, try pure TE interfaces.
|
||||
*/
|
||||
for (IEnergyHandler handler : this.teInterfaces)
|
||||
{
|
||||
return handler.receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -94,7 +120,7 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
|||
{
|
||||
TMultiPart part = this.partMap(dir.ordinal());
|
||||
|
||||
if (this.teInterfaces.contains(part))
|
||||
if (this.teConductorInterfaces.contains(part))
|
||||
{
|
||||
return ((IEnergyHandler) part).canInterface(from);
|
||||
}
|
||||
|
@ -102,18 +128,65 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
|
|||
}
|
||||
}
|
||||
|
||||
for (IEnergyHandler handler : this.teInterfaces)
|
||||
{
|
||||
return handler.canInterface(from);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from)
|
||||
{
|
||||
if (this.partMap(from.ordinal()) == null)
|
||||
{
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (dir != from.getOpposite())
|
||||
{
|
||||
TMultiPart part = this.partMap(dir.ordinal());
|
||||
|
||||
if (this.teConductorInterfaces.contains(part))
|
||||
{
|
||||
return ((IEnergyHandler) part).getEnergyStored(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IEnergyHandler handler : this.teInterfaces)
|
||||
{
|
||||
return handler.getEnergyStored(from);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from)
|
||||
{
|
||||
if (this.partMap(from.ordinal()) == null)
|
||||
{
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (dir != from.getOpposite())
|
||||
{
|
||||
TMultiPart part = this.partMap(dir.ordinal());
|
||||
|
||||
if (this.teConductorInterfaces.contains(part))
|
||||
{
|
||||
return ((IEnergyHandler) part).getMaxEnergyStored(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IEnergyHandler handler : this.teInterfaces)
|
||||
{
|
||||
return handler.getMaxEnergyStored(from);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue