aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/utils
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2021-09-18 12:29:50 +0900
committersyeyoung <cyoung06@naver.com>2021-09-18 12:29:50 +0900
commit3d42886e90d2d41603d5741a3d5d07907f7758fe (patch)
tree725c2c886d42fd9cb858a49bb9be326dbc6030d7 /src/main/java/kr/syeyoung/dungeonsguide/utils
parentb5f5a1a613ab534e247c8eb04110344e2161d8d3 (diff)
downloadSkyblock-Dungeons-Guide-3d42886e90d2d41603d5741a3d5d07907f7758fe.tar.gz
Skyblock-Dungeons-Guide-3d42886e90d2d41603d5741a3d5d07907f7758fe.tar.bz2
Skyblock-Dungeons-Guide-3d42886e90d2d41603d5741a3d5d07907f7758fe.zip
- Waypoints? and new JPS Pathfinding Algorithm
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java211
1 files changed, 211 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
index 9632d9d7..b0c54e17 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
@@ -46,6 +46,95 @@ import java.util.List;
public class RenderUtils {
public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png");
+ private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png");
+
+ /**
+ * Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0
+ * And modified to fit out need.
+ * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE
+ * @author Moulberry
+ */
+ public static void renderBeaconBeam(double x, double y, double z, AColor aColor, float partialTicks) {
+ int height = 300;
+ int bottomOffset = 0;
+ int topOffset = bottomOffset + height;
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam);
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
+ GlStateManager.disableLighting();
+ GlStateManager.enableCull();
+ GlStateManager.enableTexture2D();
+ GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+
+ double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double)partialTicks;
+ double d1 = MathHelper.func_181162_h(-time * 0.2D - (double)MathHelper.floor_double(-time * 0.1D));
+
+ int c = getColorAt(x,y,z, aColor);
+ float alpha = ((c >> 24) & 0xFF) / 255.0f;
+
+ float r = ((c >> 16) & 0xFF) / 255f;
+ float g = ((c >> 8) & 0xFF) / 255f;
+ float b = (c & 0xFF) / 255f;
+ double d2 = time * 0.025D * -1.5D;
+ double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D;
+ double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D;
+ double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D;
+ double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D;
+ double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D;
+ double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D;
+ double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D;
+ double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D;
+ double d14 = -1.0D + d1;
+ double d15 = (double)(height) * 2.5D + d14;
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
+ worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, alpha).endVertex();
+ worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, alpha).endVertex();
+ worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, alpha).endVertex();
+ worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, alpha).endVertex();
+ worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, alpha).endVertex();
+ worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, alpha).endVertex();
+ worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, alpha).endVertex();
+ worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, alpha).endVertex();
+ tessellator.draw();
+
+ GlStateManager.disableCull();
+ double d12 = -1.0D + d1;
+ double d13 = height + d12;
+
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
+ worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex();
+ worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex();
+ worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex();
+ worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex();
+ worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex();
+ worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex();
+ worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex();
+ worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
+ 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*alpha).endVertex();
+ tessellator.draw();
+ }
+
public static void drawTexturedRect(float x, float y, float width, float height, int filter) {
drawTexturedRect(x, y, width, height, 0.0F, 1.0F, 0.0F, 1.0F, filter);
@@ -478,6 +567,54 @@ public class RenderUtils {
GlStateManager.popMatrix();
}
+ public static void drawLinesVec3(List<Vec3> poses, AColor colour, float thickness, float partialTicks, boolean depth) {
+ Entity render = Minecraft.getMinecraft().getRenderViewEntity();
+ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
+
+ double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
+ double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
+ double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(-realX, -realY, -realZ);
+ GlStateManager.disableTexture2D();
+ GL11.glDisable(GL11.GL_TEXTURE_2D);
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GL11.glLineWidth(thickness);
+ if (!depth) {
+ GlStateManager.disableDepth();
+ GlStateManager.depthMask(false);
+ }
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+
+// GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f);
+ GlStateManager.color(1,1,1,1);
+ worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
+ int num = 0;
+ for (Vec3 pos:poses) {
+ int i = getColorAt(num++ * 10,0, colour);
+ worldRenderer.pos(pos.xCoord, pos.yCoord, pos.zCoord).color(
+ ((i >> 16) &0xFF)/255.0f,
+ ((i >> 8) &0xFF)/255.0f,
+ (i &0xFF)/255.0f,
+ ((i >> 24) &0xFF)/255.0f
+ ).endVertex();
+ }
+ Tessellator.getInstance().draw();
+
+ GlStateManager.translate(realX, realY, realZ);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ if (!depth) {
+ GlStateManager.enableDepth();
+ GlStateManager.depthMask(true);
+ }
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.popMatrix();
+ GL11.glLineWidth(1);
+ }
public static void drawLines(List<BlockPos> poses, AColor colour, float thickness, float partialTicks, boolean depth) {
Entity render = Minecraft.getMinecraft().getRenderViewEntity();
WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
@@ -643,6 +780,80 @@ public class RenderUtils {
}
+ public static void highlightBox(AxisAlignedBB axisAlignedBB, Color c, float partialTicks, boolean depth) {
+ Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity();
+
+ double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks);
+ double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks);
+ double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks);
+
+ GlStateManager.pushMatrix();
+
+ GlStateManager.translate(-x_fix, -y_fix, -z_fix);
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GlStateManager.disableCull();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+
+ if (!depth) {
+ GlStateManager.disableDepth();
+ GlStateManager.depthMask(false);
+ }
+ int rgb = c.getRGB();
+ GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f);
+
+ GlStateManager.translate(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ);
+
+ double x = axisAlignedBB.maxX - axisAlignedBB.minX;
+ double y = axisAlignedBB.maxY - axisAlignedBB.minY;
+ double z = axisAlignedBB.maxZ - axisAlignedBB.minZ;
+ GL11.glBegin(GL11.GL_QUADS);
+ GL11.glVertex3d(0, 0, 0);
+ GL11.glVertex3d(0, 0, z);
+ GL11.glVertex3d(0, y, z);
+ GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT
+
+ GL11.glVertex3d(x, 0, z);
+ GL11.glVertex3d(x, 0, 0);
+ GL11.glVertex3d(x, y, 0);
+ GL11.glVertex3d(x, y, z);
+
+ GL11.glVertex3d(0, y, z);
+ GL11.glVertex3d(0, 0, z);
+ GL11.glVertex3d(x, 0, z);
+ GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT
+
+ GL11.glVertex3d(0, 0, 0);
+ GL11.glVertex3d(0, y, 0);
+ GL11.glVertex3d(x, y, 0);
+ GL11.glVertex3d(x, 0, 0);
+
+ GL11.glVertex3d(0,y,0);
+ GL11.glVertex3d(0,y,z);
+ GL11.glVertex3d(x,y,z);
+ GL11.glVertex3d(x,y,0);
+
+ GL11.glVertex3d(0,0,z);
+ GL11.glVertex3d(0,0,0);
+ GL11.glVertex3d(x,0,0);
+ GL11.glVertex3d(x,0,z);
+
+
+
+ GL11.glEnd();
+
+
+ if (!depth) {
+ GlStateManager.disableDepth();
+ GlStateManager.depthMask(true);
+ }
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableLighting();
+ GlStateManager.popMatrix();
+
+ }
public static void highlightBox(Entity entity, AxisAlignedBB axisAlignedBB, AColor c, float partialTicks, boolean depth) {
Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity();