9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-22 08:29:21 +00:00

添加special model报错

This commit is contained in:
XiaoMoMi
2025-04-29 19:26:58 +08:00
parent 26dfb82f80
commit 1f50f7dcb4
9 changed files with 52 additions and 30 deletions

View File

@@ -158,6 +158,15 @@ warning.config.item.model.select.block_state.missing_property: "<yellow>Issue fo
warning.config.item.model.select.local_time.missing_pattern: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'pattern' argument for property 'minecraft:local_time'.</yellow>"
warning.config.item.model.special.missing_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'type' argument for model 'minecraft:special'.</yellow>"
warning.config.item.model.special.invalid_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid type '<arg:2>' for model 'minecraft:special'.</yellow>"
warning.config.item.model.special.banner.missing_color: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'color' argument for special model 'minecraft:banner'.</yellow>"
warning.config.item.model.special.sign.missing_wood_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'wood-type' argument for special model 'minecraft:hanging_sign'/'minecraft:standing_sign'.</yellow>"
warning.config.item.model.special.sign.missing_texture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'texture' argument for special model 'minecraft:hanging_sign'/'minecraft:standing_sign'.</yellow>"
warning.config.item.model.special.chest.missing_texture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'texture' argument for special model 'minecraft:chest'.</yellow>"
warning.config.item.model.special.chest.invalid_openness: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid 'openness' value '<arg:2>' for special model 'minecraft:chest'. Valid range '0~1.'</yellow>"
warning.config.item.model.special.shulker_box.missing_texture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'texture' argument for special model 'minecraft:shulker_box'.</yellow>"
warning.config.item.model.special.shulker_box.invalid_openness: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid 'openness' value '<arg:2>' for special model 'minecraft:shulker_box'. Valid range '0~1.'</yellow>"
warning.config.item.model.special.head.missing_kind: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'kind' argument for special model 'minecraft:head'.</yellow>"
warning.config.item.model.special.head.missing_texture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'texture' argument for special model 'minecraft:head'.</yellow>"
warning.config.block.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated block '<arg:1>'.</yellow>"
warning.config.block.missing_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'state' argument.</yellow>"
warning.config.block.state.property.missing_type: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'type' argument for property '<arg:2>'.</yellow>"

View File

