use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class MaterialRegistryExtension method beforeEach.
@Override
public void beforeEach(ExtensionContext context) {
Map<IMaterial, List<IMaterialStats>> materialSetup = MaterialFixture.ALL_MATERIAL_FIXTURES;
Map<MaterialId, IMaterial> materials = materialSetup.keySet().stream().collect(Collectors.toMap(IMaterial::getIdentifier, Function.identity()));
Map<MaterialId, Map<MaterialStatsId, IMaterialStats>> stats = materialSetup.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().getIdentifier(), entry -> entry.getValue().stream().collect(Collectors.toMap(IMaterialStats::getIdentifier, Function.identity()))));
Map<MaterialStatsId, IMaterialStats> defaultStats = MaterialStatsFixture.TIC_DEFAULT_STATS.stream().collect(Collectors.toMap(IMaterialStats::getIdentifier, Function.identity()));
// empty map as nothing using the extension uses traits
materialRegistry = new MaterialRegistryFixture(materials, stats, defaultStats, Collections.emptyMap());
MaterialRegistry.INSTANCE = new MaterialRegistry(materialRegistry);
}
use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class MaterialStatsManagerTest method testLoadFileWithEmptyStats_ok.
@Test
void testLoadFileWithEmptyStats_ok() {
MaterialId material = new MaterialId(TConstruct.getResource("empty"));
fileLoader.loadAndParseFiles(null, material);
// ensure that we get this far and that querying the missing material causes no errors
Optional<ComplexTestStats> optionalStats = materialStatsManager.getStats(material, STATS_ID_DONT_CARE);
assertThat(optionalStats).isEmpty();
}
use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class MaterialStatsManagerTest method testLoadFile_statsExist.
@Test
void testLoadFile_statsExist() {
materialStatsManager.registerMaterialStat(DEFAULT, ComplexTestStats.class, ComplexTestStats::new);
MaterialId material = new MaterialId(TConstruct.getResource("teststat"));
fileLoader.loadAndParseFiles(null, material);
Optional<BaseMaterialStats> optionalStats = materialStatsManager.getStats(material, STATS_ID_SIMPLE);
assertThat(optionalStats).isPresent();
}
use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class MaterialStatsManagerTest method testLoadFile_complexStats.
@Test
void testLoadFile_complexStats() {
materialStatsManager.registerMaterialStat(DEFAULT, ComplexTestStats.class, ComplexTestStats::new);
MaterialId material = new MaterialId(TConstruct.getResource("teststat"));
fileLoader.loadAndParseFiles(null, material);
Optional<ComplexTestStats> optionalStats = materialStatsManager.getStats(material, STATS_ID_SIMPLE);
assertThat(optionalStats).isPresent();
ComplexTestStats stats = optionalStats.get();
assertThat(stats.getNum()).isEqualTo(123);
assertThat(stats.getFloating()).isEqualTo(12.34f);
assertThat(stats.getText()).isEqualTo("why would you ever do this for stats");
}
use of slimeknights.tconstruct.library.materials.definition.MaterialId in project TinkersConstruct by SlimeKnights.
the class MaterialStatsManagerTest method testLoadMultipleFiles_addDifferentStatsToSameMaterial.
@Test
void testLoadMultipleFiles_addDifferentStatsToSameMaterial() {
MaterialStatsId otherStatId = new MaterialStatsId("test", "otherstat");
materialStatsManager.registerMaterialStat(DEFAULT, ComplexTestStats.class, ComplexTestStats::new);
materialStatsManager.registerMaterialStat(new ComplexTestStats(otherStatId, 5, 8, "other"), ComplexTestStats.class, ComplexTestStats::new);
MaterialId material = new MaterialId(TConstruct.getResource("teststat"));
fileLoader.loadAndParseFiles("extrastats", material);
assertThat(materialStatsManager.getStats(material, STATS_ID_SIMPLE)).isNotEmpty();
assertThat(materialStatsManager.getStats(material, otherStatId)).isNotEmpty();
}
Aggregations