-
Bug
-
Resolution: Fixed
-
Minecraft 1.11.2, Minecraft 17w14a, Minecraft 17w15a, Minecraft 1.12 Pre-Release 6, Minecraft 1.12 Pre-Release 7, Minecraft 1.12.2, Minecraft 17w50a, Minecraft 18w11a, Minecraft 18w31a, Minecraft 18w32a, Minecraft 18w33a, Minecraft 1.13.1-pre1, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w03b, Minecraft 19w03c, Minecraft 19w12b, Minecraft 19w13b, Minecraft 19w14a, Minecraft 19w14b, 1.14.4, 1.15 Pre-Release 2, 1.15.1
-
None
-
Confirmed
-
(Unassigned)
The bug
When you ride a pig and right-click with a carrot on a stick, your pig will be fed and will walk faster. Also the durability of the carrot on a stick is decreased by 7 units.
What I expected to happen was:
When the carrot on a stick is nearly broken and I sit on a non-boosted pig and right-click with that carrot on a stick, it should break or become a fishing rod.
What actually happened was:
The carrot on a stick was not broken and the pig did not walk faster than before. Because of this, carrots on sticks cannot be used more often than thrice and are not able to break.
To reproduce
- Give yourself an unenchanted minecraft:carrot_on_a_stick with a damage value of 19
/give @s minecraft:carrot_on_a_stick{Damage:19}
- Spawn a pig and equip it with a saddle
- Switch into survival mode and ride on that pig
- Right-click with the carrot on a stick while riding the pig
- Notice that the pig does not get boosted and the carrot on a stick stays the same
Code analysis
From MCP 9.35 for Minecraft 1.11:
ItemCarrotOnAStick.java
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn) { ItemStack itemstack = worldIn.getHeldItem(playerIn); if (worldIn.isRiding() && worldIn.getRidingEntity() instanceof EntityPig) { EntityPig entitypig = (EntityPig)worldIn.getRidingEntity(); // This line causes to check whether the remaining durability is more than seven. If it is not, the item cannot be used. if (itemstack.getMaxDamage() - itemstack.getMetadata() >= 7 && entitypig.boost()) { // Because of this line, the carrot on a stick gets damaged by seven durability points. This function also causes the carrot on a stick to break if necessary. itemstack.damageItem(7, worldIn); // This replaces the carrot on a stick by a fishing rod if it was broken. if (itemstack.func_190926_b()) { ItemStack itemstack1 = new ItemStack(Items.FISHING_ROD); itemstack1.setTagCompound(itemstack.getTagCompound()); return new ActionResult(EnumActionResult.SUCCESS, itemstack1); } return new ActionResult(EnumActionResult.SUCCESS, itemstack); } } worldIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.PASS, itemstack); }
Possible solutions
- The maximum durability of carrots on sticks could be restricted to three or four and when feeding a pig, the durability decreases by one only.
- The maximum durability of carrots on sticks could be changed to 21 or 28 and when feeding a pig, the durability decreases by seven still.
- The check whether the carrot on a stick has enough damage is removed and you can still use a carrot on a stick if it has less than six durability points remaining.