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 sc, IWorld w, BlockPos pos, BlockState state) {
        sc.setVar("block_loc", new Location(w, pos));
        sc.setVar("block_type", state.getBlock().getRegistryName().toString());
        sc.setVar("block", state.getBlock());
    }
    
    @SuppressWarnings("")
    public static void setBlockVars(Script sc, IWorld w, BlockPos pos) {
        BlockState state = w.getBlockState(pos);
        sc.setVar("block_loc", new Location(w, pos));
        sc.setVar("block_type", state.getBlock().getRegistryName().toString());
        sc.setVar("block", state.getBlock());
    }

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

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

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