#(newNuriset) Player entity floating

73 messages · Page 1 of 1 (latest)

tribal field
#

I summoned Player NPC via API, but if it take damage, it float, but never going down, keep float midair.

granite sluiceBOT
#

(newNuriset) Player entity floating

granite sluiceBOT
#

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.

stable swallow
#

seems so weird...

#

!logs

jade oracleBOT
# stable swallow !logs
Info: 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
#

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?

sharp vapor
#

Please post some logs just to confirm the version you're using

#

@tribal field

tribal field
tribal field
#

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
            }
        }
    }
}```
tribal field
#

problems conclusion:

  1. while trait is activated, wandering still works
  2. even target is null, pitch is not going back to 0
  3. become slower while targeting enemies
sharp vapor
#

@tribal field please post logs when you can

tribal field
#

sorry for being late

sharp vapor
jade oracleBOT
# sharp vapor !logcheck
Cannot Scan Attached File

Attached file has unrecognized or unsupported file extension. Use .log for log files, and .dsc for Denizen scripts.

sharp vapor
#

Can you use the paste site @tribal field

tribal field
#

ok

sharp vapor
#

!logs

jade oracleBOT
# sharp vapor !logs
Info: 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.

sharp vapor
#

@tribal field it's here

tribal field
#

ok

#
sharp vapor
#
jade oracleBOT
# sharp vapor !logcheck https://paste.denizenscript.com/View/129460
Server Version

Paper version 1.21.4-65-main@287eb52 (2024-12-28T23:19:11Z)

Plugin Version(s)

Citizens v2.0.37-SNAPSHOT (build 3659) -- (Current build :white_check_mark:)

Checked For

@sharp vapor

Other Noteworthy Plugin(s)

ProtocolLib v5.4.0-SNAPSHOT-738

Potentially Bad Line(s)

[19:34:35] [Server thread/ERROR]: [Citizens] The trait attackmeleetrait failed to load for NPC ID: 36. :warning: Log contains error messages.

tribal field
#

well i think bad lines doesnt matter - i remove all npcs upon world load.

sharp vapor
#

You shouldn't set target every tick

#

There's metadata to reset pitch every tick

tribal field
#

?

#

then how i can set target

#

another way beside Trait#run?

sharp vapor
#

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

tribal field
#

oh.

#

i got what you mean

#

letme test

tribal field
#

wait

#

is Trait activated only one at a time?

tribal field
#

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

sharp vapor
sharp vapor
sharp vapor
#

@tribal field

tribal field
#

oh

#

testing out yet

tribal field
sharp vapor
#

@tribal field did you fix it?

tribal field
sharp vapor
tribal field
#

targeting at me

#

following while looking at floor

sharp vapor
tribal field
#

no, i mean, they targeting my feet

sharp vapor
#

@tribal field can you send a video and confirm that you are setting pitch to 0 before settarget?

tribal field
#

uh

#

im at school so imma send later

violet zealotBOT
#
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.)

#

@tribal field

tribal field
#

imma handle it myself

#

ty for help