Make vertical radius configurable

This commit is contained in:
OrderedSet committed 2026-11-08 11:20:42 -08:00
1 parent 1478f21eb4
commit 0e6f01f84d
4 files changed
+54 -24

No files matched your search

@@ -475,6 +475,14 @@ public class NEIClientConfig {
"world.overlays.mobOverlayRadius",
MobOverlayScan.MIN_RADIUS,
MobOverlayScan.MAX_RADIUS));
tag.getTag("world.overlays.mobOverlayVerticalRadius")
.setComment("Blocks scanned above and below the player by the mob spawn overlay")
.getIntValue(MobOverlayScan.DEFAULT_VERTICAL_RADIUS);
API.addOption(
new OptionIntegerField(
"world.overlays.mobOverlayVerticalRadius",
MobOverlayScan.MIN_VERTICAL_RADIUS,
MobOverlayScan.MAX_VERTICAL_RADIUS));
tag.getTag("inventory.itempanelScale").getIntValue(100);
ItemsPanelGrid.updateScale();
@@ -106,7 +106,10 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
return;
}
MOB_OVERLAY_SCAN.update(entity, NEIClientConfig.getIntSetting("world.overlays.mobOverlayRadius"));
MOB_OVERLAY_SCAN.update(
entity,
NEIClientConfig.getIntSetting("world.overlays.mobOverlayRadius"),
NEIClientConfig.getIntSetting("world.overlays.mobOverlayVerticalRadius"));
final MobOverlayStyle style = MobOverlayStyle
.parseStyle(NEIClientConfig.getSetting("world.overlays.mobOverlayStyle").getValue());
final long worldTicks = entity.worldObj.getTotalWorldTime();
@@ -130,7 +133,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
final int span = MOB_OVERLAY_SCAN.getSpan();
for (int i = 0; i < span; i++) {
for (int j = 0; j < span; j++) {
for (int k = 0; k < MobOverlayScan.HEIGHT; k++) {
for (int k = 0; k < MOB_OVERLAY_SCAN.getHeight(); k++) {
if (MOB_OVERLAY_SCAN.readSpawnMode(i, k, j) == 0) continue;
final double yOffset = getOverlayYOffset(
@@ -25,8 +25,9 @@ public final class MobOverlayScan {
public static final int MIN_RADIUS = 8;
public static final int MAX_RADIUS = 64;
public static final int DEFAULT_RADIUS = 32;
public static final int VERTICAL_RADIUS = 16;
public static final int HEIGHT = 2 * VERTICAL_RADIUS + 1;
public static final int MIN_VERTICAL_RADIUS = 4;
public static final int MAX_VERTICAL_RADIUS = 64;
public static final int DEFAULT_VERTICAL_RADIUS = 16;
private static final int RECENTRE_DISTANCE = 4;
private static final int VERTICAL_RECENTRE_DISTANCE = 2;
private static final int RESCAN_TICKS = 40;
@@ -34,7 +35,9 @@ public final class MobOverlayScan {
private final IWorldAccess changeListener = new ChangeListener();
private final Column column = new Column();
private int radius;
private int verticalRadius;
private int span;
private int height;
// a ring buffer over the box, indexed by `findCell()`
private byte[] modes = new byte[0];
// indexed by `findColumn(x, z)`
@@ -54,7 +57,9 @@ public final class MobOverlayScan {
public void clear() {
if (scannedWorld != null) scannedWorld.removeWorldAccess(changeListener);
radius = 0;
verticalRadius = 0;
span = 0;
height = 0;
modes = new byte[0];
dirty = new boolean[0];
hasModes = false;
@@ -62,19 +67,24 @@ public final class MobOverlayScan {
}
/**
* Scan every column in this call after {@link #clear}, a radius change, a world change, or a move of
* {@link #getSpan} blocks or more. {@code newRadius} is clamped between {@link #MIN_RADIUS} and
* {@link #MAX_RADIUS}.
* Scan every column in this call after {@link #clear}, a change of either radius, a world change, or a move of
* {@link #getSpan} blocks or more across or {@link #getHeight} blocks or more up or down. {@code newRadius} is
* clamped between {@link #MIN_RADIUS} and {@link #MAX_RADIUS}, and {@code newVerticalRadius} between
* {@link #MIN_VERTICAL_RADIUS} and {@link #MAX_VERTICAL_RADIUS}.
*/
public void update(Entity entity, int newRadius) {
public void update(Entity entity, int newRadius, int newVerticalRadius) {
final World world = entity.worldObj;
final int clampedRadius = Math.max(MIN_RADIUS, Math.min(MAX_RADIUS, newRadius));
if (radius != clampedRadius) resize(clampedRadius);
final int clampedRadius = (int) MathHelper.clip(newRadius, MIN_RADIUS, MAX_RADIUS);
final int clampedVerticalRadius = (int) MathHelper
.clip(newVerticalRadius, MIN_VERTICAL_RADIUS, MAX_VERTICAL_RADIUS);
if (radius != clampedRadius || verticalRadius != clampedVerticalRadius) {
resize(clampedRadius, clampedVerticalRadius);
}
final int centreX = MathHelper.floor_double(entity.posX);
final int centreY = (int) MathHelper.clip(entity.posY, VERTICAL_RADIUS, world.getHeight() - VERTICAL_RADIUS);
final int centreY = (int) MathHelper.clip(entity.posY, verticalRadius, world.getHeight() - verticalRadius);
final int centreZ = MathHelper.floor_double(entity.posZ);
final boolean isNearBox = Math.abs(centreX - radius - minX) < span && Math.abs(centreZ - radius - minZ) < span
&& Math.abs(centreY - VERTICAL_RADIUS - minY) < HEIGHT;
&& Math.abs(centreY - verticalRadius - minY) < height;
if (!(hasModes && world == scannedWorld && isNearBox)) {
if (world != scannedWorld) watchWorld(world);
scanFullBox(centreX, centreY, centreZ);
@@ -100,6 +110,10 @@ public final class MobOverlayScan {
return span;
}
public int getHeight() {
return height;
}
public int getMinX() {
return minX;
}
@@ -112,15 +126,17 @@ public final class MobOverlayScan {
return minZ;
}
/** {@code i} and {@code j} are from 0 to {@link #getSpan}, and {@code k} is from 0 to {@link #HEIGHT}. */
/** {@code i} and {@code j} are from 0 to {@link #getSpan}, and {@code k} is from 0 to {@link #getHeight}. */
public byte readSpawnMode(int i, int k, int j) {
return modes[findCell(minX + i, minY + k, minZ + j)];
}
private void resize(int newRadius) {
private void resize(int newRadius, int newVerticalRadius) {
radius = newRadius;
verticalRadius = newVerticalRadius;
span = 2 * newRadius + 1;
modes = new byte[span * span * HEIGHT];
height = 2 * newVerticalRadius + 1;
modes = new byte[span * span * height];
dirty = new boolean[span * span];
hasModes = false;
}
@@ -128,7 +144,7 @@ public final class MobOverlayScan {
private void scanFullBox(int centreX, int centreY, int centreZ) {
final long startNanos = System.nanoTime();
minX = centreX - radius;
minY = centreY - VERTICAL_RADIUS;
minY = centreY - verticalRadius;
minZ = centreZ - radius;
for (int x = minX; x < minX + span; x++) {
for (int z = minZ; z < minZ + span; z++) {
@@ -139,8 +155,9 @@ public final class MobOverlayScan {
modesVersion++;
scannedTick = scannedWorld.getTotalWorldTime();
NEIClientConfig.logger.info(
"moboverlay.scan.full radius={} columns={} micros={}",
"moboverlay.scan.full radius={} verticalRadius={} columns={} micros={}",
radius,
verticalRadius,
span * span,
(System.nanoTime() - startNanos) / 1000);
}
@@ -178,9 +195,9 @@ public final class MobOverlayScan {
isMoved = true;
}
final int offsetY = centreY - VERTICAL_RADIUS - minY;
final int offsetY = centreY - verticalRadius - minY;
if (Math.abs(offsetY) > VERTICAL_RECENTRE_DISTANCE) {
final int enteringY = offsetY > 0 ? minY + HEIGHT : minY + offsetY;
final int enteringY = offsetY > 0 ? minY + height : minY + offsetY;
minY += offsetY;
for (int x = minX; x < minX + span; x++) {
for (int z = minZ; z < minZ + span; z++) {
@@ -221,7 +238,7 @@ public final class MobOverlayScan {
private boolean scanColumn(int x, int z) {
column.moveTo(x, z);
dirty[findColumn(x, z)] = false;
return column.scan(minY, minY + HEIGHT);
return column.scan(minY, minY + height);
}
private int findColumn(int x, int z) {
@@ -229,7 +246,7 @@ public final class MobOverlayScan {
}
private int findCell(int x, int y, int z) {
return findColumn(x, z) * HEIGHT + Math.floorMod(y, HEIGHT);
return findColumn(x, z) * height + Math.floorMod(y, height);
}
/**
@@ -325,7 +342,7 @@ public final class MobOverlayScan {
private void markChanged(int x, int y, int z) {
// spawn modes depend on the block below and the block above
final boolean isInBox = x >= minX && x < minX + span && z >= minZ && z < minZ + span;
if (isInBox && y >= minY - 1 && y <= minY + HEIGHT) markColumn(x, z);
if (isInBox && y >= minY - 1 && y <= minY + height) markColumn(x, z);
}
private void markColumn(int x, int z) {
@@ -572,8 +572,10 @@ nei.options.world.overlays.mobOverlayStyle.connected=Connected
nei.options.world.overlays.mobOverlayStyle.square=Square
nei.options.world.overlays.mobOverlayStyle.gtnh_logo=GTNH Logo
nei.options.world.overlays.mobOverlayStyle.pufferfish=Pufferfish
nei.options.world.overlays.mobOverlayRadius=Mob Spawn Overlay Radius
nei.options.world.overlays.mobOverlayRadius.tip=Block radius scanned around you. Range 8-64 blocks
nei.options.world.overlays.mobOverlayRadius=Mob Spawn Overlay Horizontal Radius
nei.options.world.overlays.mobOverlayRadius.tip=Horizontal block radius scanned around you. Range 8-64 blocks
nei.options.world.overlays.mobOverlayVerticalRadius=Mob Spawn Overlay Vertical Radius
nei.options.world.overlays.mobOverlayVerticalRadius.tip=Blocks scanned above and below you. Range 4-64 blocks
nei.options.tools=Tools
nei.options.tools.export_configs=Default Config Files