Search in sources :

Example 1 with IToolPart

use of slimeknights.tconstruct.library.tools.part.IToolPart in project TinkersConstruct by SlimeKnights.

the class PartRequirement method read.

/**
 * Reads a tool definition stat object from a packet buffer
 */
public static PartRequirement read(FriendlyByteBuf buffer) {
    if (buffer.readBoolean()) {
        IToolPart part = RecipeHelper.readItem(buffer, IToolPart.class);
        int weight = buffer.readVarInt();
        return ofPart(part, weight);
    } else {
        MaterialStatsId statsId = new MaterialStatsId(buffer.readResourceLocation());
        int weight = buffer.readVarInt();
        return ofStat(statsId, weight);
    }
}
Also used : MaterialStatsId(slimeknights.tconstruct.library.materials.stats.MaterialStatsId) IToolPart(slimeknights.tconstruct.library.tools.part.IToolPart)

Example 2 with IToolPart

use of slimeknights.tconstruct.library.tools.part.IToolPart in project TinkersConstruct by SlimeKnights.

the class TinkerStationRepairRecipe method getRepairPerItem.

/**
 * Gets the amount to repair per item
 */
protected float getRepairPerItem(ToolStack tool, ITinkerStationContainer inv, int slot, MaterialId repairMaterial) {
    ItemStack stack = inv.getInput(slot);
    // repair kit first
    ToolDefinitionData toolData = tool.getDefinition().getData();
    if (stack.getItem() == TinkerToolParts.repairKit.get()) {
        // multiply by 2 (part cost), divide again by the repair factor to get the final percent
        return MaterialRecipe.getRepairDurability(toolData, repairMaterial, getDefaultStatsId(tool, repairMaterial)) * 2 / MaterialRecipe.INGOTS_PER_REPAIR;
    } else {
        // material recipe fallback
        MaterialRecipe recipe = inv.getInputMaterial(slot);
        if (recipe != null) {
            if (stack.getItem() instanceof IToolPart) {
                return recipe.getRepairPerItem(toolData, ((IToolPart) stack.getItem()).getStatType());
            }
            return recipe.getRepairPerItem(toolData, getDefaultStatsId(tool, repairMaterial));
        }
    }
    return 0;
}
Also used : ToolDefinitionData(slimeknights.tconstruct.library.tools.definition.ToolDefinitionData) ItemStack(net.minecraft.world.item.ItemStack) MaterialRecipe(slimeknights.tconstruct.library.recipe.material.MaterialRecipe) IToolPart(slimeknights.tconstruct.library.tools.part.IToolPart)

Aggregations

IToolPart (slimeknights.tconstruct.library.tools.part.IToolPart)2 ItemStack (net.minecraft.world.item.ItemStack)1 MaterialStatsId (slimeknights.tconstruct.library.materials.stats.MaterialStatsId)1 MaterialRecipe (slimeknights.tconstruct.library.recipe.material.MaterialRecipe)1 ToolDefinitionData (slimeknights.tconstruct.library.tools.definition.ToolDefinitionData)1