Skip to content

Commit

Permalink
1.21-rc1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
GT3CH1 committed Jun 11, 2024
1 parent 1a3006f commit 6f8cbc3
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 78 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@

---

## Features
## es

- X-Ray
![](src/main/resources/assets/gavinsmod/screenshots/xray.png)
- With a fully configurable X-Ray filter (inspired by ate47's Xray)
![](src/main/resources/assets/gavinsmod/screenshots/xray-menu.png)
- Full Bright
![](src/main/resources/assets/gavinsmod/screenshots/fullbright.png)
- Configurable intensity and smooth fade
- Chest ESP & Tracers (both configured individually)
![](src/main/resources/assets/gavinsmod/screenshots/chests.png)
- Dolphin
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#
org.gradle.jvmargs=-Xmx8G
# Fabric Properties
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
minecraft_version=1.21-rc1
yarn_mappings=1.21-rc1+build.1
loader_version=0.15.11

# Fabric API
fabric_version=0.97.8+1.20.6
fabric_version=0.100.1+1.21
# Mod Properties
mod_version=1.4.7
maven_group=com.peasenet
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/peasenet/gavui/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ public void render(DrawContext drawContext, TextRenderer tr, int mouseX, int mou
textColor = Colors.WHITE;
}
drawText(drawContext, tr, title, getX() + 2, getY() + 1.5f, textColor);

}
drawSymbol(drawContext, tr, textColor);
if (this.drawBorder)
Expand Down
46 changes: 27 additions & 19 deletions src/main/java/com/peasenet/gavui/util/GuiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL11;

/**
* @author gt3ch1
Expand Down Expand Up @@ -59,17 +60,21 @@ public static void drawBox(Color c, BoxF box, MatrixStack matrixStack) {
public static void drawBox(Color c, BoxF box, MatrixStack matrixStack, float alpha) {
alpha = Math.max(0, Math.min(1, alpha));
var acColor = c.getAsFloatArray();
var shader = RenderSystem.getShader();
// var shader = RenderSystem.getShader();
// GL11.glDisable(GL11.GL_CULL_FACE);
// GL11.glEnable(GL11.GL_BLEND);
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//
RenderSystem.setShader(GameRenderer::getPositionProgram);
RenderSystem.enableBlend();
var shaderColors = RenderSystem.getShaderColor();
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], alpha);

var bufferBuilder = Tessellator.getInstance().getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
var tesselator = RenderSystem.renderThreadTesselator();
var bufferBuilder = tesselator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
var matrix = matrixStack.peek().getPositionMatrix();
drawBox(box, matrix, bufferBuilder);
// RenderSystem.setShader(GameRenderer::get);
var e = bufferBuilder.end();
BufferRenderer.drawWithGlobalProgram(e);
RenderSystem.applyModelViewMatrix();
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.disableBlend();
Expand Down Expand Up @@ -112,9 +117,11 @@ public static void drawOutline(Color c, BoxF box, MatrixStack matrixStack, float
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], alpha);

var matrix = matrixStack.peek().getPositionMatrix();
var bufferBuilder = Tessellator.getInstance().getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
drawBox(box, matrix, bufferBuilder);
var tess = RenderSystem.renderThreadTesselator();
var bb = tess.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
drawBox(box, matrix, bb);
var e = bb.end();
BufferRenderer.drawWithGlobalProgram(e);
RenderSystem.applyModelViewMatrix();
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.disableBlend();
Expand All @@ -132,12 +139,12 @@ private static void drawBox(BoxF box, Matrix4f matrix, BufferBuilder bufferBuild
var yt1 = box.getTopLeft().y();
var xt2 = box.getBottomRight().x();
var yt2 = box.getBottomRight().y();
bufferBuilder.vertex(matrix, xt1, yt1, 0).next();
bufferBuilder.vertex(matrix, xt1, yt2, 0).next();
bufferBuilder.vertex(matrix, xt2, yt2, 0).next();
bufferBuilder.vertex(matrix, xt2, yt1, 0).next();
bufferBuilder.vertex(matrix, xt1, yt1, 0).next();
Tessellator.getInstance().draw();
bufferBuilder.vertex(matrix, xt1, yt1, 0);
bufferBuilder.vertex(matrix, xt1, yt2, 0);
bufferBuilder.vertex(matrix, xt2, yt2, 0);
bufferBuilder.vertex(matrix, xt2, yt1, 0);
bufferBuilder.vertex(matrix, xt1, yt1, 0);

}

/**
Expand All @@ -153,12 +160,13 @@ public static void renderSingleLine(Color color, PointF p1, PointF p2, MatrixSta
RenderSystem.setShader(GameRenderer::getPositionProgram);
RenderSystem.enableBlend();
var matrix = matrixStack.peek().getPositionMatrix();
var bufferBuilder = Tessellator.getInstance().getBuffer();
var tessellator = RenderSystem.renderThreadTesselator();
RenderSystem.setShaderColor(accColor[0], accColor[1], accColor[2], alpha);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, p1.x(), p1.y(), 0).next();
bufferBuilder.vertex(matrix, p2.x(), p2.y(), 0).next();
Tessellator.getInstance().draw();
var bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, p1.x(), p1.y(), 0);
bufferBuilder.vertex(matrix, p2.x(), p2.y(), 0);
var e = bufferBuilder.end();
BufferRenderer.drawWithGlobalProgram(e);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.disableBlend();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/peasenet/mixins/CameraMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
package com.peasenet.mixins;

import com.peasenet.main.GavinsMod;
import net.minecraft.block.enums.CameraSubmersionType;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.CameraSubmersionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MixinClientPlayerEntityNausea {
@Shadow
public float nauseaIntensity;

@Inject(method = "updateNausea", at = @At("HEAD"), cancellable = true)
@Inject(method = "tickNausea", at = @At("HEAD"), cancellable = true)
public void cancelNausea(CallbackInfo ci) {
if (Mods.isActive("nonausea")) {
this.prevNauseaIntensity = 0.0f;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/peasenet/mixins/MixinInGameHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.peasenet.util.event.data.RenderOverlay;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -44,8 +45,8 @@
@Mixin(InGameHud.class)
public class MixinInGameHud {
@Inject(at = @At("HEAD"), method = "render")
private void mixin(DrawContext context, float tickDelta, CallbackInfo ci) {
var event = new InGameHudRenderEvent(context, tickDelta);
private void mixin(DrawContext context, RenderTickCounter tickDelta, CallbackInfo ci) {
var event = new InGameHudRenderEvent(context, tickDelta.getTickDelta(true));
EventManager.getEventManager().call(event);
}

Expand All @@ -61,7 +62,7 @@ private void antiPumpkin(DrawContext context, Identifier texture, float opacity,

@Inject(at = @At("HEAD"), method = "renderVignetteOverlay", cancellable = true)
private void antiVignette(CallbackInfo ci) {
var overlay = new RenderOverlay(new Identifier("textures/misc/vignette.png"));
var overlay = new RenderOverlay(Identifier.of("textures/misc/vignette.png"));
RenderOverlayEvent event = new RenderOverlayEvent(overlay);
EventManager.getEventManager().call(event);
if (event.isCancelled())
Expand Down
25 changes: 20 additions & 5 deletions src/main/kotlin/com/peasenet/gui/GuiElement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@
*/
package com.peasenet.gui

