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);
}
}
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;
}
Aggregations