Clarity rename Mob Spawn -> Mob Overlay

This commit is contained in:
OrderedSet committed 2026-11-08 00:23:11 -08:00
1 parent b29494935d
commit aa8f1c8adb
7 files changed
+81 -83

No files matched your search

@@ -4,20 +4,18 @@ import net.minecraft.client.renderer.GLAllocation;
import org.lwjgl.opengl.GL11;
/**
* The display list of the mob spawn overlay quads, and the scan version and the style that the list was compiled from.
*/
public final class MobSpawnDisplayList {
/** A GL display list of the mob spawn overlay. */
public final class MobOverlayDisplayList {
private int listId = -1;
private int modesVersion;
private MobSpawnOverlayStyle style;
private MobOverlayStyle style;
public boolean isCompiled(int currentModesVersion, MobSpawnOverlayStyle currentStyle) {
public boolean isCompiled(int currentModesVersion, MobOverlayStyle currentStyle) {
return listId >= 0 && modesVersion == currentModesVersion && style == currentStyle;
}
public void beginCompile(int newModesVersion, MobSpawnOverlayStyle newStyle) {
public void beginCompile(int newModesVersion, MobOverlayStyle newStyle) {
if (listId < 0) listId = GLAllocation.generateDisplayLists(1);
modesVersion = newModesVersion;
style = newStyle;
@@ -3,7 +3,7 @@ package codechicken.nei;
import net.minecraft.client.renderer.Tessellator;
/** The vertices of the mob spawn overlay on the top face of one block. */
public final class MobSpawnMarkedFace {
public final class MobOverlayFace {
public static final byte OUTSIDE_SCAN = -2;
@@ -26,8 +26,8 @@ public final class MobSpawnMarkedFace {
neighbourModes[indexNeighbour(offsetX, offsetZ)] = spawnMode;
}
public void applyColor(MobSpawnOverlayStyle.Colouring colouring, float alpha) {
final boolean isNightOnly = neighbourModes[indexNeighbour(0, 0)] == MobSpawnScan.NIGHT_ONLY;
public void applyColor(MobOverlayStyle.Colouring colouring, float alpha) {
final boolean isNightOnly = neighbourModes[indexNeighbour(0, 0)] == MobOverlayScan.NIGHT_ONLY;
final int rgb = switch (colouring) {
case OVERLAY -> isNightOnly ? 0xFFFF00 : 0xFF0000;
case STICKER -> isNightOnly ? 0xFFFFFF : 0xFF7373;
@@ -17,7 +17,7 @@ import codechicken.lib.math.MathHelper;
* when a pass is done. The column of a block or light change is rescanned on the next tick. The modes come from
* {@link WorldOverlayRenderer#getSpawnMode}: 0 for no spawns, 1 for night only and 2 for any time.
*/
public final class MobSpawnScan {
public final class MobOverlayScan {
public static final byte NIGHT_ONLY = 1;
public static final int MIN_RADIUS = 8;
@@ -9,14 +9,14 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
/** A mark of the mob spawn overlay. {@code world.overlays.mobSpawnStyle} is saved as {@link #formatName()}. */
public enum MobSpawnOverlayStyle {
/** A mark of the mob spawn overlay. {@code world.overlays.mobOverlayStyle} is saved as {@link #formatName()}. */
public enum MobOverlayStyle {
/** NEI's original cross from corner to corner. */
X(GL11.GL_LINES) {
@Override
public void addVertices(MobSpawnMarkedFace face) {
public void addVertices(MobOverlayFace face) {
face.addVertex(0, 0);
face.addVertex(1, 1);
face.addVertex(1, 0);
@@ -30,7 +30,7 @@ public enum MobSpawnOverlayStyle {
CONNECTED(GL11.GL_QUADS) {
@Override
public void addVertices(MobSpawnMarkedFace face) {
public void addVertices(MobOverlayFace face) {
final double BAND_WIDTH = 1.0 / 16;
face.addFullFace();
face.applyColor(Colouring.OVERLAY, MARK_ALPHA);
@@ -49,7 +49,7 @@ public enum MobSpawnOverlayStyle {
SQUARE(GL11.GL_QUADS) {
@Override
public void addVertices(MobSpawnMarkedFace face) {
public void addVertices(MobOverlayFace face) {
final double CENTRE = 0.5;
final double HALF_SIDE = 7.0 / 64;
face.addVertex(CENTRE - HALF_SIDE, CENTRE - HALF_SIDE);
@@ -63,7 +63,7 @@ public enum MobSpawnOverlayStyle {
GTNH_LOGO("gtnh_logo", Colouring.OVERLAY) {
@Override
public void addVertices(MobSpawnMarkedFace face) {
public void addVertices(MobOverlayFace face) {
face.addTexturedFace();
}
},
@@ -72,12 +72,12 @@ public enum MobSpawnOverlayStyle {
PUFFERFISH("pufferfish", Colouring.STICKER) {
@Override
public void addVertices(MobSpawnMarkedFace face) {
public void addVertices(MobOverlayFace face) {
face.addTexturedFace();
}
};
public static final MobSpawnOverlayStyle DEFAULT = CONNECTED;
public static final MobOverlayStyle DEFAULT = CONNECTED;
private static final float TINT_ALPHA = 0.15F;
// at the tint's opacity, a small mark is too faint to see
@@ -88,21 +88,21 @@ public enum MobSpawnOverlayStyle {
public final ResourceLocation texture;
public final Colouring colouring;
MobSpawnOverlayStyle(int glMode) {
MobOverlayStyle(int glMode) {
this.glMode = glMode;
this.texture = null;
this.colouring = Colouring.OVERLAY;
}
MobSpawnOverlayStyle(String textureName, Colouring colouring) {
MobOverlayStyle(String textureName, Colouring colouring) {
this.glMode = GL11.GL_QUADS;
this.texture = new ResourceLocation("nei", "textures/overlay/" + textureName + ".png");
this.colouring = colouring;
}
/** Case-insensitive. Returns {@link #DEFAULT} for an unknown name. */
public static MobSpawnOverlayStyle parseStyle(String rawStyle) {
for (MobSpawnOverlayStyle candidate : values()) {
public static MobOverlayStyle parseStyle(String rawStyle) {
for (MobOverlayStyle candidate : values()) {
if (candidate.formatName().equalsIgnoreCase(rawStyle)) return candidate;
}
return DEFAULT;
@@ -111,7 +111,7 @@ public enum MobSpawnOverlayStyle {
/** @return the {@link #formatName} of every style, separated by commas */
public static String formatAllNames() {
final StringJoiner names = new StringJoiner(", ");
for (MobSpawnOverlayStyle style : values()) {
for (MobOverlayStyle style : values()) {
names.add(style.formatName());
}
return names.toString();
@@ -123,11 +123,11 @@ public enum MobSpawnOverlayStyle {
public String getLangKey() {
return switch (this) {
case X -> "nei.options.world.overlays.mobSpawnStyle.x";
case CONNECTED -> "nei.options.world.overlays.mobSpawnStyle.connected";
case SQUARE -> "nei.options.world.overlays.mobSpawnStyle.square";
case GTNH_LOGO -> "nei.options.world.overlays.mobSpawnStyle.gtnh_logo";
case PUFFERFISH -> "nei.options.world.overlays.mobSpawnStyle.pufferfish";
case X -> "nei.options.world.overlays.mobOverlayStyle.x";
case CONNECTED -> "nei.options.world.overlays.mobOverlayStyle.connected";
case SQUARE -> "nei.options.world.overlays.mobOverlayStyle.square";
case GTNH_LOGO -> "nei.options.world.overlays.mobOverlayStyle.gtnh_logo";
case PUFFERFISH -> "nei.options.world.overlays.mobOverlayStyle.pufferfish";
};
}
@@ -144,7 +144,7 @@ public enum MobSpawnOverlayStyle {
};
}
public abstract void addVertices(MobSpawnMarkedFace face);
public abstract void addVertices(MobOverlayFace face);
public enum Colouring {
/** Yellow where mobs spawn only at night, red where mobs spawn at any time. */
@@ -443,36 +443,36 @@ public class NEIClientConfig {
tag.getTag("world.overlays.lock").getBooleanValue(true);
API.addOption(new OptionToggleButton("world.overlays.lock", true));
tag.getTag("world.overlays.mobSpawnStyle")
.setComment("Mark on each block of the mob spawn overlay: " + MobSpawnOverlayStyle.formatAllNames())
.getValue(MobSpawnOverlayStyle.DEFAULT.formatName());
API.addOption(new OptionCycled("world.overlays.mobSpawnStyle", MobSpawnOverlayStyle.values().length, true) {
tag.getTag("world.overlays.mobOverlayStyle")
.setComment("Mark on each block of the mob spawn overlay: " + MobOverlayStyle.formatAllNames())
.getValue(MobOverlayStyle.DEFAULT.formatName());
API.addOption(new OptionCycled("world.overlays.mobOverlayStyle", MobOverlayStyle.values().length, true) {
@Override
public int value() {
return MobSpawnOverlayStyle.parseStyle(getTag().getValue()).ordinal();
return MobOverlayStyle.parseStyle(getTag().getValue()).ordinal();
}
@Override
public void setValue(int value) {
getTag().setValue(MobSpawnOverlayStyle.values()[value].formatName());
getTag().setValue(MobOverlayStyle.values()[value].formatName());
}
@Override
public String getButtonText() {
final MobSpawnOverlayStyle style = MobSpawnOverlayStyle.parseStyle(getTag().getValue());
final MobOverlayStyle style = MobOverlayStyle.parseStyle(getTag().getValue());
return StatCollector.translateToLocal(style.getLangKey());
}
});
tag.getTag("world.overlays.mobSpawnRadius")
tag.getTag("world.overlays.mobOverlayRadius")
.setComment("Blocks scanned on each side of the player by the mob spawn overlay")
.getIntValue(MobSpawnScan.DEFAULT_RADIUS);
.getIntValue(MobOverlayScan.DEFAULT_RADIUS);
API.addOption(
new OptionIntegerField(
"world.overlays.mobSpawnRadius",
MobSpawnScan.MIN_RADIUS,
MobSpawnScan.MAX_RADIUS));
"world.overlays.mobOverlayRadius",
MobOverlayScan.MIN_RADIUS,
MobOverlayScan.MAX_RADIUS));
tag.getTag("inventory.itempanelScale").getIntValue(100);
ItemsPanelGrid.updateScale();
@@ -31,9 +31,9 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
public static int chunkOverlay = 0;
public static int mobOverlay = 0;
private static final MobSpawnScan MOB_SPAWN_SCAN = new MobSpawnScan();
private static final MobSpawnMarkedFace MARKED_FACE = new MobSpawnMarkedFace();
private static final MobSpawnDisplayList MOB_SPAWN_LIST = new MobSpawnDisplayList();
private static final MobOverlayScan MOB_OVERLAY_SCAN = new MobOverlayScan();
private static final MobOverlayFace MARKED_FACE = new MobOverlayFace();
private static final MobOverlayDisplayList MOB_OVERLAY_LIST = new MobOverlayDisplayList();
public static void reset() {
mobOverlay = 0;
@@ -97,51 +97,51 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
*/
private static void renderMobSpawnOverlay(Entity entity, int intOffsetX, int intOffsetY, int intOffsetZ) {
if (mobOverlay == 0) {
MOB_SPAWN_SCAN.clear();
MOB_SPAWN_LIST.delete();
MOB_OVERLAY_SCAN.clear();
MOB_OVERLAY_LIST.delete();
return;
}
MOB_SPAWN_SCAN.update(entity, NEIClientConfig.getIntSetting("world.overlays.mobSpawnRadius"));
final MobSpawnOverlayStyle style = MobSpawnOverlayStyle
.parseStyle(NEIClientConfig.getSetting("world.overlays.mobSpawnStyle").getValue());
if (!MOB_SPAWN_LIST.isCompiled(MOB_SPAWN_SCAN.getModesVersion(), style)) {
compileMobSpawnList(entity.worldObj, style);
MOB_OVERLAY_SCAN.update(entity, NEIClientConfig.getIntSetting("world.overlays.mobOverlayRadius"));
final MobOverlayStyle style = MobOverlayStyle
.parseStyle(NEIClientConfig.getSetting("world.overlays.mobOverlayStyle").getValue());
if (!MOB_OVERLAY_LIST.isCompiled(MOB_OVERLAY_SCAN.getModesVersion(), style)) {
compileMobOverlayList(entity.worldObj, style);
}
beginMobSpawnDraw(style);
beginMobOverlayDraw(style);
GL11.glPushMatrix();
GL11.glTranslated(
MOB_SPAWN_SCAN.getMinX() - intOffsetX,
MOB_SPAWN_SCAN.getMinY() - intOffsetY,
MOB_SPAWN_SCAN.getMinZ() - intOffsetZ);
MOB_SPAWN_LIST.draw();
MOB_OVERLAY_SCAN.getMinX() - intOffsetX,
MOB_OVERLAY_SCAN.getMinY() - intOffsetY,
MOB_OVERLAY_SCAN.getMinZ() - intOffsetZ);
MOB_OVERLAY_LIST.draw();
GL11.glPopMatrix();
endMobSpawnDraw(style);
endMobOverlayDraw(style);
}
/**
* Quad positions are relative to ({@link MobSpawnScan#getMinX}, {@link MobSpawnScan#getMinY},
* {@link MobSpawnScan#getMinZ}).
* Quad positions are relative to ({@link MobOverlayScan#getMinX}, {@link MobOverlayScan#getMinY},
* {@link MobOverlayScan#getMinZ}).
*/
private static void compileMobSpawnList(World world, MobSpawnOverlayStyle style) {
MOB_SPAWN_LIST.beginCompile(MOB_SPAWN_SCAN.getModesVersion(), style);
private static void compileMobOverlayList(World world, MobOverlayStyle style) {
MOB_OVERLAY_LIST.beginCompile(MOB_OVERLAY_SCAN.getModesVersion(), style);
final float alpha = style.computeAlpha();
final Tessellator tess = Tessellator.instance;
tess.startDrawing(style.glMode);
final int span = MOB_SPAWN_SCAN.getSpan();
final int span = MOB_OVERLAY_SCAN.getSpan();
for (int i = 0; i < span; i++) {
for (int j = 0; j < span; j++) {
final int column = i * span + j;
for (int k = 0; k < MOB_SPAWN_SCAN.getColumnEnd(column); k++) {
if (MOB_SPAWN_SCAN.readSpawnMode(column, k) == 0) continue;
for (int k = 0; k < MOB_OVERLAY_SCAN.getColumnEnd(column); k++) {
if (MOB_OVERLAY_SCAN.readSpawnMode(column, k) == 0) continue;
final double yOffset = getOverlayYOffset(
world,
MOB_SPAWN_SCAN.getMinX() + i,
MOB_SPAWN_SCAN.getMinY() + k,
MOB_SPAWN_SCAN.getMinZ() + j);
MOB_OVERLAY_SCAN.getMinX() + i,
MOB_OVERLAY_SCAN.getMinY() + k,
MOB_OVERLAY_SCAN.getMinZ() + j);
MARKED_FACE.moveTo(i, k + yOffset, j);
loadNeighbourModes(column, k);
MARKED_FACE.applyColor(style.colouring, alpha);
@@ -150,11 +150,11 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
}
}
tess.draw();
MOB_SPAWN_LIST.endCompile();
MOB_OVERLAY_LIST.endCompile();
}
/** {@link #endMobSpawnDraw} undoes every change here except the texture binding. */
private static void beginMobSpawnDraw(MobSpawnOverlayStyle style) {
/** {@link #endMobOverlayDraw} undoes every change here except the texture binding. */
private static void beginMobOverlayDraw(MobOverlayStyle style) {
final ResourceLocation texture = style.texture;
if (texture == null) {
GL11.glDisable(GL11.GL_TEXTURE_2D);
@@ -174,7 +174,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
}
private static void loadNeighbourModes(int column, int k) {
final int span = MOB_SPAWN_SCAN.getSpan();
final int span = MOB_OVERLAY_SCAN.getSpan();
final int i = column / span;
final int j = column % span;
for (int offsetX = -1; offsetX <= 1; offsetX++) {
@@ -182,14 +182,14 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
final int neighbourI = i + offsetX;
final int neighbourJ = j + offsetZ;
final boolean isInScan = neighbourI >= 0 && neighbourI < span && neighbourJ >= 0 && neighbourJ < span;
final byte spawnMode = isInScan ? MOB_SPAWN_SCAN.readSpawnMode(neighbourI * span + neighbourJ, k)
: MobSpawnMarkedFace.OUTSIDE_SCAN;
final byte spawnMode = isInScan ? MOB_OVERLAY_SCAN.readSpawnMode(neighbourI * span + neighbourJ, k)
: MobOverlayFace.OUTSIDE_SCAN;
MARKED_FACE.setNeighbourMode(offsetX, offsetZ, spawnMode);
}
}
}
private static void endMobSpawnDraw(MobSpawnOverlayStyle style) {
private static void endMobOverlayDraw(MobOverlayStyle style) {
if (style.isFilled()) {
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(true);
@@ -566,14 +566,14 @@ nei.options.world.overlays=Overlays Settings
nei.options.world.overlays.lock=Lock overlays between dimensions
nei.options.world.overlays.lock.true=Enabled
nei.options.world.overlays.lock.false=Disabled
nei.options.world.overlays.mobSpawnStyle=Mob Spawn Overlay Style
nei.options.world.overlays.mobSpawnStyle.x=X
nei.options.world.overlays.mobSpawnStyle.connected=Connected
nei.options.world.overlays.mobSpawnStyle.square=Square
nei.options.world.overlays.mobSpawnStyle.gtnh_logo=GTNH Logo
nei.options.world.overlays.mobSpawnStyle.pufferfish=Pufferfish
nei.options.world.overlays.mobSpawnRadius=Mob Spawn Overlay Radius
nei.options.world.overlays.mobSpawnRadius.tip=Block radius scanned around you. Range 8-64 blocks
nei.options.world.overlays.mobOverlayStyle=Mob Spawn Overlay Style
nei.options.world.overlays.mobOverlayStyle.x=X
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.tools=Tools
nei.options.tools.export_configs=Default Config Files