Accessories

Accessories

4M Downloads

Accessory items drop incorrectly (differently from vanilla inventory items), breaking data packs

GrantGryczan opened this issue · 9 comments

commented

Environment

Minecraft 1.21.1
NeoForge 21.1.148
accessories-neoforge-1.1.0-beta.35+1.21.1.jar
owo-lib-neoforge-0.12.15.1-beta.3+1.21.jar

This issue occurs in NeoForge and not Fabric.

Description

When inventory items drop in vanilla, they always drop 0.3 blocks below the player's eyes, with a PickupDelay of 40 ticks.

Items from Accessories slots, on the other hand, drop at a seemingly random position relative to the player (both horizontally and vertically), and they have zero PickupDelay.

This causes data packs which rely on these item properties to detect whether the items originated from the player's inventory, such as the Graves data pack from Vanilla Tweaks, to fail to detect these items (causing #131).

Reproduction Steps

Place a repeating command block set to Always Active with the following command inside:

execute as @e[type=item,nbt={Age:0s}] run tellraw @a [{"selector":"@s"},": {PickupDelay: ",{"entity":"@s","nbt":"PickupDelay"},", Pos: ",{"entity":"@s","nbt":"Pos"}]

This will display the PickupDelay and Pos NBT tags of any new item that drops.

Once that repeating command block is active and set (you can verify it is by dropping any item), follow these steps:

  1. Put one item in your vanilla inventory, and a different item in an Accessories slot.
  2. Note your current exact X, Y, and Z coordinates.
  3. Enter /kill @s to kill yourself.

Observe in chat that the vanilla inventory item always drops at the exact same X and Z coordinates, with a Y coordinate 0.3 blocks below wherever your eyes were. If your player entity scale is 1.0 (the default) and you're standing up normally, this will be exactly 1.32 blocks above the Y coordinate you were at before you died.

Furthermore, the vanilla inventory item always drops with a PickupDelay set to 40s.

On the other hand, the item in the Accessories slot drops with a PickupDelay of 0s, and the coordinates are randomized.

commented

Such update has been made that should fix the issue for 1.21.1

commented

Awesome, thanks for the swift fix!

commented

@GrantGryczan Were you on the latest version of Accessories for 1.21.1, just want to confirm version, loader and Minecraft is all.

commented

@Dragon-Seeker Sorry, edited the issue to include my environment information.

commented

On fabric we just inject the list of entries into the players inventory drop callback running the exact same code for dropping stacks but on Neoforge we use the LivingDropsEvent that handles dropping the stacks as ItemEntity so unknown to how such needs to handled.

commented

I'll test this on Fabric as well since you say it's handled differently there. I'm a data pack developer, not a modder, so unfortunately I don't have the experience to help with implementation details too much, only the desired outcome. But let me know if there's any other information I can provide.

commented

The logic for creating the ItemEntity can be found here and I guess this must be edit to follow Player.drop method. Problem is the method on a ServerPlayer places the entity in the world but I do not think such should happen for the Neo event... wish neoforge handled such for me here.

commented

Works perfectly in Fabric! Only the NeoForge version has this bug.

commented

Will make adjustments to the ItemEntity creation code to emulate what occurs for the player inventory to properly have this work though I be other on Neoforge may run into this exact problem with spawning the dropped stack so good for future reference I guess.