Inconsistencies in stack size when placing an item that spawns an entity
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
When an item is consumed to spawn an entity, like a player playing an armor stand, or a dispenser placing a boat or minecart, an "entity spawn" event is fired. There are several of these:
- CreatureSpawnEvent: For any entity which extends nms.LivingEntity
- ItemSpawnEvent: For any itemstacks
- VehicleCreateEvent: For any entity which implements api.Vehicle
- ProjectileLaunchEvent: For any entity implements api.Projectile
- LightningStrikeEvent: self-explanatory
- EntitySpawnEvent: The fallback event for all entities which do not have a more specialized event
All of these are cancellable and this raises the question of what to do if the "spawn" event is cancelled when the cause is an item being consumed. Should the item be consumed or not? I would expect this to be consistent across the server between all entity types. But it is not.
Observed/Actual behavior
Currently, the server sometimes consumes the item, and sometimes does not just depending on the entity type itself.
I will try to compile a list of all instances of this, but I'm sure to miss some so I'll update this as more are brought to my attention.
Dispensers
TNT: Always consumed
Projectiles: Always consumed
Armor Stand: Always consumed
Boats: Consumed only if spawn is allowed
Minecarts: Consumed only if spawn is allowed
Spawn Egg: Always consumed
Players
Hanging Entities: Always consumed (Item Frames, Paintings, Fence Leash Knots
Armor Stand: Always consumed
End Crystal: Always consumed
Fireworks: Consumed only if spawn is allowed (different behavior to dispensed fireworks)
Spawn Egg: Consumed only if spawn is allowed (different behavior to dispensed spawn eggs)
Minecarts: Consumed only if spawn is allowed
Boats: Consumed only if spawn is allowed
Ender Pearl, Eye of Ender, Egg, Snowball, XP Bottle, Trident: Consume only if spawn is allowed
Steps/models to reproduce
Just take any of the examples from above, cancel the right event and see the result. There is also a secondary issue that for many of the instances where the item is not consumed, the client still thinks that it was so there is inventory desync until a resync happens.
Plugin and Datapack List
none
Paper version
build 329
Other
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the listed player and dispenser cases while cancelling each relevant spawn event, then trace the corresponding entity-placement paths. Compare item consumption with the client inventory state. Done means the affected paths follow one documented, consistent cancellation rule and no longer cause inventory desynchronization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend, game-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100