Made Laser Relay not output to the same block it got the energy from /cc Didi

This commit is contained in:
Ellpeck 2015-10-29 21:02:10 +01:00
parent 4c6d76d82e
commit bf65cc4edb
2 changed files with 19 additions and 15 deletions

View file

@ -160,7 +160,7 @@ public class LaserRelayConnectionHandler{
System.out.println("Merged Two Networks!"); System.out.println("Merged Two Networks!");
} }
public int transferEnergyToReceiverInNeed(Network network, int maxTransfer, boolean simulate){ public int transferEnergyToReceiverInNeed(WorldPos energyGottenFrom, Network network, int maxTransfer, boolean simulate){
int transmitted = 0; int transmitted = 0;
//Go through all of the connections in the network //Go through all of the connections in the network
for(ConnectionPair pair : network.connections){ for(ConnectionPair pair : network.connections){
@ -171,8 +171,10 @@ public class LaserRelayConnectionHandler{
//Get every side of the relay //Get every side of the relay
for(int i = 0; i <= 5; i++){ for(int i = 0; i <= 5; i++){
ForgeDirection side = ForgeDirection.getOrientation(i); ForgeDirection side = ForgeDirection.getOrientation(i);
//Get the TileEntity at the side //Get the Position at the side
TileEntity tile = WorldUtil.getTileEntityFromSide(side, relay.getWorld(), relay.getX(), relay.getY(), relay.getZ()); WorldPos pos = WorldUtil.getCoordsFromSide(side, relay.getWorld(), relay.getX(), relay.getY(), relay.getZ(), 0);
if(!pos.isEqual(energyGottenFrom)){
TileEntity tile = pos.getTileEntity();
if(tile instanceof IEnergyReceiver && !(tile instanceof TileEntityLaserRelay)){ if(tile instanceof IEnergyReceiver && !(tile instanceof TileEntityLaserRelay)){
IEnergyReceiver receiver = (IEnergyReceiver)tile; IEnergyReceiver receiver = (IEnergyReceiver)tile;
if(receiver.canConnectEnergy(side.getOpposite())){ if(receiver.canConnectEnergy(side.getOpposite())){
@ -189,6 +191,7 @@ public class LaserRelayConnectionHandler{
} }
} }
} }
}
return transmitted; return transmitted;
} }

View file

@ -16,6 +16,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler; import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldPos;
import ellpeck.actuallyadditions.util.WorldUtil;
import io.netty.util.internal.ConcurrentSet; import io.netty.util.internal.ConcurrentSet;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityReddustFX; import net.minecraft.client.particle.EntityReddustFX;
@ -98,7 +99,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
@Override @Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
return this.transmitEnergy(maxReceive, simulate); return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, worldObj, xCoord, yCoord, zCoord, 0), maxReceive, simulate);
} }
@Override @Override
@ -111,12 +112,12 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
return 0; return 0;
} }
public int transmitEnergy(int maxTransmit, boolean simulate){ public int transmitEnergy(WorldPos blockFrom, int maxTransmit, boolean simulate){
int transmitted = 0; int transmitted = 0;
if(maxTransmit > 0){ if(maxTransmit > 0){
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord)); LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord));
if(network != null){ if(network != null){
transmitted = LaserRelayConnectionHandler.getInstance().transferEnergyToReceiverInNeed(network, maxTransmit, simulate); transmitted = LaserRelayConnectionHandler.getInstance().transferEnergyToReceiverInNeed(blockFrom, network, maxTransmit, simulate);
} }
} }
return transmitted; return transmitted;