When writing a plugin, I ran into a problem. I need to get the entity that fired the shulker bullet.
Seems not hard to do.
We could even add the targeted entity and its direction.
I'm not 100% sure that a shulker bullet is a projectile in the classic sense.
But it should fit I think, and it should be doable. If it isn't it should at least be possible to expose some API for what you need.
It's not a projectile in the Minecraft source code, it's just an Entity with a Living owner and an Entity target (with a bonus direction).
Edit: Forgot to mention I am trying to implement it.
I was able to get the required entity via the IndirectEntityDamageSource. But this method is not very convenient, it would be better to get through Projectile.
We _could_ make it a Sponge DamagingProjectile, and the Shulker would be a ProjectileSource.
I think this will require more thoughts.
The ShulkerBullet needs a target otherwise it would be useless (its vertical motion would just decrease), and with the actual Projectiles it is impossible to give a target, just a velocity.
Also EntityShulkerBullet does not use an AI task, but just onUpdate to track the target and decide where to go in order to reach it.
It could be a simple Projectile / DamagingProjectile or a whole new thing. Maybe a projectile variant like TargetingProjectile and a new ProjectileSource#launchProjectile overload to take a target.
I'm curious if we're allowed to modify the shulker bullet to simply tell it to move in a certain direction. I reviewed the onUpdate for it and it can be easily modified to use custom data fields that we set ourselves while avoiding vanilla's data, this way the shulker bullet will act with vanilla in mind, or if our data is not null, use our custom block position to point to a target.
This would be an added modification that we would have to maintain of course, something that I can see being done similarly to how mine carts are currently modified, or how the vanish api functions.
I haven't seen that onUpdate recently but it is definitely possible to make the bullet target a Location or follow a specific Direction.
Most helpful comment
I'm curious if we're allowed to modify the shulker bullet to simply tell it to move in a certain direction. I reviewed the
onUpdatefor it and it can be easily modified to use custom data fields that we set ourselves while avoiding vanilla's data, this way the shulker bullet will act with vanilla in mind, or if our data is not null, use our custom block position to point to a target.This would be an added modification that we would have to maintain of course, something that I can see being done similarly to how mine carts are currently modified, or how the vanish api functions.