diff --git a/gradle.properties b/gradle.properties index de4865b..9be339f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,7 @@ wthit = 5.10.0 badpackets = 0.2.1 # Recipe Viewer -recipeViewer = jei +recipeViewer = emi rei = 9.1.526 jei = 1.19.2-11.5.2.1007 emi = 0.6.3+1.19.2 diff --git a/src/main/java/badasintended/slotlink/mixin/emi/EmiRecipeFillerMixin.java b/src/main/java/badasintended/slotlink/mixin/emi/EmiRecipeFillerMixin.java new file mode 100644 index 0000000..0fdbe2f --- /dev/null +++ b/src/main/java/badasintended/slotlink/mixin/emi/EmiRecipeFillerMixin.java @@ -0,0 +1,26 @@ +package badasintended.slotlink.mixin.emi; + +import dev.emi.emi.EmiRecipeFiller; +import dev.emi.emi.mixin.accessor.ScreenHandlerAccessor; +import net.minecraft.screen.PlayerScreenHandler; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerType; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +// TODO: remove if new emi version is released +@Mixin(EmiRecipeFiller.class) +public abstract class EmiRecipeFillerMixin { + + // https://github.com/emilyploszaj/emi/pull/136 + @Redirect(require = 0, method = "getAllHandlers", at = @At(value = "INVOKE", target = "Ldev/emi/emi/mixin/accessor/ScreenHandlerAccessor;emi$getType()Lnet/minecraft/screen/ScreenHandlerType;")) + private static ScreenHandlerType slotlink(ScreenHandlerAccessor instance) { + try { + return instance instanceof PlayerScreenHandler ? null : ((ScreenHandler) instance).getType(); + } catch (UnsupportedOperationException e) { + return null; + } + } + +} diff --git a/src/main/java/badasintended/slotlink/mixin/pseudo/SortButtonWidgetMixin.java b/src/main/java/badasintended/slotlink/mixin/invsorter/SortButtonWidgetMixin.java similarity index 94% rename from src/main/java/badasintended/slotlink/mixin/pseudo/SortButtonWidgetMixin.java rename to src/main/java/badasintended/slotlink/mixin/invsorter/SortButtonWidgetMixin.java index 3433a5c..4b859ce 100644 --- a/src/main/java/badasintended/slotlink/mixin/pseudo/SortButtonWidgetMixin.java +++ b/src/main/java/badasintended/slotlink/mixin/invsorter/SortButtonWidgetMixin.java @@ -1,4 +1,4 @@ -package badasintended.slotlink.mixin.pseudo; +package badasintended.slotlink.mixin.invsorter; import badasintended.slotlink.compat.invsort.InventorySortButton; import net.minecraft.client.gui.widget.TexturedButtonWidget; diff --git a/src/main/resources/slotlink.mixins.json b/src/main/resources/slotlink.mixins.json index 2524dc7..f2dba5b 100644 --- a/src/main/resources/slotlink.mixins.json +++ b/src/main/resources/slotlink.mixins.json @@ -4,13 +4,17 @@ "package" : "badasintended.slotlink.mixin", "compatibilityLevel": "JAVA_16", "mixins" : [ - "CraftingScreenHandlerAccessor", "PlayerEntityMixin", "RecipeManagerAccessor", "ServerWorldMixin", + "CraftingScreenHandlerAccessor", + "PlayerEntityMixin", + "RecipeManagerAccessor", + "ServerWorldMixin", "WallMountedBlockMixin" ], "client" : [ "HandledScreenAccessor", "TextFieldWidgetAccessor", - "pseudo.SortButtonWidgetMixin" + "emi.EmiRecipeFillerMixin", + "invsorter.SortButtonWidgetMixin" ], "injectors" : { "defaultRequire": 1