diff --git a/README.md b/README.md index c5920175..05849046 100644 --- a/README.md +++ b/README.md @@ -340,6 +340,7 @@ All changes are toggleable via config files. * **Duplication Fixes:** Fixes various duplication exploits * **Memory Leak Fix:** Fixes a client-side memory leak when wearing Void Fortress armor * **The Erebus** + * **Fix Cabbage Drop:** Fixes Cabbage not dropping the correct items in some situations * **Preserved Blocks Fix:** Prevents HWYLA/TOP crashes with preserved blocks * **The Farlanders** * **Duplication Fixes:** Fixes various duplication exploits diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java index a0fc6dfa..f7dfe891 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java @@ -386,6 +386,11 @@ public static class EpicSiegeModCategory public static class ErebusCategory { + @Config.RequiresMcRestart + @Config.Name("Fix Cabbage Drop") + @Config.Comment("Fixes Cabbage not dropping the correct items in some situations") + public boolean utCabbageDrop = true; + @Config.RequiresMcRestart @Config.Name("Preserved Blocks Fix") @Config.Comment("Prevents HWYLA/TOP crashes with preserved blocks") diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java index a528a617..22f90632 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java @@ -51,6 +51,7 @@ public class UTMixinLoader implements ILateMixinLoader put("mixins.mods.elementarystaffs.json", () -> loaded("element")); put("mixins.mods.elenaidodge2.json", () -> loaded("elenaidodge2")); put("mixins.mods.epicsiegemod.json", () -> loaded("epicsiegemod")); + put("mixins.mods.erebus.cabbage.json", () -> loaded("erebus") && UTConfigMods.EREBUS.utCabbageDrop); put("mixins.mods.erebus.json", () -> loaded("erebus")); put("mixins.mods.extrautilities.breakcreativemill.json", () -> loaded("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utFixCreativeMillHarvestability); put("mixins.mods.extrautilities.dupes.json", () -> loaded("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utDuplicationFixesToggle); diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/erebus/cabbage/mixin/UTCabbageMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/erebus/cabbage/mixin/UTCabbageMixin.java new file mode 100644 index 00000000..b0f98ace --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/erebus/cabbage/mixin/UTCabbageMixin.java @@ -0,0 +1,48 @@ +package mod.acgaming.universaltweaks.mods.erebus.cabbage.mixin; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import erebus.ModItems; +import erebus.blocks.BlockCabbage; +import erebus.items.ItemErebusFood; +import mod.acgaming.universaltweaks.config.UTConfigMods; +import net.minecraft.block.BlockCrops; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +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 java.util.List; + +// Courtesy of WaitingIdly +@Mixin(value = BlockCabbage.class, remap = false) +public abstract class UTCabbageMixin extends BlockCrops +{ + @Inject(method = "getDrops", at = @At("HEAD"), cancellable = true) + private void utOverrideDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune, CallbackInfoReturnable> cir) + { + if (!UTConfigMods.EREBUS.utCabbageDrop) return; + NonNullList drops = NonNullList.create(); + getDrops(drops, world, pos, state, fortune); + cir.setReturnValue(drops); + } + + @Override + public int damageDropped(IBlockState blockState) + { + if (!UTConfigMods.EREBUS.utCabbageDrop) return super.damageDropped(blockState); + return ItemErebusFood.EnumFoodType.CABBAGE.ordinal(); + } + + @ModifyReturnValue(method = "getCrop", at = @At("RETURN")) + private Item utGetCrop(Item original) + { + if (!UTConfigMods.EREBUS.utCabbageDrop) return original; + return ModItems.EREBUS_FOOD; + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.mods.erebus.cabbage.json b/src/main/resources/mixins.mods.erebus.cabbage.json new file mode 100644 index 00000000..6029799f --- /dev/null +++ b/src/main/resources/mixins.mods.erebus.cabbage.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.mods.erebus.cabbage.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTCabbageMixin"] +} \ No newline at end of file