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:
@@ -203,10 +203,9 @@ fun registerPaperTask(
|
|||||||
version: String,
|
version: String,
|
||||||
dirName: String = version,
|
dirName: String = version,
|
||||||
javaVersion : Int = 21,
|
javaVersion : Int = 21,
|
||||||
serverJar: File? = null,
|
serverJar: File? = null
|
||||||
downloadPlugins: Action<DownloadPluginsSpec>? = null
|
|
||||||
) {
|
) {
|
||||||
listOf(version, "${version}-with-viaversion").forEach { taskName ->
|
listOf(version).forEach { taskName ->
|
||||||
tasks.register(taskName, RunServer::class) {
|
tasks.register(taskName, RunServer::class) {
|
||||||
group = "run dev server"
|
group = "run dev server"
|
||||||
minecraftVersion(version)
|
minecraftVersion(version)
|
||||||
@@ -224,18 +223,6 @@ fun registerPaperTask(
|
|||||||
jvmArgs("-Ddisable.watchdog=true")
|
jvmArgs("-Ddisable.watchdog=true")
|
||||||
jvmArgs("-Xlog:redefine+class*=info")
|
jvmArgs("-Xlog:redefine+class*=info")
|
||||||
jvmArgs("-XX:+AllowEnhancedClassRedefinition")
|
jvmArgs("-XX:+AllowEnhancedClassRedefinition")
|
||||||
if (taskName.contains("viaversion")) {
|
|
||||||
downloadPlugins {
|
|
||||||
url("https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/${getJenkinsArtifactFileName("https://ci.viaversion.com/job/ViaVersion/lastSuccessfulBuild/api/json?tree=artifacts[*]")}")
|
|
||||||
url("https://ci.viaversion.com/view/ViaBackwards/job/ViaBackwards/662/artifact/build/libs/${getJenkinsArtifactFileName("https://ci.viaversion.com/job/ViaBackwards/lastSuccessfulBuild/api/json?tree=artifacts[*]")}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getJenkinsArtifactFileName(url: String): String {
|
|
||||||
val response = URI.create(url).toURL().readText()
|
|
||||||
val regex = """"fileName":"([^"]+)"""".toRegex()
|
|
||||||
return regex.find(response)?.groupValues?.get(1) ?: throw Exception("fileName not found")
|
|
||||||
}
|
|
||||||
@@ -16,8 +16,9 @@ resource-pack:
|
|||||||
# This option determines the location of the generated resource pack
|
# This option determines the location of the generated resource pack
|
||||||
# You can use either an absolute path or a relative path here
|
# You can use either an absolute path or a relative path here
|
||||||
path: "./generated/resource_pack.zip"
|
path: "./generated/resource_pack.zip"
|
||||||
|
# The minimum client version supported by CraftEngine is 1.20. If you need to provide support for lower client versions, please modify the resource pack yourself.
|
||||||
# Allowed values:
|
# Allowed values:
|
||||||
# - 1.20.1, 1.21, 1.21.8, etc.
|
# - 1.20.2, 1.21, 1.21.8, etc.
|
||||||
# - latest: the latest client version
|
# - latest: the latest client version
|
||||||
# - server: the current server version
|
# - server: the current server version
|
||||||
supported-version:
|
supported-version:
|
||||||
|
|||||||
@@ -865,9 +865,8 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
}
|
}
|
||||||
for (Revision revision : revisions) {
|
for (Revision revision : revisions) {
|
||||||
JsonObject entry = new JsonObject();
|
JsonObject entry = new JsonObject();
|
||||||
JsonObject formats = new JsonObject();
|
|
||||||
entry.add("formats", formats);
|
|
||||||
JsonArray formatsArray = new JsonArray();
|
JsonArray formatsArray = new JsonArray();
|
||||||
|
entry.add("formats", formatsArray);
|
||||||
formatsArray.add(revision.minPackVersion().major());
|
formatsArray.add(revision.minPackVersion().major());
|
||||||
formatsArray.add(revision.maxPackVersion().major());
|
formatsArray.add(revision.maxPackVersion().major());
|
||||||
entry.add("min_format", revision.minPackVersion().getAsJsonArray());
|
entry.add("min_format", revision.minPackVersion().getAsJsonArray());
|
||||||
@@ -1188,8 +1187,10 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
private void validateResourcePack(Path path) {
|
private void validateResourcePack(Path path) {
|
||||||
Path packMcMetaPath = path.resolve("pack.mcmeta");
|
Path packMcMetaPath = path.resolve("pack.mcmeta");
|
||||||
PackMcMeta packMeta;
|
PackMcMeta packMeta;
|
||||||
|
JsonObject packMetaJson;
|
||||||
try {
|
try {
|
||||||
packMeta = new PackMcMeta(GsonHelper.readJsonFile(packMcMetaPath).getAsJsonObject());
|
packMetaJson = GsonHelper.readJsonFile(packMcMetaPath).getAsJsonObject();
|
||||||
|
packMeta = new PackMcMeta(packMetaJson);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
this.plugin.logger().warn("Failed to read pack.mcmeta " + packMcMetaPath.toAbsolutePath(), e);
|
this.plugin.logger().warn("Failed to read pack.mcmeta " + packMcMetaPath.toAbsolutePath(), e);
|
||||||
return;
|
return;
|
||||||
@@ -1256,7 +1257,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.validate.start",
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.validate.start",
|
||||||
String.valueOf(i + 1), String.valueOf(size), String.valueOf(segment.min()), String.valueOf(segment.max()), overlayInOrder.stream().map(Overlay::directory).toList().toString()));
|
String.valueOf(i + 1), String.valueOf(size), String.valueOf(segment.min()), String.valueOf(segment.max()), overlayInOrder.stream().map(Overlay::directory).toList().toString()));
|
||||||
ValidationResult result = validateOverlayedResourcePack(rootPathList.toArray(new Path[0]), segment.max() >= MinecraftVersion.V1_21_11.packFormat().major());
|
ValidationResult result = validateOverlayedResourcePack(rootPathList.toArray(new Path[0]), segment.max() >= MinecraftVersion.V1_21_11.packFormat().major());
|
||||||
if (Config.fixTextureAtlas()) {
|
if (Config.fixTextureAtlas() && !Config.enableObfuscation()) {
|
||||||
// 有修复物品
|
// 有修复物品
|
||||||
if (result.fixedItemAtlas != null) {
|
if (result.fixedItemAtlas != null) {
|
||||||
itemFixer.addEntry(segment.min(), segment.max(), result.fixedItemAtlas);
|
itemFixer.addEntry(segment.min(), segment.max(), result.fixedItemAtlas);
|
||||||
@@ -1272,7 +1273,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 尝试修复atlas
|
// 尝试修复atlas
|
||||||
if (Config.fixTextureAtlas()) {
|
if (Config.fixTextureAtlas() && !Config.enableObfuscation()) {
|
||||||
Map<String, JsonObject> atlasToAdd = new LinkedHashMap<>();
|
Map<String, JsonObject> atlasToAdd = new LinkedHashMap<>();
|
||||||
// 物品
|
// 物品
|
||||||
for (AtlasFixer.Entry entry : itemFixer.entries()) {
|
for (AtlasFixer.Entry entry : itemFixer.entries()) {
|
||||||
@@ -1296,7 +1297,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 方块
|
// 方块
|
||||||
for (AtlasFixer.Entry entry : itemFixer.entries()) {
|
for (AtlasFixer.Entry entry : blockFixer.entries()) {
|
||||||
int min = entry.min();
|
int min = entry.min();
|
||||||
int max = entry.max();
|
int max = entry.max();
|
||||||
String directoryName = Config.createOverlayFolderName(min + "-" + max);
|
String directoryName = Config.createOverlayFolderName(min + "-" + max);
|
||||||
@@ -1330,6 +1331,25 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JsonObject overlaysJson = packMetaJson.getAsJsonObject("overlays");
|
||||||
|
if (overlaysJson == null) {
|
||||||
|
overlaysJson = new JsonObject();
|
||||||
|
packMetaJson.add("overlays", overlaysJson);
|
||||||
|
}
|
||||||
|
JsonArray overlayEntries = overlaysJson.getAsJsonArray("entries");
|
||||||
|
if (overlayEntries == null) {
|
||||||
|
overlayEntries = new JsonArray();
|
||||||
|
overlaysJson.add("entries", overlayEntries);
|
||||||
|
}
|
||||||
|
for (JsonElement entry : atlasToAdd.values()) {
|
||||||
|
overlayEntries.add(entry);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
GsonHelper.writeJsonFile(packMetaJson, packMcMetaPath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
this.plugin.logger().warn("Failed to write pack.mcmeta", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import net.momirealms.craftengine.core.pack.conflict.PathContext;
|
import net.momirealms.craftengine.core.pack.conflict.PathContext;
|
||||||
import net.momirealms.craftengine.core.pack.mcmeta.PackVersion;
|
import net.momirealms.craftengine.core.pack.mcmeta.PackVersion;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
|
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||||
import net.momirealms.craftengine.core.util.GsonHelper;
|
import net.momirealms.craftengine.core.util.GsonHelper;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
@@ -162,12 +163,12 @@ public class ResolutionMergePackMcMeta implements Resolution {
|
|||||||
JsonObject entryJson = entry.getAsJsonObject();
|
JsonObject entryJson = entry.getAsJsonObject();
|
||||||
if (entryJson == null) continue;
|
if (entryJson == null) continue;
|
||||||
Pair<PackVersion, PackVersion> supportedVersions = getSupportedVersions(entryJson);
|
Pair<PackVersion, PackVersion> supportedVersions = getSupportedVersions(entryJson);
|
||||||
PackVersion min = supportedVersions.left();
|
PackVersion min = PackVersion.getHigher(supportedVersions.left(), PackVersion.MIN_OVERLAY_VERSION);
|
||||||
PackVersion max = supportedVersions.right();
|
PackVersion max = PackVersion.getHigher(supportedVersions.right(), PackVersion.MIN_OVERLAY_VERSION);
|
||||||
// 旧版格式支持
|
// 旧版格式支持
|
||||||
JsonObject supportedFormats = new JsonObject();
|
JsonArray supportedFormats = new JsonArray();
|
||||||
supportedFormats.addProperty("min_inclusive", min.major());
|
supportedFormats.add(min.major());
|
||||||
supportedFormats.addProperty("max_inclusive", max.major());
|
supportedFormats.add(max.major());
|
||||||
entryJson.add("formats", supportedFormats);
|
entryJson.add("formats", supportedFormats);
|
||||||
// 新版格式支持
|
// 新版格式支持
|
||||||
JsonArray minFormat = new JsonArray();
|
JsonArray minFormat = new JsonArray();
|
||||||
@@ -186,8 +187,8 @@ public class ResolutionMergePackMcMeta implements Resolution {
|
|||||||
public static void mergePack(JsonObject merged, JsonObject pack1, JsonObject pack2) {
|
public static void mergePack(JsonObject merged, JsonObject pack1, JsonObject pack2) {
|
||||||
Pair<PackVersion, PackVersion> pack1Version = getSupportedVersions(pack1);
|
Pair<PackVersion, PackVersion> pack1Version = getSupportedVersions(pack1);
|
||||||
Pair<PackVersion, PackVersion> pack2Version = getSupportedVersions(pack2);
|
Pair<PackVersion, PackVersion> pack2Version = getSupportedVersions(pack2);
|
||||||
PackVersion min = PackVersion.getLower(pack1Version.left(), pack2Version.left());
|
PackVersion min = Config.packMinVersion().packFormat();
|
||||||
PackVersion max = PackVersion.getHigher(pack1Version.right(), pack2Version.right());
|
PackVersion max = PackVersion.getHigher(PackVersion.getHigher(pack1Version.right(), pack2Version.right()), Config.packMaxVersion().packFormat());
|
||||||
// 旧版格式支持
|
// 旧版格式支持
|
||||||
JsonObject supportedFormats = new JsonObject();
|
JsonObject supportedFormats = new JsonObject();
|
||||||
supportedFormats.addProperty("min_inclusive", min.major());
|
supportedFormats.addProperty("min_inclusive", min.major());
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public record PackVersion(int major, int minor) implements Comparable<PackVersion> {
|
public record PackVersion(int major, int minor) implements Comparable<PackVersion> {
|
||||||
public static final PackVersion MIN_PACK_VERSION = new PackVersion(15, 0); // 1.20
|
public static final PackVersion MIN_PACK_VERSION = new PackVersion(15, 0); // 1.20
|
||||||
|
public static final PackVersion MIN_OVERLAY_VERSION = new PackVersion(18, 0); // 1.20
|
||||||
public static final PackVersion MAX_PACK_VERSION = new PackVersion(1000, 0); // future
|
public static final PackVersion MAX_PACK_VERSION = new PackVersion(1000, 0); // future
|
||||||
|
|
||||||
public PackVersion(int major) {
|
public PackVersion(int major) {
|
||||||
|
|||||||
Reference in New Issue
Block a user