aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorDavid Mills <85420839+Keebler408@users.noreply.github.com>2021-09-11 10:35:55 -0500
committerDavid Mills <85420839+Keebler408@users.noreply.github.com>2021-09-11 10:35:55 -0500
commite0a71fdc7a1bf466992fc6db96a15b778909cc18 (patch)
treef8e4a9e183333e96748d1baeadcfa7798f6aef2b /src/main/java/io
parent29cea4c4922443ae78c47cd49e4a74ab67eb15f2 (diff)
downloadNotEnoughUpdates-e0a71fdc7a1bf466992fc6db96a15b778909cc18.tar.gz
NotEnoughUpdates-e0a71fdc7a1bf466992fc6db96a15b778909cc18.tar.bz2
NotEnoughUpdates-e0a71fdc7a1bf466992fc6db96a15b778909cc18.zip
Fix jitter, improve metal detector beacon
- Fix jitter caused by location coord truncation from double to int - Move remaining fairy souls beacon rendering into RenderUtils.java - Add beacon option to enable depth testing when player is close by - Use new rendering for metal detector to make beacons more visible
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java112
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java12
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java32
3 files changed, 89 insertions, 67 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 75c4a35a..5f0ad94f 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
@@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.core.util.render;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -12,10 +13,7 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.MathHelper;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.*;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import org.lwjgl.util.vector.Vector3f;
@@ -149,29 +147,10 @@ public class RenderUtils {
GlStateManager.enableTexture2D();
}
- public static BlockPos getCurrentViewer(float partialTicks) {
- double viewerX;
- double viewerY;
- double viewerZ;
-
- Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(aoteInterpPos != null) {
- viewerX = aoteInterpPos.x;
- viewerY = aoteInterpPos.y;
- viewerZ = aoteInterpPos.z;
- } else {
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
- viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
- viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
- }
-
- return new BlockPos(viewerX, viewerY, viewerZ);
- }
-
private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png");
- public static void renderBeaconBeam(double x, double y, double z, int rgb, float alphaMult, float partialTicks) {
+ private static void renderBeaconBeam(double x, double y, double z, int rgb, float alphaMult,
+ float partialTicks, Boolean disableDepth) {
int height = 300;
int bottomOffset = 0;
int topOffset = bottomOffset + height;
@@ -179,8 +158,11 @@ public class RenderUtils {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam);
+ if (disableDepth) {
+ GlStateManager.disableDepth();
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
GlStateManager.disableLighting();
@@ -248,6 +230,84 @@ public class RenderUtils {
worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
tessellator.draw();
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableTexture2D();
+ if (disableDepth) {
+ GlStateManager.enableDepth();
+ }
+ }
+
+ private static void renderBoundingBox(double x, double y, double z, int rgb, float alphaMult, float partialTicks) {
+ AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x+1, y+1, z+1);
+
+ GlStateManager.disableDepth();
+ GlStateManager.disableCull();
+ GlStateManager.disableTexture2D();
+ CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, rgb));
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableCull();
+ GlStateManager.enableDepth();
+ }
+
+ public static void renderBeaconBeam(BlockPos block, int rgb, float alphaMult, float partialTicks) {
+ double viewerX;
+ double viewerY;
+ double viewerZ;
+
+ Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if(aoteInterpPos != null) {
+ viewerX = aoteInterpPos.x;
+ viewerY = aoteInterpPos.y;
+ viewerZ = aoteInterpPos.z;
+ } else {
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
+ viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
+ viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
+ }
+
+ double x = block.getX() - viewerX;
+ double y = block.getY() - viewerY;
+ double z = block.getZ() - viewerZ;
+
+ double distSq = x*x + y*y + z*z;
+
+ if(distSq > 10*10) {
+ RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true);
+ } else {
+ RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, false);
+ }
+ }
+
+ public static void renderBeaconBeamOrBoundingBox(BlockPos block, int rgb, float alphaMult, float partialTicks) {
+ double viewerX;
+ double viewerY;
+ double viewerZ;
+
+ Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if(aoteInterpPos != null) {
+ viewerX = aoteInterpPos.x;
+ viewerY = aoteInterpPos.y;
+ viewerZ = aoteInterpPos.z;
+ } else {
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
+ viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
+ viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
+ }
+
+ double x = block.getX() - viewerX;
+ double y = block.getY() - viewerY;
+ double z = block.getZ() - viewerZ;
+
+ double distSq = x*x + y*y + z*z;
+
+ if(distSq > 10*10) {
+ RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true);
+ } else {
+ RenderUtils.renderBoundingBox(x, y, z, rgb, 1.0f, partialTicks);
+ }
}
public static void renderWayPoint(String str, BlockPos loc, float partialTicks) {
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 1172f1c5..5e9c59ac 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
@@ -108,24 +108,16 @@ public class CrystalMetalDetectorSolver {
if (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows") &&
SBInfo.getInstance().location.equals("Mines of Divan")) {
- BlockPos viewer = RenderUtils.getCurrentViewer(partialTicks);
if (possibleBlocks.size() == 1) {
BlockPos block = possibleBlocks.get(0);
- double x = block.getX() - viewer.getX();
- double y = block.getY() - viewer.getY();
- double z = block.getZ() - viewer.getZ();
- RenderUtils.renderBeaconBeam(x, y, z, beaconRGB, 1.0f, partialTicks);
+ RenderUtils.renderBeaconBeam(block, beaconRGB, 1.0f, partialTicks);
RenderUtils.renderWayPoint("Treasure", possibleBlocks.get(0).add(0, 2.5, 0), partialTicks);
} else if (possibleBlocks.size() > 1 && (locations.size() > 1 || possibleBlocks.size() < 10) &&
NotEnoughUpdates.INSTANCE.config.mining.metalDetectorShowPossible) {
for (BlockPos block : possibleBlocks) {
- double x = block.getX() - viewer.getX();
- double y = block.getY() - viewer.getY();;
- double z = block.getZ() - viewer.getZ();;
-
- RenderUtils.renderBeaconBeam(x, y, z, beaconRGB, 1.0f, partialTicks);
+ RenderUtils.renderBeaconBeam(block, beaconRGB, 1.0f, partialTicks);
RenderUtils.renderWayPoint("Possible Treasure Location", block.add(0, 2.5, 0), partialTicks);
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
index 260b94ae..ac1d2fd9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
@@ -6,26 +6,17 @@ import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.commands.SimpleCommand;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
-import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.WorldRenderer;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.command.ICommandSender;
-import net.minecraft.entity.Entity;
import net.minecraft.util.*;
-import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.util.vector.Vector3f;
import java.io.*;
import java.nio.charset.StandardCharsets;
@@ -177,32 +168,11 @@ public class FairySouls {
Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
- BlockPos viewer = RenderUtils.getCurrentViewer(event.partialTicks);
-
int rgb = 0xa839ce;
for(int i=0; i<currentSoulListClose.size(); i++) {
BlockPos currentSoul = currentSoulListClose.get(i);
- double x = currentSoul.getX() - viewer.getX();
- double y = currentSoul.getY() - viewer.getY();
- double z = currentSoul.getZ() - viewer.getZ();
-
- double distSq = x*x + y*y + z*z;
-
- AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x+1, y+1, z+1);
-
- GlStateManager.disableDepth();
- GlStateManager.disableCull();
- GlStateManager.disableTexture2D();
- CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, rgb));
-
- if(distSq > 10*10) {
- RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, event.partialTicks);
- }
+ RenderUtils.renderBeaconBeamOrBoundingBox(currentSoul, rgb, 1.0f, event.partialTicks);
}
-
- GlStateManager.disableLighting();
- GlStateManager.enableTexture2D();
- GlStateManager.enableDepth();
}
public static class FairySoulsCommandAlt extends SimpleCommand {