use of net.coderbot.iris.shaderpack.materialmap.BlockRenderType in project Iris by IrisShaders.
the class IdMapTest method testLoadIdMaps.
@Test
void testLoadIdMaps() {
ShaderPack shaderPack;
// ensure that we can actually load the shader pack
try {
shaderPack = new ShaderPack(IrisTests.getTestShaderPackPath("id_maps"));
} catch (Exception e) {
Assertions.fail("Couldn't load test shader pack id_maps", e);
return;
}
Map<NamespacedId, BlockRenderType> overrides = shaderPack.getIdMap().getBlockRenderTypeMap();
Int2ObjectMap<List<BlockEntry>> blocks = shaderPack.getIdMap().getBlockProperties();
Assertions.assertEquals(EXPECTED_LAYERS, overrides);
Assertions.assertEquals(EXPECTED_BLOCKS, blocks);
}
use of net.coderbot.iris.shaderpack.materialmap.BlockRenderType in project Iris by IrisShaders.
the class IdMap method parseRenderTypeMap.
/**
* Parses a render layer map.
*
* This feature is used by Chocapic v9 and Wisdom Shaders. Otherwise, it is a rarely-used feature.
*/
private static Map<NamespacedId, BlockRenderType> parseRenderTypeMap(Properties properties, String keyPrefix, String fileName) {
Map<NamespacedId, BlockRenderType> overrides = new HashMap<>();
properties.forEach((keyObject, valueObject) -> {
String key = (String) keyObject;
String value = (String) valueObject;
if (!key.startsWith(keyPrefix)) {
// Not a valid line, ignore it
return;
}
// Note: We have to remove the prefix "layer." because fromString expects "cutout", not "layer.cutout".
String keyWithoutPrefix = key.substring(keyPrefix.length());
BlockRenderType renderType = BlockRenderType.fromString(keyWithoutPrefix).orElse(null);
if (renderType == null) {
Iris.logger.warn("Failed to parse line in " + fileName + ": invalid block render type: " + key);
return;
}
for (String part : value.split("\\s+")) {
// Note: NamespacedId performs no validation on the content. That will need to be done by whatever is
// converting these things to ResourceLocations.
overrides.put(new NamespacedId(part), renderType);
}
});
return overrides;
}
Aggregations