Troubles with transferring the inventory of one entity to the inventory of another entity

Started by Obzor on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Troubles with transferring the inventory of one entity to the inventory of another entity
Wed, 07/30/2025 - 13:48 (edited)

There are two procedures here:

According to the idea, if a custom creature kills a player, it takes all the items in player's inventory into it's inventory(1img)(The size of the entity's inventory is 100 slots). Then, when the player kills the entity, all the stolen items will drop(2img).

But in practice, if an entity dies(after killing a player with a full inventory), it drops a stack of items from only one random player slot. After a dozen tests, I still did not understand the logic of this behavior and what the problem is: in the procedure of copying the player's inventory or in the procedure of dropping items. 

I also ran a test with copying the player's inventory into the spawning chest, and it worked fine with the block's inventory(except that I had to make sure that no more than 27 slots would be occupied.), but I still don't know why the problem with the entity's is happening. 

Translated

 

Edited by Obzor on Wed, 07/30/2025 - 13:48