• Hello Guest! Did you know that ProjectKorra has an official Discord server? A lot of discussion about the official server, development process, and community discussion happens over there. Feel free to join now by clicking the link below.

    Join the Discord Server

Ability hurts myself and disappears

Gareth Swan

Verified Member
Hey so I have 2 issues with an ability I'm working on.
Firstly, even after adding:
Code:
        for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, collisionRadius)) {
            if (entity instanceof Entity && entity.getUniqueId() != player.getUniqueId()) {
                DamageHandler.damageEntity(entity, player, damage, this);
                remove();
                return;
The ability can still hurt myself. And secondly, if I look straight forward or down a bit when using the ability, it doesn't progress forward and just disappears. It displays one flash of the particles and plays the sound but then disappears
 

Loony

Verified Member
Hey so I have 2 issues with an ability I'm working on.
Firstly, even after adding:
Code:
        for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, collisionRadius)) {
            if (entity instanceof Entity && entity.getUniqueId() != player.getUniqueId()) {
                DamageHandler.damageEntity(entity, player, damage, this);
                remove();
                return;
The ability can still hurt myself. And secondly, if I look straight forward or down a bit when using the ability, it doesn't progress forward and just disappears. It displays one flash of the particles and plays the sound but then disappears
Try adding an else statement with a return & a broadcast
 

Simplicitee

Staff member
Plugin Developer
Verified Member
Hey so I have 2 issues with an ability I'm working on.
Firstly, even after adding:
Code:
        for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, collisionRadius)) {
            if (entity instanceof Entity && entity.getUniqueId() != player.getUniqueId()) {
                DamageHandler.damageEntity(entity, player, damage, this);
                remove();
                return;
The ability can still hurt myself. And secondly, if I look straight forward or down a bit when using the ability, it doesn't progress forward and just disappears. It displays one flash of the particles and plays the sound but then disappears
Use getEntityId instead of getUniqueId
 

Simplicitee

Staff member
Plugin Developer
Verified Member
Also you shouldn't do 'entity instanceof Entity', that's a redundant check because the list is already Entity
 

StrangeOne101

Staff member
Plugin Developer
Moderator
Verified Member
As @Simplicitee said, you shouldn't be testing if entity is an instanceof Entity. You need to test for a LivingEntity. LivingEntities are the ones we want to damage (other ones are things like items, arrows, paintings, etc).

I also recommend doing !entity.getUniqueId().equals(player.getUniqueId()) instead of
entity.getUniqueId() != player.getUniqueId(). Try that. ;)
 

Gareth Swan

Verified Member
As @Simplicitee said, you shouldn't be testing if entity is an instanceof Entity. You need to test for a LivingEntity. LivingEntities are the ones we want to damage (other ones are things like items, arrows, paintings, etc).

I also recommend doing !entity.getUniqueId().equals(player.getUniqueId()) instead of
entity.getUniqueId() != player.getUniqueId(). Try that. ;)
Thank you! I'll give that a go
 
Top