diff --git a/common-files/src/main/resources/internal/atlases/blocks.json b/common-files/src/main/resources/internal/atlases/blocks.json new file mode 100644 index 000000000..d2cf5a79c --- /dev/null +++ b/common-files/src/main/resources/internal/atlases/blocks.json @@ -0,0 +1,58 @@ +{ + "sources": [ + { + "type": "minecraft:directory", + "prefix": "block/", + "source": "block" + }, + { + "type": "minecraft:directory", + "prefix": "item/", + "source": "item" + }, + { + "type": "minecraft:directory", + "prefix": "entity/conduit/", + "source": "entity/conduit" + }, + { + "type": "minecraft:single", + "resource": "minecraft:entity/bell/bell_body" + }, + { + "type": "minecraft:single", + "resource": "minecraft:entity/decorated_pot/decorated_pot_side" + }, + { + "type": "minecraft:single", + "resource": "minecraft:entity/enchanting_table_book" + }, + { + "type": "minecraft:paletted_permutations", + "palette_key": "minecraft:trims/color_palettes/trim_palette", + "permutations": { + "amethyst": "minecraft:trims/color_palettes/amethyst", + "copper": "minecraft:trims/color_palettes/copper", + "diamond": "minecraft:trims/color_palettes/diamond", + "diamond_darker": "minecraft:trims/color_palettes/diamond_darker", + "emerald": "minecraft:trims/color_palettes/emerald", + "gold": "minecraft:trims/color_palettes/gold", + "gold_darker": "minecraft:trims/color_palettes/gold_darker", + "iron": "minecraft:trims/color_palettes/iron", + "iron_darker": "minecraft:trims/color_palettes/iron_darker", + "lapis": "minecraft:trims/color_palettes/lapis", + "netherite": "minecraft:trims/color_palettes/netherite", + "netherite_darker": "minecraft:trims/color_palettes/netherite_darker", + "quartz": "minecraft:trims/color_palettes/quartz", + "redstone": "minecraft:trims/color_palettes/redstone", + "resin": "minecraft:trims/color_palettes/resin" + }, + "textures": [ + "minecraft:trims/items/helmet_trim", + "minecraft:trims/items/chestplate_trim", + "minecraft:trims/items/leggings_trim", + "minecraft:trims/items/boots_trim" + ] + } + ] +} \ No newline at end of file diff --git a/common-files/src/main/resources/resources/default/configuration/furniture.yml b/common-files/src/main/resources/resources/default/configuration/furniture.yml index 35b568623..c28d53cdf 100644 --- a/common-files/src/main/resources/resources/default/configuration/furniture.yml +++ b/common-files/src/main/resources/resources/default/configuration/furniture.yml @@ -69,7 +69,7 @@ items: display-transform: NONE billboard: FIXED translation: 0,0.5,0 - rotation: -90 + rotation: 90 hitboxes: - position: 0,0,0 type: interaction diff --git a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java index 796f44029..b32c6102d 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java +++ b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java @@ -83,6 +83,7 @@ public abstract class AbstractPackManager implements PackManager { private final BiConsumer eventDispatcher; private final Map loadedPacks = new HashMap<>(); private final Map sectionParsers = new HashMap<>(); + private final JsonObject vanillaAtlas; private Map cachedConfigFiles = Collections.emptyMap(); private Map cachedAssetFiles = Collections.emptyMap(); protected BiConsumer zipGenerator; @@ -102,6 +103,11 @@ public abstract class AbstractPackManager implements PackManager { this.plugin.logger().warn("Failed to create default configs folder", e); } this.initInternalData(); + try (InputStream inputStream = plugin.resourceStream("internal/atlases/blocks.json")) { + this.vanillaAtlas = JsonParser.parseReader(new InputStreamReader(inputStream)).getAsJsonObject(); + } catch (IOException e) { + throw new RuntimeException("Failed to read internal/atlases/blocks.json", e); + } } private void initInternalData() { @@ -725,6 +731,61 @@ public abstract class AbstractPackManager implements PackManager { } } + private void processAtlas(JsonObject atlasJsonObject, BiConsumer directory, Consumer unstitch, Consumer included) { + JsonArray sources = atlasJsonObject.getAsJsonArray("sources"); + if (sources != null) { + for (JsonElement source : sources) { + if (!(source instanceof JsonObject sourceJson)) continue; + String type = Optional.ofNullable(sourceJson.get("type")).map(JsonElement::getAsString).orElse(null); + if (type == null) continue; + switch (type) { + case "directory", "minecraft:directory" -> { + JsonElement source0 = sourceJson.get("source"); + JsonElement prefix = sourceJson.get("prefix"); + if (prefix == null || source0 == null) continue; + directory.accept(prefix.getAsString(), source0.getAsString() + "/"); + } + case "single", "minecraft:single" -> { + JsonElement resource = sourceJson.get("resource"); + if (resource == null) continue; + included.accept(Key.of(resource.getAsString())); + } + case "unstitch", "minecraft:unstitch" -> { + JsonElement resource = sourceJson.get("resource"); + if (resource == null) continue; + included.accept(Key.of(resource.getAsString())); + JsonArray regions = sourceJson.getAsJsonArray("regions"); + if (regions != null) { + for (JsonElement region : regions) { + if (!(region instanceof JsonObject regionJson)) continue; + JsonElement sprite = regionJson.get("sprite"); + if (sprite == null) continue; + unstitch.accept(Key.of(sprite.getAsString())); + } + } + } + case "filter", "minecraft:filter" -> { + // todo filter + } + case "paletted_permutations", "minecraft:paletted_permutations" -> { + JsonArray textures = sourceJson.getAsJsonArray("textures"); + if (textures == null) continue; + JsonObject permutationsJson = sourceJson.getAsJsonObject("permutations"); + if (permutationsJson == null) continue; + String separator = sourceJson.has("separator") ? sourceJson.get("separator").getAsString() : "_"; + List permutations = new ArrayList<>(permutationsJson.keySet()); + for (JsonElement texture : textures) { + if (!(texture instanceof JsonPrimitive texturePath)) continue; + for (String permutation : permutations) { + included.accept(Key.of(texturePath.getAsString() + separator + permutation)); + } + } + } + } + } + } + } + @SuppressWarnings("DuplicatedCode") private void validateResourcePack(Path path) { List rootPaths; @@ -741,8 +802,7 @@ public abstract class AbstractPackManager implements PackManager { Set texturesInAtlas = new HashSet<>(); Set unstitchTextures = new HashSet<>(); Map directoryMapper = new HashMap<>(); - directoryMapper.put("item/", "item/"); - directoryMapper.put("block/", "block/"); + processAtlas(this.vanillaAtlas, directoryMapper::put, unstitchTextures::add, texturesInAtlas::add); for (Path rootPath : rootPaths) { Path assetsPath = rootPath.resolve("assets"); @@ -760,47 +820,7 @@ public abstract class AbstractPackManager implements PackManager { if (Files.exists(atlasesFile)) { try { JsonObject atlasJsonObject = GsonHelper.readJsonFile(atlasesFile).getAsJsonObject(); - JsonArray sources = atlasJsonObject.getAsJsonArray("sources"); - if (sources != null) { - for (JsonElement source : sources) { - if (!(source instanceof JsonObject sourceJson)) continue; - String type = Optional.ofNullable(sourceJson.get("type")).map(JsonElement::getAsString).orElse(null); - if (type == null) continue; - switch (type) { - case "directory", "minecraft:directory" -> { - JsonElement source0 = sourceJson.get("source"); - JsonElement prefix = sourceJson.get("prefix"); - if (prefix == null || source0 == null) continue; - directoryMapper.put(prefix.getAsString(), source0.getAsString() + "/"); - } - case "single", "minecraft:single" -> { - JsonElement resource = sourceJson.get("resource"); - if (resource == null) continue; - texturesInAtlas.add(Key.of(resource.getAsString())); - } - case "unstitch", "minecraft:unstitch" -> { - JsonElement resource = sourceJson.get("resource"); - if (resource == null) continue; - texturesInAtlas.add(Key.of(resource.getAsString())); - JsonArray regions = sourceJson.getAsJsonArray("regions"); - if (regions != null) { - for (JsonElement region : regions) { - if (!(region instanceof JsonObject regionJson)) continue; - JsonElement sprite = regionJson.get("sprite"); - if (sprite == null) continue; - unstitchTextures.add(Key.of(sprite.getAsString())); - } - } - } - case "filter", "minecraft:filter" -> { - // todo filter - } - case "paletted_permutations", "minecraft:paletted_permutations" -> { - // todo paletted_permutations - } - } - } - } + processAtlas(atlasJsonObject, directoryMapper::put, unstitchTextures::add, texturesInAtlas::add); } catch (IOException | JsonParseException e) { TranslationManager.instance().log("warning.config.resource_pack.generation.malformatted_json", atlasesFile.toAbsolutePath().toString()); } diff --git a/core/src/main/java/net/momirealms/craftengine/core/util/MiscUtils.java b/core/src/main/java/net/momirealms/craftengine/core/util/MiscUtils.java index 87f9b63a3..67c2fe9e7 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/util/MiscUtils.java +++ b/core/src/main/java/net/momirealms/craftengine/core/util/MiscUtils.java @@ -93,9 +93,9 @@ public class MiscUtils { if (split.length == 4) { return new Quaternionf(Float.parseFloat(split[0]), Float.parseFloat(split[1]), Float.parseFloat(split[2]), Float.parseFloat(split[3])); } else if (split.length == 3) { - return QuaternionUtils.toQuaternionf(Math.toRadians(Float.parseFloat(split[2])), Float.parseFloat(split[1]), Math.toRadians(-Float.parseFloat(split[0]))); + return QuaternionUtils.toQuaternionf(Math.toRadians(-Float.parseFloat(split[2])), Math.toRadians(-Float.parseFloat(split[1])), Math.toRadians(-Float.parseFloat(split[0]))); } else if (split.length == 1) { - return QuaternionUtils.toQuaternionf(0, Math.toRadians(Float.parseFloat(split[0])), 0); + return QuaternionUtils.toQuaternionf(0, Math.toRadians(-Float.parseFloat(split[0])), 0); } else { throw new LocalizedResourceConfigException("warning.config.type.quaternionf", stringFormat, option); } diff --git a/gradle.properties b/gradle.properties index 20928a66d..9fa3516c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx1G # Project settings # Rule: [major update].[feature update].[bug fix] -project_version=0.0.58.4 -config_version=39 -lang_version=20 +project_version=0.0.58.5 +config_version=40 +lang_version=21 project_group=net.momirealms latest_supported_version=1.21.6