9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-27 10:59:07 +00:00

添加优化排除文件夹

This commit is contained in:
jhqwqmc
2025-12-24 11:54:31 +08:00
parent 6ab38bd6aa
commit 4124ea8de7
5 changed files with 38 additions and 5 deletions

View File

@@ -63,7 +63,7 @@ The code you contribute will be open-sourced under the GPLv3 license. If you pre
Help sustain CraftEngine's development by going Premium!
- **Polymart**: [Support via Polymart](https://polymart.org/product/7624/craftengine)
- **BuiltByBit**: [None]
- **BuiltByBit**: [Support via BuiltByBit](https://builtbybit.com/resources/craftengine.82674/)
- **Afdian**: [Support via Afdian](https://afdian.com/@xiaomomi/)
## CraftEngine API

View File

@@ -110,10 +110,13 @@ resource-pack:
# If your image is special, for example, containing color pixels that need to be specifically recognized by a shader, the optimization might break it. You can add exclusions here.
exclude:
- assets/minecraft/textures/block/do_not_optimize.png
exclude-path:
- assets/minecraft/textures/block/do_not_optimize_path
# .json / .mcmeta
json:
enable: true
exclude: []
exclude-path: []
# [Premium Exclusive]
# Protect your resource pack from being cracked by others
protection:

View File

@@ -953,10 +953,22 @@ public abstract class AbstractPackManager implements PackManager {
List<Path> modelJsonToOptimize = new ArrayList<>();
Set<String> excludeTexture = new HashSet<>(Config.optimizeTextureExclude());
Set<String> excludeJson = new HashSet<>(Config.optimizeJsonExclude());
Set<String> excludeTexturePath = new HashSet<>(Config.optimizeTextureExcludePath());
Set<String> excludeJsonPath = new HashSet<>(Config.optimizeJsonExcludePath());
excludeTexture.addAll(this.parser.excludeTexture());
excludeJson.addAll(this.parser.excludeJson());
Predicate<Path> texturePathPredicate = p -> !excludeTexture.contains(CharacterUtils.replaceBackslashWithSlash(path.relativize(p).toString()));
Predicate<Path> jsonPathPredicate = p -> !excludeJson.contains(CharacterUtils.replaceBackslashWithSlash(path.relativize(p).toString()));
Predicate<Path> texturePathPredicate = p -> {
Path relativize = path.relativize(p);
boolean unFilteredFile = !excludeTexture.contains(CharacterUtils.replaceBackslashWithSlash(relativize.toString()));
boolean unFilteredPath = !excludeTexturePath.contains(CharacterUtils.replaceBackslashWithSlash(String.valueOf(relativize.getParent())));
return unFilteredFile && unFilteredPath;
};
Predicate<Path> jsonPathPredicate = p -> {
Path relativize = path.relativize(p);
boolean unFilteredFile = !excludeJson.contains(CharacterUtils.replaceBackslashWithSlash(relativize.toString()));
boolean unFilteredPath = !excludeJsonPath.contains(CharacterUtils.replaceBackslashWithSlash(String.valueOf(relativize.getParent())));
return unFilteredFile && unFilteredPath;
};
if (Config.optimizeJson()) {
Path metaPath = path.resolve("pack.mcmeta");

View File

@@ -109,9 +109,11 @@ public class Config {
protected boolean resource_pack$optimization$enable;
protected boolean resource_pack$optimization$texture$enable;
protected Set<String> resource_pack$optimization$texture$exlude;
protected Set<String> resource_pack$optimization$texture$exclude_path;
protected int resource_pack$optimization$texture$zopfli_iterations;
protected boolean resource_pack$optimization$json$enable;
protected Set<String> resource_pack$optimization$json$exclude;
protected Set<String> resource_pack$optimization$json$exclude_path;
protected MinecraftVersion resource_pack$supported_version$min;
protected MinecraftVersion resource_pack$supported_version$max;
@@ -391,11 +393,19 @@ public class Config {
if (!p.endsWith(".png")) return p + ".png";
return p;
}).collect(Collectors.toSet());
resource_pack$optimization$texture$exclude_path = config.getStringList("resource-pack.optimization.texture.exclude-path").stream().map(p -> {
if (p.endsWith("/")) return p.substring(0, p.length() - 1);
return p;
}).collect(Collectors.toSet());
resource_pack$optimization$json$enable = config.getBoolean("resource-pack.optimization.json.enable", true);
resource_pack$optimization$json$exclude = config.getStringList("resource-pack.optimization.json.exclude").stream().map(p -> {
if (!p.endsWith(".json") && !p.endsWith(".mcmeta")) return p + ".json";
return p;
}).collect(Collectors.toSet());
resource_pack$optimization$json$exclude_path = config.getStringList("resource-pack.optimization.json.exclude-path").stream().map(p -> {
if (p.endsWith("/")) return p.substring(0, p.length() - 1);
return p;
}).collect(Collectors.toSet());
resource_pack$validation$enable = config.getBoolean("resource-pack.validation.enable", true);
resource_pack$validation$fix_atlas = config.getBoolean("resource-pack.validation.fix-atlas", true);
resource_pack$exclude_core_shaders = config.getBoolean("resource-pack.exclude-core-shaders", false);
@@ -1209,6 +1219,10 @@ public class Config {
return instance.resource_pack$optimization$texture$exlude;
}
public static Set<String> optimizeTextureExcludePath() {
return instance.resource_pack$optimization$texture$exclude_path;
}
public static boolean optimizeJson() {
return instance.resource_pack$optimization$json$enable;
}
@@ -1217,6 +1231,10 @@ public class Config {
return instance.resource_pack$optimization$json$exclude;
}
public static Set<String> optimizeJsonExcludePath() {
return instance.resource_pack$optimization$json$exclude_path;
}
public static int zopfliIterations() {
return instance.resource_pack$optimization$texture$zopfli_iterations;
}

View File

@@ -2,8 +2,8 @@ org.gradle.jvmargs=-Xmx4G
# Project settings
project_version=0.0.66.10
config_version=65
lang_version=47
config_version=66
lang_version=48
project_group=net.momirealms
latest_supported_version=1.21.11