-
Bug
-
Resolution: Unresolved
-
None
-
1.17.1, 21w37a, 1.18 Pre-release 1, 1.18.1, 22w05a, 1.18.2, 22w17a, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20.1, 1.21, 1.21.3
-
None
-
Confirmed
-
Statistics
The Bug:
"minecraft.used:minecraft.<POTTABLE_PLANT>" doesn't increase when placing plants into flower pots.
Steps to Reproduce:
- Create a scoreboard objective for tracking when you use an allium and set it to display on the sidebar by using the commands provided below.
/scoreboard objectives add UseAllium minecraft.used:minecraft.allium
/scoreboard objectives setdisplay sidebar UseAllium
- Obtain an allium, place it on the ground, and take note of how the scoreboard increases.
- Place down a flower pot and place an allium inside of it.
- Take note as to whether or not "minecraft.used:minecraft.<POTTABLE_PLANT>" increases when placing plants into flower pots.
Observed Behavior:
The scoreboard doesn't increase.
Expected Behavior:
The scoreboard would increase.
Code Analysis:
Code analysis by Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.
public class FlowerPotBlock extends Block { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { ItemStack itemstack = $p.getItemInHand($ih); Item item = itemstack.getItem(); BlockState blockstate = (item instanceof BlockItem ? POTTED_BY_CONTENT.getOrDefault(((BlockItem)item).getBlock(), Blocks.AIR) : Blocks.AIR).defaultBlockState(); boolean flag = blockstate.is(Blocks.AIR); boolean flag1 = this.isEmpty(); if (flag != flag1) { if (flag1) { $l.setBlock($bp, blockstate, 3); $p.awardStat(Stats.POT_FLOWER); if (!$p.getAbilities().instabuild) { itemstack.shrink(1); } } ...
If we look at the above class, we can see that no stats are awarded when placing plants into flower pots. The only stat that is awarded is the POT_FLOWER stat. This is evident through the following line of code:
$p.awardStat(Stats.POT_FLOWER);
Potential Fix:
Simply adding a line of code that awards a stat when placing a plant into a flower pot should resolve this problem. The following line of code could be used in order to fix this:
$p.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
The correct piece of code within its class should look something like the following:
public class FlowerPotBlock extends Block { ... public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) { ItemStack itemstack = $p.getItemInHand($ih); Item item = itemstack.getItem(); BlockState blockstate = (item instanceof BlockItem ? POTTED_BY_CONTENT.getOrDefault(((BlockItem)item).getBlock(), Blocks.AIR) : Blocks.AIR).defaultBlockState(); boolean flag = blockstate.is(Blocks.AIR); boolean flag1 = this.isEmpty(); if (flag != flag1) { if (flag1) { $l.setBlock($bp, blockstate, 3); $p.awardStat(Stats.POT_FLOWER); $p.awardStat(Stats.ITEM_USED.get(itemstack.getItem())); if (!$p.getAbilities().instabuild) { itemstack.shrink(1); } } ...
- relates to
-
MC-224325 minecraft.used:minecraft.COMPOSTABLE_ITEM doesn't increase when placing an item into a composter
- Resolved