9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 18:09:27 +00:00

Merge pull request #237 from jhqwqmc/dev

feat(core): 添加删除所有着色器的功能
This commit is contained in:
XiaoMoMi
2025-06-22 02:04:58 +08:00
committed by GitHub
4 changed files with 30 additions and 1 deletions

View File

@@ -62,6 +62,8 @@ resource-pack:
max: LATEST
# Remove 1.21.5+ tinted_leaves particles
remove-tinted-leaves-particle: true
# Remove all shaders
remove-all-shaders: false
merge-external-folders:
- ModelEngine/resource pack
- BetterModel/build

View File

@@ -615,6 +615,9 @@ public abstract class AbstractPackManager implements PackManager {
this.generateClientLang(generatedPackPath);
this.generateEquipments(generatedPackPath);
this.generateParticle(generatedPackPath);
if (Config.removeAllShaders()) {
this.removeAllShaders(generatedPackPath);
}
if (Config.validateResourcePack()) {
this.validateResourcePack(generatedPackPath);
}
@@ -631,6 +634,24 @@ public abstract class AbstractPackManager implements PackManager {
}
}
private void removeAllShaders(Path path) {
List<Path> rootPaths;
try {
rootPaths = FileUtils.collectOverlays(path);
} catch (IOException e) {
plugin.logger().warn("Failed to collect overlays for " + path.toAbsolutePath(), e);
return;
}
for (Path rootPath : rootPaths) {
Path shadersPath = rootPath.resolve("assets/minecraft/shaders");
try {
FileUtils.deleteDirectory(shadersPath);
} catch (IOException e) {
plugin.logger().warn("Failed to delete shaders directory for " + shadersPath.toAbsolutePath(), e);
}
}
}
@SuppressWarnings("DuplicatedCode")
private void validateResourcePack(Path path) {
List<Path> rootPaths;

View File

@@ -60,6 +60,7 @@ public class Config {
protected boolean resource_pack$protection$crash_tools$method_3;
protected boolean resource_pack$validate$enable;
protected boolean resource_pack$remove_all_shaders;
protected boolean resource_pack$protection$obfuscation$enable;
protected long resource_pack$protection$obfuscation$seed;
@@ -262,6 +263,7 @@ public class Config {
resource_pack$protection$obfuscation$resource_location$bypass_sounds = config.getStringList("resource-pack.protection.obfuscation.resource-location.bypass-sounds");
resource_pack$protection$obfuscation$resource_location$bypass_equipments = config.getStringList("resource-pack.protection.obfuscation.resource-location.bypass-equipments");
resource_pack$validate$enable = config.getBoolean("resource-pack.validate.enable", true);
resource_pack$remove_all_shaders = config.getBoolean("resource-pack.remove-all-shaders", false);
try {
resource_pack$duplicated_files_handler = config.getMapList("resource-pack.duplicated-files-handler").stream().map(it -> {
@@ -736,6 +738,10 @@ public class Config {
return instance.resource_pack$validate$enable;
}
public static boolean removeAllShaders() {
return instance.resource_pack$remove_all_shaders;
}
public YamlDocument loadOrCreateYamlData(String fileName) {
Path path = this.plugin.dataFolderPath().resolve(fileName);
if (!Files.exists(path)) {

View File

@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=0.0.57.6
config_version=37
config_version=38
lang_version=19
project_group=net.momirealms
latest_supported_version=1.21.6