From 37051b4e340bd524083e536f237973e50b2ddbf2 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sat, 23 Jan 2021 10:05:56 -0500 Subject: [PATCH] Fixed the null check in GenericHandler for using a bow. --- .../bloodmagic/tile/TileAlchemyTable.java | 27 ++++++++++++------- .../util/handler/event/GenericHandler.java | 4 +++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/main/java/wayoftime/bloodmagic/tile/TileAlchemyTable.java b/src/main/java/wayoftime/bloodmagic/tile/TileAlchemyTable.java index af52463b..85ad6b3f 100644 --- a/src/main/java/wayoftime/bloodmagic/tile/TileAlchemyTable.java +++ b/src/main/java/wayoftime/bloodmagic/tile/TileAlchemyTable.java @@ -26,14 +26,14 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.ObjectHolder; import wayoftime.bloodmagic.api.event.BloodMagicCraftedEvent; -import wayoftime.bloodmagic.impl.BloodMagicAPI; -import wayoftime.bloodmagic.recipe.RecipeAlchemyTable; +import wayoftime.bloodmagic.common.item.BloodOrb; +import wayoftime.bloodmagic.common.item.IBindable; +import wayoftime.bloodmagic.common.item.IBloodOrb; import wayoftime.bloodmagic.core.data.Binding; import wayoftime.bloodmagic.core.data.SoulNetwork; import wayoftime.bloodmagic.core.data.SoulTicket; -import wayoftime.bloodmagic.common.item.IBindable; -import wayoftime.bloodmagic.common.item.BloodOrb; -import wayoftime.bloodmagic.common.item.IBloodOrb; +import wayoftime.bloodmagic.impl.BloodMagicAPI; +import wayoftime.bloodmagic.recipe.RecipeAlchemyTable; import wayoftime.bloodmagic.tile.container.ContainerAlchemyTable; import wayoftime.bloodmagic.util.Constants; import wayoftime.bloodmagic.util.helper.NetworkHelper; @@ -256,8 +256,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, // Simple recipes RecipeAlchemyTable recipeAlchemyTable = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyTable(world, inputList); - if (recipeAlchemyTable != null && (burnTime > 0 || (!getWorld().isRemote - && tier >= recipeAlchemyTable.getMinimumTier() && getContainedLp() >= recipeAlchemyTable.getSyphon()))) + if (recipeAlchemyTable != null && (burnTime > 0 || (!getWorld().isRemote && tier >= recipeAlchemyTable.getMinimumTier() && getContainedLp() >= recipeAlchemyTable.getSyphon()))) { if (burnTime == 1) notifyUpdate(); @@ -417,14 +416,22 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, { setInventorySlotContents(i, inputStack.getItem().getContainerItem(inputStack)); continue; - } else if (inputStack.isDamageable()) + } else if (inputStack.getMaxDamage() > 0) { - inputStack.setDamage(inputStack.getDamage() + 1); - if (inputStack.getDamage() >= inputStack.getMaxDamage()) +// inputStack.setDamage(inputStack.getDamage() + 1); +// if (inputStack.getDamage() >= inputStack.getMaxDamage()) +// { +// +// } + + if (inputStack.attemptDamageItem(1, world.rand, null)) { setInventorySlotContents(i, ItemStack.EMPTY); } continue; + } else if (!inputStack.isDamageable()) + { + continue; } inputStack.shrink(1); diff --git a/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java b/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java index 2b223766..4223b74b 100644 --- a/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java +++ b/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java @@ -559,6 +559,10 @@ public class GenericHandler if (stack.getItem() instanceof BowItem || stack.getItem() instanceof CrossbowItem) { AnointmentHolder holder = AnointmentHolder.fromItemStack(stack); + if (holder == null) + { + return; + } int quickDrawLevel = holder.getAnointmentLevel(AnointmentRegistrar.ANOINTMENT_QUICK_DRAW.get()); if (quickDrawLevel > 0) {