Permalink
Browse files

Fixed a crash caused by the assembler setting a null ItemStack.

  • Loading branch information...
Ri5ux committed Sep 26, 2018
1 parent 92937ef commit 05361709c5d11d8fb4e5f409a5b4c7febe6d53d0
Showing with 31 additions and 28 deletions.
  1. +31 −28 src/main/java/org/avp/item/crafting/AssemblyManager.java
@@ -13,14 +13,14 @@
public class AssemblyManager
{
public static final AssemblyManager instance = new AssemblyManager();
private ArrayList<Schematic> schematics = new ArrayList<Schematic>();
public static final AssemblyManager instance = new AssemblyManager();
private ArrayList<Schematic> schematics = new ArrayList<Schematic>();
public ArrayList<Schematic> schematics()
{
return this.schematics;
}
public static void register(Schematic schematic)
{
AssemblyManager.instance.add(schematic);
@@ -78,11 +78,11 @@ public void add(Schematic schematic)
MDX.log().warn(String.format("[AVP/API/Assembler] Schematic for id '%s' is already registered.", schematic.getName()));
}
}
public static int amountForMatchingStack(EntityPlayer player, ItemStack requirement)
{
int count = 0;
int[] matches = OreDictionary.getOreIDs(requirement);
boolean checkOreDictionary = matches.length > 0;
@@ -102,7 +102,7 @@ public static int amountForMatchingStack(EntityPlayer player, ItemStack requirem
{
count += Inventories.getAmountOfItemPlayerHas(requirement.getItem(), player);
}
return count;
}
@@ -112,42 +112,45 @@ public static boolean handleAssembly(Schematic schematic, EntityPlayer player)
{
for (ItemStack requirement : schematic.getItemsRequired())
{
int[] matches = OreDictionary.getOreIDs(requirement);
boolean checkOreDictionary = matches.length > 0;
if (checkOreDictionary)
if (requirement != null && requirement != ItemStack.EMPTY)
{
matchLoop:
for (int id : matches)
{
String sharedName = OreDictionary.getOreName(id);
int[] matches = OreDictionary.getOreIDs(requirement);
boolean checkOreDictionary = matches.length > 0;
for (ItemStack potentialMatch : OreDictionary.getOres(sharedName))
if (checkOreDictionary)
{
matchLoop:
for (int id : matches)
{
if (Inventories.getAmountOfItemPlayerHas(potentialMatch.getItem(), player) >= requirement.getCount())
String sharedName = OreDictionary.getOreName(id);
for (ItemStack potentialMatch : OreDictionary.getOres(sharedName))
{
for (int x = 0; x < requirement.getCount(); x++)
if (Inventories.getAmountOfItemPlayerHas(potentialMatch.getItem(), player) >= requirement.getCount())
{
if (!Inventories.consumeItem(player, potentialMatch.getItem()))
for (int x = 0; x < requirement.getCount(); x++)
{
return false;
if (!Inventories.consumeItem(player, potentialMatch.getItem()))
{
return false;
}
}
}
break matchLoop;
break matchLoop;
}
}
}
}
}
else
{
if (Inventories.getAmountOfItemPlayerHas(requirement.getItem(), player) >= requirement.getCount())
else
{
for (int x = 0; x < requirement.getCount(); x++)
if (Inventories.getAmountOfItemPlayerHas(requirement.getItem(), player) >= requirement.getCount())
{
if (!Inventories.consumeItem(player, requirement.getItem()))
for (int x = 0; x < requirement.getCount(); x++)
{
return false;
if (!Inventories.consumeItem(player, requirement.getItem()))
{
return false;
}
}
}
}

0 comments on commit 0536170

Please sign in to comment.