mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Add some null safety
In my survival playthrough, I got a crash when a tool with AOE broke mid-operation. This should fix it
This commit is contained in:
parent
df1ee57563
commit
527459b92c
@ -297,6 +297,10 @@ public class ItemToolAbility extends ItemTool implements IDepthRockTool, IGUIPro
|
||||
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
|
||||
ItemStack stack = player.getHeldItem();
|
||||
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
@ -485,7 +489,7 @@ public class ItemToolAbility extends ItemTool implements IDepthRockTool, IGUIPro
|
||||
public Configuration getConfiguration(ItemStack stack) {
|
||||
Configuration config = new Configuration();
|
||||
|
||||
if(!stack.hasTagCompound() || !stack.stackTagCompound.hasKey("ability") || !stack.stackTagCompound.hasKey("abilityPresets")) {
|
||||
if(stack == null || !stack.hasTagCompound() || !stack.stackTagCompound.hasKey("ability") || !stack.stackTagCompound.hasKey("abilityPresets")) {
|
||||
config.reset(availableAbilities);
|
||||
return config;
|
||||
}
|
||||
@ -496,8 +500,13 @@ public class ItemToolAbility extends ItemTool implements IDepthRockTool, IGUIPro
|
||||
}
|
||||
|
||||
public void setConfiguration(ItemStack stack, Configuration config) {
|
||||
if(!stack.hasTagCompound())
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
|
||||
config.writeToNBT(stack.stackTagCompound);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user