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

fix ic2 crops making any farmland trampleable #425

Merged
merged 1 commit into from
Sep 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,11 @@ public class FixesConfig {
@Config.RequiresMcRestart
public static boolean optimizeIc2ReactorInventoryAccess;

@Config.Comment("Fix IC2 Crops trampling any types of farmland to dirt when sprinting")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixIc2CropTrampling;

// Journey Map

@Config.Comment("Prevents journeymap from using illegal character in file paths")
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ public enum Mixins {
new Builder("IC2 Resource Pack Translation Fix").setPhase(Phase.EARLY).setSide(Side.CLIENT)
.addMixinClasses("fml.MixinLanguageRegistry", "fml.MixinFMLClientHandler", "ic2.MixinLocalization")
.setApplyIf(() -> FixesConfig.fixIc2ResourcePackTranslation).addTargetedMod(TargetedMod.IC2)),
IC2_CROP_TRAMPLING_FIX(new Builder("IC2 Crop Trampling Fix").setPhase(Phase.LATE).setSide(Side.BOTH)
.addMixinClasses("ic2.MixinIC2TileEntityCrop").setApplyIf(() -> FixesConfig.fixIc2CropTrampling)
.addTargetedMod(TargetedMod.IC2)),

// Disable update checkers
BIBLIOCRAFT_UPDATE_CHECK(new Builder("Yeet Bibliocraft Update Check").setPhase(Phase.LATE).setSide(Side.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mitchej123.hodgepodge.mixins.late.ic2;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;

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.CallbackInfo;

import ic2.core.crop.TileEntityCrop;

@Mixin(TileEntityCrop.class)
public class MixinIC2TileEntityCrop extends TileEntity {

@Inject(method = "calcTrampling", at = @At("HEAD"), cancellable = true, remap = false)
public void hodgepodge$fixIC2CropTrampling(CallbackInfo ci) {
Block below = worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord);
// If the crop is trampled (usually by sprinting over it), the block below always replaced with dirt by ic2.
// This only makes sense if the block was actually dirt-farmland, as otherwise special farmland may
// get replaced with dirt, including those that are supposed to be un-trample-able.
// Special handling for other farmland types that should be trample-able may be added here, if there are any.
if (below != Blocks.farmland) ci.cancel();
}
}