Skip to content

Commit

Permalink
Issue with control flow would cause line 128 to crash. After placing …
Browse files Browse the repository at this point in the history
…your final boiler, the item count gets set to 0 and the item is removed from your inventory. That item in your hand is then used again to verify if it was a chest. Minimal changes made to the code to prevent other bugs from popping up. Added control flow to check to verify the item is null before being used again
  • Loading branch information
dje4321 committed Apr 25, 2022
1 parent de035c4 commit 20a63c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
minecraft_version=1.7.10
forge_version=10.13.4.1566-1.7.10
tfc_version=0.79.27
mod_version=1.21
mod_version=1.22
mod_id=TerraFirmaPunkTweaks
group_name=com.JAWolfe.TerraFirmaPunkTweaks
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ public void onBlockPlaced(PlayerInteractEvent event)
{
if (event.entityPlayer.worldObj.isRemote)
return;

ItemStack itemInHand = event.entityPlayer.getCurrentEquippedItem();

if(itemInHand == null)
if(event.entityPlayer.getCurrentEquippedItem() == null)
return;

if(event.action == Action.RIGHT_CLICK_BLOCK && event.getResult() != Result.DENY)
Expand Down Expand Up @@ -124,15 +122,17 @@ else if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFro
event.entityPlayer.getCurrentEquippedItem().stackSize--;
}
}

if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.chest))
if(event.entityPlayer.getCurrentEquippedItem() != null)
{
event.setCanceled(true);
if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.chest))
{
event.setCanceled(true);

if(event.entityPlayer.getCurrentEquippedItem().stackSize == 1)
event.entityPlayer.setCurrentItemOrArmor(0, null);
else
event.entityPlayer.getCurrentEquippedItem().stackSize--;
if(event.entityPlayer.getCurrentEquippedItem().stackSize == 1)
event.entityPlayer.setCurrentItemOrArmor(0, null);
else
event.entityPlayer.getCurrentEquippedItem().stackSize--;
}
}
}
}
Expand Down

0 comments on commit 20a63c7

Please sign in to comment.