diff --git a/build.gradle b/build.gradle index ace3420..2386a43 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.7-SNAPSHOT' id 'maven-publish' } @@ -35,7 +35,7 @@ dependencies { modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}" - modApi "com.terraformersmc:modmenu:10.0.0-beta.1" + modApi "com.terraformersmc:modmenu:11.0.1" } processResources { diff --git a/gradle.properties b/gradle.properties index d8fc859..da95953 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,9 +4,9 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.1 -loader_version=0.15.10 +minecraft_version=1.21 +yarn_mappings=1.21+build.2 +loader_version=0.15.11 # Mod Properties mod_version = 2.1.0 @@ -14,5 +14,5 @@ maven_group = com.tanishisherewith archives_base_name = dynamichud # Dependencies -fabric_version=0.97.8+1.20.6 -yacl_version=3.4.4+1.20.6-fabric \ No newline at end of file +fabric_version=0.100.3+1.21 +yacl_version=3.5.0+1.21-fabric \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 20db9ad..2617362 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/tanishisherewith/dynamichud/HudRender.java b/src/main/java/com/tanishisherewith/dynamichud/HudRender.java index b4e301e..a7832cf 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/HudRender.java +++ b/src/main/java/com/tanishisherewith/dynamichud/HudRender.java @@ -3,14 +3,16 @@ import com.tanishisherewith.dynamichud.widget.WidgetRenderer; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderTickCounter; /** * Using the fabric event {@link HudRenderCallback} to render widgets in the game HUD. * Mouse positions are passed in the negatives even though theoretically it's in the centre of the screen. */ -public class HudRender implements HudRenderCallback { +public class HudRender implements HudRenderCallback{ + @Override - public void onHudRender(DrawContext drawContext, float tickDelta) { + public void onHudRender(DrawContext drawContext, RenderTickCounter tickCounter) { for (WidgetRenderer widgetRenderer : DynamicHUD.getWidgetRenderers()) { widgetRenderer.renderWidgets(drawContext, -120, -120); } diff --git a/src/main/java/com/tanishisherewith/dynamichud/config/GlobalConfig.java b/src/main/java/com/tanishisherewith/dynamichud/config/GlobalConfig.java index fde8a7a..d8b5690 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/config/GlobalConfig.java +++ b/src/main/java/com/tanishisherewith/dynamichud/config/GlobalConfig.java @@ -13,7 +13,7 @@ public final class GlobalConfig { public static final ConfigClassHandler HANDLER = ConfigClassHandler.createBuilder(GlobalConfig.class) - .id(new Identifier("dynamichud", "dynamichud_config")) + .id(Identifier.of("dynamichud", "dynamichud_config")) .serializer(config -> GsonConfigSerializerBuilder.create(config) .setPath(FabricLoader.getInstance().getConfigDir().resolve("dynamichud.json5")) .setJson5(true) diff --git a/src/main/java/com/tanishisherewith/dynamichud/helpers/DrawHelper.java b/src/main/java/com/tanishisherewith/dynamichud/helpers/DrawHelper.java index 3794f06..c310b07 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/helpers/DrawHelper.java +++ b/src/main/java/com/tanishisherewith/dynamichud/helpers/DrawHelper.java @@ -41,43 +41,41 @@ public static void drawGradient(Matrix4f matrix4f, float x, float y, float width float endAlpha = (float) (endColor >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.setShader(GameRenderer::getPositionColorProgram); - - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); - + switch (direction) { case LEFT_RIGHT: - bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(startRed, startGreen, startBlue, startAlpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(endRed, endGreen, endBlue, endAlpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(endRed, endGreen, endBlue, endAlpha).next(); - bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(startRed, startGreen, startBlue, startAlpha).next(); + bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(startRed, startGreen, startBlue, startAlpha); + bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(endRed, endGreen, endBlue, endAlpha); + bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(endRed, endGreen, endBlue, endAlpha); + bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(startRed, startGreen, startBlue, startAlpha); break; case TOP_BOTTOM: - bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(endRed, endGreen, endBlue, endAlpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(endRed, endGreen, endBlue, endAlpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(startRed, startGreen, startBlue, startAlpha).next(); - bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(startRed, startGreen, startBlue, startAlpha).next(); + bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(endRed, endGreen, endBlue, endAlpha); + bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(endRed, endGreen, endBlue, endAlpha); + bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(startRed, startGreen, startBlue, startAlpha); + bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(startRed, startGreen, startBlue, startAlpha); break; case RIGHT_LEFT: - bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(endRed, endGreen, endBlue, endAlpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(startRed, startGreen, startBlue, startAlpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(startRed, startGreen, startBlue, startAlpha).next(); - bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(endRed, endGreen, endBlue, endAlpha).next(); + bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(endRed, endGreen, endBlue, endAlpha); + bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(startRed, startGreen, startBlue, startAlpha); + bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(startRed, startGreen, startBlue, startAlpha); + bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(endRed, endGreen, endBlue, endAlpha); break; case BOTTOM_TOP: - bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(startRed, startGreen, startBlue, startAlpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(startRed, startGreen, startBlue, startAlpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(endRed, endGreen, endBlue, endAlpha).next(); - bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(endRed, endGreen, endBlue, endAlpha).next(); + bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(startRed, startGreen, startBlue, startAlpha); + bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(startRed, startGreen, startBlue, startAlpha); + bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(endRed, endGreen, endBlue, endAlpha); + bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(endRed, endGreen, endBlue, endAlpha); break; } - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); } @@ -114,21 +112,21 @@ public static void drawRectangle(Matrix4f matrix4f, float x, float y, float widt float alpha = (float) (color >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.setShader(GameRenderer::getPositionColorProgram); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); - bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, x + width, y, 0.0F).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, x, y, 0.0F).color(red, green, blue, alpha); - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); } @@ -201,15 +199,13 @@ public static void drawOutlineRoundedBox(Matrix4f matrix4f, float x, float y, fl } public static void drawRainbowGradientRectangle(Matrix4f matrix4f, float x, float y, float width, float height, float alpha) { - BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); + BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.setShader(GameRenderer::getPositionColorProgram); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); - for (int i = 0; i <= width; i++) { float hue = (float) i / width; int color = Color.HSBtoRGB(hue, 1.0f, 1.0f); @@ -220,8 +216,8 @@ public static void drawRainbowGradientRectangle(Matrix4f matrix4f, float x, floa float blue = (color & 255) / 255.0F; float alphaVal = (color >> 24 & 255) / 255.0F; - bufferBuilder.vertex(matrix4f, x + i, y, 0.0f).color(red, green, blue, alphaVal).next(); - bufferBuilder.vertex(matrix4f, x + i, y + height, 0.0f).color(red, green, blue, alphaVal).next(); + bufferBuilder.vertex(matrix4f, x + i, y, 0.0f).color(red, green, blue, alphaVal); + bufferBuilder.vertex(matrix4f, x + i, y + height, 0.0f).color(red, green, blue, alphaVal); } for (int i = (int) width; i >= 0; i--) { @@ -234,11 +230,11 @@ public static void drawRainbowGradientRectangle(Matrix4f matrix4f, float x, floa float blue = (color & 255) / 255.0F; float alphaVal = (color >> 24 & 255) / 255.0F; - bufferBuilder.vertex(matrix4f, x + i, y + height, 0.0f).color(red, green, blue, alphaVal).next(); - bufferBuilder.vertex(matrix4f, x + i, y, 0.0f).color(red, green, blue, alphaVal).next(); + bufferBuilder.vertex(matrix4f, x + i, y + height, 0.0f).color(red, green, blue, alphaVal); + bufferBuilder.vertex(matrix4f, x + i, y, 0.0f).color(red, green, blue, alphaVal); } - Tessellator.getInstance().draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); } @@ -260,16 +256,15 @@ public static void drawRainbowGradient(Matrix4f matrix, float x, float y, float RenderSystem.enableBlend(); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); for (float i = 0; i < width; i += 1.0f) { float hue = (i / width); // Multiply by 1 to go through the whole color spectrum once (red to red) Color color = Color.getHSBColor(hue, 1.0f, 1.0f); // Full saturation and brightness - bufferBuilder.vertex(matrix4f, x + i, y, 0.0F).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).next(); - bufferBuilder.vertex(matrix4f, x + i + 1.0f, y, 0.0F).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).next(); - bufferBuilder.vertex(matrix4f, x + i + 1.0f, y + height, 0.0F).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).next(); - bufferBuilder.vertex(matrix4f, x + i, y + height, 0.0F).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).next(); + bufferBuilder.vertex(matrix4f, x + i, y, 0.0F).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + bufferBuilder.vertex(matrix4f, x + i + 1.0f, y, 0.0F).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + bufferBuilder.vertex(matrix4f, x + i + 1.0f, y + height, 0.0F).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + bufferBuilder.vertex(matrix4f, x + i, y + height, 0.0F).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); } BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); @@ -297,21 +292,21 @@ public static void drawOutlineCircle(Matrix4f matrix4f, float xCenter, float yCe float alpha = (float) (color >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); + RenderSystem.setShader(GameRenderer::getPositionColorProgram); - bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); for (int i = 0; i <= 360; i++) { double x = xCenter + Math.sin(Math.toRadians(i)) * radius; double y = yCenter + Math.cos(Math.toRadians(i)) * radius; double x2 = xCenter + Math.sin(Math.toRadians(i)) * (radius + lineWidth); double y2 = yCenter + Math.cos(Math.toRadians(i)) * (radius + lineWidth); - bufferBuilder.vertex(matrix4f, (float) x, (float) y, 0).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, (float) x2, (float) y2, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, (float) x, (float) y, 0).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, (float) x2, (float) y2, 0).color(red, green, blue, alpha); } - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); } /** @@ -330,24 +325,23 @@ public static void drawFilledCircle(Matrix4f matrix4f, float xCenter, float yCen float alpha = (float) (color >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); RenderSystem.setShader(GameRenderer::getPositionColorProgram); - bufferBuilder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); - bufferBuilder.vertex(matrix4f, xCenter, yCenter, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, xCenter, yCenter, 0).color(red, green, blue, alpha); for (int i = 0; i <= 360; i++) { double x = xCenter + Math.sin(Math.toRadians(i)) * radius; double y = yCenter + Math.cos(Math.toRadians(i)) * radius; - bufferBuilder.vertex(matrix4f, (float) x, (float) y, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, (float) x, (float) y, 0).color(red, green, blue, alpha); } - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); } @@ -391,9 +385,9 @@ public static void drawFilledArc(Matrix4f matrix4f, float x, float y, float radi Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); + RenderSystem.setShader(GameRenderer::getPositionColorProgram); - bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); for (float angle = startAngle; angle <= endAngle; angle += 1.0F) { @@ -402,11 +396,11 @@ public static void drawFilledArc(Matrix4f matrix4f, float x, float y, float radi float x2 = x + MathHelper.cos((angle + 1.0F) * 0.017453292F) * radius; float y2 = y + MathHelper.sin((angle + 1.0F) * 0.017453292F) * radius; - bufferBuilder.vertex(matrix4f, x, y, 0).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, x1, y1, 0).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, x2, y2, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, x, y, 0).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, x1, y1, 0).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, x2, y2, 0).color(red, green, blue, alpha); } - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); } /* ==== Drawing Quadrants, Arcs, and Triangles ==== */ @@ -434,12 +428,12 @@ public static void drawFilledGradientQuadrant(Matrix4f matrix4f, float xCenter, float endAlpha = (float) (endColor >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + RenderSystem.setShader(GameRenderer::getPositionColorProgram); - bufferBuilder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); - bufferBuilder.vertex(matrix4f, xCenter, yCenter, 0).color(startRed, startGreen, startBlue, startAlpha).next(); + bufferBuilder.vertex(matrix4f, xCenter, yCenter, 0).color(startRed, startGreen, startBlue, startAlpha); for (int i = quadrant * 90; i <= quadrant * 90 + 90; i++) { double x = xCenter + Math.sin(Math.toRadians(i)) * radius; @@ -452,10 +446,10 @@ public static void drawFilledGradientQuadrant(Matrix4f matrix4f, float xCenter, float blue = startBlue * (1 - t) + endBlue * t; float alpha = startAlpha * (1 - t) + endAlpha * t; - bufferBuilder.vertex(matrix4f, (float) x, (float) y, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, (float) x, (float) y, 0).color(red, green, blue, alpha); } - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); } @@ -477,10 +471,9 @@ public static void drawArc(Matrix4f matrix4f, float xCenter, float yCenter, floa float alpha = (float) (color >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR); RenderSystem.setShader(GameRenderer::getPositionColorProgram); - bufferBuilder.begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); for (int i = startAngle; i <= endAngle; i++) { @@ -489,11 +482,11 @@ public static void drawArc(Matrix4f matrix4f, float xCenter, float yCenter, floa double outerX = xCenter + Math.sin(Math.toRadians(i)) * radius; double outerY = yCenter + Math.cos(Math.toRadians(i)) * radius; - bufferBuilder.vertex(matrix4f, (float) innerX, (float) innerY, 0).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, (float) outerX, (float) outerY, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, (float) innerX, (float) innerY, 0).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, (float) outerX, (float) outerY, 0).color(red, green, blue, alpha); } - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); } @@ -515,20 +508,20 @@ public static void drawFilledQuadrant(Matrix4f matrix4f, float xCenter, float yC float alpha = (float) (color >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + RenderSystem.setShader(GameRenderer::getPositionColorProgram); - bufferBuilder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); - bufferBuilder.vertex(matrix4f, xCenter, yCenter, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, xCenter, yCenter, 0).color(red, green, blue, alpha); for (int i = quadrant * 90; i <= quadrant * 90 + 90; i++) { double x = xCenter + Math.sin(Math.toRadians(i)) * radius; double y = yCenter + Math.cos(Math.toRadians(i)) * radius; - bufferBuilder.vertex(matrix4f, (float) x, (float) y, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, (float) x, (float) y, 0).color(red, green, blue, alpha); } - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); } @@ -552,15 +545,14 @@ public static void drawOutlineTriangle(Matrix4f matrix4f, int x1, int y1, int x2 float alpha = (float) (color >> 24 & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); - bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); - bufferBuilder.vertex(matrix4f, x1, y1, 0).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, x2, y2, 0).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, x3, y3, 0).color(red, green, blue, alpha).next(); - bufferBuilder.vertex(matrix4f, x1, y1, 0).color(red, green, blue, alpha).next(); + bufferBuilder.vertex(matrix4f, x1, y1, 0).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, x2, y2, 0).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, x3, y3, 0).color(red, green, blue, alpha); + bufferBuilder.vertex(matrix4f, x1, y1, 0).color(red, green, blue, alpha); - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); } /** @@ -761,14 +753,15 @@ public static void drawRoundedGradientRectangle(Matrix4f matrix, Color color1, C RenderSystem.enableBlend(); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); - bufferBuilder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR); + + bufferBuilder.vertex(matrix, x, y + height, 0.0F).color(color1.getRGB()); + bufferBuilder.vertex(matrix, x + width, y + height, 0.0F).color(color2.getRGB()); + bufferBuilder.vertex(matrix, x + width, y, 0.0F).color(color3.getRGB()); + bufferBuilder.vertex(matrix, x, y, 0.0F).color(color4.getRGB()); - bufferBuilder.vertex(matrix, x, y + height, 0.0F).color(color1.getRGB()).next(); - bufferBuilder.vertex(matrix, x + width, y + height, 0.0F).color(color2.getRGB()).next(); - bufferBuilder.vertex(matrix, x + width, y, 0.0F).color(color3.getRGB()).next(); - bufferBuilder.vertex(matrix, x, y, 0.0F).color(color4.getRGB()).next(); BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + RenderSystem.disableBlend(); RenderSystem.defaultBlendFunc(); diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/ColorGradientPicker.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/ColorGradientPicker.java index 801e652..65a15c9 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/ColorGradientPicker.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/ColorGradientPicker.java @@ -4,7 +4,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.util.GlAllocationUtils; import org.lwjgl.opengl.GL11; import java.awt.*; @@ -79,7 +78,7 @@ public void render(DrawContext drawContext, int x1, int y1) { int y = (int) ((client.getWindow().getScaledHeight() - mouseY) * framebuffer.textureHeight / client.getWindow().getScaledHeight()); //Read the pixel color at x,y pos to buffer - ByteBuffer buffer = GlAllocationUtils.allocateByteBuffer(4); + ByteBuffer buffer = ByteBuffer.allocate(4); GL11.glReadPixels(x, y, 1, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); int red = buffer.get(0) & 0xFF; int green = buffer.get(1) & 0xFF; @@ -109,7 +108,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { int x = (int) (mouseX * framebuffer.textureWidth / client.getWindow().getScaledWidth()); int y = (int) ((client.getWindow().getScaledHeight() - mouseY) * framebuffer.textureHeight / client.getWindow().getScaledHeight()); - ByteBuffer buffer = GlAllocationUtils.allocateByteBuffer(4); + ByteBuffer buffer = ByteBuffer.allocate(4); GL11.glReadPixels(x, y, 1, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); int red = buffer.get(0) & 0xFF; int green = buffer.get(1) & 0xFF; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6b211c9..6b684b8 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -18,9 +18,6 @@ "license": "All-Rights-Reserved", "environment": "client", "entrypoints": { - "dynamicHud": [ - "com.tanishisherewith.dynamichud.DynamicHudTest" - ], "client": [ "com.tanishisherewith.dynamichud.DynamicHUD" ],