Search in sources :

Example 6 with EnumMaterialGrade

use of net.silentchaos512.gems.api.lib.EnumMaterialGrade in project SilentGems by SilentChaos512.

the class ToolStats method calculate.

public ToolStats calculate() {
    if (parts.length == 0)
        return this;
    Map<ItemStat, List<ItemStatModifier>> mods = new HashMap<>();
    for (ItemStat stat : ItemStat.ALL_STATS) {
        mods.put(stat, new ArrayList<>());
    }
    Set<ToolPart> uniqueParts = Sets.newConcurrentHashSet();
    // Head (main) parts
    for (int i = 0; i < parts.length; ++i) {
        ToolPart part = parts[i];
        EnumMaterialGrade grade = grades[i];
        for (ItemStat stat : ItemStat.ALL_STATS) {
            ItemStatModifier statModifier = part.getStatModifier(stat, grade);
            if (statModifier != null) {
                mods.get(stat).add(statModifier);
            }
        }
        // float multi = (100 + grade.bonusPercent) / 100f;
        // durability += part.getDurability() * multi;
        // harvestSpeed += part.getHarvestSpeed() * multi;
        // meleeDamage += part.getMeleeDamage() * multi;
        // magicDamage += part.getMagicDamage() * multi;
        // meleeSpeed += part.getMeleeSpeed() * multi;
        // enchantability += part.getEnchantability() * multi;
        // chargeSpeed += part.getChargeSpeed() * multi;
        // protection += part.getProtection() * multi;
        // harvestLevel = Math.max(harvestLevel, part.getHarvestLevel());
        uniqueParts.add(part);
    }
    // Variety bonus
    int variety = MathHelper.clamp(uniqueParts.size(), 1, GemsConfig.VARIETY_CAP);
    float bonus = 1.0f + GemsConfig.VARIETY_BONUS * (variety - 1);
    mods.get(CommonItemStats.DURABILITY).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    mods.get(CommonItemStats.HARVEST_SPEED).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    mods.get(CommonItemStats.MELEE_DAMAGE).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    mods.get(CommonItemStats.MAGIC_DAMAGE).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    mods.get(CommonItemStats.ATTACK_SPEED).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    mods.get(CommonItemStats.CHARGE_SPEED).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    mods.get(CommonItemStats.ENCHANTABILITY).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    mods.get(CommonItemStats.ARMOR).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    mods.get(CommonItemStats.MAGIC_ARMOR).add(new ItemStatModifier(ID_VARIETY_BONUS, bonus, Operation.MULTIPLY));
    // Tool class multipliers
    if (tool.getItem() instanceof ITool) {
        ITool itool = (ITool) tool.getItem();
        durability *= itool.getDurabilityMultiplier();
        harvestSpeed *= itool.getHarvestSpeedMultiplier();
    }
    // Rod, tip, grip, frame
    ToolPart partRod = ToolHelper.getConstructionRod(tool);
    ToolPart partTip = ToolHelper.getConstructionTip(tool);
    ToolPart partGrip = ToolHelper.getPart(tool, ToolPartPosition.ROD_GRIP);
    ToolPart partFrame = ArmorHelper.getPart(tool, ArmorPartPosition.FRAME);
    for (ToolPart part : Lists.newArrayList(partRod, partTip, partGrip, partFrame)) {
        if (part != null) {
            for (ItemStat stat : ItemStat.ALL_STATS) {
                ItemStatModifier statModifier = part.getStatModifier(stat, EnumMaterialGrade.NONE);
                if (statModifier != null) {
                    mods.get(stat).add(statModifier);
                }
            }
        }
    }
    durability = calcStat(CommonItemStats.DURABILITY, mods);
    harvestSpeed = calcStat(CommonItemStats.HARVEST_SPEED, mods);
    meleeDamage = calcStat(CommonItemStats.MELEE_DAMAGE, mods);
    magicDamage = calcStat(CommonItemStats.MAGIC_DAMAGE, mods);
    meleeSpeed = calcStat(CommonItemStats.ATTACK_SPEED, mods);
    chargeSpeed = calcStat(CommonItemStats.CHARGE_SPEED, mods);
    enchantability = calcStat(CommonItemStats.ENCHANTABILITY, mods);
    protection = calcStat(CommonItemStats.ARMOR, mods);
    harvestLevel = (int) calcStat(CommonItemStats.HARVEST_LEVEL, mods);
    return this;
}
Also used : ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) HashMap(java.util.HashMap) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) ItemStatModifier(net.silentchaos512.gems.api.stats.ItemStatModifier) ArrayList(java.util.ArrayList) List(java.util.List) ITool(net.silentchaos512.gems.api.ITool) ItemStat(net.silentchaos512.gems.api.stats.ItemStat)

