mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-21 04:32:27 +00:00
Optimize + spotless
This commit is contained in:
1 parent
b7dcd0fb3d
commit
d07059cb5a
5 files changed
+61
-13
No files matched your search
@@ -50,7 +50,10 @@ public final class MobSpawnMarkedFace {
|
||||
addVertex(1, 0);
|
||||
}
|
||||
|
||||
/** Add one cell of a 3 x 3 grid over the face. Edge cells are {@code width} wide, and the middle cell fills the rest. */
|
||||
/**
|
||||
* Add one cell of a 3 x 3 grid over the face. Edge cells are {@code width} wide, and the middle cell fills the
|
||||
* rest.
|
||||
*/
|
||||
public void addCell(int offsetX, int offsetZ, double width) {
|
||||
final double west = computeCellStart(offsetX, width);
|
||||
final double east = 1 - computeCellStart(-offsetX, width);
|
||||
|
||||
@@ -23,7 +23,9 @@ public enum MobSpawnOverlayStyle {
|
||||
}
|
||||
},
|
||||
|
||||
/** A light tint, with a stronger band along the outline of each area of one spawn mode, like a connected texture. */
|
||||
/**
|
||||
* A light tint, with a stronger band along the outline of each area of one spawn mode, like a connected texture.
|
||||
*/
|
||||
CONNECTED(GL11.GL_QUADS) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,7 @@ public final class MobSpawnScan {
|
||||
private int nextMinY;
|
||||
private int nextMinZ;
|
||||
private int nextColumn;
|
||||
private int passCount;
|
||||
private boolean hasModes;
|
||||
private long scannedTick;
|
||||
// world of the front buffer
|
||||
@@ -83,6 +84,11 @@ public final class MobSpawnScan {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes each time the front buffer changes. */
|
||||
public int getPassCount() {
|
||||
return passCount;
|
||||
}
|
||||
|
||||
public int getSpan() {
|
||||
return span;
|
||||
}
|
||||
@@ -174,5 +180,6 @@ public final class MobSpawnScan {
|
||||
minX = nextMinX;
|
||||
minY = nextMinY;
|
||||
minZ = nextMinZ;
|
||||
passCount++;
|
||||
}
|
||||
}
|
||||
@@ -443,8 +443,9 @@ 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: x, connected, square, gtnh_logo or pufferfish")
|
||||
tag.getTag("world.overlays.mobSpawnStyle")
|
||||
.setComment(
|
||||
"Mark on each block of the mob spawn overlay: x, connected, square, gtnh_logo or pufferfish")
|
||||
.getValue(MobSpawnOverlayStyle.DEFAULT.formatName());
|
||||
API.addOption(new OptionCycled("world.overlays.mobSpawnStyle", MobSpawnOverlayStyle.values().length, true) {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.concurrent.Callable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSnow;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
@@ -33,6 +34,10 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
public static int mobOverlay = 0;
|
||||
private static final MobSpawnScan mobSpawnScan = new MobSpawnScan();
|
||||
private static final MobSpawnMarkedFace markedFace = new MobSpawnMarkedFace();
|
||||
// display list of the overlay quads, compiled when the scan or the style changes
|
||||
private static int mobSpawnList = -1;
|
||||
private static int mobSpawnListPass;
|
||||
private static MobSpawnOverlayStyle mobSpawnListStyle;
|
||||
|
||||
public static void reset() {
|
||||
mobOverlay = 0;
|
||||
@@ -93,18 +98,41 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
private static void renderMobSpawnOverlay(Entity entity, int intOffsetX, int intOffsetY, int intOffsetZ) {
|
||||
if (mobOverlay == 0) {
|
||||
mobSpawnScan.clear();
|
||||
deleteMobSpawnList();
|
||||
return;
|
||||
}
|
||||
|
||||
mobSpawnScan.update(entity, NEIClientConfig.getIntSetting("world.overlays.mobSpawnRadius"));
|
||||
final MobSpawnOverlayStyle style = MobSpawnOverlayStyle
|
||||
.parseStyle(NEIClientConfig.getSetting("world.overlays.mobSpawnStyle").getValue());
|
||||
if (!(mobSpawnList >= 0 && mobSpawnListPass == mobSpawnScan.getPassCount() && mobSpawnListStyle == style)) {
|
||||
compileMobSpawnList(entity.worldObj, style);
|
||||
}
|
||||
|
||||
beginMobSpawnDraw(style);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(
|
||||
mobSpawnScan.getMinX() - intOffsetX,
|
||||
mobSpawnScan.getMinY() - intOffsetY,
|
||||
mobSpawnScan.getMinZ() - intOffsetZ);
|
||||
GL11.glCallList(mobSpawnList);
|
||||
GL11.glPopMatrix();
|
||||
endMobSpawnDraw(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quad positions are relative to ({@link MobSpawnScan#getMinX}, {@link MobSpawnScan#getMinY},
|
||||
* {@link MobSpawnScan#getMinZ}).
|
||||
*/
|
||||
private static void compileMobSpawnList(World world, MobSpawnOverlayStyle style) {
|
||||
if (mobSpawnList < 0) mobSpawnList = GLAllocation.generateDisplayLists(1);
|
||||
mobSpawnListPass = mobSpawnScan.getPassCount();
|
||||
mobSpawnListStyle = style;
|
||||
|
||||
GL11.glNewList(mobSpawnList, GL11.GL_COMPILE);
|
||||
final float alpha = style.computeAlpha();
|
||||
final World world = entity.worldObj;
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawing(style.glMode);
|
||||
|
||||
final int span = mobSpawnScan.getSpan();
|
||||
for (int i = 0; i < span; i++) {
|
||||
for (int j = 0; j < span; j++) {
|
||||
@@ -113,20 +141,27 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
for (int k = 0; k < mobSpawnScan.getColumnEnd(column); k++) {
|
||||
if (mobSpawnScan.readSpawnMode(column, k) == 0) continue;
|
||||
|
||||
final int x = mobSpawnScan.getMinX() + i;
|
||||
final int y = mobSpawnScan.getMinY() + k;
|
||||
final int z = mobSpawnScan.getMinZ() + j;
|
||||
final double yOffset = getOverlayYOffset(world, x, y, z);
|
||||
markedFace.moveTo(x - intOffsetX, y - intOffsetY + yOffset, z - intOffsetZ);
|
||||
final double yOffset = getOverlayYOffset(
|
||||
world,
|
||||
mobSpawnScan.getMinX() + i,
|
||||
mobSpawnScan.getMinY() + k,
|
||||
mobSpawnScan.getMinZ() + j);
|
||||
markedFace.moveTo(i, k + yOffset, j);
|
||||
loadNeighbourModes(column, k);
|
||||
markedFace.applyColor(style.colouring, alpha);
|
||||
style.addVertices(markedFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
endMobSpawnDraw(style);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
private static void deleteMobSpawnList() {
|
||||
if (mobSpawnList < 0) return;
|
||||
|
||||
GLAllocation.deleteDisplayLists(mobSpawnList);
|
||||
mobSpawnList = -1;
|
||||
}
|
||||
|
||||
/** {@link #endMobSpawnDraw} undoes every change here except the texture binding. */
|
||||
|
||||
Reference in new issue
Block a user