import com.mojang.blaze3d.systems.RenderSystem
import com.peasenet.config.MiscConfig
import com.peasenet.gavui.Gui
import com.peasenet.gavui.GuiBuilder
import com.peasenet.gavui.GuiClick
import com.peasenet.gavui.GuiScroll
import com.peasenet.gavui.color.Colors
import com.peasenet.gavui.util.GavUISettings
import com.peasenet.main.GavinsMod
import com.peasenet.main.GavinsModClient
import com.peasenet.main.Settings
import com.peasenet.util.RenderUtils
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.render.GameRenderer
import net.minecraft.client.render.GameRenderer.getPositionProgram
import net.minecraft.text.Text
import java.util.function.Consumer

Expand Down Expand Up @@ -134,13 +139,21 @@ open class GuiElement(title: Text?) : Screen(title) {
}

override fun render(drawContext: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
RenderSystem.setShader { getPositionProgram() }
RenderSystem.enableBlend()
overlay.render(drawContext, textRenderer, mouseX, mouseY, delta)

for (g in guis) {
g.render(drawContext, textRenderer, mouseX, mouseY, delta)
}
//
// super.render(drawContext, mouseX, mouseY, delta)
assert(client != null)
// assert(client != null)
val tr = client!!.textRenderer
// RenderSystem.setShader { GameRenderer.getPositionProgram() }
// RenderSystem.enableBlend()
guis.forEach(Consumer { gui: Gui -> gui.render(drawContext, tr, mouseX, mouseY, delta) })
//// RenderSystem.setShader { GameRenderer.getPositionProgram() }
//// RenderSystem.enableBlend()
// RenderSystem.setShader(GameRenderer::getPositionProgram);
// guis.forEach(Consumer { gui: Gui -> gui.render(drawContext, tr, mouseX, mouseY, delta) })
if (titleBox != null) {
titleBox!!.setBackground(GavUISettings.getColor("gui.color.background"))
titleBox!!.render(drawContext, tr, mouseX, mouseY, delta)
Expand All @@ -149,7 +162,7 @@ open class GuiElement(title: Text?) : Screen(title) {
if (miscConfig) {
overlay.render(drawContext, tr, mouseX, mouseY, delta)
}
// RenderUtils.resetRenderSystem()
RenderUtils.resetRenderSystem()
}

/**
Expand All @@ -167,4 +180,6 @@ open class GuiElement(title: Text?) : Screen(title) {
override fun close() {
client!!.setScreen(parent)
}


}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/peasenet/mods/render/ModAntiPumpkin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ class ModAntiPumpkin : RenderMod(
}

override fun onRenderOverlay(overlay: RenderOverlay) {
if (overlay.texture == Identifier("textures/misc/pumpkinblur.png")) overlay.cancel()
if (overlay.texture == Identifier.of("textures/misc/pumpkinblur.png")) overlay.cancel()
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/peasenet/mods/render/ModNoOverlay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ class ModNoOverlay : RenderMod(
}

override fun onRenderOverlay(overlay: RenderOverlay) {
if (overlay.texture == Identifier("textures/misc/powder_snow_outline.png")) overlay.cancel()
if (overlay.texture == Identifier.of("textures/misc/powder_snow_outline.png")) overlay.cancel()
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/peasenet/mods/render/ModNoVignette.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ class ModNoVignette : RenderMod(

override fun onRenderOverlay(overlay: RenderOverlay) {
val texture = overlay.texture
if (texture == Identifier("textures/misc/vignette.png")) overlay.cancel()
if (texture == Identifier.of("textures/misc/vignette.png")) overlay.cancel()
}
}
Loading

0 comments on commit 6f8cbc3

Please sign in to comment.