mojira.dev
MC-154458

Thrown items do not copy item data to the entity if it's the last item in the stack

Using the following item in survival mode:

/give @s minecraft:snowball{custom:true} 2

Command to verify data:

/data get entity @e[type=minecraft:snowball,limit=1] Item

When there's more than 1 item left in the stack, /data will show the item's data. If the snowball thrown was the last item in the stack, the Item will be nonexistent.

Linked issues

Comments 1

Code analysis in net.minecraft.world.item.SnowballItem

 

// Item stack decrement should be done after entity.setItem
// if (!user.abilities.creativeMode) {
//     stack.decrement(1);
// }

level.playSound(null, user.x, user.y, user.z, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (RANDOM.nextFloat() * 0.4F + 0.8F));
if (!level.isClient) {
    SnowballEntity entity = new SnowballEntity(level, user);
    entity.setItem(stack);
    entity.a(user, user.pitch, user.yaw, 0.0F, 1.5F, 1.0F);
    level.spawnEntity(entity);
}

 

Skylinerw

boq

Unconfirmed

(Unassigned)

Minecraft 1.14.2, Minecraft 1.14.3 Pre-Release 2

Retrieved