mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-23 21:50:02 +00:00
Directly address review comments
This commit is contained in:
1 parent
ef310b30ce
commit
8e5f3c49b1
3 files changed
+24
-44
No files matched your search
@@ -30,7 +30,6 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
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();
|
||||
// the cells of one column, reused by each compile
|
||||
private static final byte[] COLUMN_CELLS = new byte[2 * MobOverlayScan.MAX_VERTICAL_RADIUS + 1];
|
||||
|
||||
public static void reset() {
|
||||
@@ -113,8 +112,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a marked face to {@link #MOB_OVERLAY_LIST} for each block of {@link #MOB_OVERLAY_SCAN} where mobs can spawn,
|
||||
* in the chunk columns whose cells changed.
|
||||
* Add a marked face to {@link #MOB_OVERLAY_LIST} for each block of {@link #MOB_OVERLAY_SCAN} where mobs can spawn.
|
||||
*/
|
||||
private static void compileMobOverlayList(MobOverlayStyle style, long worldTicks) {
|
||||
MOB_OVERLAY_LIST.beginCompile(MOB_OVERLAY_SCAN, style, worldTicks);
|
||||
@@ -133,7 +131,6 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
MOB_OVERLAY_LIST.endCompile();
|
||||
}
|
||||
|
||||
/** @return whether the chunk column has a marked face */
|
||||
private static boolean compileChunkFaces(MobOverlayStyle style, int chunkX, int chunkZ) {
|
||||
final int CHUNK_WIDTH = 1 << MobOverlayScan.CHUNK_SHIFT;
|
||||
final float alpha = style.computeAlpha();
|
||||
|
||||
@@ -7,17 +7,13 @@ import net.minecraft.client.renderer.GLAllocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* The mob spawn overlay quads, compiled into one GL display list for each chunk column that overlaps the box of a
|
||||
* {@link MobOverlayScan}. A compile rebuilds only the lists of the chunk columns whose
|
||||
* {@link MobOverlayScan#readChunkVersion} changed. A parent list calls the chunk-column lists, so a draw is one
|
||||
* {@code glCallList()}.
|
||||
* The mob spawn overlay quads, in one GL display list for each chunk column of the box of a {@link MobOverlayScan}. A
|
||||
* compile rebuilds only the lists whose {@link MobOverlayScan#readChunkVersion} changed.
|
||||
*/
|
||||
public final class MobOverlayDisplayList {
|
||||
|
||||
private static final int NO_LIST = -1;
|
||||
|
||||
// the first of `chunkSpan * chunkSpan` lists, in the order of the ring of `MobOverlayScan.readChunkVersion()`, then
|
||||
// the parent list
|
||||
private int firstListId = NO_LIST;
|
||||
private int parentListId = NO_LIST;
|
||||
private boolean hasParentList;
|
||||
@@ -29,7 +25,6 @@ public final class MobOverlayDisplayList {
|
||||
private boolean[] hasFaces = new boolean[0];
|
||||
private int[] compiledChunkX = new int[0];
|
||||
private int[] compiledChunkZ = new int[0];
|
||||
private int[] compiledMinY = new int[0];
|
||||
private int[] compiledChunkVersion = new int[0];
|
||||
private int modesVersion;
|
||||
private MobOverlayStyle style;
|
||||
@@ -50,11 +45,6 @@ public final class MobOverlayDisplayList {
|
||||
return modesVersion != currentModesVersion && isWaitOver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a compile of {@code scan}. After this call, {@link #beginChunk} and {@link #endChunk} compile each chunk
|
||||
* column of the box, and {@link #endCompile} compiles the parent list. The lists of the chunk columns outside the
|
||||
* box are not drawn.
|
||||
*/
|
||||
public void beginCompile(MobOverlayScan scan, MobOverlayStyle newStyle, long worldTicks) {
|
||||
if (chunkSpan != scan.getChunkSpan()) resize(scan.getChunkSpan());
|
||||
if (style != newStyle) Arrays.fill(isCompiled, false);
|
||||
@@ -78,9 +68,9 @@ public final class MobOverlayDisplayList {
|
||||
|
||||
/**
|
||||
* Start the list of chunk column ({@code chunkX}, {@code chunkZ}), with quad positions relative to block ({@code
|
||||
* chunkX * 16}, {@link MobOverlayScan#getMinY}, {@code chunkZ * 16}) of {@code scan}.
|
||||
* chunkX * 16}, {@link MobOverlayScan#getMinY}, {@code chunkZ * 16}).
|
||||
*
|
||||
* @return false, with no list started, when the list is compiled for the chunk column's version
|
||||
* @return false, with no list started, when the chunk column's list is current
|
||||
*/
|
||||
public boolean beginChunk(MobOverlayScan scan, int chunkX, int chunkZ) {
|
||||
final int chunk = Math.floorMod(chunkX, chunkSpan) * chunkSpan + Math.floorMod(chunkZ, chunkSpan);
|
||||
@@ -93,7 +83,6 @@ public final class MobOverlayDisplayList {
|
||||
isCompiled[chunk] = true;
|
||||
compiledChunkX[chunk] = chunkX;
|
||||
compiledChunkZ[chunk] = chunkZ;
|
||||
compiledMinY[chunk] = scan.getMinY();
|
||||
compiledChunkVersion[chunk] = chunkVersion;
|
||||
compilingChunk = chunk;
|
||||
GL11.glNewList(firstListId + chunk, GL11.GL_COMPILE);
|
||||
@@ -105,7 +94,6 @@ public final class MobOverlayDisplayList {
|
||||
hasFaces[compilingChunk] = hasChunkFaces;
|
||||
}
|
||||
|
||||
/** Compile the parent list, with positions relative to the box's minimum corner at {@link #beginCompile}. */
|
||||
public void endCompile() {
|
||||
GL11.glNewList(parentListId, GL11.GL_COMPILE);
|
||||
for (int chunk = 0; chunk < isCompiled.length; chunk++) {
|
||||
@@ -114,7 +102,7 @@ public final class MobOverlayDisplayList {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(
|
||||
(compiledChunkX[chunk] << MobOverlayScan.CHUNK_SHIFT) - anchorX,
|
||||
compiledMinY[chunk] - anchorY,
|
||||
0,
|
||||
(compiledChunkZ[chunk] << MobOverlayScan.CHUNK_SHIFT) - anchorZ);
|
||||
GL11.glCallList(firstListId + chunk);
|
||||
GL11.glPopMatrix();
|
||||
@@ -154,7 +142,6 @@ public final class MobOverlayDisplayList {
|
||||
hasFaces = new boolean[chunkCount];
|
||||
compiledChunkX = new int[chunkCount];
|
||||
compiledChunkZ = new int[chunkCount];
|
||||
compiledMinY = new int[chunkCount];
|
||||
compiledChunkVersion = new int[chunkCount];
|
||||
}
|
||||
}
|
||||
@@ -59,9 +59,7 @@ public final class MobOverlayScan {
|
||||
// the slice rescan of `update()` continues from this column, numbered `(x - minX) * span + (z - minZ)`
|
||||
private int nextRescanColumn;
|
||||
private int modesVersion;
|
||||
// chunk columns per side of the ring `chunkVersions`, enough for every chunk column that overlaps the box
|
||||
private int chunkSpan;
|
||||
// indexed by `findChunk()`
|
||||
private int[] chunkVersions = new int[0];
|
||||
private int chunkVersionCount;
|
||||
private boolean hasModes;
|
||||
@@ -127,7 +125,6 @@ public final class MobOverlayScan {
|
||||
return modesVersion;
|
||||
}
|
||||
|
||||
/** Chunk columns per side of the ring of {@link #readChunkVersion}. */
|
||||
public int getChunkSpan() {
|
||||
return chunkSpan;
|
||||
}
|
||||
@@ -152,10 +149,7 @@ public final class MobOverlayScan {
|
||||
return minZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version changes when a cell of the chunk column or of a column beside the chunk column changes, and when the
|
||||
* box moves.
|
||||
*/
|
||||
/** The version changes when a cell in or beside the chunk column changes, and when the box moves. */
|
||||
public int readChunkVersion(int chunkX, int chunkZ) {
|
||||
return chunkVersions[findChunk(chunkX, chunkZ)];
|
||||
}
|
||||
@@ -167,8 +161,6 @@ public final class MobOverlayScan {
|
||||
|
||||
/**
|
||||
* Copy the cells of column ({@code i}, {@code j}) to {@code columnCells}, from the bottom of the box to the top.
|
||||
* {@link #extractSpawnMode} and {@link #computeOverlayYOffset} read a cell. The indices are those of
|
||||
* {@link #readSpawnMode}.
|
||||
*/
|
||||
public void readColumn(int i, int j, byte[] columnCells) {
|
||||
final int columnStart = findColumn(minX + i, minZ + j) * height;
|
||||
@@ -310,22 +302,27 @@ public final class MobOverlayScan {
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the chunk columns of the box's edge before and after a move of {@code offset} blocks along x, or along z
|
||||
* when {@code isAlongX} is false, and of the columns that enter or leave the box. No outline is drawn between an
|
||||
* edge cell of the box and a cell outside the box, so a move changes the outlines of the edge cells.
|
||||
* No outline is drawn between an edge cell of the box and a cell outside the box, so a move changes the outlines of
|
||||
* the edge cells.
|
||||
*/
|
||||
private void markMovedEdgeChunks(int oldMin, int offset, boolean isAlongX) {
|
||||
final int lowFrom = Math.min(oldMin, oldMin + offset);
|
||||
final int lowTo = Math.max(oldMin, oldMin + offset);
|
||||
final int highFrom = lowFrom + span - 1;
|
||||
final int highTo = lowTo + span - 1;
|
||||
final int acrossFrom = isAlongX ? minZ : minX;
|
||||
for (int across = acrossFrom >> CHUNK_SHIFT; across <= (acrossFrom + span - 1) >> CHUNK_SHIFT; across++) {
|
||||
for (int along = lowFrom >> CHUNK_SHIFT; along <= lowTo >> CHUNK_SHIFT; along++) {
|
||||
markChunk(isAlongX ? along : across, isAlongX ? across : along);
|
||||
}
|
||||
for (int along = highFrom >> CHUNK_SHIFT; along <= highTo >> CHUNK_SHIFT; along++) {
|
||||
markChunk(isAlongX ? along : across, isAlongX ? across : along);
|
||||
if (isAlongX) {
|
||||
markChunks(lowFrom, lowTo, minZ, minZ + span - 1);
|
||||
markChunks(highFrom, highTo, minZ, minZ + span - 1);
|
||||
} else {
|
||||
markChunks(minX, minX + span - 1, lowFrom, lowTo);
|
||||
markChunks(minX, minX + span - 1, highFrom, highTo);
|
||||
}
|
||||
}
|
||||
|
||||
private void markChunks(int fromX, int toX, int fromZ, int toZ) {
|
||||
for (int chunkX = fromX >> CHUNK_SHIFT; chunkX <= toX >> CHUNK_SHIFT; chunkX++) {
|
||||
for (int chunkZ = fromZ >> CHUNK_SHIFT; chunkZ <= toZ >> CHUNK_SHIFT; chunkZ++) {
|
||||
markChunk(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,9 +397,8 @@ public final class MobOverlayScan {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// `SpawnerAnimals.canCreatureTypeSpawnAtLocation()` rejects a normal cube in the cell for a monster. Most
|
||||
// cells below the surface are a normal cube. Test the block here, with no light reads and no reads of the
|
||||
// blocks above and below the cell
|
||||
// vanilla `SpawnerAnimals.canCreatureTypeSpawnAtLocation()` rejects a normal cube in the cell. Test the
|
||||
// block before the light read
|
||||
if (chunk.getBlock(x & 15, y, z & 15).isNormalCube()) return 0;
|
||||
|
||||
if (chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8 || !SpawnerAnimals
|
||||
|
||||
Reference in new issue
Block a user