SpongeAPI
SpongeAPI copied to clipboard
CollideBlockEvent.Impact should work on non-projectile entities.
All the entities can be projectiles, it only depends on the usage we have of them. For example, I need to launch an Item like a Projectile (with a Player as the ProjectileSource) and I need to listen to CollideBlockEvent.Impact but its only called for Projectiles.
It would be nice if we can do a kind of generalization of the Projectile interface for all entities. It would be an optional property of an Entity, for example an Arrow which currently implements Projectile is not really a projectile if I use it to sit down a player, like the old chairs plugins.
Well, in base Minecraft nothing is a projectile that doesn't need to be, really.
The Projectile interface is really used more for classification. In the vanilla code, there's not really much of a classification for this (other than EntityThrowable). When you call launchProjectile on a ProjectileSource, the behaviour is specific to the source/projectile combination.
If you try to launch an item from a player in the same way a player launches an arrow, the item would not launch like an arrow. This is because the behaviour for each item is unique (and not component-based).
You can see how ProjectileLauncher must configure each projectile manually, making it hard to generalise this to all entities
I can throw an item with an appropriate velocity, like a projectile but I still need to listen CollideBlockEvent.Impact but its only called for "real" projectiles.
So essentially you want CollideBlockEvent.Impact to be valid for all entities, not just projectiles?
That's it mainly. I think ~~ProjectileSource#launchProjectile can also be modified to accept all entities and~~ Projectile#getShooter/setShooter can be moved to Entity#getShooter/setShooter or maybe replaced by a data key/manipulator. That's just my point of view and it's open to debate.
Edit: ProjectileSource#launchProjectile for all entities is a bad idea. I think Projectile should only be a classification interface without any method but which indicates that Sponge is able to automatically configure the velocity when you call ProjectileSource#launchProjectile.
[Google Translate] Hi I find it a pity that the event does not fire when we hit the block. [FR] Salut Je trouve cela dommage que l'event ne se déclenche pas quand on tape le bloc.
