More null stack fixes

This commit is contained in:
Nicholas Ignoffo 2017-02-19 16:06:29 -08:00
parent c682571be0
commit 5475549c18
10 changed files with 49 additions and 50 deletions

View file

@ -15,7 +15,7 @@ import net.minecraftforge.oredict.OreDictionary;
public class AlchemyTableRecipe
{
protected ItemStack output = null;
protected ItemStack output = ItemStack.EMPTY;
protected ArrayList<Object> input = new ArrayList<Object>();
@Getter
protected int lpDrained;
@ -97,11 +97,9 @@ public class AlchemyTableRecipe
{
ArrayList<Object> required = new ArrayList<Object>(input);
for (int x = 0; x < checkedList.size(); x++)
for (ItemStack slot : checkedList)
{
ItemStack slot = checkedList.get(x);
if (slot != null)
if (!slot.isEmpty())
{
boolean inRecipe = false;
@ -109,14 +107,12 @@ public class AlchemyTableRecipe
{
boolean match = false;
Object next = aRequired;
if (next instanceof ItemStack)
if (aRequired instanceof ItemStack)
{
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
} else if (next instanceof List)
match = OreDictionary.itemMatches((ItemStack) aRequired, slot, false);
} else if (aRequired instanceof List)
{
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
Iterator<ItemStack> itr = ((List<ItemStack>) aRequired).iterator();
while (itr.hasNext() && !match)
{
match = OreDictionary.itemMatches(itr.next(), slot, false);
@ -126,7 +122,7 @@ public class AlchemyTableRecipe
if (match)
{
inRecipe = true;
required.remove(next);
required.remove(aRequired);
break;
}
}

View file

@ -29,15 +29,12 @@ public class PlayerDemonWillHandler
for (ItemStack stack : inventory)
{
if (stack != null)
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type)
{
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type)
{
souls += ((IDemonWill) stack.getItem()).getWill(type, stack);
} else if (stack.getItem() instanceof IDemonWillGem)
{
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
}
souls += ((IDemonWill) stack.getItem()).getWill(type, stack);
} else if (stack.getItem() instanceof IDemonWillGem)
{
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
}
}
@ -78,7 +75,7 @@ public class PlayerDemonWillHandler
boolean hasGem = false;
for (ItemStack stack : inventory)
{
if (stack != null && stack.getItem() instanceof IDemonWillGem)
if (stack.getItem() instanceof IDemonWillGem)
{
hasGem = true;
if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack))
@ -145,11 +142,11 @@ public class PlayerDemonWillHandler
for (ItemStack stack : inventory)
{
if (stack != null && stack.getItem() instanceof IDemonWillGem)
if (stack.getItem() instanceof IDemonWillGem)
{
ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack);
if (newStack == null)
return null;
if (newStack.isEmpty())
return ItemStack.EMPTY;
}
}
@ -176,7 +173,7 @@ public class PlayerDemonWillHandler
for (ItemStack stack : inventory)
{
if (stack != null && stack.getItem() instanceof IDemonWillGem)
if (stack.getItem() instanceof IDemonWillGem)
{
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
if (remaining <= 0)
@ -209,7 +206,7 @@ public class PlayerDemonWillHandler
for (ItemStack stack : inventory)
{
if (stack != null && !stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem)
if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem)
{
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);