mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-10-26 14:24:30 +00:00
Load modern block properties (#1626)
This commit is contained in:
1 parent
27e9a4d4fd
commit
9fd02900ef
3 files changed
+73
-6
No files matched your search
@@ -235,6 +235,11 @@ public class AngelicaConfig {
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean enableHardcodedCustomUniforms;
|
||||
|
||||
@Config.Comment("Modern MC_VERSION to try if shader pack has no 1.7.10 section. 0 = default (260101)")
|
||||
@Config.DefaultInt(0)
|
||||
@Config.RangeInt(min = 0)
|
||||
public static int modernFallbackMcVersion;
|
||||
|
||||
@Config.Comment("Define IS_IRIS in shader macros.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean defineIsIris;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.coderbot.iris.shaderpack;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
@@ -58,14 +59,42 @@ public class IdMap {
|
||||
private Map<NamespacedId, BlockRenderType> blockRenderTypeMap;
|
||||
|
||||
IdMap(Path shaderPath, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) {
|
||||
itemIdMap = loadProperties(shaderPath, "item.properties", shaderPackOptions, environmentDefines).map(IdMap::parseItemIdMap).orElse(Object2IntMaps.emptyMap());
|
||||
// Check if block.properties has a dedicated 1.7.10 section
|
||||
String rawBlockProperties = readProperties(shaderPath, "block.properties");
|
||||
boolean hasLegacySection = rawBlockProperties != null
|
||||
&& rawBlockProperties.contains("MC_VERSION") && rawBlockProperties.contains("10710");
|
||||
|
||||
entityIdMap = loadProperties(shaderPath, "entity.properties", shaderPackOptions, environmentDefines).map(IdMap::parseEntityIdMap).orElse(Object2IntMaps.emptyMap());
|
||||
Iterable<StringPair> resolvedDefines;
|
||||
if (hasLegacySection) {
|
||||
// Pack has a 1.7.10 section
|
||||
resolvedDefines = environmentDefines;
|
||||
loadProperties(shaderPath, "block.properties", shaderPackOptions, environmentDefines).ifPresent(blockProperties -> {
|
||||
blockPropertiesMap = parseBlockMap(blockProperties, "block.", "block.properties");
|
||||
blockRenderTypeMap = parseRenderTypeMap(blockProperties, "layer.", "block.properties");
|
||||
});
|
||||
} else {
|
||||
// No 1.7.10 section, use modern MC_VERSION and convert entries
|
||||
ArrayList<StringPair> modernDefines = new ArrayList<>();
|
||||
for (StringPair define : environmentDefines) {
|
||||
if (!"MC_VERSION".equals(define.getKey())) {
|
||||
modernDefines.add(define);
|
||||
}
|
||||
}
|
||||
|
||||
loadProperties(shaderPath, "block.properties", shaderPackOptions, environmentDefines).ifPresent(blockProperties -> {
|
||||
blockPropertiesMap = parseBlockMap(blockProperties, "block.", "block.properties");
|
||||
blockRenderTypeMap = parseRenderTypeMap(blockProperties, "layer.", "block.properties");
|
||||
});
|
||||
String modernVersion = AngelicaConfig.modernFallbackMcVersion > 0
|
||||
? String.valueOf(AngelicaConfig.modernFallbackMcVersion) : "260101";
|
||||
modernDefines.add(new StringPair("MC_VERSION", modernVersion));
|
||||
resolvedDefines = modernDefines;
|
||||
|
||||
loadProperties(shaderPath, "block.properties", shaderPackOptions, modernDefines).ifPresent(blockProperties -> {
|
||||
blockPropertiesMap = parseBlockMap(blockProperties, "block.", "block.properties");
|
||||
blockRenderTypeMap = parseRenderTypeMap(blockProperties, "layer.", "block.properties");
|
||||
blockPropertiesMap = LegacyIdMap.convertModernBlockEntries(blockPropertiesMap);
|
||||
});
|
||||
}
|
||||
|
||||
itemIdMap = loadProperties(shaderPath, "item.properties", shaderPackOptions, resolvedDefines).map(IdMap::parseItemIdMap).orElse(Object2IntMaps.emptyMap());
|
||||
entityIdMap = loadProperties(shaderPath, "entity.properties", shaderPackOptions, resolvedDefines).map(IdMap::parseEntityIdMap).orElse(Object2IntMaps.emptyMap());
|
||||
|
||||
// TODO: Properly override block render layers
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.coderbot.iris.shaderpack;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import it.unimi.dsi.fastutil.Function;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.coderbot.iris.shaderpack.materialmap.BlockEntry;
|
||||
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
|
||||
|
||||
@@ -10,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LegacyIdMap {
|
||||
private static final ImmutableList<String> COLORS =
|
||||
@@ -19,6 +21,11 @@ public class LegacyIdMap {
|
||||
private static final ImmutableList<String> WOOD_TYPES =
|
||||
ImmutableList.of("oak", "birch", "jungle", "spruce", "acacia", "dark_oak");
|
||||
|
||||
private static final Map<String, String> MODERN_TO_LEGACY_BLOCK_IDS = Map.of(
|
||||
"grass", "tallgrass",
|
||||
"grass_block", "grass"
|
||||
);
|
||||
|
||||
public static void addLegacyValues(Int2ObjectMap<List<BlockEntry>> blockIdMap) {
|
||||
add(blockIdMap, 1, block("stone"), block("granite"), block("diorite"), block("andesite"));
|
||||
add(blockIdMap, 2, block("grass_block"));
|
||||
@@ -78,6 +85,32 @@ public class LegacyIdMap {
|
||||
// TODO: 76 -> redstone_torch (on)
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<List<BlockEntry>> convertModernBlockEntries(Int2ObjectMap<List<BlockEntry>> blockIdMap) {
|
||||
Int2ObjectMap<List<BlockEntry>> converted = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
blockIdMap.forEach((intId, entries) -> {
|
||||
List<BlockEntry> convertedEntries = new ArrayList<>(entries.size());
|
||||
for (BlockEntry entry : entries) {
|
||||
NamespacedId id = entry.getId();
|
||||
if (!"minecraft".equals(id.getNamespace())) {
|
||||
convertedEntries.add(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
String convertedName = MODERN_TO_LEGACY_BLOCK_IDS.get(id.getName());
|
||||
if (convertedName == null) {
|
||||
convertedEntries.add(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
convertedEntries.add(new BlockEntry(new NamespacedId(id.getNamespace(), convertedName), entry.getMetas()));
|
||||
}
|
||||
converted.put(intId, Collections.unmodifiableList(convertedEntries));
|
||||
});
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
private static BlockEntry block(String name) {
|
||||
return new BlockEntry(new NamespacedId("minecraft", name), Collections.emptySet());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user