SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

CollideBlockEvent.Impact should work on non-projectile entities.

Open Yeregorix opened this issue 8 years ago • 6 comments

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.

Yeregorix avatar Dec 27 '16 13:12 Yeregorix

Well, in base Minecraft nothing is a projectile that doesn't need to be, really.

codeHusky avatar Dec 27 '16 14:12 codeHusky

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

simon816 avatar Dec 27 '16 23:12 simon816

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.

Yeregorix avatar Dec 29 '16 09:12 Yeregorix

So essentially you want CollideBlockEvent.Impact to be valid for all entities, not just projectiles?

ryantheleach avatar Aug 03 '18 11:08 ryantheleach

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.

Yeregorix avatar Aug 03 '18 12:08 Yeregorix

[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.

2020-04-19 12-18-17_)

SimonBHB avatar Apr 19 '20 19:04 SimonBHB