Example 7 with EnumMaterialGrade

use of net.silentchaos512.gems.api.lib.EnumMaterialGrade in project SilentGems by SilentChaos512.

the class RecipeDecorateTool 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;
    int ammoValue = 0;
    // Find tool 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 ITool) {
                tool = stack;
                toolRow = row;
                toolCol = col;
            }
        }
    }
    // Found a tool?
    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);
    if (!checkIsDecorationMaterial(west) || !checkIsDecorationMaterial(north) || !checkIsDecorationMaterial(east) || !checkIsDecorationMaterial(south)) {
        return StackHelper.empty();
    }
    // Check other materials and get all repair values.
    List<ItemStack> otherMats = Lists.newArrayList();
    EnumMaterialTier toolTier = ToolHelper.getToolTier(tool);
    for (i = 0; i < inv.getSizeInventory(); ++i) {
        stack = inv.getStackInSlot(i);
        if (StackHelper.isValid(stack) && !(stack.getItem() instanceof ITool)) {
            ToolPart part = ToolPartRegistry.fromDecoStack(stack);
            // Invalid part or not a part?
            if (part == null) {
                return StackHelper.empty();
            }
            // Valid for tool tier?
            if (!part.validForToolOfTier(toolTier) && !(part instanceof ToolPartMain)) {
                return StackHelper.empty();
            }
            int repairAmount = part.getRepairAmount(tool, stack);
            if (repairAmount > 0) {
                repairValue += repairAmount;
                ++ammoValue;
            }
            otherMats.add(stack);
        }
    }
    if (otherMats.isEmpty()) {
        return StackHelper.empty();
    }
    ItemStack result = StackHelper.safeCopy(tool);
    result = ToolHelper.decorateTool(tool, west, north, east, south);
    boolean lockedStats = result.getTagCompound().getBoolean(ToolHelper.NBT_LOCK_STATS);
    // Other materials
    for (ItemStack other : otherMats) {
        ToolPart part = ToolPartRegistry.fromDecoStack(other);
        EnumMaterialGrade grade = EnumMaterialGrade.fromStack(other);
        if (StackHelper.isValid(result) && part instanceof ToolPartRod) {
            ToolHelper.setRenderPart(result, part, grade, ToolPartPosition.ROD);
        } else if (part instanceof ToolPartTip) {
            if (lockedStats) {
                // Tips change stats, so using them with locked tools is not allowed.
                return StackHelper.empty();
            }
            ToolHelper.setConstructionTip(result, part);
        }
    }
    if (repairValue > 0) {
        // Makes odd repair values line up better (2 polished stone on pickaxe makes a full repair, etc.)
        repairValue += 1;
    }
    // Tool repair multiplier
    repairValue *= ((ITool) tool.getItem()).getRepairMultiplier();
    // Repair.
    ItemHelper.attemptDamageItem(result, -repairValue, SilentGems.instance.random);
    // Restore ammo.
    if (result.getItem() instanceof IAmmoTool && ammoValue > 0) {
        IAmmoTool ammoTool = (IAmmoTool) result.getItem();
        ammoTool.addAmmo(result, ammoValue * GemsConfig.TOMAHAWK_AMMO_PER_MAT);
    }
    // Recalculate stats.
    ToolHelper.recalculateStats(result);
    ToolHelper.incrementStatRedecorated(result, 1);
    // Change the UUID so that rendering cache updates immediately for recipe output.
    result.getTagCompound().removeTag(ToolHelper.NBT_UUID + "Most");
    result.getTagCompound().removeTag(ToolHelper.NBT_UUID + "Least");
    ToolHelper.getUUID(result);
    return result;
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPartTip(net.silentchaos512.gems.api.tool.part.ToolPartTip) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) IAmmoTool(net.silentchaos512.gems.api.IAmmoTool) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) ItemStack(net.minecraft.item.ItemStack) ITool(net.silentchaos512.gems.api.ITool) ToolPartRod(net.silentchaos512.gems.api.tool.part.ToolPartRod)

