mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-29 20:09:13 +00:00
添加special model报错
This commit is contained in:
@@ -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<>());
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user