package com.ptsmods.morecommands.mixin.compat.compat17.plus;

import com.ptsmods.morecommands.api.IMoreGameRules;
import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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(at = @At("HEAD"), method = "onLandedUpon")
    private void onLandedUpon_setToDirt(World world, BlockState state, BlockPos pos, Entity entity, float fallDistance, CallbackInfo cbi) {
        if (world.getGameRules().getBoolean(IMoreGameRules.get().doFarmlandTrampleRule())) FarmlandBlock.setToDirt(state, world, pos);
    }
}

@@ -192,44 +192,8 @@
 ck;%0A
-import net.minecraft.entity.Entity;%0A
 impo
@@ -403,82 +403,16 @@
 ion.
-Inject;%0Aimport org.spongepowered.asm.mixin.injection.callback.CallbackInfo
+Redirect
 ;%0A%0A@
@@ -482,11 +482,13 @@
    @
-Inj
+Redir
 ect(
@@ -500,13 +500,176 @@
 @At(
-%22HEAD
+value = %22INVOKE%22, target = %22Lnet/minecraft/block/FarmlandBlock;setToDirt(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V
 %22), 
@@ -737,21 +737,8 @@
 irt(
-World world, 
 Bloc
@@ -755,73 +755,33 @@
 te, 
-BlockPos pos, Entity entity, float fallDistance, CallbackInfo cbi
+World world, BlockPos pos
 ) %7B%0A

Fix farmland blocks being trampled by any entity