Example 8 with EnumMaterialGrade

use of net.silentchaos512.gems.api.lib.EnumMaterialGrade in project SilentGems by SilentChaos512.

the class TileMaterialGrader method isItemValidForSlot.

@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
    if (index == SLOT_INPUT) {
        if (StackHelper.isEmpty(stack)) {
            return false;
        }
        ToolPart part = ToolPartRegistry.fromStack(stack);
        EnumMaterialGrade grade = EnumMaterialGrade.fromStack(stack);
        if (part != null && part instanceof ToolPartMain && grade == EnumMaterialGrade.NONE) {
            return true;
        }
        return false;
    }
    return false;
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade)

Example 9 with EnumMaterialGrade

use of net.silentchaos512.gems.api.lib.EnumMaterialGrade in project SilentGems by SilentChaos512.

the class ToolRenderHelper method clAddInformation.

@Override
public void clAddInformation(ItemStack tool, World world, List list, boolean advanced) {
    LocalizationHelper loc = SilentGems.instance.localizationHelper;
    boolean controlDown = KeyTracker.isControlDown();
    boolean altDown = KeyTracker.isAltDown();
    boolean shiftDown = KeyTracker.isShiftDown();
    String line;
    // Tipped upgrade
    ToolPartTip partTip = (ToolPartTip) ToolHelper.getConstructionTip(tool);
    if (partTip != null) {
        String tipName = partTip.getUnlocalizedName().replaceFirst("[^:]+:", "");
        tipName = loc.getMiscText("Tooltip." + tipName);
        line = loc.getMiscText("Tooltip.Tipped", tipName);
        list.add(line);
    }
    // UUID
    if (GemsConfig.DEBUG_MODE && controlDown && shiftDown) {
        UUID uuid = ToolHelper.hasUUID(tool) ? ToolHelper.getUUID(tool) : null;
        list.add(uuid == null ? "No UUID" : uuid.toString());
        uuid = ToolHelper.getSoulUUID(tool);
        list.add(uuid == null ? "No Soul UUID" : uuid.toString());
    }
    // Tool Soul
    ToolSoul soul = SoulManager.getSoul(tool);
    if (soul != null) {
        soul.addInformation(tool, world, list, advanced);
    }
    // Show original owner?
    if (controlDown) {
        String owner = ToolHelper.getOriginalOwner(tool);
        if (owner.equals(SilentGems.localizationHelper.getMiscText("Tooltip.OriginalOwner.Creative")))
            owner = TextFormatting.LIGHT_PURPLE + owner;
        if (!owner.isEmpty())
            list.add(loc.getMiscText("Tooltip.OriginalOwner", owner));
        else
            list.add(loc.getMiscText("Tooltip.OriginalOwner.Unknown"));
    }
    if (controlDown && tool.getTagCompound().getBoolean(ToolHelper.NBT_LOCK_STATS)) {
        list.add(loc.getMiscText("Tooltip.LockedStats"));
    }
    // Example tool?
    if (tool.hasTagCompound() && tool.getTagCompound().hasKey(ToolHelper.NBT_EXAMPLE_TOOL_TIER)) {
        EnumMaterialTier tier = EnumMaterialTier.values()[tool.getTagCompound().getInteger(ToolHelper.NBT_EXAMPLE_TOOL_TIER)];
        list.add(loc.getMiscText("Tooltip.ExampleTool", tier));
    } else // Missing data?
    if (ToolHelper.hasNoConstruction(tool)) {
        list.add(loc.getMiscText("Tooltip.NoData1"));
        list.add(loc.getMiscText("Tooltip.NoData2"));
    } else // Broken?
    if (ToolHelper.isBroken(tool)) {
        line = loc.getMiscText("Tooltip.Broken");
        list.add(line);
    }
    final Item item = tool.getItem();
    final boolean isSword = item instanceof ItemGemSword;
    final boolean isAxe = item instanceof ItemGemAxe;
    final boolean isWeapon = isSword || isAxe;
    final boolean isCaster = isSword && ToolHelper.getToolTier(tool).ordinal() >= EnumMaterialTier.SUPER.ordinal();
    final boolean isBow = item instanceof ItemGemBow;
    final boolean isDigger = item instanceof ItemTool;
    final boolean isShield = item instanceof ItemGemShield;
    final String sep = loc.getMiscText("Tooltip.Separator");
    if (controlDown) {
        // Properties Header
        line = loc.getMiscText("Tooltip.Properties");
        list.add(line);
        TextFormatting color = TextFormatting.YELLOW;
        // Tier
        EnumMaterialTier tier = ToolHelper.getToolTier(tool);
        line = TextFormatting.RESET + loc.getMiscText("ToolTier." + tier);
        list.add("  " + color + loc.getMiscText("ToolTier", line));
        int durabilityMax = tool.getMaxDamage();
        int durability = durabilityMax - tool.getItemDamage();
        String s1 = String.format(durability > 9999 ? "%,d" : "%d", durability);
        String s2 = String.format(durabilityMax > 9999 ? "%,d" : "%d", durabilityMax);
        float durabilityBoost = ToolSoul.getDurabilityModifierForDisplay(soul);
        String durBoostLine = durabilityBoost == 0f ? "" : " (" + TooltipHelper.numberToPercent(durabilityBoost, 0, true) + TextFormatting.RESET + ")";
        line = loc.getMiscText("Tooltip.Durability", s1 + " / " + s2 + durBoostLine);
        list.add(color + "  " + line);
        if (isShield) {
            float magicProtection = (int) (ToolHelper.getMagicProtection(tool) * 100);
            list.add(color + getTooltipLine("MagicProtection", magicProtection, 0f));
        }
        if (isDigger) {
            // @formatter:off
            int harvestLevel = ToolHelper.getHarvestLevel(tool);
            String str = color + getTooltipLine("HarvestLevel", harvestLevel, 0f);
            String key = "Tooltip.level" + harvestLevel;
            String val = SilentGems.localizationHelper.getMiscText(key);
            if (!val.equals("misc.silentgems:" + key))
                str += " (" + val + ")";
            list.add(str);
            float harvestSpeedModifier = ToolSoul.getHarvestSpeedModifierForDisplay(soul);
            list.add(color + getTooltipLine("HarvestSpeed", ToolHelper.getDigSpeedOnProperMaterial(tool), harvestSpeedModifier));
        }
        if (isWeapon) {
            float meleeSpeed = 4 + ToolHelper.getMeleeSpeedModifier(tool);
            list.add(color + getTooltipLine("MeleeSpeed", meleeSpeed, 0f).replaceFirst("%", ""));
            float meleeDamage = 1 + ToolHelper.getMeleeDamageModifier(tool);
            float meleeModifier = ToolSoul.getMeleeDamageModifierForDisplay(soul);
            list.add(color + getTooltipLine("MeleeDamage", meleeDamage, meleeModifier));
            if (isCaster) {
                EnumMagicType magicType = EnumMagicType.getMagicType(tool);
                float damagePerShot = magicType.getDamagePerShot(tool);
                String damageString = damagePerShot == (int) damagePerShot ? Integer.toString((int) damagePerShot) : String.format(TooltipHelper.FORMAT_FLOAT, damagePerShot);
                String str = damageString + "" + TextFormatting.DARK_GRAY + "x" + magicType.getShotCount(tool);
                float magicModifier = ToolSoul.getMagicDamageModifierForDisplay(soul);
                list.add(color + getTooltipLine("MagicDamage", str, magicModifier));
            }
        }
        if (isBow) {
            ToolStats statsNoSoul = ToolHelper.getStats(tool, false);
            float drawSpeed = ModItems.bow.getDrawSpeedForDisplay(tool);
            float drawSpeedPreSoul = ItemGemBow.getDrawSpeedForDisplay(statsNoSoul.meleeSpeed, statsNoSoul.harvestSpeed);
            float drawSpeedBoost = (drawSpeed - drawSpeedPreSoul) / drawSpeedPreSoul;
            list.add(color + getTooltipLine("DrawSpeed", drawSpeed, drawSpeedBoost));
            float arrowDamage = ModItems.bow.getArrowDamageForDisplay(tool);
            float arrowDamagePreSoul = ItemGemBow.getArrowDamageForDisplay(statsNoSoul.meleeDamage);
            float arrowDamageBoost = (arrowDamage - arrowDamagePreSoul) / arrowDamagePreSoul;
            list.add(color + getTooltipLine("ArrowDamage", arrowDamage, arrowDamageBoost));
        }
        list.add(color + getTooltipLine("ChargeSpeed", ToolHelper.getChargeSpeed(tool), 0f));
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.CtrlForProp"));
    }
    if (altDown) {
        // Statistics Header
        list.add(sep);
        line = loc.getMiscText("Tooltip.Statistics");
        list.add(line);
        list.add(getTooltipLine("BlocksMined", ToolHelper.getStatBlocksMined(tool), 0f));
        if (isDigger) {
            list.add(getTooltipLine("BlocksPlaced", ToolHelper.getStatBlocksPlaced(tool), 0f));
        }
        if (item instanceof ItemGemShovel) {
            list.add(getTooltipLine("PathsMade", ToolHelper.getStatPathsMade(tool), 0f));
        }
        if (item instanceof ItemGemHoe) {
            list.add(getTooltipLine("BlocksTilled", ToolHelper.getStatBlocksTilled(tool), 0f));
        }
        list.add(getTooltipLine("HitsLanded", ToolHelper.getStatHitsLanded(tool), 0f));
        if (isCaster || isBow)
            list.add(getTooltipLine("ShotsFired", ToolHelper.getStatShotsFired(tool), 0f));
        if (item instanceof ItemGemTomahawk)
            list.add(getTooltipLine("ThrownCount", ToolHelper.getStatThrownCount(tool), 0f));
        if (isWeapon)
            list.add(getTooltipLine("KillCount", ToolHelper.getStatKillCount(tool), 0f));
        list.add(getTooltipLine("Redecorated", ToolHelper.getStatRedecorated(tool), 0f));
        list.add(sep);
        line = loc.getMiscText("Tooltip.Construction");
        list.add(line);
        ToolPart[] parts = ToolHelper.getConstructionParts(tool);
        EnumMaterialGrade[] grades = ToolHelper.getConstructionGrades(tool);
        for (int i = 0; i < parts.length; ++i) {
            ToolPart part = parts[i];
            EnumMaterialGrade grade = grades[i];
            line = "  " + TextFormatting.YELLOW + part.getKey() + TextFormatting.GOLD + " (" + grade + ")";
            list.add(line);
        }
        ToolPart partRod = ToolHelper.getConstructionRod(tool);
        if (partRod != null) {
            list.add("  " + TextFormatting.YELLOW + partRod.getKey());
        }
        list.add(sep);
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.AltForStat"));
    }
    // Debug render layers
    if (controlDown && shiftDown && tool.hasTagCompound()) {
        if (!altDown)
            list.add(sep);
        list.add("Render Layers");
        IModelData modelData = getModelCache(tool);
        if (modelData != null) {
            for (ToolPartPosition pos : ToolPartPosition.values()) {
                String key = "Layer" + pos.ordinal();
                String str = "  %s: %s, %X";
                ToolPart renderPart = ToolHelper.getRenderPart(tool, pos);
                ModelResourceLocation model = renderPart == null ? null : renderPart.getModel(tool, pos, 0);
                str = String.format(str, pos.name(), model == null ? "null" : model.toString(), modelData.getColor(pos, 0));
                list.add(str);
            }
        }
    }
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) Item(net.minecraft.item.Item) ToolPartTip(net.silentchaos512.gems.api.tool.part.ToolPartTip) ToolPartPosition(net.silentchaos512.gems.api.lib.ToolPartPosition) TextFormatting(net.minecraft.util.text.TextFormatting) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) ItemGemShovel(net.silentchaos512.gems.item.tool.ItemGemShovel) UUID(java.util.UUID) ItemTool(net.minecraft.item.ItemTool) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) EnumMagicType(net.silentchaos512.gems.util.EnumMagicType) ItemGemAxe(net.silentchaos512.gems.item.tool.ItemGemAxe) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper) IModelData(net.silentchaos512.gems.lib.client.IModelData) ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) ItemGemTomahawk(net.silentchaos512.gems.item.tool.ItemGemTomahawk) ItemGemSword(net.silentchaos512.gems.item.tool.ItemGemSword) ItemGemHoe(net.silentchaos512.gems.item.tool.ItemGemHoe) ToolStats(net.silentchaos512.gems.api.tool.ToolStats)

