diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java index a8b269b..c3254b7 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java @@ -76,17 +76,13 @@ public ChemicalStack withAmount(long amount) { } public byte getForm() { - if (stack instanceof GasStack) { - return GAS; - } else if (stack instanceof InfusionStack) { - return INFUSION; - } else if (stack instanceof PigmentStack) { - return PIGMENT; - } else if (stack instanceof SlurryStack) { - return SLURRY; - } else { - throw new UnsupportedOperationException(); - } + return switch (stack) { + case GasStack ignored -> GAS; + case InfusionStack ignored -> INFUSION; + case PigmentStack ignored -> PIGMENT; + case SlurryStack ignored -> SLURRY; + default -> throw new UnsupportedOperationException(); + }; } @Override @@ -141,17 +137,17 @@ protected Component computeDisplayName() { @Override public boolean isTagged(TagKey tag) { - if (stack.getChemical() instanceof Gas gas) { - return tag.registry().equals(MekanismAPI.GAS_REGISTRY_NAME) && gas.is((TagKey) tag); - } else if (stack.getChemical() instanceof InfuseType infuse) { - return tag.registry().equals(MekanismAPI.INFUSE_TYPE_REGISTRY_NAME) && infuse.is((TagKey) tag); - } else if (stack.getChemical() instanceof Pigment pigment) { - return tag.registry().equals(MekanismAPI.PIGMENT_REGISTRY_NAME) && pigment.is((TagKey) tag); - } else if (stack.getChemical() instanceof Slurry slurry) { - return tag.registry().equals(MekanismAPI.SLURRY_REGISTRY_NAME) && slurry.is((TagKey) tag); - } else { - throw new UnsupportedOperationException(); - } + return switch (stack.getChemical()) { + case Gas gas -> tag.registry().equals(MekanismAPI.GAS_REGISTRY_NAME) + && gas.is((TagKey) tag); + case InfuseType infuse -> tag.registry().equals(MekanismAPI.INFUSE_TYPE_REGISTRY_NAME) + && infuse.is((TagKey) tag); + case Pigment pigment -> tag.registry().equals(MekanismAPI.PIGMENT_REGISTRY_NAME) + && pigment.is((TagKey) tag); + case Slurry slurry -> tag.registry().equals(MekanismAPI.SLURRY_REGISTRY_NAME) + && slurry.is((TagKey) tag); + default -> throw new UnsupportedOperationException(); + }; } @Override diff --git a/src/main/java/me/ramidzkh/mekae2/mixin/CondenserMEStorageMixin.java b/src/main/java/me/ramidzkh/mekae2/mixin/CondenserMEStorageMixin.java new file mode 100644 index 0000000..071db20 --- /dev/null +++ b/src/main/java/me/ramidzkh/mekae2/mixin/CondenserMEStorageMixin.java @@ -0,0 +1,27 @@ +package me.ramidzkh.mekae2.mixin; + +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 me.ramidzkh.mekae2.ae2.MekanismKey; +import mekanism.api.chemical.attribute.ChemicalAttributeValidator; + +import appeng.api.config.Actionable; +import appeng.api.networking.security.IActionSource; +import appeng.api.stacks.AEKey; + +@Mixin(targets = "appeng.blockentity.misc.CondenserMEStorage") +public class CondenserMEStorageMixin { + + @Inject(method = "insert", at = @At("HEAD"), cancellable = true) + private void onInsert(AEKey what, long amount, Actionable mode, IActionSource source, + CallbackInfoReturnable cir) { + if (what instanceof MekanismKey key) { + if (!ChemicalAttributeValidator.DEFAULT.process(key.getStack())) { + cir.setReturnValue(0L); + } + } + } +} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/neoforge.mods.toml similarity index 95% rename from src/main/resources/META-INF/mods.toml rename to src/main/resources/META-INF/neoforge.mods.toml index e59a0c5..f8aa212 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -13,6 +13,9 @@ displayURL = "https://github.com/AppliedEnergistics/Applied-Mekanistics#readme" logoFile = "logo.png" authors = "ramidzkh" +[[mixins]] +config = "appmek.mixins.json" + [[dependencies.appmek]] modId = "neoforge" type = "required" diff --git a/src/main/resources/appmek.mixins.json b/src/main/resources/appmek.mixins.json new file mode 100644 index 0000000..95d919b --- /dev/null +++ b/src/main/resources/appmek.mixins.json @@ -0,0 +1,9 @@ +{ + "required": true, + "minVersion": "0.8.5", + "package": "me.ramidzkh.mekae2.mixin", + "mixins": ["CondenserMEStorageMixin"], + "injectors": { + "defaultRequire": 1 + } +}