From 8e183455a56550d371f63d07b766db40282887a3 Mon Sep 17 00:00:00 2001 From: pkstDev Date: Mon, 14 Nov 2022 21:47:46 +0800 Subject: [PATCH] Correct cheat item stacks of StatusEffectEmiStack --- .../github/pkstdev/emiffect/EMIffectPlugin.java | 3 --- .../pkstdev/emiffect/mixin/package-info.java | 4 ---- .../pkstdev/emiffect/util/package-info.java | 3 +++ .../emiffect/util/stack/StatusEffectEmiStack.java | 15 +++++++++++++++ src/main/resources/emiffect.mixins.json | 13 ------------- src/main/resources/fabric.mod.json | 3 --- 6 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 src/main/java/io/github/pkstdev/emiffect/mixin/package-info.java delete mode 100644 src/main/resources/emiffect.mixins.json diff --git a/src/main/java/io/github/pkstdev/emiffect/EMIffectPlugin.java b/src/main/java/io/github/pkstdev/emiffect/EMIffectPlugin.java index e0ce3c2..bc992c2 100644 --- a/src/main/java/io/github/pkstdev/emiffect/EMIffectPlugin.java +++ b/src/main/java/io/github/pkstdev/emiffect/EMIffectPlugin.java @@ -15,13 +15,10 @@ import net.minecraft.item.Items; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; @Entrypoint("emi") // For automatically registering the entrypoint public class EMIffectPlugin implements EmiPlugin { public static final String MOD_ID = "emiffect"; - public static final Logger LOGGER = LoggerFactory.getLogger("Emiffect"); public static final Identifier CATEGORY_ICON = new Identifier(MOD_ID, "textures/gui/emi/icon.png"); public static final EmiRecipeCategory CATEGORY = new EmiRecipeCategory(new Identifier(MOD_ID, "status_effect_info"), new EmiTexture(CATEGORY_ICON, 0, 0, 16, 16, 16, 16, 16, 16)); diff --git a/src/main/java/io/github/pkstdev/emiffect/mixin/package-info.java b/src/main/java/io/github/pkstdev/emiffect/mixin/package-info.java deleted file mode 100644 index b89a7ee..0000000 --- a/src/main/java/io/github/pkstdev/emiffect/mixin/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package contains the Mixin stuffs. - */ -package io.github.pkstdev.emiffect.mixin; \ No newline at end of file diff --git a/src/main/java/io/github/pkstdev/emiffect/util/package-info.java b/src/main/java/io/github/pkstdev/emiffect/util/package-info.java index 2f1f7ac..cf64ea3 100644 --- a/src/main/java/io/github/pkstdev/emiffect/util/package-info.java +++ b/src/main/java/io/github/pkstdev/emiffect/util/package-info.java @@ -1 +1,4 @@ +/** + * Utilities used in EMIffect. + */ package io.github.pkstdev.emiffect.util; \ No newline at end of file diff --git a/src/main/java/io/github/pkstdev/emiffect/util/stack/StatusEffectEmiStack.java b/src/main/java/io/github/pkstdev/emiffect/util/stack/StatusEffectEmiStack.java index 8d207ff..7caa344 100644 --- a/src/main/java/io/github/pkstdev/emiffect/util/stack/StatusEffectEmiStack.java +++ b/src/main/java/io/github/pkstdev/emiffect/util/stack/StatusEffectEmiStack.java @@ -12,7 +12,11 @@ import net.minecraft.client.texture.StatusEffectSpriteManager; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; +import net.minecraft.potion.PotionUtil; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -20,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class StatusEffectEmiStack extends EmiStack { @@ -124,4 +129,14 @@ public Class getType() { return getValue().getClass(); } } + + @Override + public ItemStack getItemStack() { + ItemStack stack = super.getItemStack(); + if (effect != null) { + stack = PotionUtil.setCustomPotionEffects(Items.POTION.getDefaultStack(), + Collections.singletonList(new StatusEffectInstance(effect, 600))); + } + return stack; + } } diff --git a/src/main/resources/emiffect.mixins.json b/src/main/resources/emiffect.mixins.json deleted file mode 100644 index 772efcb..0000000 --- a/src/main/resources/emiffect.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "io.github.pkstdev.emiffect.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - ], - "client": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c501cc3..fccde8a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -21,9 +21,6 @@ "emi": [ ] }, - "mixins": [ - "emiffect.mixins.json" - ], "depends": { "fabricloader": ">=0.14.9",