package me.km.snuviscript;

import me.hammerle.snuviscript.code.Script;
import me.km.utils.Location;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;

public class ScriptVars {
    @SuppressWarnings("")
    public static void setBlockVars(Script qd, IWorld w, BlockPos pos) {
        BlockState state = w.getBlockState(pos);
        qd.setVar("block_loc", new Location(w, pos));
        qd.setVar("block_type", state.getBlock().getRegistryName().toString());
        qd.setVar("block", state.getBlock());
    }

    public static void setPlayerVars(Script qd, PlayerEntity p) {
        qd.setVar("player", p);
        qd.setVar("player_name", p == null ? null : p.getName().getFormattedText());
    }

    public static void setSecPlayer(Script qd, PlayerEntity p) {
        if(p != null) {
            qd.setVar("sec_player", p);
            qd.setVar("sec_player_name", p.getName().getFormattedText());
        }
    }

    public static void setEntityVars(Script qd, Entity ent) {
        qd.setVar("entity", ent);
    }
}
