Search in sources :

Example 1 with BlockRenderType

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);
}
Also used : NamespacedId(net.coderbot.iris.shaderpack.materialmap.NamespacedId) BlockRenderType(net.coderbot.iris.shaderpack.materialmap.BlockRenderType) List(java.util.List) ShaderPack(net.coderbot.iris.shaderpack.ShaderPack) Test(org.junit.jupiter.api.Test)

Example 2 with BlockRenderType

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;
}
Also used : NamespacedId(net.coderbot.iris.shaderpack.materialmap.NamespacedId) HashMap(java.util.HashMap) Object2IntOpenHashMap(it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) BlockRenderType(net.coderbot.iris.shaderpack.materialmap.BlockRenderType)

Aggregations

BlockRenderType (net.coderbot.iris.shaderpack.materialmap.BlockRenderType)2 NamespacedId (net.coderbot.iris.shaderpack.materialmap.NamespacedId)2 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 Object2IntOpenHashMap (it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ShaderPack (net.coderbot.iris.shaderpack.ShaderPack)1 Test (org.junit.jupiter.api.Test)1