This commit is contained in:
Nedelosk committed 2017-01-03 17:01:30 +01:00
1 parent 50f0efb7a0
commit f91c0574ad
2 files changed
+46 -56

No files matched your search

@@ -263,7 +263,7 @@ public abstract class InventoryUtil {
stackToRemove.setCount(stackToRemove.getCount() * count);
// try to remove the exact stack first
ItemStack removedStack = removeStack(inventory, stackToRemove, player, stowContainer, false, false);
ItemStack removedStack = removeStack(inventory, stackToRemove, null, player, stowContainer, false);
if (removedStack.isEmpty()) {
// remove crafting equivalents next
removedStack = removeStack(inventory, stackToRemove, oreDicts.get(i), player, stowContainer, craftingTools);
@@ -331,68 +331,14 @@ public abstract class ItemStackUtil {
}
}
/**
* Compare two item stacks for crafting equivalency.
*/
public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, String oreDict, boolean craftingTools) {
if (base.isEmpty() || comparison.isEmpty()) {
return false;
}
if (craftingTools && isCraftingToolEquivalent(base, comparison)) {
return true;
}
if (isCraftingEquivalent(base, comparison)) {
return true;
}
if (base.getTagCompound() != null && !base.getTagCompound().hasNoTags()) {
if (!ItemStack.areItemStacksEqual(base, comparison)) {
return false;
}
}
if (!oreDict.isEmpty()) {
int[] idsBase = OreDictionary.getOreIDs(base);
Arrays.sort(idsBase);
int idComp = OreDictionary.getOreID(oreDict);
int iBase = 0;
while (iBase < idsBase.length) {
if (idsBase[iBase] == idComp) {
iBase++;
} else {
return true;
}
}
}
return false;
}
/**
* Compare two item stacks for crafting equivalency.
*/
public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean oreDictionary, boolean craftingTools) {
if (base.isEmpty() || comparison.isEmpty()) {
if (!isCraftingEquivalent(base, comparison, craftingTools)) {
return false;
}
if (craftingTools && isCraftingToolEquivalent(base, comparison)) {
return true;
}
if (isCraftingEquivalent(base, comparison)) {
return true;
}
if (base.getTagCompound() != null && !base.getTagCompound().hasNoTags()) {
if (!ItemStack.areItemStacksEqual(base, comparison)) {
return false;
}
}
if (oreDictionary) {
int[] idsBase = OreDictionary.getOreIDs(base);
Arrays.sort(idsBase);
@@ -415,6 +361,50 @@ public abstract class ItemStackUtil {
return false;
}
/**
* Compare two item stacks for crafting equivalency.
*/
public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, String oreDict, boolean craftingTools) {
if(!isCraftingEquivalent(base, comparison, craftingTools)){
return false;
}
if (!oreDict.isEmpty()) {
int[] baseIds = OreDictionary.getOreIDs(base);
int validID = OreDictionary.getOreID(oreDict);
for(int id : baseIds){
if (id == validID) {
return true;
}
}
}
return false;
}
public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean craftingTools) {
if (base.isEmpty() || comparison.isEmpty()) {
return false;
}
if (craftingTools && isCraftingToolEquivalent(base, comparison)) {
return true;
}
if (isCraftingEquivalent(base, comparison)) {
return true;
}
if (base.getTagCompound() != null && !base.getTagCompound().hasNoTags()) {
if (!ItemStack.areItemStacksEqual(base, comparison)) {
return false;
}
}
return false;
}
public static boolean isCraftingToolEquivalent(ItemStack base, ItemStack comparison) {
if (base.isEmpty() || comparison.isEmpty()) {