mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
最终决战
This commit is contained in:
@@ -2,14 +2,12 @@ package net.momirealms.craftengine.bukkit.sound;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.momirealms.craftengine.bukkit.api.CraftEngineFurniture;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBuiltInRegistries;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MRegistries;
|
||||
import net.momirealms.craftengine.bukkit.util.ComponentUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||
import net.momirealms.craftengine.core.entity.furniture.AnchorType;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.sound.AbstractSoundManager;
|
||||
import net.momirealms.craftengine.core.sound.JukeboxSong;
|
||||
@@ -17,7 +15,6 @@ import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.craftengine.core.util.GsonHelper;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
@@ -98,7 +98,6 @@ resource-pack:
|
||||
validation:
|
||||
enable: true
|
||||
# Fix textures that are not within the atlas. It is unreasonable to always rely on plugins to fix your mistakes.
|
||||
# CraftEngine will only fix the atlas of resource pack under the first version specified in the test-versions.
|
||||
# You should strive to make your resource pack more standardized after gaining some experience with resource packs.
|
||||
# The fix-atlas feature is not all-powerful since 1.21.11. In some cases, CraftEngine cannot fix it for you, and you will need to fix your model yourself.
|
||||
fix-atlas: true
|
||||
|
||||
@@ -836,10 +836,10 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
if (!rawMeta.has("pack")) {
|
||||
JsonObject pack = new JsonObject();
|
||||
rawMeta.add("pack", pack);
|
||||
pack.addProperty("pack_format", Config.packMinVersion().packFormat().major());
|
||||
pack.addProperty("pack_format", Config.packMinVersion().majorPackFormat());
|
||||
JsonObject supportedFormats = new JsonObject();
|
||||
supportedFormats.addProperty("min_inclusive", Config.packMinVersion().packFormat().major());
|
||||
supportedFormats.addProperty("max_inclusive", Config.packMaxVersion().packFormat().major());
|
||||
supportedFormats.addProperty("min_inclusive", Config.packMinVersion().majorPackFormat());
|
||||
supportedFormats.addProperty("max_inclusive", Config.packMaxVersion().majorPackFormat());
|
||||
pack.add("supported_formats", supportedFormats);
|
||||
changed = true;
|
||||
}
|
||||
@@ -867,10 +867,11 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
JsonObject entry = new JsonObject();
|
||||
JsonObject formats = new JsonObject();
|
||||
entry.add("formats", formats);
|
||||
formats.addProperty("min_inclusive", revision.minPackVersion());
|
||||
formats.addProperty("max_inclusive", revision.maxPackVersion());
|
||||
entry.addProperty("min_format", revision.minPackVersion());
|
||||
entry.addProperty("max_format", revision.maxPackVersion());
|
||||
JsonArray formatsArray = new JsonArray();
|
||||
formatsArray.add(revision.minPackVersion().major());
|
||||
formatsArray.add(revision.maxPackVersion().major());
|
||||
entry.add("min_format", revision.minPackVersion().getAsJsonArray());
|
||||
entry.add("max_format", revision.maxPackVersion().getAsJsonArray());
|
||||
entry.addProperty("directory", Config.createOverlayFolderName(revision.versionString()));
|
||||
entries.add(entry);
|
||||
}
|
||||
@@ -1197,7 +1198,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
List<OverlayCombination.Segment> segments = new ArrayList<>();
|
||||
// 完全小于1.21.11或完全大于1.21.11
|
||||
if (Config.packMaxVersion().isBelow(MinecraftVersion.V1_21_11) || Config.packMinVersion().isAtOrAbove(MinecraftVersion.V1_21_11)) {
|
||||
OverlayCombination combination = new OverlayCombination(packMeta.overlays(), Config.packMinVersion().packFormat().major(), Config.packMaxVersion().packFormat().major());
|
||||
OverlayCombination combination = new OverlayCombination(packMeta.overlays(), Config.packMinVersion().majorPackFormat(), Config.packMaxVersion().majorPackFormat());
|
||||
while (combination.hasNext()) {
|
||||
OverlayCombination.Segment segment = combination.nextSegment();
|
||||
if (segment != null) {
|
||||
@@ -1209,7 +1210,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
}
|
||||
// 混合版本
|
||||
else {
|
||||
OverlayCombination combinationLegacy = new OverlayCombination(packMeta.overlays(), Config.packMinVersion().packFormat().major(), MinecraftVersion.V1_21_11.packFormat().major() - 1);
|
||||
OverlayCombination combinationLegacy = new OverlayCombination(packMeta.overlays(), Config.packMinVersion().majorPackFormat(), 72 /* 25w44a */);
|
||||
while (combinationLegacy.hasNext()) {
|
||||
OverlayCombination.Segment segment = combinationLegacy.nextSegment();
|
||||
if (segment != null) {
|
||||
@@ -1218,7 +1219,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
OverlayCombination combinationModern = new OverlayCombination(packMeta.overlays(), MinecraftVersion.V1_21_11.packFormat().major(), Config.packMaxVersion().packFormat().major());
|
||||
OverlayCombination combinationModern = new OverlayCombination(packMeta.overlays(), 73 /* 25w45a */, Config.packMaxVersion().majorPackFormat());
|
||||
while (combinationModern.hasNext()) {
|
||||
OverlayCombination.Segment segment = combinationModern.nextSegment();
|
||||
if (segment != null) {
|
||||
@@ -1277,9 +1278,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
for (AtlasFixer.Entry entry : itemFixer.entries()) {
|
||||
int min = entry.min();
|
||||
int max = entry.max();
|
||||
MinecraftVersion minV = MinecraftVersion.byMajorPackFormat(min).getFirst();
|
||||
MinecraftVersion maxV = MinecraftVersion.byMajorPackFormat(max).getLast();
|
||||
String directoryName = Config.createOverlayFolderName(minV.version().replace("\\.", "_") + "-" + maxV.version().replace("\\.", "_"));
|
||||
String directoryName = Config.createOverlayFolderName(min + "-" + max);
|
||||
Path atlasPath = path.resolve(directoryName)
|
||||
.resolve("assets")
|
||||
.resolve("minecraft")
|
||||
@@ -1300,9 +1299,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
for (AtlasFixer.Entry entry : itemFixer.entries()) {
|
||||
int min = entry.min();
|
||||
int max = entry.max();
|
||||
MinecraftVersion minV = MinecraftVersion.byMajorPackFormat(min).getFirst();
|
||||
MinecraftVersion maxV = MinecraftVersion.byMajorPackFormat(max).getLast();
|
||||
String directoryName = Config.createOverlayFolderName(minV.version().replace("\\.", "_") + "-" + maxV.version().replace("\\.", "_"));
|
||||
String directoryName = Config.createOverlayFolderName(min + "-" + max);
|
||||
// 这个版本不认可overlay,得把atlas直接写进主包内
|
||||
if (min <= MinecraftVersion.V1_20_1.packFormat().major()) {
|
||||
Path atlasPath = path.resolve("assets")
|
||||
|
||||
@@ -6,7 +6,6 @@ import net.momirealms.craftengine.core.plugin.Manageable;
|
||||
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.craftengine.core.pack.mcmeta;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,6 +40,21 @@ public record PackVersion(int major, int minor) implements Comparable<PackVersio
|
||||
return this.compareTo(other) < 0;
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
if (this.minor == 0) {
|
||||
return String.valueOf(this.major);
|
||||
} else {
|
||||
return this.major + "." + this.minor;
|
||||
}
|
||||
}
|
||||
|
||||
public JsonArray getAsJsonArray() {
|
||||
JsonArray array = new JsonArray();
|
||||
array.add(this.major);
|
||||
array.add(this.minor);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回两个版本中较小的那个(版本较低的)
|
||||
*/
|
||||
|
||||
@@ -68,7 +68,7 @@ public class OverlayCombination {
|
||||
return null;
|
||||
}
|
||||
// 获取事件
|
||||
VersionBasedEvent events = this.versionBasedEvents.get(this.cursor);
|
||||
VersionBasedEvent events = this.versionBasedEvents.get(this.cursor++);
|
||||
// 将上一个版本和上次记录的版本打为一个overlay返回
|
||||
Segment segment = new Segment(this.version, events.version - 1, Set.copyOf(this.currentOverlays));
|
||||
this.version = events.version;
|
||||
@@ -80,7 +80,7 @@ public class OverlayCombination {
|
||||
this.currentOverlays.add(event.overlay);
|
||||
}
|
||||
}
|
||||
this.cursor++;
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
@@ -97,9 +97,25 @@ public class OverlayCombination {
|
||||
}
|
||||
|
||||
record Event(Overlay overlay, Operation operation) {
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return "Event{" +
|
||||
"overlay=" + overlay +
|
||||
", operation=" + operation +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
record VersionBasedEvent(int version, List<Event> events) {
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return "VersionBasedEvent{" +
|
||||
"version=" + version +
|
||||
", events=" + events +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
enum Operation {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package net.momirealms.craftengine.core.pack.revision;
|
||||
|
||||
import net.momirealms.craftengine.core.pack.mcmeta.PackVersion;
|
||||
import net.momirealms.craftengine.core.util.MinecraftVersion;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public interface Revision {
|
||||
|
||||
int minPackVersion();
|
||||
PackVersion minPackVersion();
|
||||
|
||||
int maxPackVersion();
|
||||
PackVersion maxPackVersion();
|
||||
|
||||
String versionString();
|
||||
|
||||
@@ -47,7 +48,7 @@ public interface Revision {
|
||||
@Override
|
||||
public String versionString() {
|
||||
if (this.versionString == null) {
|
||||
this.versionString = this.minVersion.version().replace(".", "_");
|
||||
this.versionString = this.minVersion.packFormat().asString();
|
||||
}
|
||||
return this.versionString;
|
||||
}
|
||||
@@ -58,15 +59,13 @@ public interface Revision {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxPackVersion() {
|
||||
// todo 重构revision系统
|
||||
return MinecraftVersion.FUTURE.packFormat().major();
|
||||
public PackVersion maxPackVersion() {
|
||||
return MinecraftVersion.FUTURE.packFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minPackVersion() {
|
||||
// todo 重构revision系统
|
||||
return this.minVersion.packFormat().major();
|
||||
public PackVersion minPackVersion() {
|
||||
return this.minVersion.packFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,19 +111,19 @@ public interface Revision {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minPackVersion() {
|
||||
return this.minVersion.packFormat().major();
|
||||
public PackVersion minPackVersion() {
|
||||
return this.minVersion.packFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxPackVersion() {
|
||||
return this.maxVersion.packFormat().major();
|
||||
public PackVersion maxPackVersion() {
|
||||
return this.maxVersion.packFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String versionString() {
|
||||
if (this.versionString == null) {
|
||||
this.versionString = this.minVersion.version().replace(".", "_") + "-" + this.maxVersion.version().replace(".", "_");
|
||||
this.versionString = this.minVersion.packFormat().asString() + "-" + this.maxVersion.packFormat().asString();
|
||||
}
|
||||
return this.versionString;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ public class Config {
|
||||
|
||||
protected boolean resource_pack$validation$enable;
|
||||
protected boolean resource_pack$validation$fix_atlas;
|
||||
protected List<MinecraftVersion> resource_pack$validation$test_versions;
|
||||
protected boolean resource_pack$exclude_core_shaders;
|
||||
|
||||
protected boolean resource_pack$protection$obfuscation$enable;
|
||||
@@ -392,7 +391,6 @@ public class Config {
|
||||
}).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$validation$test_versions = config.getStringList("resource-pack.validation.test-versions", List.of("server")).stream().map(Config::getVersion).distinct().toList();
|
||||
resource_pack$exclude_core_shaders = config.getBoolean("resource-pack.exclude-core-shaders", false);
|
||||
resource_pack$overlay_format = config.getString("resource-pack.overlay-format", "overlay_{version}");
|
||||
if (!resource_pack$overlay_format.contains("{version}")) {
|
||||
@@ -1112,10 +1110,6 @@ public class Config {
|
||||
return instance.resource_pack$validation$fix_atlas;
|
||||
}
|
||||
|
||||
public static List<MinecraftVersion> validationTestVersions() {
|
||||
return instance.resource_pack$validation$test_versions;
|
||||
}
|
||||
|
||||
public static boolean excludeShaders() {
|
||||
return instance.resource_pack$exclude_core_shaders;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.momirealms.craftengine.core.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -102,7 +102,11 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
|
||||
}
|
||||
|
||||
public PackVersion packFormat() {
|
||||
return packFormat;
|
||||
return this.packFormat;
|
||||
}
|
||||
|
||||
public int majorPackFormat() {
|
||||
return packFormat().major();
|
||||
}
|
||||
|
||||
private MinecraftVersion(String version) {
|
||||
|
||||
Reference in New Issue
Block a user