Skip to content

Commit

Permalink
prevent crop trample
Browse files Browse the repository at this point in the history
  • Loading branch information
HamaIndustries committed Nov 30, 2024
1 parent 14f5605 commit 6398edf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors=jaskarth, unascribed
contributors=Patbox, IThundxr
license=AGPL-3.0-or-later
# Mod Version
baseVersion=0.6.1
baseVersion=0.6.2
# Branch Metadata
branch=1.21
tagBranch=1.21
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.modfest.fireblanket.mixin.adventure_fix;

import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
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;

@Mixin(FarmlandBlock.class)
public class MixinFarmlandBlock {
@Inject(
method = "setToDirt",
at = @At("HEAD"),
cancellable = true
)
private static void doNotSetToDirt(@Nullable Entity entity, BlockState state, World world, BlockPos pos, CallbackInfo ci) {
if (entity instanceof PlayerEntity player && !player.canModifyBlocks()) {
ci.cancel();
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/fireblanket.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"adventure_fix.MixinItemStack",
"adventure_fix.MixinPlayerInteractEntityC2SPacketHandler",
"adventure_fix.MixinServerPlayerInteractionManager",
"adventure_fix.MixinFarmlandBlock",
"ai.MixinTemptGoal",
"be_sync.MixinBlockEntity",
"be_sync.MixinChunkHolder",
Expand Down

0 comments on commit 6398edf

Please sign in to comment.