mojira.dev
MCPE-190794

Ender dragon not effected/hurt by custom projectile

In a my addon, I created a bullet projectile by copying most of the arrows components like minecraft:projectile and such. Instead of using an item to shoot the bullet, I used scripts instead.

I first spawn the bullet entity at the player, to then fling the bullet using the shoot method inside the projectile component.

I put together a stripped down version of the script.

/**
 * Shoots a bullet from the player. Similar to bow and arrow.
 * @param { Player }  player    - The player shooting.
 * @param { Vector3 } direction - The direction the bullet is shot.
 * @param { number }  spread    - How great the inaccuracy of the bullet.
 */

function fireBullet(player, direction, spread) {
  const projectile = player.dimension.spawnEntity("example:bullet", player.getHeadLocation())
  const component = projectile.getComponent("projectile")

  component.owner = player
  component.shoot(direction, { uncertainty: spread })

  console.log(component.owner.name)
}

This works as intended, the bullet is fired and entities/players get hurt on impact. However, this is not the case for the ender dragon. I assumed this is because the ender dragon cannot be effected by any entity other than the player. So, I set the owner property inside the projectile component to the player who is shooting. This does not work.

I used the console.log to read the owner name and it spits out the name of the player shooting.

I even tried running it through system.run to see if there was a difference

system.run(() => component.owner = player)

This did not change anything.

Comments 0

No comments.

Protoplosion

(Unassigned)

Unconfirmed

Multiple

Windows 10

1.21.62 Hotfix

Retrieved