Skip to content

Commit

Permalink
Add altar input item safety checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jun 13, 2024
1 parent 4bb05bd commit 19e0195
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/mod/emt/harkenscythe/blocks/HSBloodAltar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mod/emt/harkenscythe/blocks/HSSoulAltar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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));
Expand Down

0 comments on commit 19e0195

Please sign in to comment.