PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.37k stars 2.19k forks source link

Custom drops added via `PlayerDeathEvent#getDrops` are not spreaded on the ground like dropped inventory #10861

Open EpicPlayerA10 opened 3 weeks ago

EpicPlayerA10 commented 3 weeks ago

Expected behavior

Custom drops added via PlayerDeathEvent#getDrops should spread on the ground as far as the dropped inventory.

Observed/Actual behavior

Custom drops are dropped in player location without spreading it.

Steps/models to reproduce

  1. Make a plugin with this code: https://pastebin.com/sTgqQLQ8
  2. Run the server
  3. Die (execute /kill command)
  4. See that diamond that I added to custom drops is not spreading.

Plugin and Datapack List

[16:22:20 INFO]: Server Plugins (1):
[16:22:20 INFO]: Bukkit Plugins:
[16:22:20 INFO]:  - ExampleDropOnDeath
[16:22:45 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
[16:22:45 INFO]: There are no more data packs available

Paper version

[16:22:56 INFO]: Checking version, please wait... [16:22:56 INFO]: This server is running Paper version 1.20.6-137-master@bd5867a (2024-06-04T21:04:28Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT) You are running the latest version Previous version: 1.20.6-115-9d6f2cc (MC: 1.20.6)

Other

No response

electronicboy commented 3 weeks ago

the velocity for drops has already been applied to the items in that list, mutating it would just be adding new entities into the list (with unexpected behavior)

EpicPlayerA10 commented 3 weeks ago

Look what i mean: https://www.youtube.com/watch?v=SHTbn83wJHc . You can clearly see in this video that custom drop (diamond) is not spreading that far as other items that were in my inventory.

electronicboy commented 3 weeks ago

Yes, I know what you mean. Adding entities to that list will not go back and run them through the spreading logic, adding entities to that list can also result in unexpected behavior with other plugins do to the implementation (i.e. plugins can't just "remove" items from the list as they usually could)

EpicPlayerA10 commented 3 weeks ago

But there is some kind of mutation handling. When I remove item from that list it will just not drop. All items that are dropped (custom drops and normal drops like inventory) happens here: https://github.com/PaperMC/Paper/blob/bd5867a96f792f0eb32c1d249bb4bbc1d8338d14/patches/server/0932-Restore-vanilla-entity-drops-behavior.patch#L235-L242 There must be something going on with this runConsumer then.

EpicPlayerA10 commented 3 weeks ago

Oh yeah, i see. When I add custom drop to PlayerDeathEvent#getDrops then the Entity.DefaultDrop's value dropConsumer is set to null. https://github.com/PaperMC/Paper/blob/bd5867a96f792f0eb32c1d249bb4bbc1d8338d14/patches/server/0932-Restore-vanilla-entity-drops-behavior.patch#L188 And when dropConsumer is null then in this logic it will drop item in the player's location as a fallback. So the spreading is not applied because the dropConsumer applied that spreading and for some reason it is set to null when adding custom drop. https://github.com/PaperMC/Paper/blob/bd5867a96f792f0eb32c1d249bb4bbc1d8338d14/patches/server/0932-Restore-vanilla-entity-drops-behavior.patch#L69-L73