From 405f5b35aa7764bd9575be9fd3d63de5144f0edb Mon Sep 17 00:00:00 2001 From: Ibrahim Ansari Date: Thu, 5 Dec 2024 03:37:32 +0530 Subject: [PATCH] Update to Minecraft 1.21/1.21.1 - Adapt to minor API changes. - Update Gradle, Loom, FLoader/FAPI, Yarn. --- gradle.properties | 8 ++++---- .../torohealth/bars/HealthBarRenderer.java | 18 +++++++++--------- .../torohealth/bars/ParticleRenderer.java | 2 +- .../torohealth/display/BarDisplay.java | 4 ++-- .../net/torocraft/torohealth/display/Hud.java | 2 +- .../torohealth/mixin/InGameHudMixin.java | 3 ++- src/main/resources/fabric.mod.json | 2 +- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gradle.properties b/gradle.properties index e0d4ab0..d79444f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,14 +8,14 @@ org.gradle.jvmargs=-Xmx1G # To remap the mixin locations: # gradlew migrateMappings --mappings "1.16.1+build.9" -minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.3 +minecraft_version=1.21.1 +yarn_mappings=1.21.1+build.3 loader_version=0.16.9 #Fabric api -fabric_version=0.100.8+1.20.6 +fabric_version=0.110.0+1.21.1 # Mod Properties -mod_version = 1.20.5-fabric-1 +mod_version = 1.21.1-fabric-1 maven_group = net.torocraft archives_base_name = torohealth diff --git a/src/main/java/net/torocraft/torohealth/bars/HealthBarRenderer.java b/src/main/java/net/torocraft/torohealth/bars/HealthBarRenderer.java index bc9ae68..0e54c14 100644 --- a/src/main/java/net/torocraft/torohealth/bars/HealthBarRenderer.java +++ b/src/main/java/net/torocraft/torohealth/bars/HealthBarRenderer.java @@ -6,6 +6,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.render.BufferBuilder; +import net.minecraft.client.render.BufferRenderer; import net.minecraft.client.render.Camera; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.Tessellator; @@ -29,7 +30,7 @@ public class HealthBarRenderer { - private static final Identifier GUI_BARS_TEXTURES = new Identifier(ToroHealth.MODID + ":textures/gui/bars.png"); + private static final Identifier GUI_BARS_TEXTURES = Identifier.of(ToroHealth.MODID + ":textures/gui/bars.png"); private static final int DARK_GRAY = 0x808080; private static final float FULL_SIZE = 40; @@ -101,7 +102,7 @@ public static void renderInWorld(MatrixStack matrix, boolean sneaking = entity.isInSneakingPose(); float height = entity.getHeight() + 0.6F - (sneaking ? 0.25F : 0.0F); - float tickDelta = client.getTickDelta(); + float tickDelta = client.getRenderTickCounter().getTickDelta(true); double x = MathHelper.lerp((double) tickDelta, entity.prevX, entity.getX()); double y = MathHelper.lerp((double) tickDelta, entity.prevY, entity.getY()); double z = MathHelper.lerp((double) tickDelta, entity.prevZ, entity.getZ()); @@ -201,16 +202,15 @@ private static void drawBar(Matrix4f matrix4f, double x, double y, float width, float zOffsetAmount = inWorld ? -0.1F : 0.1F; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder buffer = tessellator.getBuffer(); - buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); buffer.vertex(matrix4f, (float) (-half + x), (float) y, zOffset * zOffsetAmount) - .texture(u * c, v * c).next(); + .texture(u * c, v * c); buffer.vertex(matrix4f, (float) (-half + x), (float) (h + y), zOffset * zOffsetAmount) - .texture(u * c, (v + vh) * c).next(); + .texture(u * c, (v + vh) * c); buffer.vertex(matrix4f, (float) (-half + size + x), (float) (h + y), zOffset * zOffsetAmount) - .texture((u + uw) * c, (v + vh) * c).next(); + .texture((u + uw) * c, (v + vh) * c); buffer.vertex(matrix4f, (float) (-half + size + x), (float) y, zOffset * zOffsetAmount) - .texture(((u + uw) * c), v * c).next(); - tessellator.draw(); + .texture(((u + uw) * c), v * c); + BufferRenderer.drawWithGlobalProgram(buffer.end()); } } diff --git a/src/main/java/net/torocraft/torohealth/bars/ParticleRenderer.java b/src/main/java/net/torocraft/torohealth/bars/ParticleRenderer.java index 564132e..f06eb57 100644 --- a/src/main/java/net/torocraft/torohealth/bars/ParticleRenderer.java +++ b/src/main/java/net/torocraft/torohealth/bars/ParticleRenderer.java @@ -29,7 +29,7 @@ private static void renderParticle(MatrixStack matrix, VertexConsumerProvider ve float scaleToGui = 0.025f; MinecraftClient client = MinecraftClient.getInstance(); - float tickDelta = client.getTickDelta(); + float tickDelta = client.getRenderTickCounter().getTickDelta(true); double x = MathHelper.lerp((double) tickDelta, particle.xPrev, particle.x); double y = MathHelper.lerp((double) tickDelta, particle.yPrev, particle.y); diff --git a/src/main/java/net/torocraft/torohealth/display/BarDisplay.java b/src/main/java/net/torocraft/torohealth/display/BarDisplay.java index 278b474..e1a5098 100644 --- a/src/main/java/net/torocraft/torohealth/display/BarDisplay.java +++ b/src/main/java/net/torocraft/torohealth/display/BarDisplay.java @@ -11,8 +11,8 @@ public class BarDisplay { - private static final Identifier ARMOR_TEXTURE = new Identifier("hud/armor_full"); - private static final Identifier HEART_TEXTURE = new Identifier("hud/heart/full"); + private static final Identifier ARMOR_TEXTURE = Identifier.of("hud/armor_full"); + private static final Identifier HEART_TEXTURE = Identifier.of("hud/heart/full"); private final MinecraftClient mc; public BarDisplay(MinecraftClient mc) { diff --git a/src/main/java/net/torocraft/torohealth/display/Hud.java b/src/main/java/net/torocraft/torohealth/display/Hud.java index 17e15ab..69eccb5 100644 --- a/src/main/java/net/torocraft/torohealth/display/Hud.java +++ b/src/main/java/net/torocraft/torohealth/display/Hud.java @@ -14,7 +14,7 @@ public class Hud extends Screen { private static final Identifier BACKGROUND_TEXTURE = - new Identifier(ToroHealth.MODID + ":textures/gui/default_skin_basic.png"); + Identifier.of(ToroHealth.MODID + ":textures/gui/default_skin_basic.png"); private EntityDisplay entityDisplay = new EntityDisplay(); private LivingEntity entity; private BarDisplay barDisplay; diff --git a/src/main/java/net/torocraft/torohealth/mixin/InGameHudMixin.java b/src/main/java/net/torocraft/torohealth/mixin/InGameHudMixin.java index 1a43eb7..352381b 100644 --- a/src/main/java/net/torocraft/torohealth/mixin/InGameHudMixin.java +++ b/src/main/java/net/torocraft/torohealth/mixin/InGameHudMixin.java @@ -2,6 +2,7 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import net.torocraft.torohealth.ToroHealth; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -12,7 +13,7 @@ public class InGameHudMixin { @Inject(method = "render", at = @At("RETURN")) - private void render(DrawContext drawContext, float partial, CallbackInfo info) { + private void render(DrawContext drawContext, RenderTickCounter tickCounter, CallbackInfo ci) { ToroHealth.HUD.draw(drawContext, ToroHealth.CONFIG); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8ad2af1..0d2d3ad 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,7 @@ "depends": { "fabricloader": ">=0.14.21", "fabric": "*", - "minecraft": "1.20.x", + "minecraft": "1.21.x", "java": ">=21" } }