aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-05-02 19:15:50 +0200
committerGitHub <noreply@github.com>2024-05-02 19:15:50 +0200
commita2193642bab3a35a7147fff6cc8d5c6924e1c6dd (patch)
tree17996716e51f47c33f496fe8bcbcff5aa367ea52
parent156de663b37184bc2dc67f4004947c7de1d3413e (diff)
downloadNotEnoughUpdates-a2193642bab3a35a7147fff6cc8d5c6924e1c6dd.tar.gz
NotEnoughUpdates-a2193642bab3a35a7147fff6cc8d5c6924e1c6dd.tar.bz2
NotEnoughUpdates-a2193642bab3a35a7147fff6cc8d5c6924e1c6dd.zip
Add Line to Metal Detector Solution (#1131)
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java57
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Mining.java9
3 files changed, 64 insertions, 5 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
index 5f501115..6f32136b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
@@ -417,7 +417,14 @@ public class RenderUtils {
renderWayPoint(Arrays.asList(""), new Vector3f(loc.getX(), loc.getY(), loc.getZ()), partialTicks, true);
}
- public static void drawFilledQuadWithTexture(Vec3 p1, Vec3 p2, Vec3 p3, Vec3 p4, float alpha, ResourceLocation texture) {
+ public static void drawFilledQuadWithTexture(
+ Vec3 p1,
+ Vec3 p2,
+ Vec3 p3,
+ Vec3 p4,
+ float alpha,
+ ResourceLocation texture
+ ) {
GlStateManager.pushMatrix();
Entity v = Minecraft.getMinecraft().getRenderViewEntity();
double vX = v.lastTickPosX + (v.posX - v.lastTickPosX);
@@ -433,10 +440,10 @@ public class RenderUtils {
GlStateManager.color(1.0f, 1.0f, 1.0f, alpha);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
- worldrenderer.pos(p1.xCoord-vX, p1.yCoord-vY, p1.zCoord-vZ).tex(0, 0).endVertex(); //Top Left
- worldrenderer.pos(p2.xCoord-vX, p2.yCoord-vY, p2.zCoord-vZ).tex(1, 0).endVertex(); //Top Right
- worldrenderer.pos(p3.xCoord-vX, p3.yCoord-vY, p3.zCoord-vZ).tex(1, 1).endVertex(); //Bottom Right
- worldrenderer.pos(p4.xCoord-vX, p4.yCoord-vY, p4.zCoord-vZ).tex(0, 1).endVertex(); //Bottom Left
+ worldrenderer.pos(p1.xCoord - vX, p1.yCoord - vY, p1.zCoord - vZ).tex(0, 0).endVertex(); //Top Left
+ worldrenderer.pos(p2.xCoord - vX, p2.yCoord - vY, p2.zCoord - vZ).tex(1, 0).endVertex(); //Top Right
+ worldrenderer.pos(p3.xCoord - vX, p3.yCoord - vY, p3.zCoord - vZ).tex(1, 1).endVertex(); //Bottom Right
+ worldrenderer.pos(p4.xCoord - vX, p4.yCoord - vY, p4.zCoord - vZ).tex(0, 1).endVertex(); //Bottom Left
tessellator.draw();
GlStateManager.enableCull();
GlStateManager.popMatrix();
@@ -539,4 +546,44 @@ public class RenderUtils {
if (lightingState) GlStateManager.enableLighting();
}
+
+ public static void renderLineToBlock(BlockPos block, int rgb, float partialTicks) {
+ Minecraft mc = Minecraft.getMinecraft();
+ Entity renderViewEntity = mc.getRenderViewEntity();
+
+ double cameraX = renderViewEntity.lastTickPosX + (renderViewEntity.posX - renderViewEntity.lastTickPosX);
+ double cameraY = renderViewEntity.lastTickPosY + (renderViewEntity.posY - renderViewEntity.lastTickPosY);
+ double cameraZ = renderViewEntity.lastTickPosZ + (renderViewEntity.posZ - renderViewEntity.lastTickPosZ);
+
+ GlStateManager.disableTexture2D();
+ GlStateManager.disableDepth();
+ GlStateManager.disableLighting();
+ GlStateManager.disableCull();
+ GlStateManager.enableBlend();
+ GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glEnable(GL11.GL_LINE_SMOOTH);
+ GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
+ GL11.glLineWidth(3.0F);
+
+ GlStateManager.color(
+ ((rgb >> 16) & 0xFF) / 255.0f,
+ ((rgb >> 8) & 0xFF) / 255.0f,
+ (rgb & 0xFF) / 255.0f,
+ 1.0f
+ );
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldRenderer = tessellator.getWorldRenderer();
+ worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
+ worldRenderer.pos(0, renderViewEntity.getEyeHeight(), 0).endVertex();
+ worldRenderer.pos(block.getX() + 0.5 - cameraX, block.getY() - cameraY, block.getZ() + 0.5 - cameraZ).endVertex();
+ tessellator.draw();
+
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableDepth();
+ GlStateManager.enableCull();
+ GlStateManager.disableBlend();
+ GlStateManager.enableLighting();
+ }
+
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
index a78a28f4..0624d9fa 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
@@ -369,6 +369,9 @@ public class CrystalMetalDetectorSolver {
RenderUtils.renderBeaconBeam(block.add(0, 1, 0), beaconRGB, 1.0f, partialTicks);
RenderUtils.renderWayPoint("Treasure", possibleBlocks.iterator().next().add(0, 2.5, 0), partialTicks);
+ if (NotEnoughUpdates.INSTANCE.config.mining.metalDetectorLineToSolution) {
+ RenderUtils.renderLineToBlock(block.add(0, 1, 0), 0x1fd8f1, partialTicks);
+ }
} else if (possibleBlocks.size() > 1 && NotEnoughUpdates.INSTANCE.config.mining.metalDetectorShowPossible) {
for (BlockPos block : possibleBlocks) {
RenderUtils.renderBeaconBeam(block.add(0, 1, 0), beaconRGB, 1.0f, partialTicks);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Mining.java
index e065bf3a..4ccd2a06 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Mining.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Mining.java
@@ -336,6 +336,15 @@ public class Mining {
@Expose
@ConfigOption(
+ name = "Line to Solution",
+ desc = "Draw a line to the solution block."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean metalDetectorLineToSolution = true;
+
+ @Expose
+ @ConfigOption(
name = "Show Possible Blocks",
desc = "Show waypoints on possible locations when NEU isn't sure about what block the treasure is."
)