diff --git a/gradle.properties b/gradle.properties index 8c18db7..effc8c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinFarmlandBlock.java b/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinFarmlandBlock.java new file mode 100644 index 0000000..01c915e --- /dev/null +++ b/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinFarmlandBlock.java @@ -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(); + } + } +} diff --git a/src/main/resources/fireblanket.mixins.json b/src/main/resources/fireblanket.mixins.json index f3cfcb8..6c8f2ed 100644 --- a/src/main/resources/fireblanket.mixins.json +++ b/src/main/resources/fireblanket.mixins.json @@ -14,6 +14,7 @@ "adventure_fix.MixinItemStack", "adventure_fix.MixinPlayerInteractEntityC2SPacketHandler", "adventure_fix.MixinServerPlayerInteractionManager", + "adventure_fix.MixinFarmlandBlock", "ai.MixinTemptGoal", "be_sync.MixinBlockEntity", "be_sync.MixinChunkHolder",