package jesse.keeblarcraft.mixin;

import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;

import net.minecraft.network.listener.ServerPlayPacketListener;
import net.minecraft.server.network.ServerPlayNetworkHandler;

@Mixin(ServerPlayNetworkHandler.class)
public abstract class ServerPlayNetworkHandlerMixin implements ServerPlayPacketListener {

    // Truth be told not required for a pickaxe or tool probably
    // @Redirect(
    //     method = "onPlayerInteractEntity(Lnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket;)V",
    //     at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;MAX_BREAK_SQUARED_DISTANCE:D", opcode = Opcodes.GETSTATIC))
    // private double getActualAttackRange() {
    //     return 100; // 10^2 becauses 10 blocks chosen in Client mixin
    // }

    // // Essentially replaces the 'MAX_BREAK_SQUARED_DISTANCE' value with the value we have in the function (100), or 10 blocks which bc 10^2
    // @Redirect(
    //     method = "onPlayerInteractBlock(Lnet/minecraft/network/packet/c2s/play/PlayerInteractBlockC2SPacket;)V",
    //     at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;MAX_BREAK_SQUARED_DISTANCE:D", opcode = Opcodes.GETSTATIC))
    // private double getActualReachDistance() {
    //     return 100; // 10^2 becauses 10 blocks chosen in Client mixin
    // }

    // // Search '64' inside the same onPlayerInteractBlock, would also need to replace that value maybe. This is in the github reference for that block breaking
    // // im not 100% sure what this is doing. If it's squared then sqrt(64) = 8 blocks but I'm not sure what 8 would represent here.
    // @ModifyConstant(
    //     method = "onPlayerInteractBlock(Lnet/minecraft/network/packet/c2s/play/PlayerInteractBlockC2SPacket;)V",
    //     require = 1, allow = 1, constant = @Constant(doubleValue = 64.0))
    // private double getActualReachDistance(final double reachDistance) {
    //     return 100; // 10^2 becauses 10 blocks chosen in Client mixin
    // }
}
