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
This commit is contained in:
George Paton 2024-03-19 11:51:40 +11:00
parent 67fbcfd3c2
commit cac7aa6705

View File

@ -424,8 +424,14 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
p.cl1 = cl1;
p.expired = expired;
p.plugs = new ArrayList<TileEntityHadronPower>(plugs);
p.history = new HashMap<TileEntityHadronDiode, List<ForgeDirection>>(history);
p.cloned = true;
//Deep clone the history
p.history = new HashMap<TileEntityHadronDiode, List<ForgeDirection>>(history);
for(TileEntityHadronDiode diode : p.history.keySet()) {
p.history.put(diode, new ArrayList<ForgeDirection>(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