NeoForge icon indicating copy to clipboard operation
NeoForge copied to clipboard

Duplication issue with /give command and custom item entity in Item class

Open Tiviacz1337 opened this issue 11 months ago • 2 comments

Minecraft Version: 1.21.1 (Probably more affected)

NeoForge Version: 21.1.93 Logs: No logs Code:

  • https://github.com/Tiviacz1337/Travelers-Backpack/blob/1.21-neoforge/src/main/java/com/tiviacz/travelersbackpack/items/TravelersBackpackItem.java#L212-L259

Notes for easier reproduction:

  • hasCustomEntity(ItemStack stack) -> change return hasCustomData(stack) to return true

Steps to Reproduce:

  1. execute /give <playerName> travelersbackpack:bat command
  2. 1 Copy of item lands in player inventory, second copy is created and is being thrown in world

Description of issue: When a modded item implements the hasCustomEntity method and the createEntity method to create a custom entity when added to the world, it causes the entity to duplicate when the /give command is used

Tiviacz1337 avatar Jan 10 '25 12:01 Tiviacz1337

This is a very old bug, see MinecraftForge/MinecraftForge#7785 and the issues it links. See also MinecraftForge/MinecraftForge#2349 which was reported fixed.

KnightMiner avatar Jan 10 '25 14:01 KnightMiner

So workarounds are needed? The second issue has the solution proposed but it seems like it was never introduced. Then reported that bug does not occur in 1.13, but it happens now.

Tiviacz1337 avatar Jan 10 '25 15:01 Tiviacz1337