Posted February 14, 20223 yr Since 1.18 the ExperienceOrb improperly repairs items. Having one orb it sometimes may repair all armor. In the repairing method: private int repairPlayerItems(Player p_147093_, int p_147094_) { Entry<EquipmentSlot, ItemStack> entry = EnchantmentHelper.getRandomItemWith(Enchantments.MENDING, p_147093_, ItemStack::isDamaged); if (entry != null) { ItemStack itemstack = entry.getValue(); int i = Math.min((int) (this.value * itemstack.getXpRepairRatio()), itemstack.getDamageValue()); itemstack.setDamageValue(itemstack.getDamageValue() - i); int j = p_147094_ - this.durabilityToXp(i); return j > 0 ? this.repairPlayerItems(p_147093_, j) : 0; } else { return p_147094_; } } the "this.value" is never been decreased. Looking to the [1.17.1] and older versions it should use "p_147094_" instead of "this.value". Also the methods: private int durabilityToXp(int p_20794_) { return p_20794_ / 2; } private int xpToDurability(int p_20799_) { return p_20799_ * 2; } merely ignore the the item specific repair cost using the default value "2" instead. Seems it should take "ItemStack" as a parameter to calculate proper remaining XP value. So maybe the proper port should look like: private int repairPlayerItems(Player p_147093_, int p_147094_) { Map.Entry<EquipmentSlot, ItemStack> entry = EnchantmentHelper.getRandomItemWith(Enchantments.MENDING, p_147093_, ItemStack::isDamaged); if (entry != null) { ItemStack itemstack = entry.getValue(); int i = Math.min(xpToDurability(itemstack, p_147094_), itemstack.getDamageValue()); itemstack.setDamageValue(itemstack.getDamageValue() - i); int j = p_147094_ - this.durabilityToXp(itemstack, i); return j > 0 ? this.repairPlayerItems(p_147093_, j) : 0; } else { return p_147094_; } } private int durabilityToXp(ItemStack itemstack, int p_20794_) { return (int) (p_20794_ / itemstack.getXpRepairRatio()); } private int xpToDurability(ItemStack itemstack, int p_20799_) { return (int) (p_20799_ * itemstack.getXpRepairRatio()); } Edited February 14, 20223 yr by Zeram misspell
February 14, 20223 yr Author Any ideas how to apply shim on the forge side? I'm not sure the mc team will rush into fixing that immediately.Any ideas how to apply shim on the forge side? I'm not sure the mc team will rush into fixing that immediately.
February 15, 20223 yr Author Bug 1: spawn orb with 30 value and create two damaged item 2*29=58 damage and 2*30=60. One orb fully repairs 1th item then 2nd so outcome like from two orbs with 29 and 30 value. Bug 2: spawn orb with value 1. It fully repair all armor with the getXpRepairRatio<2 let's say 1.68f because p_20794_ / 2 -> (int)(1 * 1.68f) / 2 = 0 -> int j = p_147094_ - 0 = p_147094_: the orb value is never being exhausted.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.