#(jimjams02) NPC EntityDamageEvent

25 messages · Page 1 of 1 (latest)

mellow crane
#

When an NPC has protection turned off and they are damaged, does it fire an EntityDamageEvent

bold sparrowBOT
#

(jimjams02) NPC EntityDamageEvent

#

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>

mellow crane
#

And another question

NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, boss.toString());
npc.spawn(location, SpawnReason.CREATE);
npc.setProtected(false);
entity = (LivingEntity) npc.getEntity();

entity.getPersistentDataContainer().set(bossKey, PersistentDataType.STRING, boss.toString());
        entity.customName(boss.getDisplayName());
        entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(50);
entity.setHealth(50);

Any idea why setting persistent data container, setting custom name, and setting the max health & setting health dont work

astral talon
#

Yes it will always fire that event but it will be cancelled

#

You should use citizens api to set custom name

#

Persistent data probably because the entity gets respawned

#

Max health should work

#

Maybe it’s also because the entity gets respawned

#

Maybe do the setup in a traits on spawn method to avoid that issue

green stirrupBOT
#
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.)

#

@mellow crane

mellow crane
#

You mean when i kill it?

astral talon
#

no, you haven't set a skin so it will respawn if the skin loads

#

@mellow crane

#

(also if chunk unloads/reloads)

mellow crane
#

So if i set a skin and dont unload the chunk should it solve the problem?

astral talon
#

As I said, you should use a trait

#

Or move code to npcspawnevent

mellow crane
#

That worked tysm