Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Cabbage not dropping the correct items in some situations #442

Merged
merged 5 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<List<ItemStack>> cir)
{
if (!UTConfigMods.EREBUS.utCabbageDrop) return;
NonNullList<ItemStack> 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;
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.erebus.cabbage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.erebus.cabbage.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTCabbageMixin"]
}
Loading