Skip to content

Commit

Permalink
Port to 1.21.3 NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Nov 12, 2024
1 parent 0b019db commit d1cf2f6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 22 deletions.
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ configurations {
runtimeClasspath.extendsFrom localRuntime
}

configurations.all {
resolutionStrategy {
// Override vulnerable msal4j dependency until Minecraft updates to a
// newer version. v1.15.0, used by Minecraft 1.21.3, is vulnerable to
// CVE-2024-35255.
force "com.microsoft.azure:msal4j:1.17.2"

// Fixes a weird issue in NeoForge 21.3 where it tries to load both
// ASM 9.7 and ASM 9.5 at the same time.
force "org.ow2.asm:asm-analysis:9.7"
force "org.ow2.asm:asm:9.7"
force "org.ow2.asm:asm-tree:9.7"
force "org.ow2.asm:asm-commons:9.7"
force "org.ow2.asm:asm-util:9.7"
}
}

dependencies {
// Specify the version of Minecraft to use.
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ parchment_mappings_version=2024.07.28
# Environment Properties
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
# The Minecraft version must agree with the Neo version to get a valid artifact
minecraft_version=1.21
minecraft_version=1.21.3
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21, 1.21.2)
minecraft_version_range=[1.21.2, 1.21.4)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.0.167
neo_version=21.3.4-beta
# The Neo version range can use any version of Neo as bounds
neo_version_range=[21.0.0-beta,)
neo_version_range=[21.2.0-beta,)
# The loader version range can only use the major version of FML as bounds
loader_version_range=[4,)

Expand All @@ -32,7 +32,7 @@ mod_name=ChestESP
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPL-3.0-or-later
# The mod version. See https://semver.org/
mod_version=1.2-MC1.21-NeoForge
mod_version=1.2-MC1.21.3-NeoForge
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand All @@ -43,9 +43,9 @@ mod_authors=Alexander01998
mod_description=Highlights nearby chests so you can see them through walls. Based on a Wurst Client feature of the same name.

# CurseForge
cf_game_version=1.21.1
cf_game_version=1.21.3

# Dependencies
# check at https://modrinth.com/mod/cloth-config/versions?l=neoforge
cloth_config_version=15.0.140
cloth_config_version_range=[15.0.0-beta,16.0.0-beta)
cloth_config_version=16.0.141
cloth_config_version_range=[16.0.0-beta,17.0.0-beta)
6 changes: 3 additions & 3 deletions src/main/java/net/wimods/chestesp/ChestEspMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.vehicle.ChestBoat;
import net.minecraft.world.entity.vehicle.MinecartChest;
Expand Down Expand Up @@ -191,14 +191,14 @@ public void onRender(PoseStack matrixStack, float partialTicks)

if(style.hasBoxes())
{
RenderSystem.setShader(GameRenderer::getPositionShader);
RenderSystem.setShader(CoreShaders.POSITION);
groups.allGroups.stream().filter(ChestEspGroup::isEnabled)
.forEach(espRenderer::renderBoxes);
}

if(style.hasLines())
{
RenderSystem.setShader(GameRenderer::getPositionShader);
RenderSystem.setShader(CoreShaders.POSITION);
groups.allGroups.stream().filter(ChestEspGroup::isEnabled)
.forEach(espRenderer::renderLines);
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/net/wimods/chestesp/ChestEspRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.joml.Matrix4f;

import com.mojang.blaze3d.buffers.BufferUsage;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
Expand All @@ -20,7 +21,8 @@
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexBuffer;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.renderer.ShaderInstance;

import net.minecraft.client.renderer.CompiledShaderProgram;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -61,7 +63,7 @@ public void renderBoxes(ChestEspGroup group)

Matrix4f viewMatrix = matrixStack.last().pose();
Matrix4f projMatrix = RenderSystem.getProjectionMatrix();
ShaderInstance shader = RenderSystem.getShader();
CompiledShaderProgram shader = RenderSystem.getShader();

RenderSystem.setShaderColor(colorF[0], colorF[1], colorF[2], 0.25F);
solidBox.bind();
Expand Down Expand Up @@ -108,8 +110,8 @@ public void renderLines(ChestEspGroup group)
public static void prepareBuffers()
{
closeBuffers();
solidBox = new VertexBuffer(VertexBuffer.Usage.STATIC);
outlinedBox = new VertexBuffer(VertexBuffer.Usage.STATIC);
solidBox = new VertexBuffer(BufferUsage.STATIC_WRITE);
outlinedBox = new VertexBuffer(BufferUsage.STATIC_WRITE);

AABB box = new AABB(BlockPos.ZERO);
RenderUtils.drawSolidBox(box, solidBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ private void onRenderHand(Camera camera, float tickDelta, Matrix4f matrix4f,
ordinal = 0),
method = "renderLevel(Lnet/minecraft/client/DeltaTracker;)V")
private void onRenderWorldHandRendering(DeltaTracker tickCounter,
CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2,
CallbackInfo ci, @Local(ordinal = 2) Matrix4f matrix4f3,
@Local(ordinal = 1) float tickDelta)
{
PoseStack matrixStack = new PoseStack();
matrixStack.mulPose(matrix4f2);
matrixStack.mulPose(matrix4f3);
ChestEspMod chestEsp = ChestEspMod.getInstance();

if(chestEsp != null && chestEsp.isEnabled())
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/wimods/chestesp/util/RenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -119,7 +119,7 @@ public static void drawSolidBox(AABB bb, PoseStack matrixStack)
float maxZ = (float)bb.maxZ;

Matrix4f matrix = matrixStack.last().pose();
RenderSystem.setShader(GameRenderer::getPositionShader);
RenderSystem.setShader(CoreShaders.POSITION);
Tesselator tessellator = RenderSystem.renderThreadTesselator();
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.Mode.QUADS,
DefaultVertexFormat.POSITION);
Expand Down Expand Up @@ -219,7 +219,7 @@ public static void drawOutlinedBox(AABB bb, PoseStack matrixStack)
{
Matrix4f matrix = matrixStack.last().pose();
Tesselator tessellator = RenderSystem.renderThreadTesselator();
RenderSystem.setShader(GameRenderer::getPositionShader);
RenderSystem.setShader(CoreShaders.POSITION);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION);

Expand Down Expand Up @@ -444,7 +444,7 @@ public static void drawNode(AABB bb, PoseStack matrixStack)
{
Matrix4f matrix = matrixStack.last().pose();
Tesselator tessellator = RenderSystem.renderThreadTesselator();
RenderSystem.setShader(GameRenderer::getPositionShader);
RenderSystem.setShader(CoreShaders.POSITION);

double midX = (bb.minX + bb.maxX) / 2;
double midY = (bb.minY + bb.maxY) / 2;
Expand Down Expand Up @@ -580,7 +580,7 @@ public static void drawNode(AABB bb, BufferBuilder bufferBuilder)

public static void drawArrow(Vec3 from, Vec3 to, PoseStack matrixStack)
{
RenderSystem.setShader(GameRenderer::getPositionShader);
RenderSystem.setShader(CoreShaders.POSITION);

Tesselator tessellator = RenderSystem.renderThreadTesselator();
BufferBuilder bufferBuilder = tessellator
Expand Down

0 comments on commit d1cf2f6

Please sign in to comment.