From 3d792dbef7c7e0f186e29f2e3999f99c2c14f5d7 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Fri, 5 Jul 2024 22:17:02 +0200 Subject: Port to 1.21 --- .../nea/firmament/mixins/CustomModelBakerPatch.java | 18 +++++++++--------- .../moe/nea/firmament/mixins/HudRenderEventsPatch.java | 9 +++++---- .../firmament/mixins/WorldRenderLastEventPatch.java | 10 +++++++--- .../mixins/accessor/AccessorHandledScreen.java | 1 - 4 files changed, 21 insertions(+), 17 deletions(-) (limited to 'src/main/java/moe/nea') diff --git a/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java b/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java index 012a215..baffa4c 100644 --- a/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java @@ -30,21 +30,21 @@ import java.util.function.BiFunction; public abstract class CustomModelBakerPatch { @Shadow - protected abstract void addModel(ModelIdentifier modelId); + protected abstract void loadItemModel(ModelIdentifier id); @Shadow - @Final - private Map modelsToBake; + abstract UnbakedModel getOrLoadModel(Identifier id); @Shadow - public abstract UnbakedModel getOrLoadModel(Identifier id); + @Final + private Map modelsToBake; @Inject(method = "bake", at = @At("HEAD")) - public void onBake(BiFunction spriteLoader, CallbackInfo ci) { - BakeExtraModelsEvent.Companion.publish(new BakeExtraModelsEvent(this::addModel)); + public void onBake(ModelLoader.SpriteGetter spliteGetter, CallbackInfo ci) { + BakeExtraModelsEvent.Companion.publish(new BakeExtraModelsEvent(this::loadItemModel)); modelsToBake.values().forEach(model -> model.setParents(this::getOrLoadModel)); - modelsToBake.keySet().stream() - .filter(it -> !it.getNamespace().equals("minecraft")) - .forEach(it -> System.out.println("Non minecraft texture is being loaded: " + it)); +// modelsToBake.keySet().stream() +// .filter(it -> !it.id().getNamespace().equals("minecraft")) +// .forEach(it -> System.out.println("Non minecraft texture is being loaded: " + it)); } } diff --git a/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java b/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java index 6618e95..d1b7d92 100644 --- a/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java @@ -11,6 +11,7 @@ import moe.nea.firmament.events.HotbarItemRenderEvent; import moe.nea.firmament.events.HudRenderEvent; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; @@ -21,13 +22,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(InGameHud.class) public class HudRenderEventsPatch { @Inject(method = "renderSleepOverlay", at = @At(value = "HEAD")) - public void renderCallBack(DrawContext context, float tickDelta, CallbackInfo ci) { - HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickDelta)); + public void renderCallBack(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { + HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickCounter)); } @Inject(method = "renderHotbarItem", at = @At("HEAD")) - public void onRenderHotbarItem(DrawContext context, int x, int y, float tickDelta, PlayerEntity player, ItemStack stack, int seed, CallbackInfo ci) { + public void onRenderHotbarItem(DrawContext context, int x, int y, RenderTickCounter tickCounter, PlayerEntity player, ItemStack stack, int seed, CallbackInfo ci) { if (stack != null && !stack.isEmpty()) - HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickDelta)); + HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickCounter)); } } diff --git a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java index 1ad1ae8..f3ebba9 100644 --- a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java @@ -11,6 +11,7 @@ import com.llamalad7.mixinextras.sugar.Local; import moe.nea.firmament.events.WorldRenderLastEvent; import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.world.tick.TickManager; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -26,10 +27,13 @@ public class WorldRenderLastEventPatch { private BufferBuilderStorage bufferBuilders; @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.BEFORE)) - public void onWorldRenderLast(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci - , @Local MatrixStack matrixStack) { + public void onWorldRenderLast( + RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, + LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, + CallbackInfo ci, @Local MatrixStack matrixStack + ) { var event = new WorldRenderLastEvent( - matrixStack, tickDelta, renderBlockOutline, + matrixStack, tickCounter, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, this.bufferBuilders.getEntityVertexConsumers() ); diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java index f61aca3..2e9879d 100644 --- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java +++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java @@ -6,7 +6,6 @@ package moe.nea.firmament.mixins.accessor; -import kotlin.Deprecated; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.screen.slot.Slot; import org.jetbrains.annotations.Nullable; -- cgit