use of net.minecraft.item.crafting.Ingredient in project RFTools by McJty.
the class NBTMatchingRecipe method checkMatch.
/**
* Checks if the region of a crafting inventory is match for the recipe.
*/
private boolean checkMatch(InventoryCrafting inventoryCrafting, int x, int y, boolean reversed) {
for (int col = 0; col < 3; ++col) {
for (int row = 0; row < 3; ++row) {
int i1 = col - x;
int j1 = row - y;
ItemStack itemstack = ItemStack.EMPTY;
String[] nbt = null;
if (i1 >= 0 && j1 >= 0 && i1 < this.recipeWidth && j1 < this.recipeHeight) {
int idx;
if (reversed) {
idx = this.recipeWidth - i1 - 1 + j1 * this.recipeWidth;
} else {
idx = i1 + j1 * this.recipeWidth;
}
Ingredient ingredient = this.recipeItems.get(idx);
if (ingredient.getMatchingStacks().length > 0) {
// @todo recipes most likely wrong!
itemstack = ingredient.getMatchingStacks()[0];
} else {
itemstack = ItemStack.EMPTY;
}
nbt = this.matchingNBTs[idx];
}
ItemStack itemstack1 = inventoryCrafting.getStackInRowAndColumn(col, row);
if (!itemstack1.isEmpty() || !itemstack.isEmpty()) {
if (itemstack1.isEmpty() || itemstack.isEmpty()) {
return false;
}
if (itemstack.getItem() != itemstack1.getItem()) {
return false;
}
if (itemstack.getMetadata() != 32767 && itemstack.getMetadata() != itemstack1.getMetadata()) {
return false;
}
NBTTagCompound compound = itemstack.getTagCompound();
NBTTagCompound compound1 = itemstack1.getTagCompound();
if (nbt != null) {
if (compound == null && compound1 != null) {
return false;
}
if (compound != null && compound1 == null) {
return false;
}
if (compound != null) {
for (String tagName : nbt) {
NBTBase tag = compound.getTag(tagName);
NBTBase tag1 = compound1.getTag(tagName);
if (tag == null && tag1 != null) {
return false;
}
if (tag != null && tag1 == null) {
return false;
}
if (tag != null) {
if (!tag.equals(tag1)) {
return false;
}
}
}
}
}
}
}
}
return true;
}
use of net.minecraft.item.crafting.Ingredient in project Binnie by ForestryMC.
the class RegistryRecipe method rotateIngredients.
private void rotateIngredients() {
int offset = 0;
for (int i = 0; i < input.size(); i++) {
Ingredient ingredient = input.get(i);
if (ingredient instanceof OreIngredient) {
RotatedOreIngredient rotatedOreIngredient = new RotatedOreIngredient("binnie_database", offset);
input.set(i, rotatedOreIngredient);
offset++;
}
}
}
Aggregations