From 8cf5891b655e8fb11b2bc4550be29087b0573774 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Mon, 15 Jul 2024 09:54:54 +0800 Subject: [PATCH] Temp solution for #113 - Any sync-related issues will be delayed until after the PCASyncProtocol refactoring. Signed-off-by: Hendrix-Shen --- .../MixinAbstractVillager.java | 8 +++++++ .../resources/masa_gadget_mod.mixins.json | 1 + .../MixinAbstractVillager.java | 24 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/tweakeroo/inventoryPreviewSupportTradeOfferList/MixinAbstractVillager.java create mode 100644 versions/1.21.0-fabric/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/tweakeroo/inventoryPreviewSupportTradeOfferList/MixinAbstractVillager.java diff --git a/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/tweakeroo/inventoryPreviewSupportTradeOfferList/MixinAbstractVillager.java b/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/tweakeroo/inventoryPreviewSupportTradeOfferList/MixinAbstractVillager.java new file mode 100644 index 0000000..560a8cd --- /dev/null +++ b/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/tweakeroo/inventoryPreviewSupportTradeOfferList/MixinAbstractVillager.java @@ -0,0 +1,8 @@ +package com.plusls.MasaGadget.mixin.mod_tweak.tweakeroo.inventoryPreviewSupportTradeOfferList; + +import org.spongepowered.asm.mixin.Mixin; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; + +@Mixin(DummyClass.class) +public class MixinAbstractVillager { +} diff --git a/src/main/resources/masa_gadget_mod.mixins.json b/src/main/resources/masa_gadget_mod.mixins.json index 1203be1..157cc37 100644 --- a/src/main/resources/masa_gadget_mod.mixins.json +++ b/src/main/resources/masa_gadget_mod.mixins.json @@ -58,5 +58,6 @@ "defaultRequire": 1 }, "mixins": [ + "mod_tweak.tweakeroo.inventoryPreviewSupportTradeOfferList.MixinAbstractVillager" ] } diff --git a/versions/1.21.0-fabric/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/tweakeroo/inventoryPreviewSupportTradeOfferList/MixinAbstractVillager.java b/versions/1.21.0-fabric/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/tweakeroo/inventoryPreviewSupportTradeOfferList/MixinAbstractVillager.java new file mode 100644 index 0000000..a72545a --- /dev/null +++ b/versions/1.21.0-fabric/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/tweakeroo/inventoryPreviewSupportTradeOfferList/MixinAbstractVillager.java @@ -0,0 +1,24 @@ +package com.plusls.MasaGadget.mixin.mod_tweak.tweakeroo.inventoryPreviewSupportTradeOfferList; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.MasaGadget.game.Configs; +import net.minecraft.world.entity.npc.AbstractVillager; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(AbstractVillager.class) +public class MixinAbstractVillager { + @WrapOperation( + method = "getOffers", + at = @At( + value = "FIELD", + target = "Lnet/minecraft/world/level/Level;isClientSide:Z" + ) + ) + private boolean forgiveInvoke(Level instance, @NotNull Operation original) { + return original.call(instance) && !Configs.inventoryPreviewSupportTradeOfferList.getBooleanValue(); + } +}