Example 10 with EnumMaterialGrade

use of net.silentchaos512.gems.api.lib.EnumMaterialGrade in project SilentGems by SilentChaos512.

the class ToolPartMain method getRepairAmount.

@Override
public int getRepairAmount(ItemStack toolOrArmor, ItemStack partRep) {
    if (isBlacklisted(partRep)) {
        return 0;
    }
    if (GemsConfigHC.REPAIR_LOGIC != GemsConfigHC.EnumRepairLogic.CLASSIC) {
        ToolPart repairPart = ToolPartRegistry.fromStack(partRep);
        EnumMaterialGrade repairGrade = EnumMaterialGrade.fromStack(partRep);
        float amount = repairPart.getDurability() * (100 + repairGrade.bonusPercent) / 100;
        // Since armor has much lower durability per item, we'll adjust down for armor.
        if (toolOrArmor.getItem() instanceof IArmor) {
            amount /= 2f;
        }
        switch(GemsConfigHC.REPAIR_LOGIC) {
            case HARD_MATERIAL_BASED:
                return (int) (amount / 4f);
            case MATERIAL_BASED:
                return (int) (amount / 2f);
            case NOT_ALLOWED:
                return 0;
            default:
                break;
        }
    }
    // Classic repair logic.
    int max = toolOrArmor.getMaxDamage();
    float scale = 0.0f;
    EnumMaterialTier partTier = getTier();
    EnumMaterialTier stackTier = toolOrArmor.getItem() instanceof ITool ? ToolHelper.getToolTier(toolOrArmor) : (toolOrArmor.getItem() instanceof IArmor ? ArmorHelper.getArmorTier(toolOrArmor) : null);
    if (stackTier == null)
        return 0;
    int toolTierIndex = ToolHelper.getToolTier(toolOrArmor).ordinal();
    int partTierIndex = partTier.ordinal();
    scale = REPAIR_VALUES[toolTierIndex][partTierIndex];
    return (int) (scale * max);
}
Also used : EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) IArmor(net.silentchaos512.gems.api.IArmor) ITool(net.silentchaos512.gems.api.ITool)

Aggregations

EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)10 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)8 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)5 ITool (net.silentchaos512.gems.api.ITool)4 ItemStack (net.minecraft.item.ItemStack)3 TextFormatting (net.minecraft.util.text.TextFormatting)3 ToolSoul (net.silentchaos512.gems.lib.soul.ToolSoul)3 UUID (java.util.UUID)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ItemStatModifier (net.silentchaos512.gems.api.stats.ItemStatModifier)2 ToolStats (net.silentchaos512.gems.api.tool.ToolStats)2 ToolPartMain (net.silentchaos512.gems.api.tool.part.ToolPartMain)2 ToolPartTip (net.silentchaos512.gems.api.tool.part.ToolPartTip)2 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 Item (net.minecraft.item.Item)1 ItemTool (net.minecraft.item.ItemTool)1