use of net.silentchaos512.gems.item.armor.ItemArmorFrame in project SilentGems by SilentChaos512.
the class RecipeMultiGemArmor method getCraftingResult.
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
// Get the middle stack, which determines the armor type.
ItemStack centerStack = inv.getStackInRowAndColumn(1, 1);
if (StackHelper.isEmpty(centerStack) || !(centerStack.getItem() instanceof ItemArmorFrame)) {
return StackHelper.empty();
}
// Make sure nothing is in the corners.
if (StackHelper.isValid(inv.getStackInRowAndColumn(0, 0)) || StackHelper.isValid(inv.getStackInRowAndColumn(2, 0)) || StackHelper.isValid(inv.getStackInRowAndColumn(2, 2)) || StackHelper.isValid(inv.getStackInRowAndColumn(0, 2))) {
return StackHelper.empty();
}
// Determine the target tier and output item.
ItemArmorFrame item = (ItemArmorFrame) centerStack.getItem();
Item outputItem = item.getOutputItem(centerStack);
EnumMaterialTier targetTier = item.getTier(centerStack);
// Get armor parts. Check tiers match (getGems checks all materials are same tier, or it returns null).
ItemStack[] stacks = getGems(inv);
if (stacks == null || EnumMaterialTier.fromStack(stacks[0]) != targetTier)
return StackHelper.empty();
return ArmorHelper.constructArmor(outputItem, stacks);
}
Aggregations