aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/moe/nea/firmament/init/ClientPlayerRiser.java75
-rw-r--r--src/main/java/moe/nea/firmament/init/EarlyRiser.java1
-rw-r--r--src/main/java/moe/nea/firmament/init/HandledScreenRiser.java52
-rw-r--r--src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java1
-rw-r--r--src/main/java/moe/nea/firmament/mixins/accessor/AccessorNbtComponent.java12
-rw-r--r--src/main/java/moe/nea/firmament/mixins/customgui/PatchHandledScreen.java40
-rw-r--r--src/main/java/moe/nea/firmament/mixins/feature/devcosmetics/CustomCapeFeatureRenderer.java33
-rw-r--r--src/main/kotlin/apis/UrsaManager.kt2
-rw-r--r--src/main/kotlin/events/FinalizeResourceManagerEvent.kt6
-rw-r--r--src/main/kotlin/features/debug/PowerUserTools.kt3
-rw-r--r--src/main/kotlin/features/debug/SkinPreviews.kt18
-rw-r--r--src/main/kotlin/features/debug/itemeditor/ExportRecipe.kt3
-rw-r--r--src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt6
-rw-r--r--src/main/kotlin/features/inventory/SaveCursorPosition.kt2
-rw-r--r--src/main/kotlin/features/inventory/SlotLocking.kt8
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt53
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt43
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt51
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt16
-rw-r--r--src/main/kotlin/features/mining/HotmPresets.kt5
-rw-r--r--src/main/kotlin/features/misc/CustomCapes.kt29
-rw-r--r--src/main/kotlin/features/world/TemporaryWaypoints.kt6
-rw-r--r--src/main/kotlin/gui/entity/GuiPlayer.kt44
-rw-r--r--src/main/kotlin/gui/entity/ModifyPlayerSkin.kt76
-rw-r--r--src/main/kotlin/gui/entity/ModifyRiding.kt2
-rw-r--r--src/main/kotlin/keybindings/FirmamentKeyBindings.kt4
-rw-r--r--src/main/kotlin/keybindings/GenericInputButton.kt16
-rw-r--r--src/main/kotlin/repo/RepoModResourcePack.kt5
-rw-r--r--src/main/kotlin/util/FragmentGuiScreen.kt31
-rw-r--r--src/main/kotlin/util/MC.kt1
-rw-r--r--src/main/kotlin/util/ScoreboardUtil.kt2
-rw-r--r--src/main/kotlin/util/SkyblockId.kt3
-rw-r--r--src/main/kotlin/util/customgui/CustomGui.kt15
-rw-r--r--src/main/kotlin/util/mc/CustomRenderPassHelper.kt3
-rw-r--r--src/main/kotlin/util/mc/NbtUtil.kt5
-rw-r--r--src/main/kotlin/util/mc/SkullItemData.kt4
-rw-r--r--src/main/resources/firmament.accesswidener8
37 files changed, 315 insertions, 369 deletions
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, "<init>") && Type.getMethodType(method.desc).equals(constructorDescriptor)) {
- modifyConstructor(method, superClass);
- return;
- }
- }
- var node = new MethodNode(Opcodes.ASM9, "<init>", 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(), "<init>", 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.<Element>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.<Element>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.<Element>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<InsnList> insertLoads,
- Consumer<InsnList> insertInvoke) {
+ Consumer<InsnList> insertLoads,
+ Consumer<InsnList> 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<T extends ScreenHandler> 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<T extends ScreenHandler> 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<Boolean> cir) {
+ public void onIsClickOutsideBounds(
+ double mouseX, double mouseY, int left, int top,
+ CallbackInfoReturnable<Boolean> cir) {
if (override != null) {
cir.setReturnValue(override.isClickOutsideBounds(mouseX, mouseY));
}
@@ -176,28 +181,27 @@ public class PatchHandledScreen<T extends ScreenHandler> 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<Boolean> 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<Boolean> 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<Boolean> cir) {
+ public void overrideMouseDrags(Click click, double offsetX, double offsetY, CallbackInfoReturnable<Boolean> 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<Boolean> cir) {
+ private void overrideKeyPressed(KeyInput input, CallbackInfoReturnable<Boolean> cir) {
if (override != null) {
- if (override.keyPressed(keyCode, scanCode, modifiers)) {
+ if (override.keyPressed(input)) {
cir.setReturnValue(true);
}
}
@@ -207,9 +211,9 @@ public class PatchHandledScreen<T extends ScreenHandler> extends Screen implemen
@Inject(
method = "mouseReleased",
at = @At("HEAD"), cancellable = true)
- public void overrideMouseReleases(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {
+ public void overrideMouseReleases(Click click, CallbackInfoReturnable<Boolean> 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<PlayerEn
}
@WrapOperation(
- method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/PlayerEntityRenderState;FF)V",
- at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;II)V")
+ method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/client/render/entity/state/PlayerEntityRenderState;FF)V",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/RenderLayer;IIILnet/minecraft/client/render/command/ModelCommandRenderer$CrumblingOverlayCommand;)V")
)
- private void onRender(BipedEntityModel<PlayerEntityRenderState> instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, Operation<Void> 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<Void> 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<Void> {
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() ?: "<empty>"
+ val nbt = item.get(DataComponentTypes.CUSTOM_DATA)?.unsafeNbt?.toPrettyString() ?: "<empty>"
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<ProfileComponent>()
+ var animation = mutableListOf<GameProfile>()
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
@@ -144,28 +145,11 @@ object CustomCapes {
).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.api.client.keybinding.v1.KeyBindingHelper
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil
+import moe.nea.firmament.Firmament
import moe.nea.firmament.gui.config.ManagedOption
import moe.nea.firmament.util.TestUtil
object FirmamentKeyBindings {
+ val cat = KeyBinding.Category(Firmament.identifier("category"))
fun registerKeyBinding(name: String, config: ManagedOption<SavedKeyBinding>) {
val vanillaKeyBinding = KeyBinding(
name,
InputUtil.Type.KEYSYM,
-1,
- "firmament.key.category"
+ cat
)
if (!TestUtil.isInTest) {
KeyBindingHelper.registerKeyBinding(vanillaKeyBinding)
diff --git a/src/main/kotlin/keybindings/GenericInputButton.kt b/src/main/kotlin/keybindings/GenericInputButton.kt
index ddbf509..39bb4dd 100644
--- a/src/main/kotlin/keybindings/GenericInputButton.kt
+++ b/src/main/kotlin/keybindings/GenericInputButton.kt
@@ -14,7 +14,9 @@ import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.int
import kotlinx.serialization.json.put
import net.minecraft.client.MinecraftClient
+import net.minecraft.client.input.KeyInput
import net.minecraft.client.util.InputUtil
+import net.minecraft.client.util.MacWindowUtil
import net.minecraft.text.Text
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.mc.InitLevel
@@ -107,7 +109,7 @@ sealed interface GenericInputButton {
}
override fun isPressed(): Boolean {
- return InputUtil.isKeyPressed(MC.window.handle, keyCode)
+ return InputUtil.isKeyPressed(MC.window, keyCode)
}
override fun isCtrl(): Boolean {
@@ -188,6 +190,9 @@ sealed interface GenericInputAction {
fun mouse(mouseButton: Int): GenericInputAction = MouseInput(mouseButton)
@JvmStatic
+ fun of(input: KeyInput): GenericInputAction = key(input.keycode, input.scancode)
+
+ @JvmStatic
fun key(keyCode: Int, scanCode: Int): GenericInputAction = KeyboardInput(keyCode, scanCode)
}
}
@@ -199,8 +204,8 @@ data class InputModifiers(
companion object {
@JvmStatic
fun current(): InputModifiers {
- val h = MC.window.handle
- val ctrl = if (MinecraftClient.IS_SYSTEM_MAC) {
+ val h = MC.window
+ val ctrl = if (MacWindowUtil.IS_MAC) {
InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_SUPER)
|| InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SUPER)
} else InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_CONTROL)
@@ -223,7 +228,7 @@ data class InputModifiers(
val superKeys = listOf(GLFW.GLFW_KEY_LEFT_SUPER, GLFW.GLFW_KEY_RIGHT_SUPER)
- val controlKeys = if (MinecraftClient.IS_SYSTEM_MAC) {
+ val controlKeys = if (MacWindowUtil.IS_MAC) {
listOf(GLFW.GLFW_KEY_LEFT_SUPER, GLFW.GLFW_KEY_RIGHT_SUPER)
} else {
listOf(GLFW.GLFW_KEY_LEFT_CONTROL, GLFW.GLFW_KEY_RIGHT_CONTROL)
@@ -265,6 +270,9 @@ data class InputModifiers(
@JvmStatic
fun of(modifiers: Int) = InputModifiers(modifiers)
+ @JvmStatic
+ fun of(input: KeyInput) = InputModifiers(input.modifiers)
+
fun none(): InputModifiers {
return InputModifiers(0)
}
diff --git a/src/main/kotlin/repo/RepoModResourcePack.kt b/src/main/kotlin/repo/RepoModResourcePack.kt
index 6c06a67..8b201af 100644
--- a/src/main/kotlin/repo/RepoModResourcePack.kt
+++ b/src/main/kotlin/repo/RepoModResourcePack.kt
@@ -91,7 +91,8 @@ class RepoModResourcePack(val basePath: Path) : ModResourcePack {
.forEach {
consumer.accept(
Identifier.tryParse("neurepo", it.toString()) ?: return@forEach,
- InputSupplier.create(it))
+ InputSupplier.create(it)
+ )
}
}
@@ -109,7 +110,7 @@ class RepoModResourcePack(val basePath: Path) : ModResourcePack {
"description": "NEU Repo Resources"
}
}
-""".trimIndent().byteInputStream()
+""".trimIndent().byteInputStream(), info
)
}
diff --git a/src/main/kotlin/util/FragmentGuiScreen.kt b/src/main/kotlin/util/FragmentGuiScreen.kt
index de53ac0..74558a0 100644
--- a/src/main/kotlin/util/FragmentGuiScreen.kt
+++ b/src/main/kotlin/util/FragmentGuiScreen.kt
@@ -6,8 +6,11 @@ import io.github.notenoughupdates.moulconfig.gui.GuiContext
import me.shedaniel.math.Dimension
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.input.CharInput
+import net.minecraft.client.input.KeyInput
import net.minecraft.text.Text
abstract class FragmentGuiScreen(
@@ -29,15 +32,15 @@ abstract class FragmentGuiScreen(
return true
}
- override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ override fun keyPressed(input: KeyInput): Boolean {
return ifPopup {
- it.keyPressed(keyCode, scanCode, modifiers)
+ it.keyPressed(input)
}
}
- override fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ override fun keyReleased(input: KeyInput): Boolean {
return ifPopup {
- it.keyReleased(keyCode, scanCode, modifiers)
+ it.keyReleased(input)
}
}
@@ -45,35 +48,35 @@ abstract class FragmentGuiScreen(
ifPopup { it.mouseMoved(mouseX, mouseY) }
}
- override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ override fun mouseReleased(click: Click): Boolean {
return ifPopup {
- it.mouseReleased(mouseX, mouseY, button)
+ it.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 {
return ifPopup {
- it.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
+ it.mouseDragged(click, offsetX, offsetY)
}
}
- override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
return ifPopup {
if (!Rectangle(
it.position,
Dimension(it.guiContext.root.width, it.guiContext.root.height)
- ).contains(Point(mouseX, mouseY))
+ ).contains(Point(click.x, click.y))
&& dismissOnOutOfBounds
) {
popup = null
} else {
- it.mouseClicked(mouseX, mouseY, button)
+ it.mouseClicked(click, doubled)
}
- }|| super.mouseClicked(mouseX, mouseY, button)
+ }|| super.mouseClicked(click, doubled)
}
- override fun charTyped(chr: Char, modifiers: Int): Boolean {
- return ifPopup { it.charTyped(chr, modifiers) }
+ override fun charTyped(input: CharInput): Boolean {
+ return ifPopup { it.charTyped(input) }
}
override fun mouseScrolled(
diff --git a/src/main/kotlin/util/MC.kt b/src/main/kotlin/util/MC.kt
index d60e19c..9f3fe99 100644
--- a/src/main/kotlin/util/MC.kt
+++ b/src/main/kotlin/util/MC.kt
@@ -114,7 +114,6 @@ object MC {
inline val player: ClientPlayerEntity? get() = TestUtil.unlessTesting { instance.player }
inline val camera: Entity? get() = instance.cameraEntity
inline val stackInHand: ItemStack get() = player?.mainHandStack ?: ItemStack.EMPTY
- inline val guiAtlasManager get() = instance.guiAtlasManager
inline val world: ClientWorld? get() = TestUtil.unlessTesting { instance.world }
inline val playerName: String get() = player?.name?.unformattedString ?: MC.instance.session.username
inline var screen: Screen?
diff --git a/src/main/kotlin/util/ScoreboardUtil.kt b/src/main/kotlin/util/ScoreboardUtil.kt
index 0970892..f5f28b9 100644
--- a/src/main/kotlin/util/ScoreboardUtil.kt
+++ b/src/main/kotlin/util/ScoreboardUtil.kt
@@ -22,7 +22,7 @@ object ScoreboardUtil {
}
private fun getScoreboardLinesUncached(): List<Text> {
- val scoreboard = MC.player?.scoreboard ?: return listOf()
+ val scoreboard = MC.instance.world?.scoreboard ?: return listOf()
val activeObjective = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.SIDEBAR) ?: return listOf()
return scoreboard.getScoreboardEntries(activeObjective)
.filter { !it.hidden() }
diff --git a/src/main/kotlin/util/SkyblockId.kt b/src/main/kotlin/util/SkyblockId.kt
index 7e39a75..8fd32c7 100644
--- a/src/main/kotlin/util/SkyblockId.kt
+++ b/src/main/kotlin/util/SkyblockId.kt
@@ -36,6 +36,7 @@ import moe.nea.firmament.util.collections.WeakCache
import moe.nea.firmament.util.json.DashlessUUIDSerializer
import moe.nea.firmament.util.mc.displayNameAccordingToNbt
import moe.nea.firmament.util.mc.loreAccordingToNbt
+import moe.nea.firmament.util.mc.unsafeNbt
import moe.nea.firmament.util.skyblock.ScreenIdentification
import moe.nea.firmament.util.skyblock.ScreenType
@@ -137,7 +138,7 @@ var ItemStack.extraAttributes: NbtCompound
set(DataComponentTypes.CUSTOM_DATA, component)
component
}
- return customData.nbt
+ return customData.unsafeNbt
}
fun ItemStack.modifyExtraAttributes(block: (NbtCompound) -> Unit) {
diff --git a/src/main/kotlin/util/customgui/CustomGui.kt b/src/main/kotlin/util/customgui/CustomGui.kt
index 35c60ac..457632b 100644
--- a/src/main/kotlin/util/customgui/CustomGui.kt
+++ b/src/main/kotlin/util/customgui/CustomGui.kt
@@ -1,7 +1,10 @@
package moe.nea.firmament.util.customgui
import me.shedaniel.math.Rectangle
+import net.minecraft.client.gui.Click
import net.minecraft.client.gui.DrawContext
+import net.minecraft.client.input.CharInput
+import net.minecraft.client.input.KeyInput
import net.minecraft.screen.slot.Slot
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenPushREIEvent
@@ -30,7 +33,7 @@ abstract class CustomGui {
) {
}
- open fun mouseClick(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ open fun mouseClick(click: Click, doubled: Boolean): Boolean {
return false
}
@@ -69,23 +72,23 @@ abstract class CustomGui {
return true
}
- open fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ open fun mouseReleased(click: Click): Boolean {
return false
}
- open fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean {
+ open fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
return false
}
- open fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ open fun keyPressed(input: KeyInput): Boolean {
return false
}
- open fun charTyped(chr: Char, modifiers: Int): Boolean {
+ open fun charTyped(input: CharInput): Boolean {
return false
}
- open fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ open fun keyReleased(input: KeyInput): Boolean {
return false
}
}
diff --git a/src/main/kotlin/util/mc/CustomRenderPassHelper.kt b/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
index 295f727..67fb2f8 100644
--- a/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
+++ b/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
@@ -11,6 +11,7 @@ import java.nio.ByteBuffer
import java.nio.ByteOrder
import java.util.OptionalDouble
import java.util.OptionalInt
+import org.joml.Vector3f
import org.joml.Vector4f
import net.minecraft.client.gl.Framebuffer
import net.minecraft.client.render.BufferBuilder
@@ -67,7 +68,7 @@ class CustomRenderPassHelper(
.write(
RenderSystem.getModelViewMatrix(),
Vector4f(1.0F, 1.0F, 1.0F, 1.0F),
- RenderSystem.getModelOffset(),
+ Vector3f(), // TODO: 1.21.10
RenderSystem.getTextureMatrix(),
RenderSystem.getShaderLineWidth()
)
diff --git a/src/main/kotlin/util/mc/NbtUtil.kt b/src/main/kotlin/util/mc/NbtUtil.kt
index 2cab1c7..5c47c28 100644
--- a/src/main/kotlin/util/mc/NbtUtil.kt
+++ b/src/main/kotlin/util/mc/NbtUtil.kt
@@ -1,10 +1,15 @@
package moe.nea.firmament.util.mc
+import net.minecraft.component.type.NbtComponent
import net.minecraft.nbt.NbtElement
import net.minecraft.nbt.NbtList
+import moe.nea.firmament.mixins.accessor.AccessorNbtComponent
fun Iterable<NbtElement>.toNbtList() = NbtList().also {
for (element in this) {
it.add(element)
}
}
+
+@Suppress("CAST_NEVER_SUCCEEDS")
+val NbtComponent.unsafeNbt get() = (this as AccessorNbtComponent).unsafeNbt_firmament
diff --git a/src/main/kotlin/util/mc/SkullItemData.kt b/src/main/kotlin/util/mc/SkullItemData.kt
index 3a4c508..6f8f24b 100644
--- a/src/main/kotlin/util/mc/SkullItemData.kt
+++ b/src/main/kotlin/util/mc/SkullItemData.kt
@@ -46,7 +46,7 @@ fun ItemStack.setEncodedSkullOwner(uuid: UUID, encodedData: String) {
assert(this.item == Items.PLAYER_HEAD)
val gameProfile = GameProfile(uuid, "LameGuy123")
gameProfile.properties.put(propertyTextures, Property(propertyTextures, encodedData.padToValidBase64()))
- this.set(DataComponentTypes.PROFILE, ProfileComponent(gameProfile))
+ this.set(DataComponentTypes.PROFILE, ProfileComponent.ofStatic(gameProfile))
}
val arbitraryUUID = UUID.fromString("d3cb85e2-3075-48a1-b213-a9bfb62360c1")
@@ -63,7 +63,7 @@ fun ItemStack.setSkullOwner(uuid: UUID, url: String) {
profileName = "nea89",
)
)
- this.set(DataComponentTypes.PROFILE, ProfileComponent(gameProfile))
+ this.set(DataComponentTypes.PROFILE, ProfileComponent.ofStatic(gameProfile))
}
diff --git a/src/main/resources/firmament.accesswidener b/src/main/resources/firmament.accesswidener
index af71627..2bc3a9a 100644
--- a/src/main/resources/firmament.accesswidener
+++ b/src/main/resources/firmament.accesswidener
@@ -26,7 +26,7 @@ accessible method net/minecraft/client/render/model/BlockStatesLoader combine (L
mutable field net/minecraft/screen/slot/Slot x I
mutable field net/minecraft/screen/slot/Slot y I
-accessible field net/minecraft/entity/player/PlayerEntity PLAYER_MODEL_PARTS Lnet/minecraft/entity/data/TrackedData;
+#accessible field net/minecraft/entity/player/PlayerEntity PLAYER_MODEL_PARTS Lnet/minecraft/entity/data/TrackedData;
accessible field net/minecraft/client/render/WorldRenderer chunks Lnet/minecraft/client/render/BuiltChunkStorage;
accessible field net/minecraft/client/render/OverlayTexture texture Lnet/minecraft/client/texture/NativeImageBackedTexture;
@@ -37,3 +37,9 @@ accessible field net/minecraft/client/network/ClientPlayerInteractionManager cur
accessible field net/minecraft/client/render/RenderLayer$MultiPhase pipeline Lcom/mojang/blaze3d/pipeline/RenderPipeline;
mutable field net/minecraft/client/render/entity/state/LivingEntityRenderState headItemRenderState Lnet/minecraft/client/render/item/ItemRenderState;
+
+accessible field net/minecraft/entity/Entity world Lnet/minecraft/world/World;
+accessible field net/minecraft/client/MinecraftClient userApiService Lcom/mojang/authlib/minecraft/UserApiService;
+accessible field net/minecraft/entity/Entity pos Lnet/minecraft/util/math/Vec3d;
+accessible method net/minecraft/component/type/ProfileComponent get ()Lcom/mojang/datafixers/util/Either;
+accessible field net/minecraft/entity/PlayerLikeEntity PLAYER_MODE_CUSTOMIZATION_ID Lnet/minecraft/entity/data/TrackedData;