From cac7aa6705e9197068e56a3e98dd6d99c1e3d920 Mon Sep 17 00:00:00 2001 From: George Paton Date: Tue, 19 Mar 2024 11:51:40 +1100 Subject: [PATCH] Fix diode reentry behaviour being wonky due to shallow history copy Fix diode error handling, will always fail if a particle can't leave a diode --- .../hbm/tileentity/machine/TileEntityHadron.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityHadron.java b/src/main/java/com/hbm/tileentity/machine/TileEntityHadron.java index a0c634cd9..55bbf917f 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityHadron.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityHadron.java @@ -424,8 +424,14 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs p.cl1 = cl1; p.expired = expired; p.plugs = new ArrayList(plugs); - p.history = new HashMap>(history); p.cloned = true; + + //Deep clone the history + p.history = new HashMap>(history); + for(TileEntityHadronDiode diode : p.history.keySet()) { + p.history.put(diode, new ArrayList(p.history.get(diode))); + } + return p; } @@ -752,8 +758,11 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs //Add the used direction to the main particle AFTER cloning, so the clones don't get incorrect travel history usedDirections.add(p.dir); - //If we managed to exit, keep going - if(hasTurnedCurrent) return; + //If we failed to exit, raise DIODE_COLLISION + if(!hasTurnedCurrent) + expire(p, EnumHadronState.ERROR_DIODE_COLLISION); + + return; } //next step is air or the core, proceed