From ad490f2ea7967cb6bb97cb797b33aa3554de46a5 Mon Sep 17 00:00:00 2001 From: nea Date: Sat, 28 Oct 2023 04:07:47 +0200 Subject: Rename mixins after what they do, rather than where they do it [no changelog] Mixins are now named after what they do, and mixins for the same class that do different things should be in two separate mixins now. --- .../mixins/CaseInsensitiveCommandMapPatch.java | 29 +++++++++++ .../moe/nea/firmament/mixins/ChatPeekingPatch.java | 28 ++++++++++ .../firmament/mixins/CustomModelBakerPatch.java | 50 ++++++++++++++++++ .../firmament/mixins/CustomModelEventPatch.java | 33 ++++++++++++ .../firmament/mixins/CustomSkullTexturePatch.java | 25 +++++++++ .../nea/firmament/mixins/DFUEntityIdFixPatch.java | 38 ++++++++++++++ .../mixins/FirmKeybindsInVanillaControlsPatch.java | 59 ++++++++++++++++++++++ .../moe/nea/firmament/mixins/HudRenderEvents.java | 32 ++++++++++++ .../mixins/IncomingPacketListenerPatches.java | 44 ++++++++++++++++ .../mixins/KeyPressInWorldEventPatch.java | 23 +++++++++ .../moe/nea/firmament/mixins/MixinChatHud.java | 28 ---------- .../mixins/MixinClientCommonNetworkHandler.java | 25 --------- .../firmament/mixins/MixinClientPacketHandler.java | 44 ---------------- .../firmament/mixins/MixinClientPlayerEntity.java | 32 ------------ .../moe/nea/firmament/mixins/MixinCommandNode.java | 29 ----------- .../mixins/MixinDownloadingTerrainScreen.java | 22 -------- .../moe/nea/firmament/mixins/MixinEntityIdFix.java | 38 -------------- .../moe/nea/firmament/mixins/MixinInGameHud.java | 32 ------------ .../moe/nea/firmament/mixins/MixinItemModels.java | 33 ------------ .../moe/nea/firmament/mixins/MixinKeyBinding.java | 22 -------- .../nea/firmament/mixins/MixinKeybindsScreen.java | 59 ---------------------- .../moe/nea/firmament/mixins/MixinKeyboard.java | 23 --------- .../moe/nea/firmament/mixins/MixinMinecraft.java | 32 ------------ .../moe/nea/firmament/mixins/MixinModelLoader.java | 50 ------------------ .../java/moe/nea/firmament/mixins/MixinMouse.java | 44 ---------------- .../moe/nea/firmament/mixins/MixinProperty.java | 33 ------------ .../mixins/MixinSkullBlockEntityRenderer.java | 25 --------- .../nea/firmament/mixins/MixinWorldRenderer.java | 36 ------------- .../mixins/MixinYggdrasilServicesKeyInfo.java | 25 --------- .../firmament/mixins/OutgoingPacketEventPatch.java | 25 +++++++++ .../nea/firmament/mixins/PlayerDropEventPatch.java | 32 ++++++++++++ .../mixins/PropertySignatureIgnorePatch.java | 33 ++++++++++++ .../firmament/mixins/SaveCursorPositionPatch.java | 44 ++++++++++++++++ .../firmament/mixins/ScreenChangeEventPatch.java | 32 ++++++++++++ .../nea/firmament/mixins/ToggleSprintPatch.java | 22 ++++++++ .../nea/firmament/mixins/WorldReadyEventPatch.java | 22 ++++++++ .../mixins/WorldRenderLastEventPatch.java | 36 +++++++++++++ .../mixins/YggdrasilSignatureIgnorePatch.java | 25 +++++++++ 38 files changed, 632 insertions(+), 632 deletions(-) create mode 100644 src/main/java/moe/nea/firmament/mixins/CaseInsensitiveCommandMapPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/CustomModelEventPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/CustomSkullTexturePatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/HudRenderEvents.java create mode 100644 src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java create mode 100644 src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinChatHud.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinClientCommonNetworkHandler.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinCommandNode.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinDownloadingTerrainScreen.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinEntityIdFix.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinInGameHud.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinItemModels.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinKeyBinding.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinKeybindsScreen.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinKeyboard.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinMinecraft.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinModelLoader.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinMouse.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinProperty.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinSkullBlockEntityRenderer.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinWorldRenderer.java delete mode 100644 src/main/java/moe/nea/firmament/mixins/MixinYggdrasilServicesKeyInfo.java create mode 100644 src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/PropertySignatureIgnorePatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java create mode 100644 src/main/java/moe/nea/firmament/mixins/YggdrasilSignatureIgnorePatch.java (limited to 'src/main/java/moe') diff --git a/src/main/java/moe/nea/firmament/mixins/CaseInsensitiveCommandMapPatch.java b/src/main/java/moe/nea/firmament/mixins/CaseInsensitiveCommandMapPatch.java new file mode 100644 index 0000000..2696a6f --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/CaseInsensitiveCommandMapPatch.java @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.mojang.brigadier.tree.CommandNode; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.Locale; +import java.util.Map; + +@Mixin(value = CommandNode.class, remap = false) +public class CaseInsensitiveCommandMapPatch { + @WrapOperation(method = "getRelevantNodes", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"), remap = false) + public Object modify(Map map, Object text, Operation op) { + var original = op.call(map, text); + if (original == null) { + return map.get(((String) text).toLowerCase(Locale.ROOT)); + } + return original; + } + +} diff --git a/src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java b/src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java new file mode 100644 index 0000000..25ba0eb --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/ChatPeekingPatch.java @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import moe.nea.firmament.features.fixes.Fixes; +import net.minecraft.client.gui.hud.ChatHud; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ChatHud.class) +public class ChatPeekingPatch { + + @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z")) + public boolean onGetChatHud(boolean old) { + return old || Fixes.INSTANCE.shouldPeekChat(); + } + + @ModifyExpressionValue(method = "getHeight", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z")) + public boolean onGetChatHudHeight(boolean old) { + return old || Fixes.INSTANCE.shouldPeekChat(); + } + +} diff --git a/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java b/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java new file mode 100644 index 0000000..2da4176 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java @@ -0,0 +1,50 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.model.ModelLoader; +import net.minecraft.client.render.model.UnbakedModel; +import net.minecraft.client.texture.Sprite; +import net.minecraft.client.util.ModelIdentifier; +import net.minecraft.client.util.SpriteIdentifier; +import net.minecraft.resource.Resource; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Map; +import java.util.function.BiFunction; + +@Mixin(ModelLoader.class) +public abstract class CustomModelBakerPatch { + + @Shadow + protected abstract void addModel(ModelIdentifier modelId); + + @Shadow + @Final + private Map modelsToBake; + + @Shadow + public abstract UnbakedModel getOrLoadModel(Identifier id); + + @Inject(method = "bake", at = @At("HEAD")) + public void onBake(BiFunction spriteLoader, CallbackInfo ci) { + Map resources = + MinecraftClient.getInstance().getResourceManager().findResources("models/item", it -> "firmskyblock".equals(it.getNamespace()) && it.getPath().endsWith(".json")); + for (Identifier identifier : resources.keySet()) { + ModelIdentifier modelId = new ModelIdentifier("firmskyblock", identifier.getPath().substring("models/item/".length(), identifier.getPath().length() - ".json".length()), "inventory"); + addModel(modelId); + } + modelsToBake.values().forEach(model -> model.setParents(this::getOrLoadModel)); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/CustomModelEventPatch.java b/src/main/java/moe/nea/firmament/mixins/CustomModelEventPatch.java new file mode 100644 index 0000000..e8f02d4 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/CustomModelEventPatch.java @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.CustomItemModelEvent; +import net.minecraft.client.render.item.ItemModels; +import net.minecraft.client.render.model.BakedModel; +import net.minecraft.client.render.model.BakedModelManager; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ItemModels.class) +public class CustomModelEventPatch { + @Shadow + @Final + private BakedModelManager modelManager; + + @Inject(method = "getModel(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/client/render/model/BakedModel;", at = @At("HEAD"), cancellable = true) + public void onGetModel(ItemStack stack, CallbackInfoReturnable cir) { + var model = CustomItemModelEvent.getModel(stack, modelManager); + if (model != null) + cir.setReturnValue(model); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/CustomSkullTexturePatch.java b/src/main/java/moe/nea/firmament/mixins/CustomSkullTexturePatch.java new file mode 100644 index 0000000..a8cede4 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/CustomSkullTexturePatch.java @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.mojang.authlib.GameProfile; +import moe.nea.firmament.features.texturepack.CustomSkyBlockTextures; +import net.minecraft.block.SkullBlock; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(SkullBlockEntityRenderer.class) +public class CustomSkullTexturePatch { + @Inject(method = "getRenderLayer", at = @At("HEAD"), cancellable = true) + private static void onGetRenderLayer(SkullBlock.SkullType type, GameProfile profile, CallbackInfoReturnable cir) { + CustomSkyBlockTextures.INSTANCE.modifySkullTexture(type, profile, cir); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java b/src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java new file mode 100644 index 0000000..8f16686 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/DFUEntityIdFixPatch.java @@ -0,0 +1,38 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.mojang.datafixers.DataFix; +import com.mojang.datafixers.TypeRewriteRule; +import com.mojang.datafixers.schemas.Schema; +import com.mojang.datafixers.util.Pair; +import net.minecraft.datafixer.TypeReferences; +import net.minecraft.datafixer.fix.EntityIdFix; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Map; + +@Mixin(EntityIdFix.class) +public abstract class DFUEntityIdFixPatch extends DataFix { + @Shadow + @Final + private static Map RENAMED_ENTITIES; + + public DFUEntityIdFixPatch(Schema outputSchema, boolean changesType) { + super(outputSchema, changesType); + } + + @Inject(method = "makeRule", at = @At("RETURN"), cancellable = true) + public void onMakeRule(CallbackInfoReturnable cir) { + cir.setReturnValue(TypeRewriteRule.seq(fixTypeEverywhere("EntityIdFix", getInputSchema().findChoiceType(TypeReferences.ENTITY), getOutputSchema().findChoiceType(TypeReferences.ENTITY), dynamicOps -> pair -> ((Pair) pair).mapFirst(string -> RENAMED_ENTITIES.getOrDefault(string, (String) string))), convertUnchecked("Fix Type", getInputSchema().getType(TypeReferences.ITEM_STACK), getOutputSchema().getType(TypeReferences.ITEM_STACK)))); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java b/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java new file mode 100644 index 0000000..be3a3c0 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java @@ -0,0 +1,59 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.gui.config.ManagedConfig; +import moe.nea.firmament.keybindings.FirmamentKeyBindings; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.option.ControlsListWidget; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.option.KeyBinding; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ControlsListWidget.KeyBindingEntry.class) +public class FirmKeybindsInVanillaControlsPatch { + + @Mutable + @Shadow + @Final + private ButtonWidget editButton; + + @Shadow + @Final + private KeyBinding binding; + + @Shadow + @Final + private ButtonWidget resetButton; + + @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ButtonWidget;builder(Lnet/minecraft/text/Text;Lnet/minecraft/client/gui/widget/ButtonWidget$PressAction;)Lnet/minecraft/client/gui/widget/ButtonWidget$Builder;")) + public ButtonWidget.PressAction onInit(ButtonWidget.PressAction action) { + ManagedConfig config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding); + if (config == null) return action; + return button -> { + config.showConfigEditor(MinecraftClient.getInstance().currentScreen); + }; + } + + @Inject(method = "update", at = @At("HEAD"), cancellable = true) + public void onUpdate(CallbackInfo ci) { + ManagedConfig config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding); + if (config == null) return; + resetButton.active = false; + editButton.setMessage(Text.translatable("firmament.keybinding.external")); + ci.cancel(); + } + +} diff --git a/src/main/java/moe/nea/firmament/mixins/HudRenderEvents.java b/src/main/java/moe/nea/firmament/mixins/HudRenderEvents.java new file mode 100644 index 0000000..5ed969d --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/HudRenderEvents.java @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.HotbarItemRenderEvent; +import moe.nea.firmament.events.HudRenderEvent; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(InGameHud.class) +public class HudRenderEvents { + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getSleepTimer()I")) + public void renderCallBack(DrawContext context, float tickDelta, CallbackInfo ci) { + HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickDelta)); + } + + @Inject(method = "renderHotbarItem", at = @At("HEAD")) + public void onRenderHotbarItem(DrawContext context, int x, int y, float tickDelta, PlayerEntity player, ItemStack stack, int seed,CallbackInfo ci) { + if (stack != null) + HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickDelta)); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java b/src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java new file mode 100644 index 0000000..0984264 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/IncomingPacketListenerPatches.java @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.mojang.brigadier.CommandDispatcher; +import moe.nea.firmament.events.MaskCommands; +import moe.nea.firmament.events.ParticleSpawnEvent; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ClientPlayNetworkHandler.class) +public abstract class IncomingPacketListenerPatches { + + + @ModifyExpressionValue(method = "onCommandTree", at = @At(value = "NEW", target = "(Lcom/mojang/brigadier/tree/RootCommandNode;)Lcom/mojang/brigadier/CommandDispatcher;")) + public CommandDispatcher onOnCommandTree(CommandDispatcher dispatcher) { + MaskCommands.Companion.publish(new MaskCommands(dispatcher)); + return dispatcher; + } + + @Inject(method = "onParticle", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER), cancellable = true) + public void onParticleSpawn(ParticleS2CPacket packet, CallbackInfo ci) { + var event = new ParticleSpawnEvent( + packet.getParameters(), + new Vec3d(packet.getX(), packet.getY(), packet.getZ()), + new Vec3d(packet.getOffsetX(), packet.getOffsetY(), packet.getOffsetZ()), + packet.isLongDistance(), + packet.getCount() + ); + ParticleSpawnEvent.Companion.publish(event); + if (event.getCancelled()) + ci.cancel(); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java b/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java new file mode 100644 index 0000000..79c575b --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java @@ -0,0 +1,23 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.WorldKeyboardEvent; +import net.minecraft.client.Keyboard; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Keyboard.class) +public class KeyPressInWorldEventPatch { + + @Inject(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;)V")) + public void onKeyBoardInWorld(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) { + WorldKeyboardEvent.Companion.publish(new WorldKeyboardEvent(key, scancode, modifiers)); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java b/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java deleted file mode 100644 index aa1bf54..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinChatHud.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import moe.nea.firmament.features.fixes.Fixes; -import net.minecraft.client.gui.hud.ChatHud; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(ChatHud.class) -public class MixinChatHud { - - @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z")) - public boolean onGetChatHud(boolean old) { - return old || Fixes.INSTANCE.shouldPeekChat(); - } - - @ModifyExpressionValue(method = "getHeight", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z")) - public boolean onGetChatHudHeight(boolean old) { - return old || Fixes.INSTANCE.shouldPeekChat(); - } - -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinClientCommonNetworkHandler.java b/src/main/java/moe/nea/firmament/mixins/MixinClientCommonNetworkHandler.java deleted file mode 100644 index 767d25c..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinClientCommonNetworkHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.events.OutgoingPacketEvent; -import net.minecraft.client.network.ClientCommonNetworkHandler; -import net.minecraft.network.packet.Packet; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ClientCommonNetworkHandler.class) -public class MixinClientCommonNetworkHandler { - @Inject(method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) - public void onSendPacket(Packet packet, CallbackInfo ci) { - if (OutgoingPacketEvent.Companion.publish(new OutgoingPacketEvent(packet)).getCancelled()) { - ci.cancel(); - } - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java b/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java deleted file mode 100644 index 0dbf60c..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinClientPacketHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.mojang.brigadier.CommandDispatcher; -import moe.nea.firmament.events.MaskCommands; -import moe.nea.firmament.events.ParticleSpawnEvent; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; -import net.minecraft.util.math.Vec3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ClientPlayNetworkHandler.class) -public abstract class MixinClientPacketHandler { - - - @ModifyExpressionValue(method = "onCommandTree", at = @At(value = "NEW", target = "(Lcom/mojang/brigadier/tree/RootCommandNode;)Lcom/mojang/brigadier/CommandDispatcher;")) - public CommandDispatcher onOnCommandTree(CommandDispatcher dispatcher) { - MaskCommands.Companion.publish(new MaskCommands(dispatcher)); - return dispatcher; - } - - @Inject(method = "onParticle", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER), cancellable = true) - public void onParticleSpawn(ParticleS2CPacket packet, CallbackInfo ci) { - var event = new ParticleSpawnEvent( - packet.getParameters(), - new Vec3d(packet.getX(), packet.getY(), packet.getZ()), - new Vec3d(packet.getOffsetX(), packet.getOffsetY(), packet.getOffsetZ()), - packet.isLongDistance(), - packet.getCount() - ); - ParticleSpawnEvent.Companion.publish(event); - if (event.getCancelled()) - ci.cancel(); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java b/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java deleted file mode 100644 index 16e8fc3..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.events.IsSlotProtectedEvent; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.screen.slot.Slot; -import net.minecraft.screen.slot.SlotActionType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ClientPlayerEntity.class) -public abstract class MixinClientPlayerEntity extends PlayerEntity { - public MixinClientPlayerEntity() { - super(null, null, 0, null); - } - - @Inject(method = "dropSelectedItem", at = @At("HEAD"), cancellable = true) - public void onDropSelectedItem(boolean entireStack, CallbackInfoReturnable cir) { - Slot fakeSlot = new Slot(getInventory(), getInventory().selectedSlot, 0, 0); - if (IsSlotProtectedEvent.shouldBlockInteraction(fakeSlot, SlotActionType.THROW)) { - cir.setReturnValue(false); - } - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinCommandNode.java b/src/main/java/moe/nea/firmament/mixins/MixinCommandNode.java deleted file mode 100644 index aa8e584..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinCommandNode.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.mojang.brigadier.tree.CommandNode; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import java.util.Locale; -import java.util.Map; - -@Mixin(value = CommandNode.class, remap = false) -public class MixinCommandNode { - @WrapOperation(method = "getRelevantNodes", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"), remap = false) - public Object modify(Map map, Object text, Operation op) { - var original = op.call(map, text); - if (original == null) { - return map.get(((String) text).toLowerCase(Locale.ROOT)); - } - return original; - } - -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinDownloadingTerrainScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinDownloadingTerrainScreen.java deleted file mode 100644 index 0f23af1..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinDownloadingTerrainScreen.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.events.WorldReadyEvent; -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; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(DownloadingTerrainScreen.class) -public class MixinDownloadingTerrainScreen { - @Inject(method = "close", at = @At("HEAD")) - public void onClose(CallbackInfo ci) { - WorldReadyEvent.Companion.publish(new WorldReadyEvent()); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinEntityIdFix.java b/src/main/java/moe/nea/firmament/mixins/MixinEntityIdFix.java deleted file mode 100644 index 45c3ddd..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinEntityIdFix.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import com.mojang.datafixers.DataFix; -import com.mojang.datafixers.TypeRewriteRule; -import com.mojang.datafixers.schemas.Schema; -import com.mojang.datafixers.util.Pair; -import net.minecraft.datafixer.TypeReferences; -import net.minecraft.datafixer.fix.EntityIdFix; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.Map; - -@Mixin(EntityIdFix.class) -public abstract class MixinEntityIdFix extends DataFix { - @Shadow - @Final - private static Map RENAMED_ENTITIES; - - public MixinEntityIdFix(Schema outputSchema, boolean changesType) { - super(outputSchema, changesType); - } - - @Inject(method = "makeRule", at = @At("RETURN"), cancellable = true) - public void onMakeRule(CallbackInfoReturnable cir) { - cir.setReturnValue(TypeRewriteRule.seq(fixTypeEverywhere("EntityIdFix", getInputSchema().findChoiceType(TypeReferences.ENTITY), getOutputSchema().findChoiceType(TypeReferences.ENTITY), dynamicOps -> pair -> ((Pair) pair).mapFirst(string -> RENAMED_ENTITIES.getOrDefault(string, (String) string))), convertUnchecked("Fix Type", getInputSchema().getType(TypeReferences.ITEM_STACK), getOutputSchema().getType(TypeReferences.ITEM_STACK)))); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinInGameHud.java b/src/main/java/moe/nea/firmament/mixins/MixinInGameHud.java deleted file mode 100644 index 826d4e2..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinInGameHud.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.events.HotbarItemRenderEvent; -import moe.nea.firmament.events.HudRenderEvent; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(InGameHud.class) -public class MixinInGameHud { - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getSleepTimer()I")) - public void renderCallBack(DrawContext context, float tickDelta, CallbackInfo ci) { - HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickDelta)); - } - - @Inject(method = "renderHotbarItem", at = @At("HEAD")) - public void onRenderHotbarItem(DrawContext context, int x, int y, float tickDelta, PlayerEntity player, ItemStack stack, int seed,CallbackInfo ci) { - if (stack != null) - HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickDelta)); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinItemModels.java b/src/main/java/moe/nea/firmament/mixins/MixinItemModels.java deleted file mode 100644 index 7e8d78b..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinItemModels.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.events.CustomItemModelEvent; -import net.minecraft.client.render.item.ItemModels; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BakedModelManager; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ItemModels.class) -public class MixinItemModels { - @Shadow - @Final - private BakedModelManager modelManager; - - @Inject(method = "getModel(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/client/render/model/BakedModel;", at = @At("HEAD"), cancellable = true) - public void onGetModel(ItemStack stack, CallbackInfoReturnable cir) { - var model = CustomItemModelEvent.getModel(stack, modelManager); - if (model != null) - cir.setReturnValue(model); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinKeyBinding.java b/src/main/java/moe/nea/firmament/mixins/MixinKeyBinding.java deleted file mode 100644 index f77caf5..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinKeyBinding.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.features.fixes.Fixes; -import net.minecraft.client.option.KeyBinding; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(KeyBinding.class) -public class MixinKeyBinding { - @Inject(method = "isPressed", at = @At("HEAD"), cancellable = true) - public void onIsPressed(CallbackInfoReturnable cir) { - Fixes.INSTANCE.handleIsPressed((KeyBinding) (Object) this, cir); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinKeybindsScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinKeybindsScreen.java deleted file mode 100644 index 3a17983..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinKeybindsScreen.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.gui.config.ManagedConfig; -import moe.nea.firmament.keybindings.FirmamentKeyBindings; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.option.ControlsListWidget; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ControlsListWidget.KeyBindingEntry.class) -public class MixinKeybindsScreen { - - @Mutable - @Shadow - @Final - private ButtonWidget editButton; - - @Shadow - @Final - private KeyBinding binding; - - @Shadow - @Final - private ButtonWidget resetButton; - - @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ButtonWidget;builder(Lnet/minecraft/text/Text;Lnet/minecraft/client/gui/widget/ButtonWidget$PressAction;)Lnet/minecraft/client/gui/widget/ButtonWidget$Builder;")) - public ButtonWidget.PressAction onInit(ButtonWidget.PressAction action) { - ManagedConfig config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding); - if (config == null) return action; - return button -> { - config.showConfigEditor(MinecraftClient.getInstance().currentScreen); - }; - } - - @Inject(method = "update", at = @At("HEAD"), cancellable = true) - public void onUpdate(CallbackInfo ci) { - ManagedConfig config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding); - if (config == null) return; - resetButton.active = false; - editButton.setMessage(Text.translatable("firmament.keybinding.external")); - ci.cancel(); - } - -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinKeyboard.java b/src/main/java/moe/nea/firmament/mixins/MixinKeyboard.java deleted file mode 100644 index 8307ae0..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinKeyboard.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.events.WorldKeyboardEvent; -import net.minecraft.client.Keyboard; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(Keyboard.class) -public class MixinKeyboard { - - @Inject(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;)V")) - public void onKeyBoardInWorld(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) { - WorldKeyboardEvent.Companion.publish(new WorldKeyboardEvent(key, scancode, modifiers)); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinMinecraft.java b/src/main/java/moe/nea/firmament/mixins/MixinMinecraft.java deleted file mode 100644 index 90ecd36..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinMinecraft.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.events.ScreenOpenEvent; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(MinecraftClient.class) -public abstract class MixinMinecraft { - @Shadow - @Nullable - public Screen currentScreen; - - @Inject(method = "setScreen", at = @At("HEAD"), cancellable = true) - public void onScreenChange(Screen screen, CallbackInfo ci) { - var event = new ScreenOpenEvent(currentScreen, screen); - if (ScreenOpenEvent.Companion.publish(event).getCancelled()) { - ci.cancel(); - } - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinModelLoader.java b/src/main/java/moe/nea/firmament/mixins/MixinModelLoader.java deleted file mode 100644 index 78beba2..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinModelLoader.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.model.ModelLoader; -import net.minecraft.client.render.model.UnbakedModel; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.util.ModelIdentifier; -import net.minecraft.client.util.SpriteIdentifier; -import net.minecraft.resource.Resource; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.Map; -import java.util.function.BiFunction; - -@Mixin(ModelLoader.class) -public abstract class MixinModelLoader { - - @Shadow - protected abstract void addModel(ModelIdentifier modelId); - - @Shadow - @Final - private Map modelsToBake; - - @Shadow - public abstract UnbakedModel getOrLoadModel(Identifier id); - - @Inject(method = "bake", at = @At("HEAD")) - public void onBake(BiFunction spriteLoader, CallbackInfo ci) { - Map resources = - MinecraftClient.getInstance().getResourceManager().findResources("models/item", it -> "firmskyblock".equals(it.getNamespace()) && it.getPath().endsWith(".json")); - for (Identifier identifier : resources.keySet()) { - ModelIdentifier modelId = new ModelIdentifier("firmskyblock", identifier.getPath().substring("models/item/".length(), identifier.getPath().length() - ".json".length()), "inventory"); - addModel(modelId); - } - modelsToBake.values().forEach(model -> model.setParents(this::getOrLoadModel)); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinMouse.java b/src/main/java/moe/nea/firmament/mixins/MixinMouse.java deleted file mode 100644 index 68dda34..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinMouse.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import kotlin.Pair; -import moe.nea.firmament.features.inventory.SaveCursorPosition; -import net.minecraft.client.Mouse; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(Mouse.class) -public class MixinMouse { - @Shadow - private double x; - - @Shadow - private double y; - - @Inject(method = "lockCursor", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/Mouse;cursorLocked:Z")) - public void onLockCursor(CallbackInfo ci) { - SaveCursorPosition.saveCursorOriginal(x, y); - } - - @Inject(method = "lockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) - public void onLockCursorAfter(CallbackInfo ci) { - SaveCursorPosition.saveCursorMiddle(x, y); - } - - @Inject(method = "unlockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) - public void onUnlockCursor(CallbackInfo ci) { - Pair cursorPosition = SaveCursorPosition.loadCursor(this.x, this.y); - if (cursorPosition == null) return; - this.x = cursorPosition.getFirst(); - this.y = cursorPosition.getSecond(); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinProperty.java b/src/main/java/moe/nea/firmament/mixins/MixinProperty.java deleted file mode 100644 index 15ff6e4..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinProperty.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import com.mojang.authlib.properties.Property; -import moe.nea.firmament.features.fixes.Fixes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.security.PublicKey; - -@Mixin(value = Property.class, remap = false) -public class MixinProperty { - @Inject(method = "isSignatureValid", cancellable = true, at = @At("HEAD"), remap = false) - public void onValidateSignature(PublicKey publicKey, CallbackInfoReturnable cir) { - if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { - cir.setReturnValue(true); - } - } - - @Inject(method = "hasSignature", cancellable = true, at = @At("HEAD"), remap = false) - public void onHasSignature(CallbackInfoReturnable cir) { - if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { - cir.setReturnValue(true); - } - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinSkullBlockEntityRenderer.java b/src/main/java/moe/nea/firmament/mixins/MixinSkullBlockEntityRenderer.java deleted file mode 100644 index 7f54150..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinSkullBlockEntityRenderer.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import com.mojang.authlib.GameProfile; -import moe.nea.firmament.features.texturepack.CustomSkyBlockTextures; -import net.minecraft.block.SkullBlock; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(SkullBlockEntityRenderer.class) -public class MixinSkullBlockEntityRenderer { - @Inject(method = "getRenderLayer", at = @At("HEAD"), cancellable = true) - private static void onGetRenderLayer(SkullBlock.SkullType type, GameProfile profile, CallbackInfoReturnable cir) { - CustomSkyBlockTextures.INSTANCE.modifySkullTexture(type, profile, cir); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinWorldRenderer.java b/src/main/java/moe/nea/firmament/mixins/MixinWorldRenderer.java deleted file mode 100644 index 8aa105f..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinWorldRenderer.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import moe.nea.firmament.events.WorldRenderLastEvent; -import net.minecraft.client.render.*; -import net.minecraft.client.util.math.MatrixStack; -import org.joml.Matrix4f; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(WorldRenderer.class) -public class MixinWorldRenderer { - @Shadow - @Final - private BufferBuilderStorage bufferBuilders; - - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.BEFORE)) - public void onWorldRenderLast(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) { - var event = new WorldRenderLastEvent( - matrices, tickDelta, renderBlockOutline, - camera, gameRenderer, lightmapTextureManager, - positionMatrix, - this.bufferBuilders.getEntityVertexConsumers() - ); - WorldRenderLastEvent.Companion.publish(event); - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/MixinYggdrasilServicesKeyInfo.java b/src/main/java/moe/nea/firmament/mixins/MixinYggdrasilServicesKeyInfo.java deleted file mode 100644 index 38c380b..0000000 --- a/src/main/java/moe/nea/firmament/mixins/MixinYggdrasilServicesKeyInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Linnea Gräf - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -package moe.nea.firmament.mixins; - -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.yggdrasil.YggdrasilServicesKeyInfo; -import moe.nea.firmament.features.fixes.Fixes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = YggdrasilServicesKeyInfo.class, remap = false) -public class MixinYggdrasilServicesKeyInfo { - @Inject(method = "validateProperty", at = @At("HEAD"), cancellable = true, remap = false) - public void validate(Property property, CallbackInfoReturnable cir) { - if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { - cir.setReturnValue(true); - } - } -} diff --git a/src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java b/src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java new file mode 100644 index 0000000..de1f722 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/OutgoingPacketEventPatch.java @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.OutgoingPacketEvent; +import net.minecraft.client.network.ClientCommonNetworkHandler; +import net.minecraft.network.packet.Packet; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ClientCommonNetworkHandler.class) +public class OutgoingPacketEventPatch { + @Inject(method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) + public void onSendPacket(Packet packet, CallbackInfo ci) { + if (OutgoingPacketEvent.Companion.publish(new OutgoingPacketEvent(packet)).getCancelled()) { + ci.cancel(); + } + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java b/src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java new file mode 100644 index 0000000..9f6d83b --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/PlayerDropEventPatch.java @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.IsSlotProtectedEvent; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.screen.slot.Slot; +import net.minecraft.screen.slot.SlotActionType; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ClientPlayerEntity.class) +public abstract class PlayerDropEventPatch extends PlayerEntity { + public PlayerDropEventPatch() { + super(null, null, 0, null); + } + + @Inject(method = "dropSelectedItem", at = @At("HEAD"), cancellable = true) + public void onDropSelectedItem(boolean entireStack, CallbackInfoReturnable cir) { + Slot fakeSlot = new Slot(getInventory(), getInventory().selectedSlot, 0, 0); + if (IsSlotProtectedEvent.shouldBlockInteraction(fakeSlot, SlotActionType.THROW)) { + cir.setReturnValue(false); + } + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/PropertySignatureIgnorePatch.java b/src/main/java/moe/nea/firmament/mixins/PropertySignatureIgnorePatch.java new file mode 100644 index 0000000..4c1f3be --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/PropertySignatureIgnorePatch.java @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.mojang.authlib.properties.Property; +import moe.nea.firmament.features.fixes.Fixes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.security.PublicKey; + +@Mixin(value = Property.class, remap = false) +public class PropertySignatureIgnorePatch { + @Inject(method = "isSignatureValid", cancellable = true, at = @At("HEAD"), remap = false) + public void onValidateSignature(PublicKey publicKey, CallbackInfoReturnable cir) { + if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { + cir.setReturnValue(true); + } + } + + @Inject(method = "hasSignature", cancellable = true, at = @At("HEAD"), remap = false) + public void onHasSignature(CallbackInfoReturnable cir) { + if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { + cir.setReturnValue(true); + } + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java b/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java new file mode 100644 index 0000000..30d435f --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import kotlin.Pair; +import moe.nea.firmament.features.inventory.SaveCursorPosition; +import net.minecraft.client.Mouse; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Mouse.class) +public class SaveCursorPositionPatch { + @Shadow + private double x; + + @Shadow + private double y; + + @Inject(method = "lockCursor", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/Mouse;cursorLocked:Z")) + public void onLockCursor(CallbackInfo ci) { + SaveCursorPosition.saveCursorOriginal(x, y); + } + + @Inject(method = "lockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) + public void onLockCursorAfter(CallbackInfo ci) { + SaveCursorPosition.saveCursorMiddle(x, y); + } + + @Inject(method = "unlockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) + public void onUnlockCursor(CallbackInfo ci) { + Pair cursorPosition = SaveCursorPosition.loadCursor(this.x, this.y); + if (cursorPosition == null) return; + this.x = cursorPosition.getFirst(); + this.y = cursorPosition.getSecond(); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java b/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java new file mode 100644 index 0000000..1f46f25 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.ScreenChangeEvent; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MinecraftClient.class) +public abstract class ScreenChangeEventPatch { + @Shadow + @Nullable + public Screen currentScreen; + + @Inject(method = "setScreen", at = @At("HEAD"), cancellable = true) + public void onScreenChange(Screen screen, CallbackInfo ci) { + var event = new ScreenChangeEvent(currentScreen, screen); + if (ScreenChangeEvent.Companion.publish(event).getCancelled()) { + ci.cancel(); + } + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java b/src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java new file mode 100644 index 0000000..d223ed0 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/ToggleSprintPatch.java @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.features.fixes.Fixes; +import net.minecraft.client.option.KeyBinding; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(KeyBinding.class) +public class ToggleSprintPatch { + @Inject(method = "isPressed", at = @At("HEAD"), cancellable = true) + public void onIsPressed(CallbackInfoReturnable cir) { + Fixes.INSTANCE.handleIsPressed((KeyBinding) (Object) this, cir); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java b/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java new file mode 100644 index 0000000..33b5894 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/WorldReadyEventPatch.java @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.WorldReadyEvent; +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; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(DownloadingTerrainScreen.class) +public class WorldReadyEventPatch { + @Inject(method = "close", at = @At("HEAD")) + public void onClose(CallbackInfo ci) { + WorldReadyEvent.Companion.publish(new WorldReadyEvent()); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java new file mode 100644 index 0000000..268aa01 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.events.WorldRenderLastEvent; +import net.minecraft.client.render.*; +import net.minecraft.client.util.math.MatrixStack; +import org.joml.Matrix4f; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(WorldRenderer.class) +public class WorldRenderLastEventPatch { + @Shadow + @Final + private BufferBuilderStorage bufferBuilders; + + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.BEFORE)) + public void onWorldRenderLast(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) { + var event = new WorldRenderLastEvent( + matrices, tickDelta, renderBlockOutline, + camera, gameRenderer, lightmapTextureManager, + positionMatrix, + this.bufferBuilders.getEntityVertexConsumers() + ); + WorldRenderLastEvent.Companion.publish(event); + } +} diff --git a/src/main/java/moe/nea/firmament/mixins/YggdrasilSignatureIgnorePatch.java b/src/main/java/moe/nea/firmament/mixins/YggdrasilSignatureIgnorePatch.java new file mode 100644 index 0000000..2018b06 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/YggdrasilSignatureIgnorePatch.java @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.yggdrasil.YggdrasilServicesKeyInfo; +import moe.nea.firmament.features.fixes.Fixes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = YggdrasilServicesKeyInfo.class, remap = false) +public class YggdrasilSignatureIgnorePatch { + @Inject(method = "validateProperty", at = @At("HEAD"), cancellable = true, remap = false) + public void validate(Property property, CallbackInfoReturnable cir) { + if (Fixes.TConfig.INSTANCE.getFixUnsignedPlayerSkins()) { + cir.setReturnValue(true); + } + } +} -- cgit