From 54ca7c2ba49185062e2070983b75803e83470f1e Mon Sep 17 00:00:00 2001 From: Ramid Khan Date: Sun, 7 Jul 2024 12:53:01 +1000 Subject: [PATCH] Check on overflow destruction card Closes #61 --- settings.gradle | 8 ------ .../mekae2/mixin/MEInventoryHandlerMixin.java | 27 +++++++++++++++++++ src/main/resources/appmek.mixins.json | 2 +- 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/main/java/me/ramidzkh/mekae2/mixin/MEInventoryHandlerMixin.java diff --git a/settings.gradle b/settings.gradle index 1c91964..a2e6625 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven { url = 'https://maven.minecraftforge.net/' } - maven { url = 'https://maven.neoforged.net/releases' } - } -} - rootProject.name = "Applied-Mekanistics" diff --git a/src/main/java/me/ramidzkh/mekae2/mixin/MEInventoryHandlerMixin.java b/src/main/java/me/ramidzkh/mekae2/mixin/MEInventoryHandlerMixin.java new file mode 100644 index 0000000..9158cd7 --- /dev/null +++ b/src/main/java/me/ramidzkh/mekae2/mixin/MEInventoryHandlerMixin.java @@ -0,0 +1,27 @@ +package me.ramidzkh.mekae2.mixin; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import me.ramidzkh.mekae2.ae2.MekanismKey; +import mekanism.api.chemical.attribute.ChemicalAttributeValidator; + +import appeng.api.stacks.AEKey; +import appeng.me.storage.MEInventoryHandler; + +@Mixin(MEInventoryHandler.class) +public class MEInventoryHandlerMixin { + + @ModifyExpressionValue(method = "insert", at = @At(value = "FIELD", target = "Lappeng/me/storage/MEInventoryHandler;voidOverflow:Z")) + private boolean voidOverflow(boolean original, AEKey what) { + if (what instanceof MekanismKey key) { + if (!ChemicalAttributeValidator.DEFAULT.process(key.getStack())) { + return false; + } + } + + return original; + } +} diff --git a/src/main/resources/appmek.mixins.json b/src/main/resources/appmek.mixins.json index 95d919b..f1ef01d 100644 --- a/src/main/resources/appmek.mixins.json +++ b/src/main/resources/appmek.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8.5", "package": "me.ramidzkh.mekae2.mixin", - "mixins": ["CondenserMEStorageMixin"], + "mixins": ["CondenserMEStorageMixin", "MEInventoryHandlerMixin"], "injectors": { "defaultRequire": 1 }