Skip to content

Commit 6398edf

Browse files
prevent crop trample
1 parent 14f5605 commit 6398edf

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ authors=jaskarth, unascribed
1717
contributors=Patbox, IThundxr
1818
license=AGPL-3.0-or-later
1919
# Mod Version
20-
baseVersion=0.6.1
20+
baseVersion=0.6.2
2121
# Branch Metadata
2222
branch=1.21
2323
tagBranch=1.21
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package net.modfest.fireblanket.mixin.adventure_fix;
2+
3+
import net.minecraft.block.BlockState;
4+
import net.minecraft.block.FarmlandBlock;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.entity.player.PlayerEntity;
7+
import net.minecraft.util.math.BlockPos;
8+
import net.minecraft.world.World;
9+
import org.jetbrains.annotations.Nullable;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
import org.spongepowered.asm.mixin.injection.Inject;
13+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14+
15+
@Mixin(FarmlandBlock.class)
16+
public class MixinFarmlandBlock {
17+
@Inject(
18+
method = "setToDirt",
19+
at = @At("HEAD"),
20+
cancellable = true
21+
)
22+
private static void doNotSetToDirt(@Nullable Entity entity, BlockState state, World world, BlockPos pos, CallbackInfo ci) {
23+
if (entity instanceof PlayerEntity player && !player.canModifyBlocks()) {
24+
ci.cancel();
25+
}
26+
}
27+
}

src/main/resources/fireblanket.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"adventure_fix.MixinItemStack",
1515
"adventure_fix.MixinPlayerInteractEntityC2SPacketHandler",
1616
"adventure_fix.MixinServerPlayerInteractionManager",
17+
"adventure_fix.MixinFarmlandBlock",
1718
"ai.MixinTemptGoal",
1819
"be_sync.MixinBlockEntity",
1920
"be_sync.MixinChunkHolder",

0 commit comments

Comments
 (0)