-
Bug
-
Resolution: Unresolved
-
None
-
1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4 Pre-release 3, 1.19.4, 23w18a, 1.20.1, 1.20.4, 24w05b, 24w13a
-
None
-
Confirmed
-
Items, Statistics
-
Low
-
Platform
The bug
You can use air in minecraft when you break a crossbow in 1.14+ (1.14-1.19).
Video that shows it: https://youtu.be/ggE56xeICmA?t=13
In the scoreboard and files it shows the stat, but in the statistics menu its not counted.
To reproduce
- Execute the following commands:
/scoreboard objectives add usedAir minecraft.used:minecraft.air "usedAir"
/scoreboard objectives setdisplay sidebar usedAir
Until 1.20.4/give @p minecraft:crossbow{Charged:1b,ChargedProjectiles:[{id:"minecraft:arrow",Count:1b}],Damage:465}
1.20.5+/give @p minecraft:crossbow[charged_projectiles=[{id:"minecraft:arrow",count:1b}],damage=465]
- Use the given crossbow.
- The score goes up by one, indicating you have used air.
Code analysis
The bug is caused because the code of crossbow breaking is before that the adding the stat. In the screenshot (named Screenshot_20220723_183443) we can see that is on the function "onCrossbowShot". This function is called in the Screenshot_20220723_183409, and the breaking of the item is in "shootProjectile". So the item here is null or is less than 0, in the first photo we can see that is called "getItem()" (Screenshot_20220723_183309), if the variable "emptyCacheFlag" is true it returns air (here is the air use). This variable depends on the function "isEmpty" that is true when the crossbow breaks.
(The class of the 2 first screenshots is "CrossbowItem", and the other is "ItemStack")
To fix this bug the easiest way is to move the count of the stat in the start of the function "performShooting"