Fix possible NPE and crashes
This commit is contained in:
parent
bd8f0e7235
commit
bb3bf76bb4
4 changed files with 24 additions and 11 deletions
|
@ -73,6 +73,9 @@ public abstract class ItemBlueprint extends ItemBuildCraft {
|
||||||
|
|
||||||
public static BlueprintId getId (ItemStack stack) {
|
public static BlueprintId getId (ItemStack stack) {
|
||||||
NBTTagCompound nbt = NBTUtils.getItemData(stack);
|
NBTTagCompound nbt = NBTUtils.getItemData(stack);
|
||||||
|
if (nbt == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
BlueprintId id = new BlueprintId ();
|
BlueprintId id = new BlueprintId ();
|
||||||
id.read (nbt);
|
id.read (nbt);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ public final class NBTUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NBTTagCompound getItemData(ItemStack stack) {
|
public static NBTTagCompound getItemData(ItemStack stack) {
|
||||||
|
if (stack == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
NBTTagCompound nbt = stack.getTagCompound();
|
NBTTagCompound nbt = stack.getTagCompound();
|
||||||
if (nbt == null) {
|
if (nbt == null) {
|
||||||
nbt = new NBTTagCompound();
|
nbt = new NBTTagCompound();
|
||||||
|
|
|
@ -149,6 +149,9 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I
|
||||||
NBTTagCompound cpt = list.getCompoundTagAt(i);
|
NBTTagCompound cpt = list.getCompoundTagAt(i);
|
||||||
|
|
||||||
ItemStack stack = ItemStack.loadItemStackFromNBT(cpt);
|
ItemStack stack = ItemStack.loadItemStackFromNBT(cpt);
|
||||||
|
if (stack == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (AssemblyRecipe r : AssemblyRecipeManager.INSTANCE.getRecipes()) {
|
for (AssemblyRecipe r : AssemblyRecipeManager.INSTANCE.getRecipes()) {
|
||||||
if (r.output.getItem() == stack.getItem() && r.output.getItemDamage() == stack.getItemDamage()) {
|
if (r.output.getItem() == stack.getItem() && r.output.getItemDamage() == stack.getItemDamage()) {
|
||||||
|
|
|
@ -216,6 +216,7 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isBlockValidForFacade(Block block) {
|
private static boolean isBlockValidForFacade(Block block) {
|
||||||
|
try {
|
||||||
if (block.getRenderType() != 0 && block.getRenderType() != 31) {
|
if (block.getRenderType() != 0 && block.getRenderType() != 31) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -229,6 +230,9 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GETTERS FOR FACADE DATA
|
// GETTERS FOR FACADE DATA
|
||||||
|
|
Loading…
Add table
Reference in a new issue