Issue with control flow would cause line 128 to crash. After placing 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

This commit is contained in:
Emily Ediger 2022-04-24 20:17:37 -05:00
parent de035c4647
commit 20a63c75cb
2 changed files with 11 additions and 11 deletions

View File

@ -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

View File

@ -89,10 +89,8 @@ public class PlayerInteractionHandler
{
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)
@ -124,15 +122,17 @@ public class PlayerInteractionHandler
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--;
}
}
}
}