From ebb027382c0f97a25d3dcfbe3ad4e8028b29353c Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Fri, 21 Jun 2024 18:11:48 -0400 Subject: [PATCH 1/9] Add Map Icon Slicing for 1.20.5+ --- .../forwards/ForwardsPackConverter.java | 4 + .../impl/textures/MapIconSlicerConverter.java | 44 +++ .../main/resources/forwards/map_icons.json | 347 ++++++++++++++++++ .../resourcepack/library/utilities/Util.java | 4 +- library/src/main/resources/protocol.json | 5 +- 5 files changed, 401 insertions(+), 3 deletions(-) create mode 100644 conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/MapIconSlicerConverter.java create mode 100644 conversions/Forwards/src/main/resources/forwards/map_icons.json diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/ForwardsPackConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/ForwardsPackConverter.java index 45b4d7a3..d8696044 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/ForwardsPackConverter.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/ForwardsPackConverter.java @@ -108,6 +108,10 @@ private void converterRunner(String from, String to, String light) { if (protocolFrom <= Util.getVersionProtocol(gson, "1.20.1") && protocolTo >= Util.getVersionProtocol(gson, "1.20.2")) this.registerConverter(new SlicerConverter(this, protocolFrom)); + + if (protocolFrom < Util.getVersionProtocol(gson, "1.20.5") + && protocolTo >= Util.getVersionProtocol(gson, "1.20.5")) + this.registerConverter(new MapIconSlicerConverter(this, protocolFrom)); } public void runPack(Pack pack) { diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/MapIconSlicerConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/MapIconSlicerConverter.java new file mode 100644 index 00000000..e0f568fa --- /dev/null +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/MapIconSlicerConverter.java @@ -0,0 +1,44 @@ +package com.agentdid127.resourcepack.forwards.impl.textures; + +import com.agentdid127.resourcepack.forwards.impl.textures.slicing.Slice; +import com.agentdid127.resourcepack.forwards.impl.textures.slicing.Slicer; +import com.agentdid127.resourcepack.library.Converter; +import com.agentdid127.resourcepack.library.PackConverter; +import com.agentdid127.resourcepack.library.pack.Pack; +import com.agentdid127.resourcepack.library.utilities.JsonUtil; +import com.google.gson.Gson; +import com.google.gson.JsonObject; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; + +public class MapIconSlicerConverter extends Converter { + private final int protocolFrom; + + public MapIconSlicerConverter(PackConverter packConverter, int protocolFrom) { + super(packConverter); + this.protocolFrom = protocolFrom; + } + + /** + * Converts maps + * + * @param pack + * @throws IOException + */ + @Override + public void convert(Pack pack) throws IOException { + Path texturesPath = pack.getWorkingPath().resolve("assets/minecraft/textures".replace("/", File.separator)); + if (!texturesPath.toFile().exists()) + return; + Path mapIconsPath = texturesPath.resolve("map/".replace("/", File.separator)); + if (!mapIconsPath.toFile().exists()) + return; + Gson gson = packConverter.getGson(); + JsonObject mapIconsJson = JsonUtil.readJsonResource(gson, "/forwards/map_icons.json", JsonObject.class); + assert mapIconsJson != null; + Slice slice = Slice.parse(mapIconsJson); + Slicer.runSlicer(gson, slice, mapIconsPath, SlicerConverter.PredicateRunnable.class, protocolFrom, false); + } +} diff --git a/conversions/Forwards/src/main/resources/forwards/map_icons.json b/conversions/Forwards/src/main/resources/forwards/map_icons.json new file mode 100644 index 00000000..b37875f4 --- /dev/null +++ b/conversions/Forwards/src/main/resources/forwards/map_icons.json @@ -0,0 +1,347 @@ +{ + "path": "map_icons.png", + "width": 128, + "height": 128, + "delete": true, + "textures": [ + { + "path": "decorations/player.png", + "box": { + "x": 0, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/frame.png", + "box": { + "x": 8, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/red_marker.png", + "box": { + "x": 16, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/target_x.png", + "box": { + "x": 24, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/target_point.png", + "box": { + "x": 32, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/player_off_map.png", + "box": { + "x": 40, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/player_off_limits.png", + "box": { + "x": 48, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/woodland_mansion.png", + "box": { + "x": 56, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/ocean_monument.png", + "box": { + "x": 64, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/white_banner.png", + "box": { + "x": 72, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/orange_banner.png", + "box": { + "x": 80, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/magenta_banner.png", + "box": { + "x": 88, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/light_blue_banner.png", + "box": { + "x": 96, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/yellow_banner.png", + "box": { + "x": 104, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/lime_banner.png", + "box": { + "x": 112, + "y": 0, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/pink_banner.png", + "box": { + "x": 0, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/gray_banner.png", + "box": { + "x": 8, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/light_gray_banner.png", + "box": { + "x": 16, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/cyan_banner.png", + "box": { + "x": 24, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/purple_banner.png", + "box": { + "x": 32, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/blue_banner.png", + "box": { + "x": 40, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/brown_banner.png", + "box": { + "x": 48, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/green_banner.png", + "box": { + "x": 56, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/red_banner.png", + "box": { + "x": 64, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/black_banner.png", + "box": { + "x": 72, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/red_x.png", + "box": { + "x": 80, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/desert_village.png", + "predicate": { + "protocol": { + "min_inclusive": 764, + "max_inclusive": null + } + }, + "box": { + "x": 88, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/plains_village.png", + "predicate": { + "protocol": { + "min_inclusive": 764, + "max_inclusive": null + } + }, + "box": { + "x": 96, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/savanna_village.png", + "predicate": { + "protocol": { + "min_inclusive": 764, + "max_inclusive": null + } + }, + "box": { + "x": 104, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/snowy_village.png", + "predicate": { + "protocol": { + "min_inclusive": 764, + "max_inclusive": null + } + }, + "box": { + "x": 112, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/taiga_village.png", + "predicate": { + "protocol": { + "min_inclusive": 764, + "max_inclusive": null + } + }, + "box": { + "x": 120, + "y": 8, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/jungle_temple.png", + "predicate": { + "protocol": { + "min_inclusive": 764, + "max_inclusive": null + } + }, + "box": { + "x": 0, + "y": 16, + "width": 8, + "height": 8 + } + }, + { + "path": "decorations/swamp_hut.png", + "predicate": { + "protocol": { + "min_inclusive": 764, + "max_inclusive": null + } + }, + "box": { + "x": 8, + "y": 16, + "width": 8, + "height": 8 + } + } + ] +} \ No newline at end of file diff --git a/library/src/main/java/com/agentdid127/resourcepack/library/utilities/Util.java b/library/src/main/java/com/agentdid127/resourcepack/library/utilities/Util.java index 38f5baf5..2225117b 100644 --- a/library/src/main/java/com/agentdid127/resourcepack/library/utilities/Util.java +++ b/library/src/main/java/com/agentdid127/resourcepack/library/utilities/Util.java @@ -48,7 +48,7 @@ public static int getVersionProtocol(Gson gson, String version) { } public static int getLatestProtocol(Gson gson) { - return getVersionProtocol(gson, "1.20.4"); + return getVersionProtocol(gson, "1.21"); } /** @@ -63,7 +63,7 @@ public static String getVersionFromProtocol(Gson gson, int protocol) { JsonObject protocols = JsonUtil.readJsonResource(gson, "/protocol.json"); if (protocols == null) return null; - Collection keys = protocols.entrySet().stream().map(i -> i.getKey()) + Collection keys = protocols.entrySet().stream().map(Map.Entry::getKey) .collect(Collectors.toCollection(ArrayList::new)); keys.forEach(key -> { if (Integer.parseInt(protocols.get(key).getAsString()) == protocol) diff --git a/library/src/main/resources/protocol.json b/library/src/main/resources/protocol.json index 81238833..40c964c7 100644 --- a/library/src/main/resources/protocol.json +++ b/library/src/main/resources/protocol.json @@ -76,5 +76,8 @@ "1.20.1": "763", "1.20.2": "764", "1.20.3": "765", - "1.20.4": "765" + "1.20.4": "765", + "1.20.5": "766", + "1.20.6": "766", + "1.21": "767" } \ No newline at end of file From 1c8a63e3fd636a72f45cf8d4226d2a5a045f6dca Mon Sep 17 00:00:00 2001 From: CoryBorek Date: Fri, 21 Jun 2024 18:23:58 -0400 Subject: [PATCH 2/9] let mcmeta support 1.20.5+ --- .../resourcepack/backwards/impl/PackMetaConverter.java | 8 +++++++- .../resourcepack/forwards/impl/PackMetaConverter.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/conversions/Backwards/src/main/java/com/agentdid127/resourcepack/backwards/impl/PackMetaConverter.java b/conversions/Backwards/src/main/java/com/agentdid127/resourcepack/backwards/impl/PackMetaConverter.java index eeda5567..835be486 100644 --- a/conversions/Backwards/src/main/java/com/agentdid127/resourcepack/backwards/impl/PackMetaConverter.java +++ b/conversions/Backwards/src/main/java/com/agentdid127/resourcepack/backwards/impl/PackMetaConverter.java @@ -31,7 +31,13 @@ public void convert(Pack pack) throws IOException { if (!file.toFile().exists()) return; // Possible TODO: Make this JSON? Possibly use protocol.json, but update it. - if (version >= Util.getVersionProtocol(packConverter.getGson(), "1.20.3")) + if (version >= Util.getVersionProtocol(packConverter.getGson(), "1.21")) + versionInt = 34; + else if (version >= Util.getVersionProtocol(packConverter.getGson(), "1.20.5") + && version < Util.getVersionProtocol(packConverter.getGson(), "1.21")) + versionInt = 32; + else if (version >= Util.getVersionProtocol(packConverter.getGson(), "1.20.3") + && version < Util.getVersionProtocol(packConverter.getGson(), "1.20.5")) versionInt = 22; else if (version >= Util.getVersionProtocol(packConverter.getGson(), "1.20.2") && version < Util.getVersionProtocol(packConverter.getGson(), "1.20.3")) diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/PackMetaConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/PackMetaConverter.java index 9d32d198..28afb558 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/PackMetaConverter.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/PackMetaConverter.java @@ -36,7 +36,13 @@ public void convert(Pack pack) throws IOException { int versionInt = 4; // Possible TODO: Make this JSON? Possibly use protocol.json, but update it. - if (to >= Util.getVersionProtocol(packConverter.getGson(), "1.20.3")) + if (to >= Util.getVersionProtocol(packConverter.getGson(), "1.21")) + versionInt = 34; + else if (to >= Util.getVersionProtocol(packConverter.getGson(), "1.20.5") + && to < Util.getVersionProtocol(packConverter.getGson(), "1.21")) + versionInt = 32; + else if (to >= Util.getVersionProtocol(packConverter.getGson(), "1.20.3") + && to < Util.getVersionProtocol(packConverter.getGson(), "1.20.5")) versionInt = 22; else if (to >= Util.getVersionProtocol(packConverter.getGson(), "1.20.2") && to < Util.getVersionProtocol(packConverter.getGson(), "1.20.3")) From 19a7b95133e1864c89e2bc3ff0d1dbc8d9a18ca9 Mon Sep 17 00:00:00 2001 From: CoryBorek Date: Fri, 21 Jun 2024 21:14:31 -0400 Subject: [PATCH 3/9] update README, license, and notice of original upstream --- LICENSE | 2 +- README.MD | 14 +++++++------- licenses/hypixel | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 licenses/hypixel diff --git a/LICENSE b/LICENSE index a0f0e2ac..577621d8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Hypixel Inc. +Copyright (c) 2024 agentdid127. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.MD b/README.MD index 86ee49e5..5c84fadc 100644 --- a/README.MD +++ b/README.MD @@ -1,12 +1,9 @@ # Resource Pack Converter [![](https://jitpack.io/v/agentdid127/ResourcePackConverter.svg)](https://jitpack.io/#agentdid127/ResourcePackConverter) +This is a program that converts most issues with resource packs between any version from 1.7.2 all the way to 1.20.3. -This is my fork of Hypixel's Resource Pack Converter. It updates to any newer version from 1.8.x - 1.20.x - -We know that many use resource packs in nonstandard and quirky ways - but giving this a shot *may* reduce quite a bit of your pain and workload for the 1.13 conversion. - -This should convert most things, but if it doesn't please let me know what didn't work so I can fix it. +This should convert most things, but if you notice anything that does not work correctly, or should be added, create an issue on Github. Also if any other developers would like to open any PRs with fixes and additions please feel free. @@ -31,9 +28,12 @@ To update to any other version than 1.12-1.13, you can use these parameters. We hope this helps out! -# Not On the list to add -- Horse and Zombified Piglin Conversion (the models were changed, which may make that much more difficult to convert) +## Not On the list to add +- Horse, Zombified Piglin, and Bat Conversion (the models were changed, which may make that much more difficult to convert) ## In-Development Versions Before a version of the converter is ready for release, it will be automatically built on a Jenkins server, where you can get non-production builds. Note: that there is no guaruntee that these versions are stable, however, feel free to post issue reports on the issues page. [Jenkins Server](https://jenkins.dc1.agentdid127.com/job/agentdid127/job/ResourcePackConverter/job/master/) + +### Upstream +This program was originally derived from Hypixel's Resource Pack Converter, though has been essentially reworked over the span of 5 years. Very few, if any bits of the original software remain, but in case that does exist, their original license is included in the licenses' directory. diff --git a/licenses/hypixel b/licenses/hypixel new file mode 100644 index 00000000..a0f0e2ac --- /dev/null +++ b/licenses/hypixel @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Hypixel Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 58ba5f2523ce79df9a0c74237cf1f91fcad4902c Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Sat, 22 Jun 2024 13:38:32 -0400 Subject: [PATCH 4/9] Fix Particle Texture Size for Conversion --- .../textures/ParticleTextureConverter.java | 24 ++++++++++++++++--- .../forwards/impl/textures/slicing/Slice.java | 20 ++++++++++++---- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java index 65e2db17..86debe66 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java @@ -6,7 +6,9 @@ import com.agentdid127.resourcepack.library.PackConverter; import com.agentdid127.resourcepack.library.pack.Pack; import com.agentdid127.resourcepack.library.utilities.FileUtil; +import com.agentdid127.resourcepack.library.utilities.ImageConverter; import com.agentdid127.resourcepack.library.utilities.JsonUtil; +import com.agentdid127.resourcepack.library.utilities.Util; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -25,7 +27,7 @@ public ParticleTextureConverter(PackConverter packConverter, int from, int to) { /** * Slice particles.png into multiple for 1.14+ - * + * * @param pack * @throws IOException */ @@ -38,10 +40,26 @@ public void convert(Pack pack) throws IOException { if (!particlePath.toFile().exists()) return; Gson gson = packConverter.getGson(); - JsonObject particlesJson = JsonUtil.readJsonResource(gson, "/forwards/particles.json", - JsonObject.class); + + JsonObject particlesJson = JsonUtil.readJsonResource(gson, "/forwards/particles.json", JsonObject.class); + assert particlesJson != null; + Slice slice = Slice.parse(particlesJson); + if (from <= Util.getVersionProtocol(gson, "1.12.2") && + to >= Util.getVersionProtocol(gson, "1.13")) { + Path particlesPath = particlePath.resolve(slice.getPath()); + if (particlesPath.toFile().exists()) { + ImageConverter converter = new ImageConverter(slice.getWidth(), slice.getHeight(), particlesPath); + converter.newImage(256, 256); + converter.subImage(0, 0, 128, 128, 0, 0); + converter.store(); + slice.setWidth(256); + slice.setHeight(256); + } + } + Slicer.runSlicer(gson, slice, particlePath, SlicerConverter.PredicateRunnable.class, from, false); + Path entityPath = texturesPath.resolve("entity"); FileUtil.moveIfExists(particlePath.resolve("fishing_hook.png"), entityPath.resolve("fishing_hook.png")); } diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/slicing/Slice.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/slicing/Slice.java index c8269fe3..f99f5946 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/slicing/Slice.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/slicing/Slice.java @@ -1,13 +1,13 @@ package com.agentdid127.resourcepack.forwards.impl.textures.slicing; -import java.io.File; -import java.util.LinkedList; -import java.util.List; - import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import java.io.File; +import java.util.LinkedList; +import java.util.List; + public class Slice { private String path; private String name; @@ -33,6 +33,18 @@ public int getHeight() { return height; } + public void setWidth(int width) { + if (this.width == width) + return; + this.width = width; + } + + public void setHeight(int height) { + if (this.height == height) + return; + this.height = height; + } + public JsonObject getPredicate() { return predicate; } From 41f3c996cdb54af352f6725289634642965ad9fb Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Sat, 22 Jun 2024 13:56:19 -0400 Subject: [PATCH 5/9] Fix slicing for versions & New log message --- .../textures/ParticleTextureConverter.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java index 86debe66..b3059453 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java @@ -5,10 +5,7 @@ import com.agentdid127.resourcepack.library.Converter; import com.agentdid127.resourcepack.library.PackConverter; import com.agentdid127.resourcepack.library.pack.Pack; -import com.agentdid127.resourcepack.library.utilities.FileUtil; -import com.agentdid127.resourcepack.library.utilities.ImageConverter; -import com.agentdid127.resourcepack.library.utilities.JsonUtil; -import com.agentdid127.resourcepack.library.utilities.Util; +import com.agentdid127.resourcepack.library.utilities.*; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -17,7 +14,8 @@ import java.nio.file.Path; public class ParticleTextureConverter extends Converter { - int from, to; + private final int from; + private final int to; public ParticleTextureConverter(PackConverter packConverter, int from, int to) { super(packConverter); @@ -36,9 +34,11 @@ public void convert(Pack pack) throws IOException { Path texturesPath = pack.getWorkingPath().resolve("assets/minecraft/textures".replace("/", File.separator)); if (!texturesPath.toFile().exists()) return; + Path particlePath = texturesPath.resolve("particle"); if (!particlePath.toFile().exists()) return; + Gson gson = packConverter.getGson(); JsonObject particlesJson = JsonUtil.readJsonResource(gson, "/forwards/particles.json", JsonObject.class); @@ -47,6 +47,7 @@ public void convert(Pack pack) throws IOException { Slice slice = Slice.parse(particlesJson); if (from <= Util.getVersionProtocol(gson, "1.12.2") && to >= Util.getVersionProtocol(gson, "1.13")) { + Logger.log("Detected 'particles.png' from versions before 1.13, converting to newer size.."); Path particlesPath = particlePath.resolve(slice.getPath()); if (particlesPath.toFile().exists()) { ImageConverter converter = new ImageConverter(slice.getWidth(), slice.getHeight(), particlesPath); @@ -58,9 +59,11 @@ public void convert(Pack pack) throws IOException { } } - Slicer.runSlicer(gson, slice, particlePath, SlicerConverter.PredicateRunnable.class, from, false); - - Path entityPath = texturesPath.resolve("entity"); - FileUtil.moveIfExists(particlePath.resolve("fishing_hook.png"), entityPath.resolve("fishing_hook.png")); + if (from <= Util.getVersionProtocol(gson, "1.13.2") && + to >= Util.getVersionProtocol(gson, "1.14")) { + Slicer.runSlicer(gson, slice, particlePath, SlicerConverter.PredicateRunnable.class, from, false); + Path entityPath = texturesPath.resolve("entity"); + FileUtil.moveIfExists(particlePath.resolve("fishing_hook.png"), entityPath.resolve("fishing_hook.png")); + } } } \ No newline at end of file From 887f9a57267241bd56c63af2ee55a68ae05344b8 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Sat, 22 Jun 2024 13:57:27 -0400 Subject: [PATCH 6/9] Move new log message into the if block --- .../forwards/impl/textures/ParticleTextureConverter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java index b3059453..ab8b30d0 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java @@ -47,9 +47,9 @@ public void convert(Pack pack) throws IOException { Slice slice = Slice.parse(particlesJson); if (from <= Util.getVersionProtocol(gson, "1.12.2") && to >= Util.getVersionProtocol(gson, "1.13")) { - Logger.log("Detected 'particles.png' from versions before 1.13, converting to newer size.."); Path particlesPath = particlePath.resolve(slice.getPath()); if (particlesPath.toFile().exists()) { + Logger.log("Detected 'particles.png' from versions before 1.13, converting to newer size.."); ImageConverter converter = new ImageConverter(slice.getWidth(), slice.getHeight(), particlesPath); converter.newImage(256, 256); converter.subImage(0, 0, 128, 128, 0, 0); From ca8aaf5ade52185058e8f4d71a416ddb9e16a5a2 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Sat, 22 Jun 2024 16:05:52 -0400 Subject: [PATCH 7/9] Fix my hiccup in particles default size --- .../forwards/ForwardsPackConverter.java | 2 +- .../textures/ParticleTextureConverter.java | 4 ++-- .../src/main/resources/forwards/particles.json | 4 ++-- .../library/utilities/JsonUtil.java | 18 +++++++++--------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/ForwardsPackConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/ForwardsPackConverter.java index 5ff1e8d4..5d5271d9 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/ForwardsPackConverter.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/ForwardsPackConverter.java @@ -1,12 +1,12 @@ package com.agentdid127.resourcepack.forwards; +import com.agentdid127.resourcepack.forwards.impl.*; import com.agentdid127.resourcepack.forwards.impl.textures.*; import com.agentdid127.resourcepack.library.Converter; import com.agentdid127.resourcepack.library.PackConverter; import com.agentdid127.resourcepack.library.pack.Pack; import com.agentdid127.resourcepack.library.utilities.Logger; import com.agentdid127.resourcepack.library.utilities.Util; -import com.agentdid127.resourcepack.forwards.impl.*; import com.google.gson.GsonBuilder; import java.io.IOException; diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java index ab8b30d0..0e35ce18 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java @@ -54,9 +54,9 @@ public void convert(Pack pack) throws IOException { converter.newImage(256, 256); converter.subImage(0, 0, 128, 128, 0, 0); converter.store(); - slice.setWidth(256); - slice.setHeight(256); } + slice.setWidth(256); + slice.setHeight(256); } if (from <= Util.getVersionProtocol(gson, "1.13.2") && diff --git a/conversions/Forwards/src/main/resources/forwards/particles.json b/conversions/Forwards/src/main/resources/forwards/particles.json index 20a495ba..1dacc8e5 100644 --- a/conversions/Forwards/src/main/resources/forwards/particles.json +++ b/conversions/Forwards/src/main/resources/forwards/particles.json @@ -1,7 +1,7 @@ { "path": "particles.png", - "width": 256, - "height": 256, + "width": 128, + "height": 128, "delete": true, "textures": [ { diff --git a/library/src/main/java/com/agentdid127/resourcepack/library/utilities/JsonUtil.java b/library/src/main/java/com/agentdid127/resourcepack/library/utilities/JsonUtil.java index 7a1a1b0f..14e0fb0b 100644 --- a/library/src/main/java/com/agentdid127/resourcepack/library/utilities/JsonUtil.java +++ b/library/src/main/java/com/agentdid127/resourcepack/library/utilities/JsonUtil.java @@ -1,21 +1,21 @@ package com.agentdid127.resourcepack.library.utilities; +import com.agentdid127.resourcepack.library.PackConverter; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.stream.JsonReader; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringReader; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; -import com.agentdid127.resourcepack.library.PackConverter; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.stream.JsonReader; - public class JsonUtil { public static JsonArray add(JsonArray lhs, JsonArray rhs) { return add(lhs, rhs, (byte) 1); @@ -63,7 +63,7 @@ public static JsonArray asArray(Gson gson, String raw) { } public static void writeJson(Gson gson, Path out, JsonElement json) throws IOException { - Files.write(out, Collections.singleton(gson.toJson(json)), Charset.forName("UTF-8")); + Files.write(out, Collections.singleton(gson.toJson(json)), StandardCharsets.UTF_8); } public static boolean isJson(Gson gson, String Json) { From 29fcee7ec9cfd4f5c6129432006f35e2a118594d Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Sat, 22 Jun 2024 16:10:55 -0400 Subject: [PATCH 8/9] Another hiccup, fixed. --- .../textures/ParticleTextureConverter.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java index 0e35ce18..8f109837 100644 --- a/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java +++ b/conversions/Forwards/src/main/java/com/agentdid127/resourcepack/forwards/impl/textures/ParticleTextureConverter.java @@ -45,16 +45,18 @@ public void convert(Pack pack) throws IOException { assert particlesJson != null; Slice slice = Slice.parse(particlesJson); - if (from <= Util.getVersionProtocol(gson, "1.12.2") && - to >= Util.getVersionProtocol(gson, "1.13")) { - Path particlesPath = particlePath.resolve(slice.getPath()); - if (particlesPath.toFile().exists()) { - Logger.log("Detected 'particles.png' from versions before 1.13, converting to newer size.."); - ImageConverter converter = new ImageConverter(slice.getWidth(), slice.getHeight(), particlesPath); - converter.newImage(256, 256); - converter.subImage(0, 0, 128, 128, 0, 0); - converter.store(); + if (to >= Util.getVersionProtocol(gson, "1.13")) { + if (from <= Util.getVersionProtocol(gson, "1.12.2")) { + Path particlesPath = particlePath.resolve(slice.getPath()); + if (particlesPath.toFile().exists()) { + Logger.log("Detected 'particles.png' from versions before 1.13, converting to newer size.."); + ImageConverter converter = new ImageConverter(slice.getWidth(), slice.getHeight(), particlesPath); + converter.newImage(256, 256); + converter.subImage(0, 0, 128, 128, 0, 0); + converter.store(); + } } + slice.setWidth(256); slice.setHeight(256); } From af673cc271436ba8edae2b51c9baf9c949308df0 Mon Sep 17 00:00:00 2001 From: CoryBorek Date: Sat, 29 Jun 2024 21:50:29 -0400 Subject: [PATCH 9/9] version bump --- Applications/Console/pom.xml | 2 +- Applications/Gui/pom.xml | 2 +- Applications/pom.xml | 6 +++--- conversions/Backwards/pom.xml | 2 +- conversions/Forwards/pom.xml | 2 +- conversions/pom.xml | 4 ++-- library/pom.xml | 2 +- pom.xml | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Applications/Console/pom.xml b/Applications/Console/pom.xml index 43239265..659243c6 100644 --- a/Applications/Console/pom.xml +++ b/Applications/Console/pom.xml @@ -5,7 +5,7 @@ Applications com.agentdid127.resourcepack - 2.2.4 + 2.2.5 4.0.0 diff --git a/Applications/Gui/pom.xml b/Applications/Gui/pom.xml index e7d77534..6f44e016 100644 --- a/Applications/Gui/pom.xml +++ b/Applications/Gui/pom.xml @@ -5,7 +5,7 @@ Applications com.agentdid127.resourcepack - 2.2.4 + 2.2.5 4.0.0 diff --git a/Applications/pom.xml b/Applications/pom.xml index 1360e1a8..9ed8e767 100644 --- a/Applications/pom.xml +++ b/Applications/pom.xml @@ -5,7 +5,7 @@ ResourcePackConverter com.agentdid127 - 2.2.4 + 2.2.5 4.0.0 @@ -33,12 +33,12 @@ com.agentdid127.resourcepack Forwards - 2.2.4 + 2.2.5 com.agentdid127.resourcepack Backwards - 2.2.4 + 2.2.5 diff --git a/conversions/Backwards/pom.xml b/conversions/Backwards/pom.xml index f9628855..5d49c732 100644 --- a/conversions/Backwards/pom.xml +++ b/conversions/Backwards/pom.xml @@ -5,7 +5,7 @@ conversions com.agentdid127.resourcepack - 2.2.4 + 2.2.5 4.0.0 diff --git a/conversions/Forwards/pom.xml b/conversions/Forwards/pom.xml index 7f3f1ce9..61f01879 100644 --- a/conversions/Forwards/pom.xml +++ b/conversions/Forwards/pom.xml @@ -5,7 +5,7 @@ conversions com.agentdid127.resourcepack - 2.2.4 + 2.2.5 4.0.0 diff --git a/conversions/pom.xml b/conversions/pom.xml index 6fde6fb2..de11e72a 100644 --- a/conversions/pom.xml +++ b/conversions/pom.xml @@ -5,7 +5,7 @@ ResourcePackConverter com.agentdid127 - 2.2.4 + 2.2.5 4.0.0 @@ -32,7 +32,7 @@ com.agentdid127.resourcepack Library - 2.2.4 + 2.2.5 diff --git a/library/pom.xml b/library/pom.xml index bf0cfb9c..d49628c7 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -10,7 +10,7 @@ com.agentdid127 ResourcePackConverter - 2.2.4 + 2.2.5 ../pom.xml \ No newline at end of file diff --git a/pom.xml b/pom.xml index a6a5a34f..8327da3c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.agentdid127 ResourcePackConverter - 2.2.4 + 2.2.5 pom ResourcePackConverter