From 4d8399ff4d769def62e6a8241327c4f2dac47e71 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 15 Nov 2025 23:13:50 +0100 Subject: snapshot: main source set compile --- gradle/libs.versions.toml | 39 +++++------ .../moe/nea/firmament/init/ClientPlayerRiser.java | 75 --------------------- .../java/moe/nea/firmament/init/EarlyRiser.java | 1 - .../moe/nea/firmament/init/HandledScreenRiser.java | 52 ++++++++------- .../nea/firmament/mixins/WorldReadyEventPatch.java | 1 - .../mixins/accessor/AccessorNbtComponent.java | 12 ++++ .../mixins/customgui/PatchHandledScreen.java | 40 +++++++----- .../devcosmetics/CustomCapeFeatureRenderer.java | 33 ++++++---- src/main/kotlin/apis/UrsaManager.kt | 2 +- .../kotlin/events/FinalizeResourceManagerEvent.kt | 6 +- src/main/kotlin/features/debug/PowerUserTools.kt | 3 +- src/main/kotlin/features/debug/SkinPreviews.kt | 18 ++--- .../features/debug/itemeditor/ExportRecipe.kt | 3 +- .../debug/itemeditor/LegacyItemExporter.kt | 6 +- .../features/inventory/SaveCursorPosition.kt | 2 +- src/main/kotlin/features/inventory/SlotLocking.kt | 8 +-- .../inventory/buttons/InventoryButtonEditor.kt | 53 ++++++++------- .../storageoverlay/StorageOverlayCustom.kt | 43 ++++++------ .../storageoverlay/StorageOverlayScreen.kt | 51 ++++++++------- .../storageoverlay/StorageOverviewScreen.kt | 16 +++-- src/main/kotlin/features/mining/HotmPresets.kt | 5 +- src/main/kotlin/features/misc/CustomCapes.kt | 29 ++------- .../kotlin/features/world/TemporaryWaypoints.kt | 6 +- src/main/kotlin/gui/entity/GuiPlayer.kt | 44 +++---------- src/main/kotlin/gui/entity/ModifyPlayerSkin.kt | 76 ++++++++++++---------- src/main/kotlin/gui/entity/ModifyRiding.kt | 2 +- .../kotlin/keybindings/FirmamentKeyBindings.kt | 4 +- src/main/kotlin/keybindings/GenericInputButton.kt | 16 +++-- src/main/kotlin/repo/RepoModResourcePack.kt | 5 +- src/main/kotlin/util/FragmentGuiScreen.kt | 31 +++++---- src/main/kotlin/util/MC.kt | 1 - src/main/kotlin/util/ScoreboardUtil.kt | 2 +- src/main/kotlin/util/SkyblockId.kt | 3 +- src/main/kotlin/util/customgui/CustomGui.kt | 15 +++-- src/main/kotlin/util/mc/CustomRenderPassHelper.kt | 3 +- src/main/kotlin/util/mc/NbtUtil.kt | 5 ++ src/main/kotlin/util/mc/SkullItemData.kt | 4 +- src/main/resources/firmament.accesswidener | 8 ++- 38 files changed, 330 insertions(+), 393 deletions(-) delete mode 100644 src/main/java/moe/nea/firmament/init/ClientPlayerRiser.java create mode 100644 src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4c18ea7..625f436 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: CC0-1.0 [versions] -minecraft = "1.21.7" +minecraft = "1.21.10" # Update from https://maven.fabricmc.net/net/fabricmc/fabric-language-kotlin/ fabric_kotlin = "1.13.7+kotlin.2.2.21" @@ -13,44 +13,37 @@ kotlin = "2.2.21" kotlin_ksp = "2.2.21-2.0.4" # Update from https://linkie.shedaniel.dev/dependencies?loader=fabric -yarn = "1.21.7+build.8" -fabric_loader = "0.16.14" -fabric_api = "0.129.0+1.21.7" -architectury = "17.0.6" -modmenu = "15.0.0-beta.3" +yarn = "1.21.10+build.2" +fabric_loader = "0.18.0" +fabric_api = "0.138.3+1.21.10" +architectury = "18.0.6" +modmenu = "16.0.0-rc.1" # Update from https://maven.architectury.dev/me/shedaniel/RoughlyEnoughItems-fabric/ (but is typically late) -rei = "19.0.805" +rei = "20.0.811" reidev = "33d8900cd6621816680634fcbae2dd07f1cffbd3" # Update from https://maven.architectury.dev/dev/architectury/loom/dev.architectury.loom.gradle.plugin/ loom = "1.13.457" # TODO: port back to architectury (and) 1.9.424 -# Update from https://modrinth.com/mod/qolify/versions?l=fabric -qolify = "1.6.0-1.21.1" - # Update from https://modrinth.com/mod/sodium/versions?l=fabric -sodium = "mc1.21.8-0.7.2-fabric" +sodium = "mc1.21.10-0.7.3-fabric" # Update from https://modrinth.com/mod/freecam/versions?l=fabric -freecammod = "1.3.4+mc1.21.6" - -# Update from https://modrinth.com/mod/no-chat-reports/versions?l=fabric -ncr = "Fabric-1.21.7-v2.14.0" +freecammod = "1.3.5+mc1.21.10" # Update from https://modrinth.com/mod/female-gender/versions?l=fabric -femalegender = "4.3.4+1.21.7" +femalegender = "5.0.0-Beta.2+1.21.10" # Update from https://modrinth.com/mod/iris/versions?l=fabric -iris = "1.9.6+1.21.8-fabric" +iris = "1.9.6+1.21.10-fabric" shadow = "8.3.8" - # Update from https://modrinth.com/mod/not-enough-animations/versions?l=fabric -notenoughanimations = "JTLkasT1" +notenoughanimations = "rPkK5la7" # Update from https://modrinth.com/mod/jade/versions?l=fabric -jade = "19.0.4+fabric" +jade = "20.1.0+fabric" devauth = "1.2.1" @@ -84,7 +77,7 @@ manninghamMills = "2.4.1" # Update from https://docs.isxander.dev/yet-another-config-lib/installing-yacl # Nvm, they just don't update docs: https://modrinth.com/mod/yacl/versions?l=fabric -yacl = "3.7.1+1.21.6-fabric" +yacl = "3.8.0+1.21.9-fabric" # Update from https://maven.shedaniel.me/me/shedaniel/cloth/basic-math/ basicMath = "0.6.1" @@ -109,7 +102,7 @@ rei_fabric = { module = "me.shedaniel:RoughlyEnoughItems-fabric", version.ref = rei_dev_api = { module = "com.github.shedaniel.roughlyenoughitems:RoughlyEnoughItems-api", version.ref = "reidev" } rei_dev_fabric = { module = "com.github.shedaniel.roughlyenoughitems:RoughlyEnoughItems-fabric", version.ref = "reidev" } -moulconfig = { module = "org.notenoughupdates.moulconfig:modern-1.21.7", version.ref = "moulconfig" } +moulconfig = { module = "org.notenoughupdates.moulconfig:modern-1.21.10", version.ref = "moulconfig" } repoparser = { module = "moe.nea:neurepoparser", version.ref = "neurepoparser" } mixinextras = { module = "io.github.llamalad7:mixinextras-fabric", version.ref = "mixinextras" } jarvis_api = { module = "moe.nea.jarvis:jarvis-api", version.ref = "jarvis" } @@ -125,8 +118,6 @@ hotswap = { module = "virtual.github.hotswapagent:hotswap-agent", version.ref = architectury_fabric = { module = "dev.architectury:architectury-fabric", version.ref = "architectury" } devauth = { module = "me.djtheredstoner:DevAuth-fabric", version.ref = "devauth" } modmenu = { module = "maven.modrinth:modmenu", version.ref = "modmenu" } -qolify = { module = "maven.modrinth:qolify", version.ref = "qolify" } -ncr = { module = "maven.modrinth:no-chat-reports", version.ref = "ncr" } sodium = { module = "maven.modrinth:sodium", version.ref = "sodium" } freecammod = { module = "maven.modrinth:freecam", version.ref = "freecammod" } femalegender = { module = "maven.modrinth:female-gender", version.ref = "femalegender" } diff --git a/src/main/java/moe/nea/firmament/init/ClientPlayerRiser.java b/src/main/java/moe/nea/firmament/init/ClientPlayerRiser.java deleted file mode 100644 index d60e3e7..0000000 --- a/src/main/java/moe/nea/firmament/init/ClientPlayerRiser.java +++ /dev/null @@ -1,75 +0,0 @@ -package moe.nea.firmament.init; - -import me.shedaniel.mm.api.ClassTinkerers; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.VarInsnNode; - -import java.lang.reflect.Modifier; -import java.util.Objects; - -public class ClientPlayerRiser extends RiserUtils { - @IntermediaryName(net.minecraft.entity.player.PlayerEntity.class) - String PlayerEntity; - @IntermediaryName(net.minecraft.world.World.class) - String World; - String GameProfile = "com.mojang.authlib.GameProfile"; - @IntermediaryName(net.minecraft.util.math.BlockPos.class) - String BlockPos; - @IntermediaryName(net.minecraft.client.network.AbstractClientPlayerEntity.class) - String AbstractClientPlayerEntity; - String GuiPlayer = "moe.nea.firmament.gui.entity.GuiPlayer"; - // World world, BlockPos pos, float yaw, GameProfile gameProfile - Type constructorDescriptor = Type.getMethodType(Type.VOID_TYPE, getTypeForClassName(World), getTypeForClassName(BlockPos), Type.FLOAT_TYPE, getTypeForClassName(GameProfile)); - - - private void mapClassNode(ClassNode classNode, Type superClass) { - for (MethodNode method : classNode.methods) { - if (Objects.equals(method.name, "") && Type.getMethodType(method.desc).equals(constructorDescriptor)) { - modifyConstructor(method, superClass); - return; - } - } - var node = new MethodNode(Opcodes.ASM9, "", constructorDescriptor.getDescriptor(), null, null); - classNode.methods.add(node); - modifyConstructor(node, superClass); - } - - - private void modifyConstructor(MethodNode method, Type superClass) { - method.access = (method.access | Modifier.PUBLIC) & ~Modifier.PRIVATE & ~Modifier.PROTECTED; - if (method.instructions.size() != 0) return; // Some other mod has already made a constructor here - - // World world, BlockPos pos, float yaw, GameProfile gameProfile - // ALOAD this - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - - // ALOAD World - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1)); - - // ALOAD BlockPos - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2)); - - // ALOAD yaw - method.instructions.add(new VarInsnNode(Opcodes.FLOAD, 3)); - - // ALOAD gameProfile - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 4)); - - // Call super - method.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, superClass.getInternalName(), "", constructorDescriptor.getDescriptor(), false)); - - // Return - method.instructions.add(new InsnNode(Opcodes.RETURN)); - } - - @Override - public void addTinkerers() { - ClassTinkerers.addTransformation(AbstractClientPlayerEntity, it -> mapClassNode(it, getTypeForClassName(PlayerEntity)), true); - ClassTinkerers.addTransformation(GuiPlayer, it -> mapClassNode(it, getTypeForClassName(AbstractClientPlayerEntity)), true); - } -} diff --git a/src/main/java/moe/nea/firmament/init/EarlyRiser.java b/src/main/java/moe/nea/firmament/init/EarlyRiser.java index 5441255..ae26bd7 100644 --- a/src/main/java/moe/nea/firmament/init/EarlyRiser.java +++ b/src/main/java/moe/nea/firmament/init/EarlyRiser.java @@ -4,7 +4,6 @@ package moe.nea.firmament.init; public class EarlyRiser implements Runnable { @Override public void run() { - new ClientPlayerRiser().addTinkerers(); new HandledScreenRiser().addTinkerers(); new SectionBuilderRiser().addTinkerers(); // TODO: new ItemColorsSodiumRiser().addTinkerers(); diff --git a/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java b/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java index f7db18c..cb0058d 100644 --- a/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java +++ b/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java @@ -3,6 +3,10 @@ package moe.nea.firmament.init; import me.shedaniel.mm.api.ClassTinkerers; import net.minecraft.client.gui.Element; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.input.CharInput; +import net.minecraft.client.input.KeyInput; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; @@ -19,23 +23,28 @@ import java.lang.reflect.Modifier; import java.util.function.Consumer; public class HandledScreenRiser extends RiserUtils { - @IntermediaryName(net.minecraft.client.gui.screen.Screen.class) + @IntermediaryName(Screen.class) String Screen; - @IntermediaryName(net.minecraft.client.gui.screen.ingame.HandledScreen.class) + @IntermediaryName(KeyInput.class) + String KeyInput; + @IntermediaryName(CharInput.class) + String CharInput; + @IntermediaryName(HandledScreen.class) String HandledScreen; Type mouseScrolledDesc = Type.getMethodType(Type.BOOLEAN_TYPE, Type.DOUBLE_TYPE, Type.DOUBLE_TYPE, Type.DOUBLE_TYPE, Type.DOUBLE_TYPE); - String mouseScrolled = remapper.mapMethodName("intermediary", "net.minecraft.class_364", "method_25401", - mouseScrolledDesc.getDescriptor()); + String mouseScrolled = remapper.mapMethodName("intermediary", Intermediary.className(), + Intermediary.methodName(Element::mouseScrolled), + mouseScrolledDesc.getDescriptor()); // boolean keyReleased(int keyCode, int scanCode, int modifiers) - Type keyReleasedDesc = Type.getMethodType(Type.BOOLEAN_TYPE, Type.INT_TYPE, Type.INT_TYPE, Type.INT_TYPE); + Type keyReleasedDesc = Type.getMethodType(Type.BOOLEAN_TYPE, getTypeForClassName(KeyInput)); String keyReleased = remapper.mapMethodName("intermediary", Intermediary.className(), - Intermediary.methodName(Element::keyReleased), - keyReleasedDesc.getDescriptor()); + Intermediary.methodName(Element::keyReleased), + keyReleasedDesc.getDescriptor()); // public boolean charTyped(char chr, int modifiers) - Type charTypedDesc = Type.getMethodType(Type.BOOLEAN_TYPE, Type.CHAR_TYPE, Type.INT_TYPE); + Type charTypedDesc = Type.getMethodType(Type.BOOLEAN_TYPE, getTypeForClassName(CharInput)); String charTyped = remapper.mapMethodName("intermediary", Intermediary.className(), - Intermediary.methodName(Element::charTyped), - charTypedDesc.getDescriptor()); + Intermediary.methodName(Element::charTyped), + charTypedDesc.getDescriptor()); @Override @@ -56,8 +65,8 @@ public class HandledScreenRiser extends RiserUtils { * @param insertInvoke insert the invokevirtual/invokestatic call */ void insertTrueHandler(MethodNode node, - Consumer insertLoads, - Consumer insertInvoke) { + Consumer insertLoads, + Consumer insertInvoke) { var insns = new InsnList(); insertLoads.accept(insns); @@ -80,10 +89,8 @@ public class HandledScreenRiser extends RiserUtils { insns -> { // ALOAD 0, load this insns.add(new VarInsnNode(Opcodes.ALOAD, 0)); - // ILOAD 1-3, load args - insns.add(new VarInsnNode(Opcodes.ILOAD, 1)); - insns.add(new VarInsnNode(Opcodes.ILOAD, 2)); - insns.add(new VarInsnNode(Opcodes.ILOAD, 3)); + // ALOAD 1, load args + insns.add(new VarInsnNode(Opcodes.ALOAD, 1)); }); } @@ -93,9 +100,8 @@ public class HandledScreenRiser extends RiserUtils { insns -> { // ALOAD 0, load this insns.add(new VarInsnNode(Opcodes.ALOAD, 0)); - // ILOAD 1-2, load args. chars = ints - insns.add(new VarInsnNode(Opcodes.ILOAD, 1)); - insns.add(new VarInsnNode(Opcodes.ILOAD, 2)); + // ALOAD 1, load args + insns.add(new VarInsnNode(Opcodes.ALOAD, 1)); }); } @@ -119,7 +125,7 @@ public class HandledScreenRiser extends RiserUtils { loadArgs.accept(insns); // INVOKESPECIAL call super method insns.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, getTypeForClassName(Screen).getInternalName(), - name, desc.getDescriptor())); + name, desc.getDescriptor())); // IRETURN return int on stack (booleans are int at runtime) insns.add(new InsnNode(Opcodes.IRETURN)); classNode.methods.add(keyReleasedNode); @@ -127,9 +133,9 @@ public class HandledScreenRiser extends RiserUtils { insertTrueHandler(keyReleasedNode, loadArgs, insns -> { // INVOKEVIRTUAL call custom handler insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, - getTypeForClassName(HandledScreen).getInternalName(), - firmamentName, - desc.getDescriptor())); + getTypeForClassName(HandledScreen).getInternalName(), + firmamentName, + desc.getDescriptor())); }); } diff --git a/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java b/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java index d4b8c9e..f05eb05 100644 --- a/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java @@ -4,7 +4,6 @@ package moe.nea.firmament.mixins; import moe.nea.firmament.events.WorldReadyEvent; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.DownloadingTerrainScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java new file mode 100644 index 0000000..8ce981c --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java @@ -0,0 +1,12 @@ +package moe.nea.firmament.mixins.accessor; + +import net.minecraft.component.type.NbtComponent; +import net.minecraft.nbt.NbtCompound; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(NbtComponent.class) +public interface AccessorNbtComponent { + @Accessor("nbt") + NbtCompound getUnsafeNbt_firmament(); +} diff --git a/src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java index 9027865..3769ceb 100644 --- a/src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java +++ b/src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java @@ -10,9 +10,12 @@ import moe.nea.firmament.keybindings.InputModifiers; import moe.nea.firmament.util.customgui.CoordRememberingSlot; import moe.nea.firmament.util.customgui.CustomGui; import moe.nea.firmament.util.customgui.HasCustomGui; +import net.minecraft.client.gui.Click; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.input.CharInput; +import net.minecraft.client.input.KeyInput; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.slot.Slot; import net.minecraft.text.Text; @@ -75,17 +78,17 @@ public class PatchHandledScreen extends Screen implemen return override != null && override.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount); } - public boolean keyReleased_firmament(int keyCode, int scanCode, int modifiers) { + public boolean keyReleased_firmament(KeyInput input) { if (HandledScreenKeyReleasedEvent.Companion.publish(new HandledScreenKeyReleasedEvent( (HandledScreen) (Object) this, - GenericInputAction.key(keyCode, scanCode), - InputModifiers.of(modifiers))).getCancelled()) + GenericInputAction.of(input), + InputModifiers.of(input))).getCancelled()) return true; - return override != null && override.keyReleased(keyCode, scanCode, modifiers); + return override != null && override.keyReleased(input); } - public boolean charTyped_firmament(char chr, int modifiers) { - return override != null && override.charTyped(chr, modifiers); + public boolean charTyped_firmament(CharInput input) { + return override != null && override.charTyped(input); } @Inject(method = "init", at = @At("TAIL")) @@ -118,7 +121,9 @@ public class PatchHandledScreen extends Screen implemen } @Inject(method = "isClickOutsideBounds", at = @At("HEAD"), cancellable = true) - public void onIsClickOutsideBounds(double mouseX, double mouseY, int left, int top, int button, CallbackInfoReturnable cir) { + public void onIsClickOutsideBounds( + double mouseX, double mouseY, int left, int top, + CallbackInfoReturnable cir) { if (override != null) { cir.setReturnValue(override.isClickOutsideBounds(mouseX, mouseY)); } @@ -176,28 +181,27 @@ public class PatchHandledScreen extends Screen implemen @WrapOperation( method = "mouseClicked", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(DDI)Z")) - public boolean overrideMouseClicks(HandledScreen instance, double mouseX, double mouseY, int button, - Operation original) { + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(Lnet/minecraft/client/gui/Click;Z)Z")) + public boolean overrideMouseClicks(HandledScreen instance, Click click, boolean doubled, Operation original) { if (override != null) { - if (override.mouseClick(mouseX, mouseY, button)) + if (override.mouseClick(click, doubled)) return true; } - return original.call(instance, mouseX, mouseY, button); + return original.call(instance, click, doubled); } @Inject(method = "mouseDragged", at = @At("HEAD"), cancellable = true) - public void overrideMouseDrags(double mouseX, double mouseY, int button, double deltaX, double deltaY, CallbackInfoReturnable cir) { + public void overrideMouseDrags(Click click, double offsetX, double offsetY, CallbackInfoReturnable cir) { if (override != null) { - if (override.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) + if (override.mouseDragged(click, offsetX, offsetY)) cir.setReturnValue(true); } } @Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true) - private void overrideKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) { + private void overrideKeyPressed(KeyInput input, CallbackInfoReturnable cir) { if (override != null) { - if (override.keyPressed(keyCode, scanCode, modifiers)) { + if (override.keyPressed(input)) { cir.setReturnValue(true); } } @@ -207,9 +211,9 @@ public class PatchHandledScreen extends Screen implemen @Inject( method = "mouseReleased", at = @At("HEAD"), cancellable = true) - public void overrideMouseReleases(double mouseX, double mouseY, int button, CallbackInfoReturnable cir) { + public void overrideMouseReleases(Click click, CallbackInfoReturnable cir) { if (override != null) { - if (override.mouseReleased(mouseX, mouseY, button)) + if (override.mouseReleased(click)) cir.setReturnValue(true); } } diff --git a/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java b/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java index c9115d2..5d69e96 100644 --- a/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java +++ b/src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java @@ -5,17 +5,20 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import kotlin.Unit; import moe.nea.firmament.features.misc.CustomCapes; +import net.minecraft.client.model.Model; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.command.ModelCommandRenderer; +import net.minecraft.client.render.command.OrderedRenderCommandQueue; import net.minecraft.client.render.entity.feature.CapeFeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRendererContext; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.client.render.entity.state.PlayerEntityRenderState; -import net.minecraft.client.util.SkinTextures; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.player.SkinTextures; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -26,19 +29,21 @@ public abstract class CustomCapeFeatureRenderer extends FeatureRenderer instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, Operation original, @Local(argsOnly = true) PlayerEntityRenderState playerEntityRenderState, @Local SkinTextures skinTextures, @Local VertexConsumerProvider vertexConsumerProvider) { - CustomCapes.render( - playerEntityRenderState, - vertexConsumer, - RenderLayer.getEntitySolid(skinTextures.capeTexture()), - vertexConsumerProvider, - matrixStack, - updatedConsumer -> { - original.call(instance, matrixStack, updatedConsumer, light, overlay); - return Unit.INSTANCE; - }); + private void onRender(OrderedRenderCommandQueue instance, Model model, Object o, MatrixStack matrixStack, RenderLayer renderLayer, int light, int overlay, int outlineColor, ModelCommandRenderer.CrumblingOverlayCommand crumblingOverlayCommand, Operation original, + @Local(argsOnly = true) PlayerEntityRenderState playerEntityRenderState, @Local SkinTextures skinTextures) { + // TODO: 1.21.10 custom capes by pre rendering the texture id. this is more viable on this version i am fairly sure, without clogging up all of the cached image render layers +// CustomCapes.render( +// playerEntityRenderState, +// vertexConsumer, +// RenderLayer.getEntitySolid(skinTextures.cape().id()), +// vertexConsumerProvider, +// matrixStack, +// updatedConsumer -> { +// original.call(instance, matrixStack, updatedConsumer, light, overlay, outlineColor); +// return Unit.INSTANCE; +// }); } } diff --git a/src/main/kotlin/apis/UrsaManager.kt b/src/main/kotlin/apis/UrsaManager.kt index cee6904..e5d519e 100644 --- a/src/main/kotlin/apis/UrsaManager.kt +++ b/src/main/kotlin/apis/UrsaManager.kt @@ -48,7 +48,7 @@ object UrsaManager { withContext(Dispatchers.IO) { val mc = MinecraftClient.getInstance() val serverId = UUID.randomUUID().toString() - mc.sessionService.joinServer(mc.session.uuidOrNull, mc.session.accessToken, serverId) + mc.apiServices.sessionService.joinServer(mc.session.uuidOrNull, mc.session.accessToken, serverId) request.header("x-ursa-username", mc.session.username) request.header("x-ursa-serverid", serverId) } diff --git a/src/main/kotlin/events/FinalizeResourceManagerEvent.kt b/src/main/kotlin/events/FinalizeResourceManagerEvent.kt index 12167f8..df1c3eb 100644 --- a/src/main/kotlin/events/FinalizeResourceManagerEvent.kt +++ b/src/main/kotlin/events/FinalizeResourceManagerEvent.kt @@ -14,13 +14,13 @@ data class FinalizeResourceManagerEvent( inline fun registerOnApply(name: String, crossinline function: () -> Unit) { resourceManager.registerReloader(object : ResourceReloader { override fun reload( - synchronizer: ResourceReloader.Synchronizer, - manager: ResourceManager, + store: ResourceReloader.Store, prepareExecutor: Executor, + reloadSynchronizer: ResourceReloader.Synchronizer, applyExecutor: Executor ): CompletableFuture { return CompletableFuture.completedFuture(Unit) - .thenCompose(synchronizer::whenPrepared) + .thenCompose(reloadSynchronizer::whenPrepared) .thenAcceptAsync({ function() }, applyExecutor) } diff --git a/src/main/kotlin/features/debug/PowerUserTools.kt b/src/main/kotlin/features/debug/PowerUserTools.kt index a549f7e..fc36806 100644 --- a/src/main/kotlin/features/debug/PowerUserTools.kt +++ b/src/main/kotlin/features/debug/PowerUserTools.kt @@ -41,6 +41,7 @@ import moe.nea.firmament.util.mc.SNbtFormatter.Companion.toPrettyString import moe.nea.firmament.util.mc.displayNameAccordingToNbt import moe.nea.firmament.util.mc.iterableArmorItems import moe.nea.firmament.util.mc.loreAccordingToNbt +import moe.nea.firmament.util.mc.unsafeNbt import moe.nea.firmament.util.skyBlockId import moe.nea.firmament.util.tr @@ -166,7 +167,7 @@ object PowerUserTools { Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.modelid", model.toString())) } else if (it.matches(TConfig.copyNbtData)) { // TODO: copy full nbt - val nbt = item.get(DataComponentTypes.CUSTOM_DATA)?.nbt?.toPrettyString() ?: "" + val nbt = item.get(DataComponentTypes.CUSTOM_DATA)?.unsafeNbt?.toPrettyString() ?: "" ClipboardUtils.setTextContent(nbt) lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.nbt")) } else if (it.matches(TConfig.copyLoreData)) { diff --git a/src/main/kotlin/features/debug/SkinPreviews.kt b/src/main/kotlin/features/debug/SkinPreviews.kt index aff5c13..a853cd1 100644 --- a/src/main/kotlin/features/debug/SkinPreviews.kt +++ b/src/main/kotlin/features/debug/SkinPreviews.kt @@ -1,5 +1,6 @@ package moe.nea.firmament.features.debug +import com.mojang.authlib.GameProfile import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.put @@ -35,18 +36,7 @@ object SkinPreviews { return val entity = event.entity as? LivingEntity ?: return val stack = entity.getEquippedStack(EquipmentSlot.HEAD) ?: return - val profile = stack.get(DataComponentTypes.PROFILE) ?: return - if (!profile.isCompleted) { - lastDiscard = TimeMark.now() - animation.clear() - MC.sendChat( - tr( - "firmament.dev.skinpreviews.discarding", - "Encountered unloaded skin, discarding all previews skin frames." - ) - ) - return - } + val profile = stack.get(DataComponentTypes.PROFILE)?.gameProfile ?: return if (profile == animation.lastOrNull()) return animation.add(profile) val shortened = animation.shortenCycle() @@ -59,7 +49,7 @@ object SkinPreviews { put( "textures", shortened.map { - it.gameProfile().id.toString() + ":" + it.properties()["textures"].first().value() + it.id.toString() + ":" + it.properties()["textures"].first().value() }.toJsonArray() ) } @@ -74,7 +64,7 @@ object SkinPreviews { } } - var animation = mutableListOf() + var animation = mutableListOf() var pos = Vec3d(-1.0, 72.0, -101.25) var isRecording = false var skinColor: String? = null diff --git a/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt b/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt index 9356dd3..b3dc69a 100644 --- a/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt +++ b/src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt @@ -6,6 +6,7 @@ import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive import net.minecraft.client.network.AbstractClientPlayerEntity import net.minecraft.entity.decoration.ArmorStandEntity +import net.minecraft.util.AssetInfo import moe.nea.firmament.Firmament import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.HandledScreenKeyPressedEvent @@ -67,7 +68,7 @@ object ExportRecipe { val id = generateName(reply) ItemExporter.exportStub(id, "§9$reply") { val playerEntity = entity as? AbstractClientPlayerEntity - val textureUrl = playerEntity?.skinTextures?.textureUrl + val textureUrl = (playerEntity?.skin?.body as? AssetInfo.SkinAssetInfo)?.url if (textureUrl != null) it.setSkullOwner(playerEntity.uuid, textureUrl) } diff --git a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt index f06eb43..65f9fa1 100644 --- a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt +++ b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt @@ -291,12 +291,10 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) { fun copyLegacySkullNbt() { val profile = itemStack.get(DataComponentTypes.PROFILE) ?: return legacyNbt.put("SkullOwner", NbtCompound().apply { - profile.uuid.ifPresent { - putString("Id", it.toString()) - } + putString("Id", profile.gameProfile.id.toString()) putBoolean("hypixelPopulated", true) put("Properties", NbtCompound().apply { - profile.properties().forEach { prop, value -> + profile.gameProfile.properties().forEach { prop, value -> val list = getListOrEmpty(prop) put(prop, list) list.add(NbtCompound().apply { diff --git a/src/main/kotlin/features/inventory/SaveCursorPosition.kt b/src/main/kotlin/features/inventory/SaveCursorPosition.kt index 5a54aca..c523661 100644 --- a/src/main/kotlin/features/inventory/SaveCursorPosition.kt +++ b/src/main/kotlin/features/inventory/SaveCursorPosition.kt @@ -44,7 +44,7 @@ object SaveCursorPosition { (lastPosition.middle.second - middleY).absoluteValue < 1 ) { InputUtil.setCursorParameters( - MC.window.handle, + MC.window, InputUtil.GLFW_CURSOR_NORMAL, lastPosition.cursor.first, lastPosition.cursor.second diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt index 87edbe1..10c58cb 100644 --- a/src/main/kotlin/features/inventory/SlotLocking.kt +++ b/src/main/kotlin/features/inventory/SlotLocking.kt @@ -393,12 +393,12 @@ object SlotLocking { hotX + sx, hotY + sy, color(anyHovered) ) - event.context.drawBorder( + event.context.drawStrokedRectangle( hotbarSlot.x + sx, hotbarSlot.y + sy, 16, 16, color(hotbarSlot in highlitSlots).color ) - event.context.drawBorder( + event.context.drawStrokedRectangle( // TODO: 1.21.10 inventorySlot.x + sx, inventorySlot.y + sy, 16, 16, color(inventorySlot in highlitSlots).color @@ -416,7 +416,7 @@ object SlotLocking { val sx = accScreen.x_Firmament val sy = accScreen.y_Firmament val (borderX, borderY) = draggingSlot.lineCenter() - event.context.drawBorder(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) + event.context.drawStrokedRectangle(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) // TODO: 1.21.10 if (hoveredSlot == null) { event.context.drawLine( borderX + sx, borderY + sy, @@ -430,7 +430,7 @@ object SlotLocking { hovX + sx, hovY + sy, me.shedaniel.math.Color.ofOpaque(0x00FF00) ) - event.context.drawBorder( + event.context.drawStrokedRectangle( hoveredSlot.x + sx, hoveredSlot.y + sy, 16, 16, 0xFF00FF00u.toInt() diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt index ce074d8..d5d291c 100644 --- a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt +++ b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt @@ -9,9 +9,12 @@ import me.shedaniel.math.Point import me.shedaniel.math.Rectangle import org.lwjgl.glfw.GLFW import net.minecraft.client.MinecraftClient +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.widget.ButtonWidget +import net.minecraft.client.gui.widget.MultilineTextWidget import net.minecraft.client.gui.widget.TextWidget +import net.minecraft.client.input.KeyInput import net.minecraft.client.util.InputUtil import net.minecraft.text.Text import net.minecraft.util.math.MathHelper @@ -74,24 +77,20 @@ class InventoryButtonEditor( override fun init() { super.init() addDrawableChild( - TextWidget( + MultilineTextWidget( lastGuiRect.minX, 25, - lastGuiRect.width, - 9, Text.translatable("firmament.inventory-buttons.delete"), MC.font - ).alignCenter() + ).setCentered(true).setMaxWidth(lastGuiRect.width) ) addDrawableChild( - TextWidget( + MultilineTextWidget( lastGuiRect.minX, 40, - lastGuiRect.width, - 9, Text.translatable("firmament.inventory-buttons.info"), MC.font - ).alignCenter() + ).setCentered(true).setMaxWidth(lastGuiRect.width) ) addDrawableChild( ButtonWidget.builder(Text.translatable("firmament.inventory-buttons.reset")) { @@ -216,27 +215,27 @@ class InventoryButtonEditor( renderPopup(context, mouseX, mouseY, delta) } - override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { - if (super.keyPressed(keyCode, scanCode, modifiers)) return true - if (keyCode == GLFW.GLFW_KEY_ESCAPE) { + override fun keyPressed(input: KeyInput): Boolean { + if (super.keyPressed(input)) return true + if (input.keycode == GLFW.GLFW_KEY_ESCAPE) { close() return true } return false } - override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean { - if (super.mouseReleased(mouseX, mouseY, button)) return true - val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(mouseX, mouseY)) } + override fun mouseReleased(click: Click): Boolean { + if (super.mouseReleased(click)) return true + val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(click.x, click.y)) } if (clickedButton != null && !justPerformedAClickAction) { if (InputUtil.isKeyPressed( - MC.window.handle, + MC.window, InputUtil.GLFW_KEY_LEFT_CONTROL ) ) Editor(clickedButton).delete() else createPopup( MoulConfigUtils.loadGui("button_editor_fragment", Editor(clickedButton)), - Point(mouseX, mouseY) + Point(click.x, click.y) ) return true } @@ -245,14 +244,14 @@ class InventoryButtonEditor( return false } - override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean { - if (super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) return true + override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean { + if (super.mouseDragged(click, offsetX, offsetY)) return true - if (initialDragMousePosition.distanceSquared(Vec2f(mouseX.toFloat(), mouseY.toFloat())) >= 4 * 4) { + if (initialDragMousePosition.distanceSquared(Vec2f(click.x.toFloat(), click.y.toFloat())) >= 4 * 4) { initialDragMousePosition = Vec2f(-10F, -10F) lastDraggedButton?.let { dragging -> justPerformedAClickAction = true - val (anchorRight, anchorBottom, offsetX, offsetY) = getCoordsForMouse(mouseX.toInt(), mouseY.toInt()) + val (anchorRight, anchorBottom, offsetX, offsetY) = getCoordsForMouse(click.x.toInt(), click.y.toInt()) ?: return true dragging.x = offsetX dragging.y = offsetY @@ -287,7 +286,7 @@ class InventoryButtonEditor( val anchorBottom = my > lastGuiRect.maxY var offsetX = mx - if (anchorRight) lastGuiRect.maxX else lastGuiRect.minX var offsetY = my - if (anchorBottom) lastGuiRect.maxY else lastGuiRect.minY - if (InputUtil.isKeyPressed(MC.window.handle, InputUtil.GLFW_KEY_LEFT_SHIFT)) { + if (InputUtil.isKeyPressed(MC.window, InputUtil.GLFW_KEY_LEFT_SHIFT)) { offsetX = MathHelper.floor(offsetX / 20F) * 20 offsetY = MathHelper.floor(offsetY / 20F) * 20 } @@ -297,16 +296,16 @@ class InventoryButtonEditor( return anchoredCoords } - override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { - if (super.mouseClicked(mouseX, mouseY, button)) return true - val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(mouseX, mouseY)) } + override fun mouseClicked(click: Click, doubled: Boolean): Boolean { + if (super.mouseClicked(click, doubled)) return true + val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(click.x, click.y) } if (clickedButton != null) { lastDraggedButton = clickedButton - initialDragMousePosition = Vec2f(mouseX.toFloat(), mouseY.toFloat()) + initialDragMousePosition = Vec2f(click.y.toFloat(), click.y.toFloat()) return true } - val mx = mouseX.toInt() - val my = mouseY.toInt() + val mx = click.x.toInt() + val my = click.y.toInt() val (anchorRight, anchorBottom, offsetX, offsetY) = getCoordsForMouse(mx, my) ?: return true buttons.add(InventoryButton(offsetX, offsetY, anchorRight, anchorBottom, null, null)) justPerformedAClickAction = true diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt index e4d4e42..a4199c9 100644 --- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt +++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt @@ -3,8 +3,11 @@ package moe.nea.firmament.features.inventory.storageoverlay import me.shedaniel.math.Point import me.shedaniel.math.Rectangle import net.minecraft.client.MinecraftClient +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.GenericContainerScreen +import net.minecraft.client.input.CharInput +import net.minecraft.client.input.KeyInput import net.minecraft.entity.player.PlayerInventory import net.minecraft.screen.slot.Slot import moe.nea.firmament.mixins.accessor.AccessorHandledScreen @@ -60,39 +63,41 @@ class StorageOverlayCustom( return false } - override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean { - return overview.mouseReleased(mouseX, mouseY, button) + override fun mouseReleased(click: Click): Boolean { + return overview.mouseReleased(click) } - override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean { - return overview.mouseDragged(mouseX, mouseY, button, deltaX, deltaY) + override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean { + return overview.mouseDragged(click, offsetX, offsetY) } - override fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { - return overview.keyReleased(keyCode, scanCode, modifiers) + override fun keyReleased(input: KeyInput): Boolean { + return overview.keyReleased(input) } - override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { - return overview.keyPressed(keyCode, scanCode, modifiers) + override fun keyPressed(input: KeyInput): Boolean { + return overview.keyPressed(input) } - override fun charTyped(chr: Char, modifiers: Int): Boolean { - return overview.charTyped(chr, modifiers) + override fun charTyped(input: CharInput): Boolean { + return overview.charTyped(input) } - override fun mouseClick(mouseX: Double, mouseY: Double, button: Int): Boolean { - return overview.mouseClicked(mouseX, mouseY, button, (handler as? StorageBackingHandle.Page)?.storagePageSlot) + override fun mouseClick(click: Click, doubled: Boolean): Boolean { + return overview.mouseClicked(click, doubled, (handler as? StorageBackingHandle.Page)?.storagePageSlot) } override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { overview.drawBackgrounds(drawContext) - overview.drawPages(drawContext, - mouseX, - mouseY, - delta, - (handler as? StorageBackingHandle.Page)?.storagePageSlot, - screen.screenHandler.slots.take(screen.screenHandler.rows * 9).drop(9), - Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament)) + overview.drawPages( + drawContext, + mouseX, + mouseY, + delta, + (handler as? StorageBackingHandle.Page)?.storagePageSlot, + screen.screenHandler.slots.take(screen.screenHandler.rows * 9).drop(9), + Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament) + ) overview.drawScrollBar(drawContext) overview.drawControls(drawContext, mouseX, mouseY) } diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt index c7ca6e4..d2fff9c 100644 --- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt +++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt @@ -13,9 +13,12 @@ import io.github.notenoughupdates.moulconfig.observer.Property import java.util.TreeSet import me.shedaniel.math.Point import me.shedaniel.math.Rectangle +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.screen.ingame.HandledScreen +import net.minecraft.client.input.CharInput +import net.minecraft.client.input.KeyInput import net.minecraft.item.ItemStack import net.minecraft.screen.slot.Slot import net.minecraft.text.Text @@ -307,11 +310,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) { get() = guiContext.focusedElement == knobStub set(value) = knobStub.setFocus(value) - override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { - return mouseClicked(mouseX, mouseY, button, null) + override fun mouseClicked(click: Click, doubled: Boolean): Boolean { + return mouseClicked(click, doubled, null) } - override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean { + override fun mouseReleased(click: Click): Boolean { if (knobGrabbed) { knobGrabbed = false return true @@ -320,30 +323,32 @@ class StorageOverlayScreen : Screen(Text.literal("")) { controlComponent, measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, - mouseX.toInt(), mouseY.toInt(), - MouseEvent.Click(button, false) + click.x.toInt(), click.y.toInt(), + MouseEvent.Click(click.button(), false) ) ) return true - return super.mouseReleased(mouseX, mouseY, button) + return super.mouseReleased(click) } - override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean { + override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean { if (knobGrabbed) { val sbRect = getScrollBarRect() - val percentage = (mouseY - sbRect.getY()) / sbRect.getHeight() + val percentage = (click.x - sbRect.getY()) / sbRect.getHeight() scroll = (getMaxScroll() * percentage).toFloat() mouseScrolled(0.0, 0.0, 0.0, 0.0) return true } - return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY) + return super.mouseDragged(click, offsetX, offsetY) } - fun mouseClicked(mouseX: Double, mouseY: Double, button: Int, activePage: StoragePageSlot?): Boolean { + fun mouseClicked(click: Click, doubled: Boolean, activePage: StoragePageSlot?): Boolean { guiContext.setFocusedElement(null) // Blur all elements. They will be refocused by clickMCComponentInPlace if in doubt, and we don't have any double click components. + val mouseX = click.x + val mouseY = click.y if (getScrollPanelInner().contains(mouseX, mouseY)) { - val data = StorageOverlay.Data.data ?: StorageData() + val data = StorageOverlay.Data.data layoutedForEach(data) { rect, page, _ -> - if (rect.contains(mouseX, mouseY) && activePage != page && button == 0) { + if (rect.contains(mouseX, mouseY) && activePage != page && click.button() == 0) { page.navigateTo() return true } @@ -363,53 +368,53 @@ class StorageOverlayScreen : Screen(Text.literal("")) { measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, mouseX.toInt(), mouseY.toInt(), - MouseEvent.Click(button, true) + MouseEvent.Click(click.button(), true) ) ) return true return false } - override fun charTyped(chr: Char, modifiers: Int): Boolean { + override fun charTyped(input: CharInput): Boolean { if (typeMCComponentInPlace( controlComponent, measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, - KeyboardEvent.CharTyped(chr) + KeyboardEvent.CharTyped(input.asString().first()) // TODO: i dont like this .first() ) ) { return true } - return super.charTyped(chr, modifiers) + return super.charTyped(input) } - override fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { + override fun keyReleased(input: KeyInput): Boolean { if (typeMCComponentInPlace( controlComponent, measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, - KeyboardEvent.KeyPressed(keyCode, scanCode, false) + KeyboardEvent.KeyPressed(input.keycode, input.scancode, false) ) ) { return true } - return super.keyReleased(keyCode, scanCode, modifiers) + return super.keyReleased(input) } override fun shouldCloseOnEsc(): Boolean { return this === MC.screen // Fixes this UI closing the handled screen on Escape press. } - override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { + override fun keyPressed(input: KeyInput): Boolean { if (typeMCComponentInPlace( controlComponent, measurements.controlX, measurements.controlY, CONTROL_WIDTH, CONTROL_HEIGHT, - KeyboardEvent.KeyPressed(keyCode, scanCode, true) + KeyboardEvent.KeyPressed(input.keycode, input.scancode, true) ) ) { return true } - return super.keyPressed(keyCode, scanCode, modifiers) + return super.keyPressed(input) } @@ -506,7 +511,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) { val name = inventory.title val pageHeight = inv.rows * SLOT_SIZE + 8 + textRenderer.fontHeight if (slots != null && StorageOverlay.TConfig.outlineActiveStoragePage) - context.drawBorder( + context.drawStrokedRectangle( x, y + 3 + textRenderer.fontHeight, PAGE_WIDTH, diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt index 65d7e8c..a55b5ac 100644 --- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt +++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt @@ -5,8 +5,10 @@ package moe.nea.firmament.features.inventory.storageoverlay import org.lwjgl.glfw.GLFW import kotlin.math.max import net.minecraft.block.Blocks +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.Screen +import net.minecraft.client.input.KeyInput import net.minecraft.item.Item import net.minecraft.item.Items import net.minecraft.text.Text @@ -72,10 +74,10 @@ class StorageOverviewScreen() : Screen(Text.empty()) { lastRenderedHeight = totalHeight + currentMaxHeight } - override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { + override fun mouseClicked(click: Click, doubled: Boolean): Boolean { layoutedForEach { (k, p), x, y -> - val rx = mouseX - x - val ry = mouseY - y + val rx = click.x - x + val ry = click.y - y if (rx in (0.0..pageWidth.toDouble()) && ry in (0.0..getStorePageHeight(p).toDouble())) { close() StorageOverlay.lastStorageOverlay = this @@ -83,7 +85,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) { return true } } - return super.mouseClicked(mouseX, mouseY, button) + return super.mouseClicked(click, doubled) } fun getStorePageHeight(page: StorageData.StorageInventory): Int { @@ -127,9 +129,9 @@ class StorageOverviewScreen() : Screen(Text.empty()) { } } - override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { - if (keyCode == GLFW.GLFW_KEY_ESCAPE) + override fun keyPressed(input: KeyInput): Boolean { + if (input.keycode == GLFW.GLFW_KEY_ESCAPE) isClosing = true - return super.keyPressed(keyCode, scanCode, modifiers) + return super.keyPressed(input) } } diff --git a/src/main/kotlin/features/mining/HotmPresets.kt b/src/main/kotlin/features/mining/HotmPresets.kt index aa45d82..97c9a7c 100644 --- a/src/main/kotlin/features/mining/HotmPresets.kt +++ b/src/main/kotlin/features/mining/HotmPresets.kt @@ -4,6 +4,7 @@ import me.shedaniel.math.Rectangle import kotlinx.serialization.Serializable import kotlin.time.Duration.Companion.seconds import net.minecraft.block.Blocks +import net.minecraft.client.gui.Click import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.entity.player.PlayerInventory @@ -99,14 +100,14 @@ object HotmPresets { var hasScrolled = false var hasAll = false - override fun mouseClick(mouseX: Double, mouseY: Double, button: Int): Boolean { + override fun mouseClick(click: Click, doubled: Boolean): Boolean { if (!hasScrolled) { val slot = screen.screenHandler.getSlot(8) println("Clicking ${slot.stack}") slot.clickRightMouseButton(screen.screenHandler) } hasScrolled = true - return super.mouseClick(mouseX, mouseY, button) + return super.mouseClick(click, doubled) } override fun shouldDrawForeground(): Boolean { diff --git a/src/main/kotlin/features/misc/CustomCapes.kt b/src/main/kotlin/features/misc/CustomCapes.kt index 086f2fb..d66e6a3 100644 --- a/src/main/kotlin/features/misc/CustomCapes.kt +++ b/src/main/kotlin/features/misc/CustomCapes.kt @@ -8,8 +8,9 @@ import net.minecraft.client.render.RenderLayer import net.minecraft.client.render.VertexConsumer import net.minecraft.client.render.VertexConsumerProvider import net.minecraft.client.render.entity.state.PlayerEntityRenderState -import net.minecraft.client.util.SkinTextures import net.minecraft.client.util.math.MatrixStack +import net.minecraft.entity.player.SkinTextures +import net.minecraft.util.AssetInfo import net.minecraft.util.Identifier import moe.nea.firmament.Firmament import moe.nea.firmament.util.MC @@ -143,29 +144,12 @@ object CustomCapes { Devs.FurfSky.all.map { it to AllCapes.FURFSKY_STATIC }, ).flatten().flatMap { (dev, cape) -> dev.uuids.map { it to cape.cape } }.toMap() - @JvmStatic - fun render( - playerEntityRenderState: PlayerEntityRenderState, - vertexConsumer: VertexConsumer, - renderLayer: RenderLayer, - vertexConsumerProvider: VertexConsumerProvider, - matrixStack: MatrixStack, - model: (VertexConsumer) -> Unit - ) { - val capeStorage = CapeStorage.cast(playerEntityRenderState) - val firmCape = capeStorage.cape_firmament - if (firmCape != null) { - firmCape.render.replaceRender(renderLayer, vertexConsumerProvider, matrixStack, model) - } else { - model(vertexConsumer) - } - } - @JvmStatic fun addCapeData( player: AbstractClientPlayerEntity, playerEntityRenderState: PlayerEntityRenderState ) { + if (true) return // TODO: see capefeaturerenderer mixin val cape = if (TConfig.showCapes) byUuid[player.uuid] else null val capeStorage = CapeStorage.cast(playerEntityRenderState) if (cape == null) { @@ -173,10 +157,9 @@ object CustomCapes { } else { capeStorage.cape_firmament = cape playerEntityRenderState.skinTextures = SkinTextures( - playerEntityRenderState.skinTextures.texture, - playerEntityRenderState.skinTextures.textureUrl, - Firmament.identifier("placeholder/fake_cape"), - playerEntityRenderState.skinTextures.elytraTexture, + playerEntityRenderState.skinTextures.body, + AssetInfo.TextureAssetInfo(Firmament.identifier("placeholder/fake_cape"), Firmament.identifier("placeholder/fake_cape")), + playerEntityRenderState.skinTextures.elytra, playerEntityRenderState.skinTextures.model, playerEntityRenderState.skinTextures.secure, ) diff --git a/src/main/kotlin/features/world/TemporaryWaypoints.kt b/src/main/kotlin/features/world/TemporaryWaypoints.kt index f5653ad..14a9f74 100644 --- a/src/main/kotlin/features/world/TemporaryWaypoints.kt +++ b/src/main/kotlin/features/world/TemporaryWaypoints.kt @@ -41,20 +41,20 @@ object TemporaryWaypoints { } temporaryPlayerWaypointList.forEach { (player, waypoint) -> val skin = - MC.networkHandler?.listedPlayerListEntries?.find { it.profile.name == player }?.skinTextures?.texture + MC.networkHandler?.listedPlayerListEntries?.find { it.profile.name == player }?.skinTextures?.body withFacingThePlayer(waypoint.pos.toCenterPos()) { waypoint(waypoint.pos, Text.stringifiedTranslatable("firmament.waypoint.temporary", player)) if (skin != null) { matrixStack.translate(0F, -20F, 0F) // Head front texture( - skin, 16, 16, + skin.id(), 16, 16, // TODO: 1.21.10 test 1 / 8f, 1 / 8f, 2 / 8f, 2 / 8f, ) // Head overlay texture( - skin, 16, 16, + skin.id(), 16, 16, // TODO: 1.21.10 5 / 8f, 1 / 8f, 6 / 8f, 2 / 8f, ) diff --git a/src/main/kotlin/gui/entity/GuiPlayer.kt b/src/main/kotlin/gui/entity/GuiPlayer.kt index e7f2e45..2598de6 100644 --- a/src/main/kotlin/gui/entity/GuiPlayer.kt +++ b/src/main/kotlin/gui/entity/GuiPlayer.kt @@ -1,56 +1,28 @@ package moe.nea.firmament.gui.entity -import com.mojang.authlib.GameProfile -import java.util.UUID -import net.minecraft.client.network.AbstractClientPlayerEntity +import net.minecraft.client.network.ClientMannequinEntity import net.minecraft.client.util.DefaultSkinHelper -import net.minecraft.client.util.SkinTextures -import net.minecraft.client.util.SkinTextures.Model import net.minecraft.client.world.ClientWorld -import net.minecraft.util.Identifier -import net.minecraft.util.math.Vec3d +import net.minecraft.entity.player.SkinTextures import net.minecraft.world.World +import moe.nea.firmament.util.MC -/** - * @see moe.nea.firmament.init.EarlyRiser - */ fun makeGuiPlayer(world: World): GuiPlayer { - val constructor = GuiPlayer::class.java.getDeclaredConstructor(ClientWorld::class.java, GameProfile::class.java) - val player = constructor.newInstance(world, GameProfile(UUID.randomUUID(), "Linnea")) - player.postInit() + val player = GuiPlayer(MC.instance.world!!) return player } -class GuiPlayer(world: ClientWorld?, profile: GameProfile?) : AbstractClientPlayerEntity(world, profile) { +class GuiPlayer(world: ClientWorld?) : ClientMannequinEntity(world, MC.instance.playerSkinCache) { override fun isSpectator(): Boolean { return false } - fun postInit() { - skinTexture = DefaultSkinHelper.getSkinTextures(this.getUuid()).texture - lastVelocity = Vec3d.ZERO - model = Model.WIDE - } - - override fun isCreative(): Boolean { - return false - } - override fun shouldRenderName(): Boolean { return false } - lateinit var skinTexture: Identifier - var capeTexture: Identifier? = null - var model: Model = Model.WIDE - override fun getSkinTextures(): SkinTextures { - return SkinTextures( - skinTexture, - null, - capeTexture, - null, - model, - true - ) + var skinTextures: SkinTextures = DefaultSkinHelper.getSkinTextures(this.getUuid()) // TODO: 1.21.10 + override fun getSkin(): SkinTextures { + return skinTextures } } diff --git a/src/main/kotlin/gui/entity/ModifyPlayerSkin.kt b/src/main/kotlin/gui/entity/ModifyPlayerSkin.kt index 28f0070..48cd855 100644 --- a/src/main/kotlin/gui/entity/ModifyPlayerSkin.kt +++ b/src/main/kotlin/gui/entity/ModifyPlayerSkin.kt @@ -1,47 +1,57 @@ - package moe.nea.firmament.gui.entity import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import kotlin.experimental.and import kotlin.experimental.or -import net.minecraft.client.util.SkinTextures +import net.minecraft.client.network.ClientPlayerLikeEntity import net.minecraft.entity.LivingEntity +import net.minecraft.entity.PlayerLikeEntity import net.minecraft.entity.player.PlayerEntity import net.minecraft.entity.player.PlayerModelPart +import net.minecraft.entity.player.PlayerSkinType +import net.minecraft.entity.player.SkinTextures +import net.minecraft.util.AssetInfo import net.minecraft.util.Identifier object ModifyPlayerSkin : EntityModifier { - val playerModelPartIndex = PlayerModelPart.entries.associateBy { it.getName() } - override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity { - require(entity is GuiPlayer) - info["cape"]?.let { - entity.capeTexture = Identifier.of(it.asString) - } - info["skin"]?.let { - entity.skinTexture = Identifier.of(it.asString) - } - info["slim"]?.let { - entity.model = if (it.asBoolean) SkinTextures.Model.SLIM else SkinTextures.Model.WIDE - } - info["parts"]?.let { - var trackedData = entity.dataTracker.get(PlayerEntity.PLAYER_MODEL_PARTS) - if (it is JsonPrimitive && it.isBoolean) { - trackedData = (if (it.asBoolean) -1 else 0).toByte() - } else { - val obj = it.asJsonObject - for ((k, v) in obj.entrySet()) { - val part = playerModelPartIndex[k]!! - trackedData = if (v.asBoolean) { - trackedData and (part.bitFlag.inv().toByte()) - } else { - trackedData or (part.bitFlag.toByte()) - } - } - } - entity.dataTracker.set(PlayerEntity.PLAYER_MODEL_PARTS, trackedData) - } - return entity - } + val playerModelPartIndex = PlayerModelPart.entries.associateBy { it.getName() } + override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity { + require(entity is GuiPlayer) + var capeTexture = entity.skinTextures.cape + var model = entity.skinTextures.model + var bodyTexture = entity.skinTextures.body + fun mkTexAsset(id: Identifier) = AssetInfo.TextureAssetInfo(id, id) + info["cape"]?.let { + capeTexture = mkTexAsset(Identifier.of(it.asString)) + } + info["skin"]?.let { + bodyTexture = mkTexAsset(Identifier.of(it.asString)) + } + info["slim"]?.let { + model = if (it.asBoolean) PlayerSkinType.SLIM else PlayerSkinType.WIDE + } + info["parts"]?.let { + var trackedData = entity.dataTracker.get(PlayerLikeEntity.PLAYER_MODE_CUSTOMIZATION_ID) + if (it is JsonPrimitive && it.isBoolean) { + trackedData = (if (it.asBoolean) -1 else 0).toByte() + } else { + val obj = it.asJsonObject + for ((k, v) in obj.entrySet()) { + val part = playerModelPartIndex[k]!! + trackedData = if (v.asBoolean) { + trackedData and (part.bitFlag.inv().toByte()) + } else { + trackedData or (part.bitFlag.toByte()) + } + } + } + entity.dataTracker.set(PlayerEntity.PLAYER_MODE_CUSTOMIZATION_ID, trackedData) + } + entity.skinTextures = SkinTextures( + bodyTexture, capeTexture, null, model, true + ) + return entity + } } diff --git a/src/main/kotlin/gui/entity/ModifyRiding.kt b/src/main/kotlin/gui/entity/ModifyRiding.kt index 5c4c78d..d482b37 100644 --- a/src/main/kotlin/gui/entity/ModifyRiding.kt +++ b/src/main/kotlin/gui/entity/ModifyRiding.kt @@ -8,7 +8,7 @@ object ModifyRiding : EntityModifier { override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity { val newEntity = EntityRenderer.constructEntity(info) require(newEntity != null) - newEntity.startRiding(entity, true) + newEntity.startRiding(entity, true, false) return entity } diff --git a/src/main/kotlin/keybindings/FirmamentKeyBindings.kt b/src/main/kotlin/keybindings/FirmamentKeyBindings.kt index 59b131a..fe87eff 100644 --- a/src/main/kotlin/keybindings/FirmamentKeyBindings.kt +++ b/src/main/kotlin/keybindings/FirmamentKeyBindings.kt @@ -3,16 +3,18 @@ package moe.nea.firmament.keybindings import net.fabricmc.fabric.ap