Fix incompatibility with Unmending mod (#1566)

This commit is contained in:
Nicholas Ignoffo 2019-04-14 08:48:47 -07:00
parent d5834a34ba
commit 59f5fe9407

View file

@ -78,6 +78,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerPickupXpEvent; import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
import net.minecraftforge.event.world.ExplosionEvent; import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -433,10 +434,12 @@ public class GenericHandler {
EntityPlayer player = event.getEntityPlayer(); EntityPlayer player = event.getEntityPlayer();
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, player); ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, player);
if (!itemstack.isEmpty() && itemstack.isItemDamaged()) { if (Loader.isModLoaded("unmending")) {
int i = Math.min(xpToDurability(event.getOrb().xpValue), itemstack.getItemDamage()); if (!itemstack.isEmpty() && itemstack.isItemDamaged()) {
event.getOrb().xpValue -= durabilityToXp(i); int i = Math.min(xpToDurability(event.getOrb().xpValue), itemstack.getItemDamage());
itemstack.setItemDamage(itemstack.getItemDamage() - i); event.getOrb().xpValue -= durabilityToXp(i);
itemstack.setItemDamage(itemstack.getItemDamage() - i);
}
} }
if (!player.getEntityWorld().isRemote) { if (!player.getEntityWorld().isRemote) {