diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index b5a0ef202c..535462e200 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -33,7 +33,7 @@ public class BlockIndexer{ /** Stores all damaged tile entities by team. */ private Seq[] damagedTiles = new Seq[Team.all.length]; /** All ores available on this map. */ - private ObjectSet allOres = new ObjectSet<>(); + private ObjectIntMap allOres = new ObjectIntMap<>(); /** Stores teams that are present here as tiles. */ private Seq activeTeams = new Seq<>(Team.class); /** Maps teams to a map of flagged tiles by flag. */ @@ -78,8 +78,6 @@ public class BlockIndexer{ var drop = tile.drop(); if(drop != null){ - allOres.add(drop); - int qx = (tile.x / quadrantSize); int qy = (tile.y / quadrantSize); @@ -92,6 +90,7 @@ public class BlockIndexer{ ores[drop.id][qx][qy] = new IntSeq(false, 16); } ores[drop.id][qx][qy].add(tile.pos()); + allOres.increment(drop); } } } @@ -150,9 +149,11 @@ public class BlockIndexer{ //when the drop can be mined, record the ore position if(tile.block() == Blocks.air && !seq.contains(pos)){ seq.add(pos); + allOres.increment(drop); }else{ //otherwise, it likely became blocked, remove it (even if it wasn't there) seq.removeValue(pos); + allOres.increment(drop, -1); } } @@ -177,7 +178,7 @@ public class BlockIndexer{ /** @return whether this item is present on this map. */ public boolean hasOre(Item item){ - return allOres.contains(item); + return allOres.get(item) > 0; } /** Returns all damaged tiles by team. */