Paper
Paper copied to clipboard
Add ItemSpawnEntityEvent and BlockPlaceEntityEvent and expand EntityPlaceEvent
WIP so far, still adding spots these events should be called, but should be a catch-all now for non-hanging entities spawned as a result of item "placement".
Resolves https://github.com/PaperMC/Paper/issues/4795 Resolves https://github.com/PaperMC/Paper/issues/6898 Supersedes https://github.com/PaperMC/Paper/pull/4184
Changes
Adds ItemSpawnEntityEvent Adds PlaceEntityEvent (extends ItemSpawnEntityEvent) Adds BlockPlaceEntityEvent (extends PlaceEntityEvent) Makes EntityPlaceEvent extend PlaceEntityEvent
Added an ItemStack field on ItemSpawnEntityEvent since that applies to all uses of that event and EntityPlaceEvent.
New Event Calls
ItemSpawnEntityEvent
- Spawn eggs from dispensers and players
EntityPlaceEvent (player only)
- mob eggs from players
BlockPlaceEntityEvent (dispenser only)
- boats
- armor stand
- mob buckets
- tnt
### Entity Placements
- [x] Spawn Eggs - ItemSpawnEntityEvent (dispenser w/null player)
- [x] Boats - EntityPlaceEvent/BlockPlaceEntityEvent
- [x] ~~Item Frame, Painting, Leash~~ (HangingPlaceEvent) (can't change due to API break)
- [x] Armor Stand - EntityPlaceEvent/BlockPlaceEntityEvent
- [x] End Crystals - EntityPlaceEvent
- [x] Fish Buckets - EntityPlaceEvent/BlockPlaceEntityEvent
- [x] ~~Fireworks~~ already tracks its spawning stack and shooter
- [x] ~~Fire Charges~~ already tracks its spawning stack and shooter
- [x] PrimedTNT BlockPlaceEntityEvent
This is not the same as https://github.com/PaperMC/Paper/pull/4184?
@molor a couple differences with that
- Its type inhertiance doesn't integerate with EntityPlaceEvent
- this provides access to the blockface
- no "entity setter", that really doesn't make sense with how the API deals with entities IMO
- This PR expands EntityPlaceEvent in addition to adding a new event
This would probably also close #6898, at least in regards to what I initially wanted to achieve.
Something I'm not sure about, are fire charges from dispeners? those technically do spawn an entity from an itemstack. but its different because a player can't do the same thing.
I would say the event should be called in this case, as it otherwise would be inconsistent to call the events for something like fireworks and spawn eggs, but not for fire charges. And to me it would be more likely for someone wanting to modify the dispensed fire charge, then someone wondering why there's always a null player on an entity which cannot be "summoned" by a player.
Ok, that makes sense, but should it be EntityPlaceEvent or ItemSpawnEntityEvent? I’m leaning to EntityPlaceEvent even tho it’s more of a launch. (Like fireworks I guess)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I've decided against adding Fire Charges and fireworks. I don't want to add any projectiles. They already have api that tracks their spawning stack and shooter. I did add PrimedTNT to the list, since a dispenser is placing that and its creating an entity.
Rebased for 1.19
Rebased and updated for 1.19.3. Reworked things a big to keep EntityPlaceEvent a player-only event.
This can consider the staled #6487 ? its like the #6898 created later.. mostly for the Wither/Golems created using blocks detect how and who build (for avoid things like try listen place blocks and spawn for try make that)
Rebased for 1.20.4
gave this a look over as much as I can with my level of sleep and sight, overall looks fine of what I've seen
Rebased for 1.20.6
Half a year has passed. Has this PR been forgotten? Up to now, there is still a lack of an event for tracking the generation of fish by using buckets.