From 07d0c2bfc17e1e0dfc74d513c2563a3379cacb7b Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Fri, 27 Mar 2015 17:09:23 -0400 Subject: [PATCH] Hopefully fixed negative buffer issue --- .../java/mekanism/api/gas/GasNetwork.java | 16 ++++----------- .../java/mekanism/common/EnergyNetwork.java | 20 +++++-------------- .../java/mekanism/common/FluidNetwork.java | 14 ++++--------- .../mekanism/common/InventoryNetwork.java | 12 +++-------- 4 files changed, 16 insertions(+), 46 deletions(-) diff --git a/src/main/java/mekanism/api/gas/GasNetwork.java b/src/main/java/mekanism/api/gas/GasNetwork.java index 10b2e0c29..b00827fc8 100644 --- a/src/main/java/mekanism/api/gas/GasNetwork.java +++ b/src/main/java/mekanism/api/gas/GasNetwork.java @@ -7,7 +7,6 @@ import java.util.EnumSet; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import mekanism.api.Coord4D; @@ -16,7 +15,6 @@ import mekanism.api.transmitters.IGridTransmitter; import mekanism.api.transmitters.ITransmitterNetwork; import mekanism.api.transmitters.TransmissionType; import mekanism.api.util.ListUtils; - import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; @@ -328,27 +326,21 @@ public class GasNetwork extends DynamicNetwork { Set> iterTubes = (Set>)transmitters.clone(); Iterator> it = iterTubes.iterator(); - boolean networkChanged = false; while(it.hasNext()) { - IGridTransmitter conductor = (IGridTransmitter)it.next(); + IGridTransmitter conductor = it.next(); if(conductor == null || conductor.getTile().isInvalid()) { - it.remove(); - networkChanged = true; - transmitters.remove(conductor); + removeTransmitter(conductor); } else { conductor.setTransmitterNetwork(this); } } - - if(networkChanged) - { - updateCapacity(); - } + + needsUpdate = true; } @Override diff --git a/src/main/java/mekanism/common/EnergyNetwork.java b/src/main/java/mekanism/common/EnergyNetwork.java index ca96c95f9..c0c3730ea 100644 --- a/src/main/java/mekanism/common/EnergyNetwork.java +++ b/src/main/java/mekanism/common/EnergyNetwork.java @@ -1,5 +1,8 @@ package mekanism.common; +import ic2.api.energy.EnergyNet; +import ic2.api.energy.tile.IEnergySink; + import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -7,7 +10,6 @@ import java.util.EnumSet; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import mekanism.api.Coord4D; @@ -19,17 +21,13 @@ import mekanism.api.transmitters.TransmissionType; import mekanism.api.util.ListUtils; import mekanism.common.util.CableUtils; import mekanism.common.util.MekanismUtils; - import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; +import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.Event; -import cofh.api.energy.IEnergyReceiver; -import ic2.api.energy.EnergyNet; -import ic2.api.energy.tile.IEnergySink; - public class EnergyNetwork extends DynamicNetwork { private double lastPowerScale = 0; @@ -304,7 +302,6 @@ public class EnergyNetwork extends DynamicNetwork { Set> iterCables = (Set>)transmitters.clone(); Iterator> it = iterCables.iterator(); - boolean networkChanged = false; while(it.hasNext()) { @@ -312,20 +309,13 @@ public class EnergyNetwork extends DynamicNetwork if(conductor == null || conductor.getTile().isInvalid()) { - it.remove(); - transmitters.remove(conductor); - networkChanged = true; + removeTransmitter(conductor); } else { conductor.setTransmitterNetwork(this); } } - if(networkChanged) - { - updateCapacity(); - } - needsUpdate = true; } diff --git a/src/main/java/mekanism/common/FluidNetwork.java b/src/main/java/mekanism/common/FluidNetwork.java index af752fd6a..4feb3a87d 100644 --- a/src/main/java/mekanism/common/FluidNetwork.java +++ b/src/main/java/mekanism/common/FluidNetwork.java @@ -342,8 +342,7 @@ public class FluidNetwork extends DynamicNetwork public synchronized void refresh() { Set> iterPipes = (Set>)transmitters.clone(); - Iterator it = iterPipes.iterator(); - boolean networkChanged = false; + Iterator> it = iterPipes.iterator(); while(it.hasNext()) { @@ -351,19 +350,14 @@ public class FluidNetwork extends DynamicNetwork if(conductor == null || conductor.getTile().isInvalid()) { - it.remove(); - networkChanged = true; - transmitters.remove(conductor); + removeTransmitter(conductor); } else { conductor.setTransmitterNetwork(this); } } - - if(networkChanged) - { - updateCapacity(); - } + + needsUpdate = true; } @Override diff --git a/src/main/java/mekanism/common/InventoryNetwork.java b/src/main/java/mekanism/common/InventoryNetwork.java index 91159e54a..4b71ecbe0 100644 --- a/src/main/java/mekanism/common/InventoryNetwork.java +++ b/src/main/java/mekanism/common/InventoryNetwork.java @@ -137,7 +137,6 @@ public class InventoryNetwork extends DynamicNetwork> iterPipes = (Set>)transmitters.clone(); Iterator it = iterPipes.iterator(); - boolean networkChanged = false; while(it.hasNext()) { @@ -145,19 +144,14 @@ public class InventoryNetwork extends DynamicNetwork