mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-13 03:49:09 +01:00
Make Laser Relays ignore full containers
This commit is contained in:
parent
1846d52e50
commit
ad1768302f
2 changed files with 44 additions and 12 deletions
|
@ -123,16 +123,32 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
|||
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
||||
if(relayTile instanceof TileEntityLaserRelayEnergy){
|
||||
TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile;
|
||||
boolean workedOnce = false;
|
||||
|
||||
int amount = theRelay.receiversAround.size();
|
||||
if(theRelay == this && theRelay.receiversAround.containsKey(from)){
|
||||
//So that the tile energy was gotten from isn't factored into the amount
|
||||
amount--;
|
||||
for(EnumFacing facing : theRelay.receiversAround.keySet()){
|
||||
if(theRelay != this || facing != from){
|
||||
TileEntity tile = theRelay.receiversAround.get(facing);
|
||||
|
||||
EnumFacing opp = facing.getOpposite();
|
||||
if(tile instanceof IEnergyReceiver){
|
||||
IEnergyReceiver iReceiver = (IEnergyReceiver)tile;
|
||||
if(iReceiver.canConnectEnergy(opp) && iReceiver.receiveEnergy(opp, Integer.MAX_VALUE, true) > 0){
|
||||
totalReceiverAmount++;
|
||||
workedOnce = true;
|
||||
}
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){
|
||||
ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp);
|
||||
if(cap != null && cap.givePower(maxTransfer, true) > 0){
|
||||
totalReceiverAmount++;
|
||||
workedOnce = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(amount > 0){
|
||||
if(workedOnce){
|
||||
relaysThatWork.add(theRelay);
|
||||
totalReceiverAmount += amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,16 +117,32 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
|||
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
||||
if(relayTile instanceof TileEntityLaserRelayFluids){
|
||||
TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile;
|
||||
boolean workedOnce = false;
|
||||
|
||||
int amount = theRelay.receiversAround.size();
|
||||
if(theRelay == this && theRelay.receiversAround.containsKey(from)){
|
||||
//So that the tile energy was gotten from isn't factored into the amount
|
||||
amount--;
|
||||
for(EnumFacing facing : theRelay.receiversAround.keySet()){
|
||||
if(theRelay != this || facing != from){
|
||||
TileEntity tile = theRelay.receiversAround.get(facing);
|
||||
|
||||
EnumFacing opp = facing.getOpposite();
|
||||
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||
net.minecraftforge.fluids.IFluidHandler iHandler = (net.minecraftforge.fluids.IFluidHandler)tile;
|
||||
if(iHandler.canFill(opp, stack.getFluid()) && iHandler.fill(opp, stack, false) > 0){
|
||||
totalReceiverAmount++;
|
||||
workedOnce = true;
|
||||
}
|
||||
}
|
||||
else if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)){
|
||||
IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp);
|
||||
if(cap != null && cap.fill(stack, false) > 0){
|
||||
totalReceiverAmount++;
|
||||
workedOnce = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(amount > 0){
|
||||
if(workedOnce){
|
||||
relaysThatWork.add(theRelay);
|
||||
totalReceiverAmount += amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue