diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-02-27 21:52:02 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-02-27 21:52:02 +1000 |
commit | 47ff638d276f5f926640b224e443bdccfd7b8506 (patch) | |
tree | 2b39067caab27d5bf93e6b8bbb84e6e3eb342d98 /src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java | |
parent | 7711c80664fdfa703b5e60e62af437655da783ae (diff) | |
download | GT5-Unofficial-47ff638d276f5f926640b224e443bdccfd7b8506.tar.gz GT5-Unofficial-47ff638d276f5f926640b224e443bdccfd7b8506.tar.bz2 GT5-Unofficial-47ff638d276f5f926640b224e443bdccfd7b8506.zip |
Pushing more things to Git which weren't there.
ToroiseGit doesn't auto add new files to be pushed/committed unless you manually add them to a commit. :(
Diffstat (limited to 'src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java')
-rw-r--r-- | src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java b/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java index 79990c6959..43db642248 100644 --- a/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java +++ b/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java @@ -1,9 +1,12 @@ package crazypants.enderio.conduit.gas; -import com.enderio.core.common.util.BlockCoord; +import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent; +import crazypants.enderio.conduit.ConduitNetworkTickHandler; +import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener; import crazypants.enderio.conduit.ConnectionMode; import crazypants.enderio.conduit.IConduit; import crazypants.enderio.conduit.IConduitBundle; +import crazypants.util.BlockCoord; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -23,12 +26,19 @@ public class GasConduitNetwork private int ticksActiveUnsynced; private boolean lastSyncedActive = false; private int lastSyncedVolume = -1; + private long timeAtLastApply; + private final InnerTickHandler tickHandler = new InnerTickHandler(null); public GasConduitNetwork() { super(GasConduit.class); } + public Class<IGasConduit> getBaseConduitType() + { + return IGasConduit.class; + } + public void addConduit(GasConduit con) { this.tank.setCapacity(this.tank.getMaxGas() + 1000); @@ -87,7 +97,24 @@ public class GasConduitNetwork } } - public void doNetworkTick() + public void onUpdateEntity(IConduit conduit) + { + World world = conduit.getBundle().getEntity().getWorldObj(); + if (world == null) { + return; + } + if (world.isRemote) { + return; + } + long curTime = world.getTotalWorldTime(); + if ((curTime > 0L) && (curTime != this.timeAtLastApply)) + { + this.timeAtLastApply = curTime; + ConduitNetworkTickHandler.instance.addListener(this.tickHandler); + } + } + + private void doTick() { if ((this.gasType == null) || (this.outputs.isEmpty()) || (!this.tank.containsValidGas()) || (this.tank.isEmpty())) { @@ -277,4 +304,17 @@ public class GasConduitNetwork setConduitVolumes(); this.lastSyncedVolume = this.tank.getStored(); } + + private class InnerTickHandler + implements ConduitNetworkTickHandler.TickListener + { + private InnerTickHandler() {} + + public void tickStart(TickEvent.ServerTickEvent evt) {} + + public void tickEnd(TickEvent.ServerTickEvent evt) + { + GasConduitNetwork.this.doTick(); + } + } } |