Search in sources :

Example 1 with CollideOption

use of thpmc.vanilla_source.api.util.collision.CollideOption in project VanillaSource by TheHollowPlanetMC.

the class TestListener method onChat.

@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
    Player player = event.getPlayer();
    if (!event.getMessage().equals("spawn"))
        return;
    TaskHandler.runSync(() -> {
        Location location = player.getLocation();
        INMSHandler nmsHandler = VanillaSourceAPI.getInstance().getNMSHandler();
        GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "NPC");
        NMSEntityController entityPlayer = nmsHandler.createNMSEntityController(location.getWorld(), location.getX(), location.getY(), location.getZ(), EntityType.PLAYER, gameProfile);
        entityPlayer.setPositionRaw(location.getX(), location.getY(), location.getZ());
        CollideOption collideOption = new CollideOption(FluidCollisionMode.NEVER, true);
    /*
            collideOption.setCollideBlockFunction(engineBlock -> {
                return engineBlock.getMaterial() != Material.GLASS;
            });*/
    /*
            VanillaSourceAPI.getInstance().getTickRunnerPool().spawn(tickRunner -> {
                EnginePlayerEntity npc = new EnginePlayerEntity(tickRunner.getThreadLocalCache().getWorld(location.getWorld().getName()), (NMSEntityPlayer) entityPlayer, tickRunner, true);
                npc.getGoalSelector().registerGoal(0, new EntityFollowGoal(player));
                npc.setMovementCollideOption(collideOption);
                tickRunner.addEntity(npc);
            });*/
    });
}
Also used : Player(org.bukkit.entity.Player) GameProfile(com.mojang.authlib.GameProfile) CollideOption(thpmc.vanilla_source.api.util.collision.CollideOption) NMSEntityController(thpmc.vanilla_source.api.nms.entity.NMSEntityController) INMSHandler(thpmc.vanilla_source.api.nms.INMSHandler) EventHandler(org.bukkit.event.EventHandler)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1 INMSHandler (thpmc.vanilla_source.api.nms.INMSHandler)1 NMSEntityController (thpmc.vanilla_source.api.nms.entity.NMSEntityController)1 CollideOption (thpmc.vanilla_source.api.util.collision.CollideOption)1