From 19e0195c375aee577fe499c1d16442d3d9852fc9 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:42:29 +0200 Subject: [PATCH] Add altar input item safety checks --- src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java | 4 ++-- src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java b/src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java index c13f631..9536fc7 100644 --- a/src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java +++ b/src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java @@ -57,11 +57,12 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En if (te instanceof HSTileEntityBloodAltar) { HSTileEntityBloodAltar altar = (HSTileEntityBloodAltar) te; + ItemStack altarItem = altar.getInputStack(); ItemStack heldItem = player.getHeldItem(hand); if (heldItem.getItem() == HSItems.harken_athame) { - if (altar.isValidRecipe()) + if (!altarItem.isEmpty() && altar.isValidRecipe()) { Item item = altar.getInputStack().getItem(); int requiredBloods = HSAltarRecipes.getRequiredBlood(altar.getInputStack().getItem()); @@ -81,7 +82,6 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En } else if (!heldItem.isEmpty()) { - ItemStack altarItem = altar.getInputStack(); if (altarItem.isEmpty()) { altar.setInputStack(heldItem.splitStack(1)); diff --git a/src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java b/src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java index b5989da..b025d44 100644 --- a/src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java +++ b/src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java @@ -57,11 +57,12 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En if (te instanceof HSTileEntitySoulAltar) { HSTileEntitySoulAltar altar = (HSTileEntitySoulAltar) te; + ItemStack altarItem = altar.getInputStack(); ItemStack heldItem = player.getHeldItem(hand); if (heldItem.getItem() == HSItems.harken_athame) { - if (altar.isValidRecipe()) + if (!altarItem.isEmpty() && altar.isValidRecipe()) { Item item = altar.getInputStack().getItem(); int requiredSouls = HSAltarRecipes.getRequiredSouls(altar.getInputStack().getItem()); @@ -81,7 +82,6 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En } else if (!heldItem.isEmpty()) { - ItemStack altarItem = altar.getInputStack(); if (altarItem.isEmpty()) { altar.setInputStack(heldItem.splitStack(1));