use of WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb in project PneumaticCraft by MineMaarten.
the class ShapedBloodOrbRecipe method checkMatch.
@SuppressWarnings("unchecked")
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) {
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) {
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) {
int subX = x - startX;
int subY = y - startY;
Object target = null;
if (subX >= 0 && subY >= 0 && subX < width && subY < height) {
if (mirror) {
target = input[width - subX - 1 + subY * width];
} else {
target = input[subX + subY * width];
}
}
ItemStack slot = inv.getStackInRowAndColumn(x, y);
//If target is integer, then we should be check the blood orb value of the item instead
if (target instanceof Integer) {
if (slot != null && slot.getItem() instanceof IBloodOrb) {
IBloodOrb orb = (IBloodOrb) slot.getItem();
if (orb.getOrbLevel() < (Integer) target) {
return false;
}
} else
return false;
} else if (target instanceof ItemStack) {
if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) {
return false;
}
} else if (target instanceof ArrayList) {
boolean matched = false;
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) target).iterator();
while (itr.hasNext() && !matched) {
matched = OreDictionary.itemMatches(itr.next(), slot, false);
}
if (!matched) {
return false;
}
} else if (target == null && slot != null) {
return false;
}
}
}
return true;
}
use of WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb in project PneumaticCraft by MineMaarten.
the class ShapelessBloodOrbRecipe method matches.
@SuppressWarnings("unchecked")
@Override
public boolean matches(InventoryCrafting var1, World world) {
ArrayList<Object> required = new ArrayList<Object>(input);
for (int x = 0; x < var1.getSizeInventory(); x++) {
ItemStack slot = var1.getStackInSlot(x);
if (slot != null) {
boolean inRecipe = false;
Iterator<Object> req = required.iterator();
while (req.hasNext()) {
boolean match = false;
Object next = req.next();
//If target is integer, then we should be check the blood orb value of the item instead
if (next instanceof Integer) {
if (slot != null && slot.getItem() instanceof IBloodOrb) {
IBloodOrb orb = (IBloodOrb) slot.getItem();
if (orb.getOrbLevel() < (Integer) next) {
return false;
}
} else
return false;
} else if (next instanceof ItemStack) {
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
} else if (next instanceof ArrayList) {
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) next).iterator();
while (itr.hasNext() && !match) {
match = OreDictionary.itemMatches(itr.next(), slot, false);
}
}
if (match) {
inRecipe = true;
required.remove(next);
break;
}
}
if (!inRecipe) {
return false;
}
}
}
return required.isEmpty();
}