use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class TinkerStationRepairRecipe method updateInputs.
@Override
public void updateInputs(ItemStack result, IMutableTinkerStationContainer inv, boolean isServer) {
ToolStack inputTool = ToolStack.from(inv.getTinkerableStack());
ToolStack resultTool = ToolStack.from(result);
// iterate stacks, removing items as we repair
int repairRemaining = inputTool.getDamage() - resultTool.getDamage();
MaterialId primaryMaterial = getPrimaryMaterial(inputTool);
for (int i = 0; i < inv.getInputCount() && repairRemaining > 0; i++) {
final int slot = i;
repairRemaining -= repairFromSlot(inputTool, primaryMaterial, inv, repairRemaining, i, count -> inv.shrinkInput(slot, count));
}
if (repairRemaining > 0) {
TConstruct.LOG.error("Recipe repair on {} consumed too few items. {} durability unaccounted for", result, repairRemaining);
}
}
use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class MaterialStatsManager method finishLoad.
@Override
protected void finishLoad(Map<ResourceLocation, Map<ResourceLocation, JsonObject>> map, ResourceManager manager) {
// Take the final structure and actually load the different material stats. This drops all invalid stats
materialToStatsPerType = map.entrySet().stream().collect(Collectors.toMap(entry -> new MaterialId(entry.getKey()), entry -> deserializeMaterialStatsFromContent(entry.getValue())));
log.debug("Loaded stats for materials:{}", Util.toIndentedStringList(materialToStatsPerType.entrySet().stream().map(entry -> String.format("%s - %s", entry.getKey(), Arrays.toString(entry.getValue().keySet().toArray()))).collect(Collectors.toList())));
onLoaded.run();
}
use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class MaterialTraitsManagerTest method empty.
@Test
void empty() {
MaterialId empty = new MaterialId(TConstruct.getResource("empty"));
fileLoader.loadAndParseFiles(null, empty);
// ensure we got this far and there were no errors
List<ModifierEntry> defaultTraits = traitsManager.getDefaultTraits(DEFAULT_TRAITS);
assertThat(defaultTraits).isNotNull();
assertThat(defaultTraits).isEmpty();
}
use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class SpecializedRepairRecipeSerializer method fromNetworkSafe.
@Nullable
@Override
protected T fromNetworkSafe(ResourceLocation id, FriendlyByteBuf buffer) {
Ingredient tool = Ingredient.fromNetwork(buffer);
MaterialId repairMaterial = new MaterialId(buffer.readUtf(Short.MAX_VALUE));
return factory.create(id, tool, repairMaterial);
}
use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class MaterialIdNBT method resolveRedirects.
/**
* Resolves all redirects, replacing with material redirects
*/
public MaterialIdNBT resolveRedirects() {
boolean changed = false;
ImmutableList.Builder<MaterialVariantId> builder = ImmutableList.builder();
IMaterialRegistry registry = MaterialRegistry.getInstance();
for (MaterialVariantId id : materials) {
MaterialId original = id.getId();
MaterialId resolved = registry.resolve(original);
if (resolved != original) {
changed = true;
}
builder.add(MaterialVariantId.create(resolved, id.getVariant()));
}
// return a new instance only if things changed
if (changed) {
return new MaterialIdNBT(builder.build());
}
return this;
}
Aggregations