#(Latestion) NPC spawn API

62 messages · Page 1 of 1 (latest)

viral waveBOT
#

(Latestion) NPC spawn

#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

lucid nacelle
#

@south quarry how are you giving the location

#

/npc create -c for center may help

#

or --at x:y:z

south quarry
#

I am using API

#

For some reason I cant figure out how to make the api works lol, everything works great with commands

#

/npc path How does that work with the API?

south quarry
#

(Latestion) NPC spawn API

lucid nacelle
#

@south quarry what's your code

#

the /npc path code works with the Waypoints trait

south quarry
south quarry
# lucid nacelle <@484409542080331797> what's your code
  public GuardTest spawnEntity(Location location) {
        this.loc = location;

        npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "Guard");

        id = npc.getId();

        sentinel = npc.getOrAddTrait(SentinelTrait.class);
        if (type == CellGuardType.ATTACK) {
            setSkin();

            sentinel.spawnPoint = loc;
            sentinel.addTarget("players");
            sentinel.chaseRange = 10.0;
            // sentinel.rangedChase = true;

            LinearWaypointProvider provider = new LinearWaypointProvider(npc);
            provider.addWaypoint(new Waypoint(loc));

            npc.data().setPersistent(NPC.Metadata.COLLIDABLE, !npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected()));
        }
        // Set a single point in /npc path. It will stand and guard that spot, and return there when not in combat.
        // npc respawn -1

        npc.spawn(loc);

        return this;
    }
lucid nacelle
#

I would clone your locations as best practice

south quarry
#

Its a TestClass

#

Will fix it later

#

@lucid nacelle any reasons for this?

lucid nacelle
#

@south quarry try cloning your locations

#

LinearWaypointProvider provider = (LinearWaypointProvider) npc.getOrAddTrait(Waypoints.class).getCurrentProvider();

south quarry
#

Will do

#

@lucid nacelle that works, but spawning them is still a tad bit off

lucid nacelle
#

ok, and what's the location?

south quarry
lucid nacelle
#

no, in java

#

what is the value of loc

south quarry
#

Oh

#

Its method value

#

@lucid nacelle Its weird, they just stop 1 block behind or sometimes they dont

lucid nacelle
#

@south quarry can you print out the value of loc

#

if you're talking about the waypoint, that's a separate discussion on pathfinding

south quarry
lucid nacelle
#

you can also use HomeTrait if you want to accomplish this

south quarry
#

Oh

#

Which is better lol

lucid nacelle
#

pathfinding always pathfinds to the centre of the block

#

so I need to know what loc is

south quarry
#

Ill send it wait

lucid nacelle
#

yeah, so your location is at the block edge

#

if you want it centred then center it

#

if you have an issue with the waypoint, open a new thread

mellow flameBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@south quarry

south quarry
#

F

#

my bad man, thanks a lot

mellow flameBOT
#

@south quarry

Thread Close Blocked

Thread was closed either automatically by timeout or by the Discord manual close button. If closing was intentional, please use </resolved:1028673926114594866> or </invalid:1028673926898909185>.

#

@south quarry

Thread Close Blocked

Thread was closed either automatically by timeout or by the Discord manual close button. If closing was intentional, please use </resolved:1028673926114594866> or </invalid:1028673926898909185>.

lucid nacelle
#

@south quarry ^

south quarry
#

ohh f

pastel parrotBOT
south quarry
#

sorry sorry