#Entities stopping code after it & not detecting entities around it properly

1 messages · Page 1 of 1 (latest)

frosty flicker
#

I have a sword that spawns an entity (a "projectile") which is supposed to move forward and damage mobs it hits. But when I spawn multiple, only the entity closest to the world origin will move and the next entity only moves when the one before it dies. None of the projectiles are actually damaging anything like they should... When the entity is in the world, all of the code other than that entity's process will stop. (The for (let player of world.getPlayers()) { player.runCommandAsync('titleraw @s actionbar {"rawtext": [{"text": "§9✎"}, {"score":{"name": "@s","objective": "mana"}}]}'); } for example, will not run until all the entities are dead.)

I'm using @minecraft/server 1.12.0-beta

For some reason removing all of ```js
let player = entity.dimension.getPlayers({
closest:1
});
let proj1hitentities = entity.dimension.getEntities({
maxDistance: 2,
excludeTypes: ['villager', 'armor_stand', 'xp_orb', 'item', 'npc', 'box:projectile1'],
excludeNames: [player.name],
location: entity.location,
closest:1
});
proj1hitentities.applyDamage(500)
if (proj1hitentities){
entity.kill();
}

river glade
#

Thats bc of closest: 1

#

It literally returns only the closest entity from the specified location

frosty flicker
#

But it excludes itself, it finds something that isn't in excludeTypes

#

And thats just for damaging an entity it hits it doesn't explain the movement

heavy ferry
#
 let player = entity.dimension.getPlayers({ 
            closest:1
        })[0];
        let proj1hitentities = entity.dimension.getEntities({
            maxDistance: 2,
            excludeTypes: ['villager', 'armor_stand', 'xp_orb', 'item', 'npc', 'box:projectile1'],
            excludeNames: [player.name],
            location: entity.location,
            closest:1
        })[0];
        proj1hitentities.applyDamage(500)
        if (proj1hitentities){
            entity.kill();
        }
frosty flicker
# heavy ferry try this

That did fix it not killing entites, thanks for that

however it still has the weird issue of only moving 1 projectile at a time and halting all other code