diff --git a/gradle.properties b/gradle.properties index b41451c..bba43d0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,13 +2,13 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 -loader_version=0.16.2 +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 +loader_version=0.16.7 # Mod Properties -mod_version=1.8.7 +mod_version=1.8.8 maven_group=net.toshimichi archives_base_name=thymine # Dependencies -# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api -fabric_version=0.102.1+1.21.1 +# Fabric API +fabric_version=0.107.0+1.21.3 diff --git a/src/main/java/net/toshimichi/thymine/ArmorHud.java b/src/main/java/net/toshimichi/thymine/ArmorHud.java index 8a415d3..abb85b2 100644 --- a/src/main/java/net/toshimichi/thymine/ArmorHud.java +++ b/src/main/java/net/toshimichi/thymine/ArmorHud.java @@ -3,6 +3,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.item.ItemStack; +import net.minecraft.util.profiler.Profilers; import net.minecraft.world.GameMode; import net.toshimichi.thymine.mixin.ClientPlayerInteractionManagerAccessor; @@ -16,7 +17,7 @@ public void render(DrawContext context) { GameMode current = ((ClientPlayerInteractionManagerAccessor) client.interactionManager).getGameMode(); if (current != GameMode.SURVIVAL && current != GameMode.ADVENTURE) return; - client.getProfiler().push("armorHud"); + Profilers.get().push("armorHud"); int index = 0; ArrayList armorItems = new ArrayList<>(); @@ -28,9 +29,9 @@ public void render(DrawContext context) { int x = width / 2 + 12 + (index * 20); int y = height - 57; context.drawItem(itemStack, x, y); - context.drawItemInSlot(client.textRenderer, itemStack, x, y); + context.drawStackOverlay(client.textRenderer, itemStack, x, y); index++; } - client.getProfiler().pop(); + Profilers.get().pop(); } } diff --git a/src/main/java/net/toshimichi/thymine/PotionHud.java b/src/main/java/net/toshimichi/thymine/PotionHud.java index 1585761..3277bc3 100644 --- a/src/main/java/net/toshimichi/thymine/PotionHud.java +++ b/src/main/java/net/toshimichi/thymine/PotionHud.java @@ -1,17 +1,19 @@ package net.toshimichi.thymine; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderLayer; import net.minecraft.client.texture.Sprite; import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.util.math.ColorHelper; +import net.minecraft.util.profiler.Profilers; public class PotionHud { public void render(DrawContext context) { MinecraftClient client = MinecraftClient.getInstance(); - client.getProfiler().push("potionHud"); + Profilers.get().push("potionHud"); TextRenderer renderer = client.textRenderer; float x = ThymineMod.getOptions().potionHudOptions.getX(); @@ -26,8 +28,7 @@ public void render(DrawContext context) { String text = String.format("%02d:%02d", minutes, seconds % 60); Sprite sprite = client.getStatusEffectSpriteManager().getSprite(effect.getEffectType()); - RenderSystem.setShaderTexture(0, sprite.getAtlasId()); - context.drawSprite((int) x, (int) y + (index * 25), 0, 18, 18, sprite); + context.drawSpriteStretched(RenderLayer::getGuiTextured, sprite, (int) x, (int) y + (index * 25), 18, 18, ColorHelper.getWhite(1)); context.drawTextWithShadow(renderer, text, (int) (x + 21), (int) (y + 5 + (index * 25)), ThymineMod.getOptions().potionHudOptions.color); if (effect.getAmplifier() > 0) { @@ -36,6 +37,6 @@ public void render(DrawContext context) { } index++; } - client.getProfiler().pop(); + Profilers.get().pop(); } } diff --git a/src/main/java/net/toshimichi/thymine/ToggleSprintHud.java b/src/main/java/net/toshimichi/thymine/ToggleSprintHud.java index 18dcf2b..18e7625 100644 --- a/src/main/java/net/toshimichi/thymine/ToggleSprintHud.java +++ b/src/main/java/net/toshimichi/thymine/ToggleSprintHud.java @@ -4,12 +4,13 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; +import net.minecraft.util.profiler.Profilers; public class ToggleSprintHud { public void render(DrawContext context) { MinecraftClient client = MinecraftClient.getInstance(); - client.getProfiler().push("toggleSprint"); + Profilers.get().push("toggleSprint"); TextRenderer renderer = client.textRenderer; int x = (int) ThymineMod.getOptions().toggleSprintHud.getX(); @@ -22,6 +23,6 @@ public void render(DrawContext context) { String toggleSprintDisabled = Text.translatable("thymine.messages.toggleSprint.disabled").getString(); context.drawTextWithShadow(renderer, toggleSprintDisabled, x, y, color); } - client.getProfiler().pop(); + Profilers.get().pop(); } } diff --git a/src/main/java/net/toshimichi/thymine/mixin/EntityRenderDispatcherMixin.java b/src/main/java/net/toshimichi/thymine/mixin/EntityRenderDispatcherMixin.java index 69eab21..de14791 100644 --- a/src/main/java/net/toshimichi/thymine/mixin/EntityRenderDispatcherMixin.java +++ b/src/main/java/net/toshimichi/thymine/mixin/EntityRenderDispatcherMixin.java @@ -3,8 +3,10 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.VertexRendering; import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.render.entity.state.EntityRenderState; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.util.math.Box; @@ -17,11 +19,11 @@ @Mixin(EntityRenderDispatcher.class) public class EntityRenderDispatcherMixin { - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V"), method = "render") - public void render(Entity entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderer;render(Lnet/minecraft/client/render/entity/state/EntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"), method = "render(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/EntityRenderer;)V") + public void render(Entity entity, double x, double y, double z, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, EntityRenderer renderer, CallbackInfo ci) { if (ThymineMod.getOptions().showHitBox && !entity.isInvisible() && !(entity instanceof ClientPlayerEntity)) { Box box = entity.getBoundingBox().offset(-entity.getX(), -entity.getY(), -entity.getZ()); - WorldRenderer.drawBox(matrices, vertexConsumers.getBuffer(RenderLayer.getLines()), box, 1.0f, 1.0f, 1.0f, 1.0f); + VertexRendering.drawBox(matrices, vertexConsumers.getBuffer(RenderLayer.getLines()), box, 1.0f, 1.0f, 1.0f, 1.0f); } } } diff --git a/src/main/java/net/toshimichi/thymine/mixin/InGameHudMixin.java b/src/main/java/net/toshimichi/thymine/mixin/InGameHudMixin.java index bb82eba..a913e64 100644 --- a/src/main/java/net/toshimichi/thymine/mixin/InGameHudMixin.java +++ b/src/main/java/net/toshimichi/thymine/mixin/InGameHudMixin.java @@ -8,6 +8,7 @@ import net.toshimichi.thymine.ThymineMod; import net.toshimichi.thymine.ToggleSprintHud; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -15,8 +16,11 @@ @Mixin(InGameHud.class) public class InGameHudMixin { + @Unique private final ToggleSprintHud toggleSprintHud = new ToggleSprintHud(); + @Unique private final PotionHud potionHud = new PotionHud(); + @Unique private final ArmorHud armorHud = new ArmorHud(); @Inject(at = @At("TAIL"), method = "render")