From b25ddde5c89dfcae90ce8bf6f4afeab723b5ab3a Mon Sep 17 00:00:00 2001 From: Curle Date: Fri, 30 Jun 2023 06:05:16 +0100 Subject: [PATCH] smol coolant logic cleanup --- .../gemwire/engage/block/coolant/CoolantBaseBlock.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/uk/gemwire/engage/block/coolant/CoolantBaseBlock.java b/src/main/java/uk/gemwire/engage/block/coolant/CoolantBaseBlock.java index 045b1dd..d30e1cc 100644 --- a/src/main/java/uk/gemwire/engage/block/coolant/CoolantBaseBlock.java +++ b/src/main/java/uk/gemwire/engage/block/coolant/CoolantBaseBlock.java @@ -17,7 +17,7 @@ import java.util.*; public class CoolantBaseBlock extends Block { static Logger LOGGER = LogManager.getLogger(); - static List VALID_COOLANT_BLOCKS = List.of(Blocks.COMPRESSOR_BLOCK.block().get(), Blocks.COPPER_TUBE_BLOCK.block().get(), Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get(), Blocks.COOLANT_METERING_BLOCK.block().get()); + static Set VALID_COOLANT_BLOCKS = Set.of(Blocks.COMPRESSOR_BLOCK.block().get(), Blocks.COPPER_TUBE_BLOCK.block().get(), Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get(), Blocks.COOLANT_METERING_BLOCK.block().get()); public CoolantBaseBlock(Properties p_49795_) { super(p_49795_); @@ -31,7 +31,7 @@ public class CoolantBaseBlock extends Block { boolean encounteredMetering = false; boolean encounteredCompressor = false; boolean encounteredHeatSpreader = false; - List visitedBlocks = new ArrayList<>(); + Set visitedBlocks = new HashSet<>(); // If we happened to choose the path that encounters the metering device before a heat spreader, we need to swap our detection system. boolean prematureMetering = false; Direction lastTransitionDirection; @@ -120,7 +120,7 @@ public class CoolantBaseBlock extends Block { // Try to finalise stuff - we gotta have everything in our network. // First, check that the last remaining direction takes us into a block we've already visited (the closed loop) - if (visitedBlocks.contains(dirs.values().toArray()[0])) { + if (visitedBlocks.contains(dirs.values().iterator().next())) { // Check for premature mode if (prematureMetering) { if (!(encounteredCompressor && encounteredHeatSpreader)) { @@ -146,8 +146,8 @@ public class CoolantBaseBlock extends Block { LOGGER.info("Discovery took " + (endTime - startTime) + "ms"); } - private Map getValidTransitionsFrom(BlockPos pos, Direction incoming, Level level, List visited) { - Map dirs = new HashMap<>(); + private Map getValidTransitionsFrom(BlockPos pos, Direction incoming, Level level, Set visited) { + Map dirs = new EnumMap<>(Direction.class); for (Direction dir : Direction.values()) { if (incoming != null && dir == incoming) continue; BlockPos newPos = pos.relative(dir);