#(Latestion) NPC spawn API
62 messages · Page 1 of 1 (latest)
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>
@south quarry how are you giving the location
/npc create -c for center may help
or --at x:y:z
Oh i am sorry.
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?
(Latestion) NPC spawn API
@south quarry what's your code
the /npc path code works with the Waypoints trait
package index
Ohh gothc
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;
}
I would clone your locations as best practice
@south quarry try cloning your locations
LinearWaypointProvider provider = (LinearWaypointProvider) npc.getOrAddTrait(Waypoints.class).getCurrentProvider();
ok, and what's the location?
The orange blocks
Oh
Its method value
@lucid nacelle Its weird, they just stop 1 block behind or sometimes they dont
@south quarry can you print out the value of loc
if you're talking about the waypoint, that's a separate discussion on pathfinding
Location is definitely correct, because during pathfinding it does go the proper location sometimes.
you can also use HomeTrait if you want to accomplish this
pathfinding always pathfinds to the centre of the block
so I need to know what loc is
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
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
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 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 ^
ohh f
sorry sorry