mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
添加自定义生成资源包路径
This commit is contained in:
@@ -10,6 +10,9 @@ forced-locale: ''
|
|||||||
filter-configuration-phase-disconnect: false
|
filter-configuration-phase-disconnect: false
|
||||||
|
|
||||||
resource-pack:
|
resource-pack:
|
||||||
|
# This option determines the location of the generated resource pack
|
||||||
|
# You can use either an absolute path or a relative path here
|
||||||
|
path: "./generated/resource_pack.zip"
|
||||||
# Should those images in minecraft:default font also work in minecraft:uniform
|
# Should those images in minecraft:default font also work in minecraft:uniform
|
||||||
override-uniform-font: true
|
override-uniform-font: true
|
||||||
# Generate assets for CraftEngine fabric mod
|
# Generate assets for CraftEngine fabric mod
|
||||||
|
|||||||
@@ -191,9 +191,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path resourcePackPath() {
|
public Path resourcePackPath() {
|
||||||
return this.plugin.dataFolderPath()
|
return Config.resourcePackPath();
|
||||||
.resolve("generated")
|
|
||||||
.resolve("resource_pack.zip");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -203,7 +201,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
if (hostingObj instanceof Map<?,?>) {
|
if (hostingObj instanceof Map<?,?>) {
|
||||||
arguments = MiscUtils.castToMap(hostingObj, false);
|
arguments = MiscUtils.castToMap(hostingObj, false);
|
||||||
} else if (hostingObj instanceof List<?> list && !list.isEmpty()) {
|
} else if (hostingObj instanceof List<?> list && !list.isEmpty()) {
|
||||||
arguments = MiscUtils.castToMap(list.get(0), false);
|
arguments = MiscUtils.castToMap(list.getFirst(), false);
|
||||||
} else {
|
} else {
|
||||||
this.resourcePackHost = NoneHost.INSTANCE;
|
this.resourcePackHost = NoneHost.INSTANCE;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class Config {
|
|||||||
protected List<String> resource_pack$merge_external_folders;
|
protected List<String> resource_pack$merge_external_folders;
|
||||||
protected List<String> resource_pack$merge_external_zips;
|
protected List<String> resource_pack$merge_external_zips;
|
||||||
protected Set<String> resource_pack$exclude_file_extensions;
|
protected Set<String> resource_pack$exclude_file_extensions;
|
||||||
|
protected Path resource_pack$path;
|
||||||
|
|
||||||
protected boolean resource_pack$protection$crash_tools$method_1;
|
protected boolean resource_pack$protection$crash_tools$method_1;
|
||||||
protected boolean resource_pack$protection$crash_tools$method_2;
|
protected boolean resource_pack$protection$crash_tools$method_2;
|
||||||
@@ -282,6 +283,7 @@ public class Config {
|
|||||||
debug$resource_pack = config.getBoolean("debug.resource-pack", false);
|
debug$resource_pack = config.getBoolean("debug.resource-pack", false);
|
||||||
|
|
||||||
// resource pack
|
// resource pack
|
||||||
|
resource_pack$path = resolvePath(config.getString("resource-pack.path", "./generated/resource_pack.zip"));
|
||||||
resource_pack$override_uniform_font = config.getBoolean("resource-pack.override-uniform-font", false);
|
resource_pack$override_uniform_font = config.getBoolean("resource-pack.override-uniform-font", false);
|
||||||
resource_pack$generate_mod_assets = config.getBoolean("resource-pack.generate-mod-assets", false);
|
resource_pack$generate_mod_assets = config.getBoolean("resource-pack.generate-mod-assets", false);
|
||||||
resource_pack$remove_tinted_leaves_particle = config.getBoolean("resource-pack.remove-tinted-leaves-particle", true);
|
resource_pack$remove_tinted_leaves_particle = config.getBoolean("resource-pack.remove-tinted-leaves-particle", true);
|
||||||
@@ -1010,6 +1012,10 @@ public class Config {
|
|||||||
return instance.item$default_material;
|
return instance.item$default_material;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Path resourcePackPath() {
|
||||||
|
return instance.resource_pack$path;
|
||||||
|
}
|
||||||
|
|
||||||
public void setObf(boolean enable) {
|
public void setObf(boolean enable) {
|
||||||
this.resource_pack$protection$obfuscation$enable = enable;
|
this.resource_pack$protection$obfuscation$enable = enable;
|
||||||
}
|
}
|
||||||
@@ -1065,7 +1071,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Path resolvePath(String path) {
|
private Path resolvePath(String path) {
|
||||||
return path.startsWith(".") ? CraftEngine.instance().dataFolderPath().resolve(path) : Path.of(path);
|
return FileUtils.isAbsolute(path) ? Path.of(path) : this.plugin.dataFolderPath().resolve(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public YamlDocument settings() {
|
public YamlDocument settings() {
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ public class FileUtils {
|
|||||||
|
|
||||||
private FileUtils() {}
|
private FileUtils() {}
|
||||||
|
|
||||||
|
public static boolean isAbsolute(final String path) {
|
||||||
|
return path.startsWith("/") || path.matches("^[A-Za-z]:\\\\.*");
|
||||||
|
}
|
||||||
|
|
||||||
public static String getExtension(Path path) {
|
public static String getExtension(Path path) {
|
||||||
final String name = path.getFileName().toString();
|
final String name = path.getFileName().toString();
|
||||||
int index = name.lastIndexOf('.');
|
int index = name.lastIndexOf('.');
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ public class Int2ObjectBiMap<K> implements IndexedIterable<K> {
|
|||||||
for (int i = 0; i < idToValues.length; i++) {
|
for (int i = 0; i < idToValues.length; i++) {
|
||||||
K prev = idToValues[i];
|
K prev = idToValues[i];
|
||||||
if (prev == null) break;
|
if (prev == null) break;
|
||||||
idToValues[i] = function.apply(prev);
|
K apply = function.apply(prev);
|
||||||
|
idToValues[i] = apply;
|
||||||
|
if (!apply.equals(prev)) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -172,7 +176,7 @@ public class Int2ObjectBiMap<K> implements IndexedIterable<K> {
|
|||||||
|
|
||||||
private int findFree(int size) {
|
private int findFree(int size) {
|
||||||
int i;
|
int i;
|
||||||
for(i = size; i < this.values.length; ++i) {
|
for (i = size; i < this.values.length; ++i) {
|
||||||
if (this.values[i] == EMPTY) {
|
if (this.values[i] == EMPTY) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user