Change thermal evap controller check to not recurse. Fixes
package mekanism.common.tile;
+import java.util.Deque;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.Set;
import javax.annotation.Nonnull;
import mekanism.api.Coord4D;
@@ -14,6 +16,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
+import net.minecraft.util.math.BlockPos;
public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock implements IComputerIntegration {
@@ -81,6 +84,16 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock
public void updateController() {
if (!(this instanceof TileEntityThermalEvaporationController)) {
+ for (EnumFacing side : EnumFacing.values()){
+ BlockPos checkPos = pos.offset(side);
+ TileEntity check;
+ if (world.isBlockLoaded(checkPos) && (check = world.getTileEntity(checkPos)) instanceof TileEntityThermalEvaporationBlock) {
+ if (check instanceof TileEntityThermalEvaporationController){
+ ((TileEntityThermalEvaporationController) check).refresh();
+ return;
+ }
+ }
+ }
TileEntityThermalEvaporationController found = new ControllerFinder().find();
if (found != null) {
@@ -148,34 +161,40 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock
public TileEntityThermalEvaporationController found;
- public Set<Coord4D> iterated = new HashSet<>();
+ public Set<BlockPos> iterated = new HashSet<>();
- public void loop(Coord4D pos) {
- if (iterated.size() > 512 || found != null) {
- return;
- }
+ private Deque<BlockPos> checkQueue = new LinkedList<>();
- iterated.add(pos);
-
- for (EnumFacing side : EnumFacing.VALUES) {
- Coord4D coord = pos.offset(side);
+ public void loop(BlockPos startPos) {
+ checkQueue.add(startPos);
- if (!iterated.contains(coord) && coord
- .getTileEntity(world) instanceof TileEntityThermalEvaporationBlock) {
- ((TileEntityThermalEvaporationBlock) coord.getTileEntity(world)).attempted = true;
-
- if (coord.getTileEntity(world) instanceof TileEntityThermalEvaporationController) {
- found = (TileEntityThermalEvaporationController) coord.getTileEntity(world);
+ while (checkQueue.peek() != null) {
+ BlockPos checkPos = checkQueue.pop();
+ if (iterated.contains(checkPos)) {
+ continue;
+ }
+ iterated.add(checkPos);
+ if (world.isBlockLoaded(checkPos)) {
+ TileEntity te = world.getTileEntity(checkPos);
+ if (te instanceof TileEntityThermalEvaporationController) {
+ found = (TileEntityThermalEvaporationController) te;
return;
}
-
- loop(coord);
+ if (te instanceof TileEntityThermalEvaporationBlock) {
+ ((TileEntityThermalEvaporationBlock) te).attempted = true;
+ for (EnumFacing side : EnumFacing.VALUES) {
+ BlockPos coord = checkPos.offset(side);
+ if (!iterated.contains(coord)) {
+ checkQueue.addLast(coord);
+ }
+ }
+ }
}
}
}
public TileEntityThermalEvaporationController find() {
- loop(Coord4D.get(TileEntityThermalEvaporationBlock.this));
+ loop(TileEntityThermalEvaporationBlock.this.pos);
return found;
}
