package eu.mhsl.minenet.minigames.util;

import eu.mhsl.minenet.minigames.world.BlockPallet;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block;

public class Intersect {
    public static boolean withPressurePlate(Instance instance, BlockPallet target, Pos playerPosition) {
        Pos[] corners = {
                playerPosition.add(0.3-Position.PIXEL, 0, 0.3-Position.PIXEL),
                playerPosition.add(0.3-Position.PIXEL, 0, -0.3+Position.PIXEL),
                playerPosition.add(-0.3+Position.PIXEL, 0, 0.3-Position.PIXEL),
                playerPosition.add(-0.3+Position.PIXEL, 0, -0.3+Position.PIXEL)
        };

        for(Pos coroner : corners) {
            Block pressed = instance.getBlock(coroner);
            if(target.contains(pressed) && playerPosition.y() < playerPosition.blockY() + Position.PIXEL)
                return true;
        }

        return false;
    }

}