@@ -131,16 +131,6 @@ public abstract class AbstractPackManager implements PackManager {
}
}
private void loadInternalPng(String path, Consumer<byte[]> callback) {
try (InputStream inputStream = this.plugin.resourceStream(path)) {
if (inputStream != null) {
callback.accept(inputStream.readAllBytes());
}
} catch (IOException e) {
this.plugin.logger().warn("Failed to load " + path, e);
}
}
@Override
public Path resourcePackPath() {
return this.plugin.dataFolderPath()
@@ -1156,7 +1146,7 @@ public abstract class AbstractPackManager implements PackManager {
if (Files.exists(sourceFolder)) {
Files.walkFileTree(sourceFolder, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
public @NotNull FileVisitResult visitFile(@NotNull Path file, @NotNull BasicFileAttributes attrs) throws IOException {
Path relative = sourceFolder.relativize(file);
Path targetPath = targetFolder.resolve(relative);
List<Path> conflicts = conflictChecker.computeIfAbsent(relative, k -> new ArrayList<>());

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.special;
import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key;
import java.util.Map;
@@ -31,8 +32,11 @@ public class BannerSpecialModel implements SpecialModel {
@Override
public SpecialModel create(Map<String, Object> arguments) {
String color = Objects.requireNonNull(arguments.get("color"), "color").toString();
return new BannerSpecialModel(color);
Object color = arguments.get("color");
if (color == null) {
throw new LocalizedResourceConfigException("");
}
return new BannerSpecialModel(color.toString());
}
}
}

View File

@@ -1,8 +1,10 @@
package net.momirealms.craftengine.core.pack.model.special;
import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
import software.amazon.awssdk.services.s3.endpoints.internal.Value;
import java.util.Map;
import java.util.Objects;
@@ -36,11 +38,14 @@ public class ChestSpecialModel implements SpecialModel {
@Override
public SpecialModel create(Map<String, Object> arguments) {
float openness = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("openness", 0), "openness");
String texture = Objects.requireNonNull(arguments.get("texture"), "texture").toString();
if (openness > 1 || openness < 0) {
throw new IllegalArgumentException("Invalid openness: " + openness + ". Valid range 0~1");
Object texture = arguments.get("texture");
if (texture == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.chest.missing_texture");
}
return new ChestSpecialModel(texture, openness);
if (openness > 1 || openness < 0) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.chest.invalid_openness", String.valueOf(openness));
}
return new ChestSpecialModel(texture.toString(), openness);
}
}
}

View File

@@ -1,11 +1,11 @@
package net.momirealms.craftengine.core.pack.model.special;
import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
import java.util.Map;
import java.util.Objects;
public class HeadSpecialModel implements SpecialModel {
public static final Factory FACTORY = new Factory();
@@ -38,10 +38,16 @@ public class HeadSpecialModel implements SpecialModel {
@Override
public SpecialModel create(Map<String, Object> arguments) {
String kind = Objects.requireNonNull(arguments.get("kind"), "kind").toString();
String texture = Objects.requireNonNull(arguments.get("texture"), "texture").toString();
Object kind = arguments.get("kind");
if (kind == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.head.missing_kind");
}
Object texture = arguments.get("texture");
if (texture == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.head.missing_texture");
}
int animation = ResourceConfigUtils.getAsInt(arguments.getOrDefault("animation", 0), "animation");
return new HeadSpecialModel(kind, texture, animation);
return new HeadSpecialModel(kind.toString(), texture.toString(), animation);
}
}
}

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.special;
import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Direction;
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
@@ -41,12 +42,15 @@ public class ShulkerBoxSpecialModel implements SpecialModel {
@Override
public SpecialModel create(Map<String, Object> arguments) {
float openness = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("openness", 0), "openness");
String texture = Objects.requireNonNull(arguments.get("texture"), "texture").toString();
Object texture = arguments.get("texture");
if (texture == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.shulker_box.missing_texture");
}
Direction orientation = Direction.valueOf(arguments.getOrDefault("orientation", "down").toString().toUpperCase(Locale.ENGLISH));
if (openness > 1 || openness < 0) {
throw new IllegalArgumentException("Invalid openness: " + openness + ". Valid range 0~1");
throw new LocalizedResourceConfigException("warning.config.item.model.special.shulker_box.invalid_openness", String.valueOf(openness));
}
return new ShulkerBoxSpecialModel(texture, openness, orientation);
return new ShulkerBoxSpecialModel(texture.toString(), openness, orientation);
}
}
}

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.special;
import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key;
import java.util.Map;
@@ -37,9 +38,15 @@ public class SignSpecialModel implements SpecialModel {
@Override
public SpecialModel create(Map<String, Object> arguments) {
Key type = Key.of(arguments.get("type").toString());
String woodType = Objects.requireNonNull(arguments.get("wood-type"), "lack wood-type").toString();
String texture = Objects.requireNonNull(arguments.get("texture"), "lack texture").toString();
return new SignSpecialModel(type, woodType, texture);
Object woodType = arguments.get("wood-type");
if (woodType == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.sign.missing_wood_type");
}
Object texture = arguments.get("texture");
if (texture == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.special.sign.missing_texture");
}
return new SignSpecialModel(type, woodType.toString(), texture.toString());
}
}
}

View File

@@ -1,7 +1,5 @@
package net.momirealms.craftengine.core.world.chunk;
import net.momirealms.craftengine.core.block.ImmutableBlockState;
import java.util.function.IntConsumer;
public class PackedIntegerArray implements PaletteStorage {

View File

@@ -1,6 +1,5 @@
package net.momirealms.craftengine.mod;
import net.minecraft.world.level.chunk.PalettedContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.objectweb.asm.tree.ClassNode;