Search in sources :

Example 1 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class RecipeMixedMaterialItem method getMaterials.

protected ItemStackList getMaterials(InventoryCrafting inv) {
    ItemStackList list = ItemStackList.create();
    for (int i = 0; i < inv.getSizeInventory(); ++i) {
        ItemStack stack = inv.getStackInSlot(i);
        ToolPart part = ToolPartRegistry.fromStack(stack);
        if (part != null && !part.isBlacklisted(stack) && part instanceof ToolPartMain) {
            list.add(stack);
        }
    }
    return list;
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemStackList(net.silentchaos512.lib.collection.ItemStackList) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class RecipeDecorateArmor method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    int i;
    int toolRow = 0;
    int toolCol = 0;
    ItemStack stack;
    ItemStack tool = StackHelper.empty();
    int repairValue = 0;
    // Find armor position
    for (int row = 0; row < inv.getWidth(); ++row) {
        for (int col = 0; col < inv.getHeight(); ++col) {
            stack = inv.getStackInRowAndColumn(row, col);
            if (StackHelper.isValid(stack) && stack.getItem() instanceof IArmor) {
                tool = stack;
                toolRow = row;
                toolCol = col;
            }
        }
    }
    // Found armor piece?
    if (StackHelper.isEmpty(tool)) {
        return StackHelper.empty();
    }
    // Check adjacent materials
    ItemStack west = inv.getStackInRowAndColumn(toolRow - 1, toolCol);
    ItemStack north = inv.getStackInRowAndColumn(toolRow, toolCol - 1);
    ItemStack east = inv.getStackInRowAndColumn(toolRow + 1, toolCol);
    ItemStack south = inv.getStackInRowAndColumn(toolRow, toolCol + 1);
    int validPartCount = (StackHelper.isEmpty(west) ? 0 : 1) + (StackHelper.isEmpty(north) ? 0 : 1) + (StackHelper.isEmpty(east) ? 0 : 1) + (StackHelper.isEmpty(south) ? 0 : 1);
    if (!checkIsDecorationMaterial(west) || !checkIsDecorationMaterial(north) || !checkIsDecorationMaterial(east) || !checkIsDecorationMaterial(south)) {
        return StackHelper.empty();
    }
    // Check for other pieces (invalid for armor) and get all repair values.
    EnumMaterialTier toolTier = ArmorHelper.getArmorTier(tool);
    ToolPart part;
    int partsFound = 0;
    for (i = 0; i < inv.getSizeInventory(); ++i) {
        stack = inv.getStackInSlot(i);
        if (StackHelper.isValid(stack) && !(stack.getItem() instanceof IArmor)) {
            part = ToolPartRegistry.fromStack(stack);
            // Invalid part or not a part?
            if (part == null || !(part instanceof ToolPartMain)) {
                return StackHelper.empty();
            }
            // Found a part.
            ++partsFound;
            // Add to total repair value.
            repairValue += part.getRepairAmount(tool, stack);
        }
    }
    // Make sure we got no other parts.
    if (partsFound != validPartCount) {
        return StackHelper.empty();
    }
    ItemStack result = ArmorHelper.decorateArmor(tool, west, north, east, south);
    // Repair.
    result.attemptDamageItem(-repairValue, SilentGems.random);
    // Recalculate stats.
    ArmorHelper.recalculateStats(result);
    ArmorHelper.incrementStatRedecorated(result, 1);
    return result;
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) ItemStack(net.minecraft.item.ItemStack) IArmor(net.silentchaos512.gems.api.IArmor)

Example 3 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class RecipeMultiGemBow method getGems.

private ItemStack[] getGems(InventoryCrafting inv, boolean orientation) {
    ItemStack gem1 = inv.getStackInRowAndColumn(1, 2);
    ItemStack gem2 = inv.getStackInRowAndColumn(orientation ? 0 : 2, 1);
    ItemStack gem3 = inv.getStackInRowAndColumn(1, 0);
    gem1 = ToolPartRegistry.fromStack(gem1) instanceof ToolPartMain ? gem1 : StackHelper.empty();
    gem2 = ToolPartRegistry.fromStack(gem2) instanceof ToolPartMain ? gem2 : StackHelper.empty();
    gem3 = ToolPartRegistry.fromStack(gem3) instanceof ToolPartMain ? gem3 : StackHelper.empty();
    return StackHelper.isEmpty(gem1) || StackHelper.isEmpty(gem2) || StackHelper.isEmpty(gem3) ? null : new ItemStack[] { gem1, gem2, gem3 };
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class RecipeMultiGemTool method getGems.

private ItemStack[] getGems(InventoryCrafting inv) {
    List<ItemStack> list = Lists.newArrayList();
    ItemStack stack;
    for (int i = 0; i < inv.getSizeInventory(); ++i) {
        stack = inv.getStackInSlot(i);
        ToolPart part = ToolPartRegistry.fromStack(stack);
        if (part != null && part instanceof ToolPartMain) {
            list.add(stack);
        }
    }
    return list.toArray(new ItemStack[list.size()]);
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class ArmorHelper method decorate.

private static ItemStack decorate(ItemStack armor, ItemStack material, ArmorPartPosition pos) {
    if (StackHelper.isEmpty(armor))
        return StackHelper.empty();
    if (StackHelper.isEmpty(material))
        return armor;
    ToolPart part = ToolPartRegistry.fromDecoStack(material);
    if (part == null)
        return null;
    // Only main parts (like gems) work
    if (!(part instanceof ToolPartMain))
        return armor;
    ItemStack result = StackHelper.safeCopy(armor);
    setTagPart(result, pos.getDecoKey(), part, EnumMaterialGrade.fromStack(material));
    return result;
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ToolPartMain (net.silentchaos512.gems.api.tool.part.ToolPartMain)13 ItemStack (net.minecraft.item.ItemStack)12 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)11 ToolPartRod (net.silentchaos512.gems.api.tool.part.ToolPartRod)4 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)3 ITool (net.silentchaos512.gems.api.ITool)2 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)2 ItemGemShield (net.silentchaos512.gems.item.tool.ItemGemShield)2 IBlockState (net.minecraft.block.state.IBlockState)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 IAmmoTool (net.silentchaos512.gems.api.IAmmoTool)1 IArmor (net.silentchaos512.gems.api.IArmor)1 ToolPartGrip (net.silentchaos512.gems.api.tool.part.ToolPartGrip)1 ToolPartTip (net.silentchaos512.gems.api.tool.part.ToolPartTip)1 ItemStackList (net.silentchaos512.lib.collection.ItemStackList)1