This commit is contained in:
Anuken
2025-07-12 12:42:05 -04:00
parent 0539d00cda
commit aeee327e6c

View File

@@ -203,43 +203,44 @@ public class BlockIndexer{
} }
} }
public void addIndex(Tile tile){ public void addIndex(Tile base){
process(tile); process(base);
Item drop = tile.drop(), wallDrop = tile.wallDrop(); base.getLinkedTiles(tile -> {
if(drop == null && wallDrop == null) return; Item drop = tile.drop(), wallDrop = tile.wallDrop();
int qx = tile.x / quadrantSize, qy = tile.y / quadrantSize; if(drop == null && wallDrop == null) return;
int pos = tile.pos(); int qx = tile.x / quadrantSize, qy = tile.y / quadrantSize;
int pos = tile.pos();
if(tile.block() == Blocks.air){ if(tile.block() == Blocks.air){
if(drop != null){ //floor if(drop != null){ //floor
if(ores[drop.id] == null) ores[drop.id] = new IntSeq[quadWidth][quadHeight]; if(ores[drop.id] == null) ores[drop.id] = new IntSeq[quadWidth][quadHeight];
if(ores[drop.id][qx][qy] == null) ores[drop.id][qx][qy] = new IntSeq(false, 16); if(ores[drop.id][qx][qy] == null) ores[drop.id][qx][qy] = new IntSeq(false, 16);
if(ores[drop.id][qx][qy].addUnique(pos)){ if(ores[drop.id][qx][qy].addUnique(pos)){
int old = allOres.increment(drop); //increment ore count only if not already counted int old = allOres.increment(drop); //increment ore count only if not already counted
if(old == 0) updatePresentOres(); if(old == 0) updatePresentOres();
}
}
if(wallDrop != null && wallOres != null && wallOres[wallDrop.id] != null && wallOres[wallDrop.id][qx][qy] != null && wallOres[wallDrop.id][qx][qy].removeValue(pos)){ //wall
int old = allWallOres.increment(wallDrop, -1);
if(old == 1) updatePresentOres();
}
}else{
if(wallDrop != null){ //wall
if(wallOres[wallDrop.id] == null) wallOres[wallDrop.id] = new IntSeq[quadWidth][quadHeight];
if(wallOres[wallDrop.id][qx][qy] == null) wallOres[wallDrop.id][qx][qy] = new IntSeq(false, 16);
if(wallOres[wallDrop.id][qx][qy].addUnique(pos)){
int old = allWallOres.increment(wallDrop); //increment ore count only if not already counted
if(old == 0) updatePresentOres();
}
}
if(drop != null && ores != null && ores[drop.id] != null && ores[drop.id][qx][qy] != null && ores[drop.id][qx][qy].removeValue(pos)){ //floor
int old = allOres.increment(drop, -1);
if(old == 1) updatePresentOres();
} }
} }
if(wallDrop != null && wallOres != null && wallOres[wallDrop.id] != null && wallOres[wallDrop.id][qx][qy] != null && wallOres[wallDrop.id][qx][qy].removeValue(pos)){ //wall });
int old = allWallOres.increment(wallDrop, -1);
if(old == 1) updatePresentOres();
}
}else{
if(wallDrop != null){ //wall
if(wallOres[wallDrop.id] == null) wallOres[wallDrop.id] = new IntSeq[quadWidth][quadHeight];
if(wallOres[wallDrop.id][qx][qy] == null) wallOres[wallDrop.id][qx][qy] = new IntSeq(false, 16);
if(wallOres[wallDrop.id][qx][qy].addUnique(pos)){
int old = allWallOres.increment(wallDrop); //increment ore count only if not already counted
if(old == 0) updatePresentOres();
}
}
if(drop != null && ores != null && ores[drop.id] != null && ores[drop.id][qx][qy] != null && ores[drop.id][qx][qy].removeValue(pos)){ //floor
int old = allOres.increment(drop, -1);
if(old == 1) updatePresentOres();
}
}
} }
/** @return whether a certain block is anywhere on this map. */ /** @return whether a certain block is anywhere on this map. */