diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java index 9459c9159..377166cb7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java @@ -154,15 +154,32 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ if(relayTile instanceof TileEntityLaserRelayEnergy){ TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile; if(theRelay.mode != Mode.INPUT_ONLY){ - 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--; + boolean workedOnce = false; + + for(EnumFacing facing : theRelay.receiversAround.keySet()){ + if(theRelay != this || facing != from){ + TileEntity tile = theRelay.receiversAround.get(facing); + + EnumFacing opp = facing.getOpposite(); + if(tile.hasCapability(CapabilityEnergy.ENERGY, opp)){ + IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, opp); + if(cap != null && cap.receiveEnergy(maxTransfer, 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; } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java index d2ada896d..539b321d1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java @@ -151,15 +151,25 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements if(relayTile instanceof TileEntityLaserRelayFluids){ TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile; if(theRelay.mode != Mode.INPUT_ONLY){ - 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--; + boolean workedOnce = false; + + for(EnumFacing facing : theRelay.receiversAround.keySet()){ + if(theRelay != this || facing != from){ + TileEntity tile = theRelay.receiversAround.get(facing); + + EnumFacing opp = facing.getOpposite(); + 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; } } }