mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
完善atlas生成
This commit is contained in:
@@ -1248,8 +1248,8 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
Multimap<Key, Key> textureToEquipments = ArrayListMultimap.create(); // 纹理到盔甲的映射
|
||||
Multimap<Key, Key> oggToSoundEvents = ArrayListMultimap.create(); // 音频到声音的映射
|
||||
|
||||
Map<Path, JsonObject> blockAtlasJsons = new HashMap<>();
|
||||
Map<Path, JsonObject> itemAtlasJsons = new HashMap<>();
|
||||
Map<Path, JsonObject> blockAtlasJsons = new LinkedHashMap<>();
|
||||
Map<Path, JsonObject> itemAtlasJsons = new LinkedHashMap<>();
|
||||
|
||||
// 如果需要验证资源包,则需要先读取所有atlas
|
||||
for (Path rootPath : rootPaths) {
|
||||
@@ -1291,6 +1291,24 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
itemAtlasJsons.put(defaultItemAtlas, new JsonObject());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
构建Atlas文件
|
||||
|
||||
|
||||
*/
|
||||
Atlas blockAtlas = new Atlas(MiscUtils.make(new ArrayList<>(), k -> {
|
||||
k.add(blockAtlasJsons.get(defaultBlockAtlas));
|
||||
k.add(this.vanillaBlockAtlas);
|
||||
return k;
|
||||
}));
|
||||
Atlas itemAtlas = new Atlas(MiscUtils.make(new ArrayList<>(), k -> {
|
||||
k.add(itemAtlasJsons.get(defaultItemAtlas));
|
||||
k.add(this.vanillaItemAtlas);
|
||||
return k;
|
||||
}));
|
||||
|
||||
for (Path rootPath : rootPaths) {
|
||||
Path assetsPath = rootPath.resolve("assets");
|
||||
if (!Files.isDirectory(assetsPath)) continue;
|
||||
@@ -1512,24 +1530,6 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
/*
|
||||
|
||||
|
||||
构建Atlas文件
|
||||
|
||||
|
||||
*/
|
||||
Atlas blockAtlas = new Atlas(MiscUtils.make(new ArrayList<>(), k -> {
|
||||
k.addAll(blockAtlasJsons.values());
|
||||
k.add(this.vanillaBlockAtlas);
|
||||
return k;
|
||||
}));
|
||||
Atlas itemAtlas = new Atlas(MiscUtils.make(new ArrayList<>(), k -> {
|
||||
k.addAll(itemAtlasJsons.values());
|
||||
k.add(this.vanillaItemAtlas);
|
||||
return k;
|
||||
}));
|
||||
|
||||
/*
|
||||
|
||||
|
||||
收集全部 含有贴图的有效模型阶段
|
||||
有效指的是被实际使用的模型
|
||||
|
||||
@@ -1753,7 +1753,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.fixTextureAtlas()) {
|
||||
if (Config.fixTextureAtlas() && !Config.enableObfuscation()) {
|
||||
// 获取两个 Multimap 的所有 key
|
||||
// 找出相同的 key
|
||||
Set<Key> commonKeys = new LinkedHashSet<>(blockAtlasesToFix.keySet());
|
||||
@@ -1792,6 +1792,13 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
后续我们先对剩余的正常模型进行贴图路径验证(此阶段不验证那些存在atlas问题的模型,理论已被全部移除)
|
||||
|
||||
*/
|
||||
|
||||
// 如果最低支持版本太低了,那么全部塞blocks.json里
|
||||
if (!Config.packMinVersion().isAtOrAbove(MinecraftVersions.V1_21_11)) {
|
||||
blockAtlasesToFix.putAll(itemAtlasesToFix);
|
||||
itemAtlasesToFix.clear();
|
||||
}
|
||||
|
||||
if (!itemAtlasesToFix.isEmpty()) {
|
||||
List<JsonObject> sourcesToAdd = new ArrayList<>();
|
||||
for (Key itemTexture : itemAtlasesToFix.keySet()) {
|
||||
|
||||
@@ -122,6 +122,7 @@ public final class Atlas {
|
||||
JsonArray newSources = new JsonArray();
|
||||
atlasJson.add("sources", newSources);
|
||||
for (JsonObject other : atlasJsons) {
|
||||
if (other == null) continue;
|
||||
JsonArray sources = other.getAsJsonArray("sources");
|
||||
if (sources != null) {
|
||||
newSources.addAll(sources);
|
||||
|
||||
Reference in New Issue
Block a user