mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
@@ -17,6 +17,8 @@ resource-pack:
|
||||
# Generate assets for CraftEngine fabric mod
|
||||
# Note: fabric mod is used for clientside Axiom/WorldEdit mod
|
||||
generate-mod-assets: false
|
||||
# Remove 1.21.5+ tinted_leaves particles
|
||||
remove-tinted-leaves-particle: true
|
||||
# Resource pack protection
|
||||
protection:
|
||||
# Warning: Do not attempt to unzip the resource pack with crash tools enabled.
|
||||
|
||||
@@ -6157,4 +6157,111 @@ public class Reflections {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 1.20.2+
|
||||
public static final Class<?> clazz$ServerboundClientInformationPacket =
|
||||
ReflectionUtils.getClazz(
|
||||
BukkitReflectionUtils.assembleMCClass("network.protocol.common.ServerboundClientInformationPacket")
|
||||
);
|
||||
|
||||
// 1.20.2+
|
||||
public static final Constructor<?> constructor$ServerboundClientInformationPacket = Optional.ofNullable(clazz$ServerboundClientInformationPacket)
|
||||
.map(it -> ReflectionUtils.getConstructor(it, 1))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+
|
||||
public static final Field field$ServerboundClientInformationPacket$information = Optional.ofNullable(clazz$ServerboundClientInformationPacket)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 0))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+
|
||||
// 从 1.21.2+ 才有 particleStatus
|
||||
public static final Class<?> clazz$ClientInformation =
|
||||
ReflectionUtils.getClazz(
|
||||
BukkitReflectionUtils.assembleMCClass("server.level.ClientInformation")
|
||||
);
|
||||
|
||||
// 1.20.2+
|
||||
public static final Constructor<?> constructor$ClientInformation = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getConstructor(it, 1))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+ String
|
||||
public static final Field field$ClientInformation$language = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 0))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+ int
|
||||
public static final Field field$ClientInformation$viewDistance = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 1))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+ ChatVisiblity
|
||||
public static final Field field$ClientInformation$chatVisibility = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 2))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+ boolean
|
||||
public static final Field field$ClientInformation$chatColors = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 3))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+ int
|
||||
public static final Field field$ClientInformation$modelCustomisation = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 4))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+ HumanoidArm
|
||||
public static final Field field$ClientInformation$mainHand = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 5))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+ boolean
|
||||
public static final Field field$ClientInformation$textFilteringEnabled = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 6))
|
||||
.orElse(null);
|
||||
|
||||
// 1.20.2+ boolean
|
||||
public static final Field field$ClientInformation$allowsListing = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 7))
|
||||
.orElse(null);
|
||||
|
||||
// 1.21.2+
|
||||
public static final Class<?> clazz$ParticleStatus =
|
||||
ReflectionUtils.getClazz(
|
||||
BukkitReflectionUtils.assembleMCClass("server.level.ParticleStatus")
|
||||
);
|
||||
|
||||
// 1.21.2+
|
||||
public static final Method method$ParticleStatus$values = Optional.ofNullable(clazz$ParticleStatus)
|
||||
.map(it -> ReflectionUtils.getStaticMethod(it, it.arrayType()))
|
||||
.orElse(null);
|
||||
|
||||
// 1.21.2+
|
||||
public static final Object instance$ParticleStatus$ALL;
|
||||
public static final Object instance$ParticleStatus$DECREASED;
|
||||
public static final Object instance$ParticleStatus$MINIMAL;
|
||||
|
||||
// 1.21.2+
|
||||
static {
|
||||
try {
|
||||
if (VersionHelper.isVersionNewerThan1_21_2()) {
|
||||
Object[] values = (Object[]) method$ParticleStatus$values.invoke(null);
|
||||
instance$ParticleStatus$ALL = values[0];
|
||||
instance$ParticleStatus$DECREASED = values[1];
|
||||
instance$ParticleStatus$MINIMAL = values[2];
|
||||
} else {
|
||||
instance$ParticleStatus$ALL = null;
|
||||
instance$ParticleStatus$DECREASED = null;
|
||||
instance$ParticleStatus$MINIMAL = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 1.21.2+ ParticleStatus
|
||||
public static final Field field$ClientInformation$particleStatus = Optional.ofNullable(clazz$ClientInformation)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, 8))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -56,10 +58,21 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
private final Map<String, Pack> loadedPacks = new HashMap<>();
|
||||
private final Map<String, ConfigSectionParser> sectionParsers = new HashMap<>();
|
||||
private final TreeMap<ConfigSectionParser, List<CachedConfig>> cachedConfigs = new TreeMap<>();
|
||||
private static final byte[] emptyImage;
|
||||
protected BiConsumer<Path, Path> zipGenerator;
|
||||
protected String packHash;
|
||||
protected UUID packUUID;
|
||||
|
||||
static {
|
||||
var stream = new ByteArrayOutputStream();
|
||||
try {
|
||||
ImageIO.write(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB), "png", stream);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
emptyImage = stream.toByteArray();
|
||||
}
|
||||
|
||||
public AbstractPackManager(CraftEngine plugin, BiConsumer<Path, Path> eventDispatcher) {
|
||||
this.plugin = plugin;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
@@ -497,6 +510,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
this.generateCustomSounds(generatedPackPath);
|
||||
this.generateClientLang(generatedPackPath);
|
||||
this.generateEquipments(generatedPackPath);
|
||||
this.generateParticle(generatedPackPath);
|
||||
|
||||
Path zipFile = resourcePackPath();
|
||||
try {
|
||||
@@ -527,6 +541,39 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateParticle(Path generatedPackPath) {
|
||||
if (!Config.removeTintedLeavesParticle()) return;
|
||||
if (Config.packMaxVersion() < 21.49f) return;
|
||||
var json = new JsonObject();
|
||||
var textures = new JsonArray();
|
||||
textures.add("empty");
|
||||
json.add("textures", textures);
|
||||
var jsonPath = generatedPackPath
|
||||
.resolve("assets")
|
||||
.resolve("minecraft")
|
||||
.resolve("particles")
|
||||
.resolve("tinted_leaves.json");
|
||||
var pngPath = generatedPackPath
|
||||
.resolve("assets")
|
||||
.resolve("minecraft")
|
||||
.resolve("textures")
|
||||
.resolve("particle")
|
||||
.resolve("empty.png");
|
||||
try {
|
||||
Files.createDirectories(jsonPath.getParent());
|
||||
Files.createDirectories(pngPath.getParent());
|
||||
} catch (IOException e) {
|
||||
plugin.logger().severe("Error creating directories", e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
GsonHelper.writeJsonFile(json, jsonPath);
|
||||
Files.write(pngPath, emptyImage);
|
||||
} catch (IOException e) {
|
||||
this.plugin.logger().severe("Error writing particles file", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateEquipments(Path generatedPackPath) {
|
||||
for (EquipmentGeneration generator : this.plugin.itemManager().equipmentsToGenerate()) {
|
||||
EquipmentData equipmentData = generator.modernData();
|
||||
|
||||
@@ -45,6 +45,7 @@ public class Config {
|
||||
protected boolean metrics;
|
||||
protected boolean filterConfigurationPhaseDisconnect;
|
||||
|
||||
protected boolean resource_pack$remove_tinted_leaves_particle;
|
||||
protected boolean resource_pack$generate_mod_assets;
|
||||
protected boolean resource_pack$override_uniform_font;
|
||||
protected List<ConditionalResolution> resource_pack$duplicated_files_handler;
|
||||
@@ -187,6 +188,7 @@ public class Config {
|
||||
// resource pack
|
||||
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$remove_tinted_leaves_particle = config.getBoolean("resource-pack.remove-tinted-leaves-particle", true);
|
||||
resource_pack$supported_version$min = getVersion(config.get("resource-pack.supported-version.min", "1.20").toString());
|
||||
resource_pack$supported_version$max = getVersion(config.get("resource-pack.supported-version.max", "LATEST").toString());
|
||||
resource_pack$merge_external_folders = config.getStringList("resource-pack.merge-external-folders");
|
||||
@@ -537,6 +539,10 @@ public class Config {
|
||||
return instance.resource_pack$generate_mod_assets;
|
||||
}
|
||||
|
||||
public static boolean removeTintedLeavesParticle() {
|
||||
return instance.resource_pack$remove_tinted_leaves_particle;
|
||||
}
|
||||
|
||||
public static boolean filterChat() {
|
||||
return instance().image$illegal_characters_filter$chat;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=0.0.44
|
||||
config_version=20
|
||||
config_version=21
|
||||
lang_version=4
|
||||
project_group=net.momirealms
|
||||
latest_supported_version=1.21.5
|
||||
|
||||
Reference in New Issue
Block a user