#(newNuriset) Player entity floating
73 messages · Page 1 of 1 (latest)
(newNuriset) Player entity floating
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.
Please post your full latest log file.
Background Info: One of the most helpful tools to identifying the source of a problem is your server logs file! Logs contain all sorts of important information like server and plugin versions, any error messages, and a lot more important information (More Info).
How To: Your log can be found in the logs folder within your server folder. The most recent log is a text file labeled latest.log. To get help using these logs, please open that file in a text editor and copy all of the text, then open https://paste.denizenscript.com/New/Log and paste the text into the box on the page. Then click "Submit" and copy the URL and paste that back into this channel.
Please do not upload the file to Discord or to other pastebin services, use the log pastebin linked above.
no logs
it did not throw error
instead i will give you spawn code:
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "mob");
npc.addTrait(AttackMelee.class);
npc.spawn(/* some location */);
public class AttackMelee extends Trait {
public AttackMelee() {
super("AttackMeleeTrait");
}
@Override
public void run() {
if (!npc.isSpawned()) return;
Player target = findTarget();
if (target != null) {
npc.getNavigator().setTarget(target, true);
if (target.getNoDamageTicks() == 0) {
attack(target);
}
}
}
private Player findTarget() {
return npc.getEntity().getWorld().getNearbyEntities(npc.getEntity().getLocation(), 10, 10, 10)
.stream()
.filter(entity -> entity instanceof Player)
.filter(entity -> !entity.getUniqueId().equals(npc.getEntity().getUniqueId()))
.map(player -> (Player) player)
.findFirst()
.orElse(null);
}
@SneakyThrows
private void attack(Player target) {
Entity entity = npc.getEntity();
if (target != null && entity.getLocation().distance(target.getLocation()) <= 1) {
if (entity instanceof LivingEntity attacker) attacker.swingMainHand();
target.damage(25, entity);
}
}
uh, they're behaving like they have no gravity?
is it NPC#getNavigator#setTarget issue?
i mean is they did not affect whether floor is air
oh wait
they have gravity while wandering
only when my custom trait is activated
import net.citizensnpcs.api.trait.Trait;
import org.bukkit.GameMode;
import org.bukkit.entity.*;
public class AttackMelee extends Trait {
public AttackMelee() {
super("AttackMeleeTrait");
}
@Override
public void run() {
if (!npc.isSpawned()) return;
npc.getDefaultGoalController().setPaused(false); // Seems this not working, i use wandering to use WanderGoal, but npc shaking head while tracking me
npc.getEntity().getLocation().setPitch(0); // Why this not working?
Player target = findTarget(10); // This return nearest player within 10 blocks
if (target != null) {
npc.getNavigator().setTarget(target.getLocation()); // get slower while targeting
npc.faceLocation(target.getLocation());
npc.getDefaultGoalController().setPaused(true);
if (target.getNoDamageTicks() == 0) {
attack(target); // actual attack logic
}
}
}
}```
problems conclusion:
- while trait is activated, wandering still works
- even target is null, pitch is not going back to 0
- become slower while targeting enemies
@tribal field please post logs when you can
!logcheck
Can you use the paste site @tribal field
!logs
Please post your full latest log file.
Background Info: One of the most helpful tools to identifying the source of a problem is your server logs file! Logs contain all sorts of important information like server and plugin versions, any error messages, and a lot more important information (More Info).
How To: Your log can be found in the logs folder within your server folder. The most recent log is a text file labeled latest.log. To get help using these logs, please open that file in a text editor and copy all of the text, then open https://paste.denizenscript.com/New/Log and paste the text into the box on the page. Then click "Submit" and copy the URL and paste that back into this channel.
Please do not upload the file to Discord or to other pastebin services, use the log pastebin linked above.
@tribal field it's here
ok
Content of Server Log Paste #129460: Logs... pasted 2024/12/29 02:35:57 UTC-08:00, Paste length: 11835 characters across 114 lines, Content: [19:34:23] [ServerMain/INFO]: [bootstrap] Running Java 21 (OpenJDK 64-Bit Server VM 21.0.3+9-LTS; Amazon.com Inc. Corretto-21.0.3.9.1) on Windows 10 10.0 (amd64) [19:34:23] [ServerMain/INFO...
Content of Server Log Paste #129460: Logs... pasted 2024/12/29 02:35:57 UTC-08:00, Paste length: 11835 characters across 114 lines, Content: [19:34:23] [ServerMain/INFO]: [bootstrap] Running Java 21 (OpenJDK 64-Bit Server VM 21.0.3+9-LTS; Amazon.com Inc. Corretto-21.0.3.9.1) on Windows 10 10.0 (amd64) [19:34:23] [ServerMain/INFO...
Paper version 1.21.4-65-main@287eb52 (2024-12-28T23:19:11Z)
Citizens v2.0.37-SNAPSHOT (build 3659) -- (Current build :white_check_mark:)
@sharp vapor
ProtocolLib v5.4.0-SNAPSHOT-738
[19:34:35] [Server thread/ERROR]: [Citizens] The trait attackmeleetrait failed to load for NPC ID: 36. :warning: Log contains error messages.
well i think bad lines doesnt matter - i remove all npcs upon world load.
You should only set it if there isn't a target already
You are just going to lag the server if you set it every tick
The problem is that settarget changes the entity onground state
seems working good, except one, how to make npc un-target player when player's gamemode is not survival?
+following player with fixed initial pitch and yaw
you should be able to figure this one out
need more information
@tribal field
well its fixed but now they look at feet of me
@tribal field did you fix it?
yes bedside this
When do they look at feet
Did you try resetting the pitch before?
no, i mean, they targeting my feet
@tribal field can you send a video and confirm that you are setting pitch to 0 before settarget?
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.)
@tribal field