-
Bug
-
Resolution: Fixed
-
Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12.2, Minecraft 1.13-pre1, Minecraft 1.13.1
-
Confirmed
-
(Unassigned)
The bug
Mobs with a drop chance of 0 can still drop their item when they pick up a better item. With a drop chance of exactly 0 this happens in about 10% of the cases where a mob picks up an item.
How to reproduce
- Summon multiple mobs with a drop chance of 0. Do this for example by using the following command multiple times
/execute @e ~ ~ ~ /summon husk ~ ~ ~ {CanPickUpLoot:1b,HandItems:[{id:"stone",Count:1b}],HandDropChances:[0f,0f]}
- Summon a better item for all mobs
/execute @e[type=husk] ~ ~ ~ /summon item ~ ~ ~ {Item:{id:"wooden_sword",Count:1b}}
- Wait until the mobs have picked up the sword
- List all items
/say @e[type=item]
→ You should see stone items being listed; if not repeat the steps again
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The method net.minecraft.entity.EntityLiving.updateEquipmentIfNeeded(EntityItem) uses the condition (double)(this.rand.nextFloat() - 0.1F) < dropChance to drop the current item. This creates problems like this because for example 0 - 0.1 < 0. Additionally this calculation breaks the concept of drop chances. For example a very unlikely dropped item with a chance of 0.0001% is suddenly dropped in 10.0001% of all cases where a mob picks up an item.
A better calculation could for example be
(double)(this.rand.nextFloat()) * 0.9 < d0
- relates to
-
MC-2958 Custom mobs and normal Vexes drop equipped items with looting despite DropChances set to 0
- Resolved