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) {
|
||||
NBTTagCompound nbt = NBTUtils.getItemData(stack);
|
||||
if (nbt == null) {
|
||||
return null;
|
||||
}
|
||||
BlueprintId id = new BlueprintId ();
|
||||
id.read (nbt);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -216,19 +216,23 @@ public class ItemFacade extends ItemBuildCraft {
|
|||
}
|
||||
|
||||
private static boolean isBlockValidForFacade(Block block) {
|
||||
if (block.getRenderType() != 0 && block.getRenderType() != 31) {
|
||||
try {
|
||||
if (block.getRenderType() != 0 && block.getRenderType() != 31) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (block.getBlockBoundsMaxX() != 1.0 || block.getBlockBoundsMaxY() != 1.0 || block.getBlockBoundsMaxZ() != 1.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (block instanceof BlockSpring || block instanceof BlockGenericPipe) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Throwable ignored) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (block.getBlockBoundsMaxX() != 1.0 || block.getBlockBoundsMaxY() != 1.0 || block.getBlockBoundsMaxZ() != 1.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (block instanceof BlockSpring || block instanceof BlockGenericPipe) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// GETTERS FOR FACADE DATA
|
||||
|
|
Loading…
Reference in a new issue