Fix possible NPE and crashes

This commit is contained in:
Prototik 2014-05-18 16:46:14 +08:00
parent bd8f0e7235
commit bb3bf76bb4
4 changed files with 24 additions and 11 deletions

View file

@ -73,6 +73,9 @@ public abstract class ItemBlueprint extends ItemBuildCraft {
public static BlueprintId getId (ItemStack stack) {
NBTTagCompound nbt = NBTUtils.getItemData(stack);
if (nbt == null) {
return null;
}
BlueprintId id = new BlueprintId ();
id.read (nbt);

View file

@ -23,6 +23,9 @@ public final class NBTUtils {
}
public static NBTTagCompound getItemData(ItemStack stack) {
if (stack == null) {
return null;
}
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null) {
nbt = new NBTTagCompound();

View file

@ -149,6 +149,9 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I
NBTTagCompound cpt = list.getCompoundTagAt(i);
ItemStack stack = ItemStack.loadItemStackFromNBT(cpt);
if (stack == null) {
continue;
}
for (AssemblyRecipe r : AssemblyRecipeManager.INSTANCE.getRecipes()) {
if (r.output.getItem() == stack.getItem() && r.output.getItemDamage() == stack.getItemDamage()) {

View file

@ -216,6 +216,7 @@ public class ItemFacade extends ItemBuildCraft {
}
private static boolean isBlockValidForFacade(Block block) {
try {
if (block.getRenderType() != 0 && block.getRenderType() != 31) {
return false;
}
@ -229,6 +230,9 @@ public class ItemFacade extends ItemBuildCraft {
}
return true;
} catch (Throwable ignored) {
return false;
}
}
// GETTERS FOR FACADE DATA