From 45b7ccf0c4707e593baf90a4dcb165a84021eb06 Mon Sep 17 00:00:00 2001 From: CoryBorek Date: Sat, 7 Mar 2020 17:00:32 -0500 Subject: [PATCH] Added painting conversion --- .../hypixel/resourcepack/PackConverter.java | 9 +- .../resourcepack/impl/ChestConverter.java | 1 + .../resourcepack/impl/PaintingConverter.java | 91 +++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 src/main/java/net/hypixel/resourcepack/impl/PaintingConverter.java diff --git a/src/main/java/net/hypixel/resourcepack/PackConverter.java b/src/main/java/net/hypixel/resourcepack/PackConverter.java index 4ef1f1d6..31c03c8d 100644 --- a/src/main/java/net/hypixel/resourcepack/PackConverter.java +++ b/src/main/java/net/hypixel/resourcepack/PackConverter.java @@ -41,8 +41,12 @@ public PackConverter(OptionSet optionSet) { // this needs to be run first, other converters might reference new directory names if (from.equals("1.12")) this.registerConverter(new NameConverter(this)); - if (to.equals("1.15")) this.registerConverter(new PackMetaConverter(this, "1.15")); - else if (to.equals("1.14")) this.registerConverter(new PackMetaConverter(this, "1.14")); + if (to.equals("1.15")){ + this.registerConverter(new PackMetaConverter(this, "1.15")); + } + else if (to.equals("1.14")){ + this.registerConverter(new PackMetaConverter(this, "1.14")); + } else this.registerConverter(new PackMetaConverter(this, "1.13")); if (from.equals("1.12")) { this.registerConverter(new ModelConverter(this, light)); @@ -57,6 +61,7 @@ public PackConverter(OptionSet optionSet) { } this.registerConverter(new LangConverter(this)); if (to.equals("1.15")) this.registerConverter(new ChestConverter(this)); + if ((from.equals("1.13") || from.equals("1.12")) && (to.equals("1.14") || (to.equals("1.15")))) this.registerConverter(new PaintingConverter(this)); } public void registerConverter(Converter converter) { diff --git a/src/main/java/net/hypixel/resourcepack/impl/ChestConverter.java b/src/main/java/net/hypixel/resourcepack/impl/ChestConverter.java index 4422a04f..9cfa11ad 100644 --- a/src/main/java/net/hypixel/resourcepack/impl/ChestConverter.java +++ b/src/main/java/net/hypixel/resourcepack/impl/ChestConverter.java @@ -31,6 +31,7 @@ public void convert(Pack pack) throws IOException { chest(imagePath, "ender"); + } private void chest(Path imagePath, String name) throws IOException diff --git a/src/main/java/net/hypixel/resourcepack/impl/PaintingConverter.java b/src/main/java/net/hypixel/resourcepack/impl/PaintingConverter.java new file mode 100644 index 00000000..a29edbc1 --- /dev/null +++ b/src/main/java/net/hypixel/resourcepack/impl/PaintingConverter.java @@ -0,0 +1,91 @@ +package net.hypixel.resourcepack.impl; + +import net.hypixel.resourcepack.Converter; +import net.hypixel.resourcepack.PackConverter; +import net.hypixel.resourcepack.extra.ImageConverter; +import net.hypixel.resourcepack.pack.Pack; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; + +public class PaintingConverter extends Converter { + + public PaintingConverter(PackConverter packConverter) { + super(packConverter); + } + + @Override + public void convert(Pack pack) throws IOException { + Path paintingPath = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "textures" + File.separator + "painting" + File.separator); + if (!paintingPath.toFile().exists()) return; + + + //16x16 + painting(paintingPath, "kebab.png", 0, 0, 1, 1); + painting(paintingPath, "aztec.png", 16, 0, 1, 1); + painting(paintingPath, "alban.png", 32, 0, 1, 1); + painting(paintingPath, "aztec2.png", 48, 0, 1, 1); + painting(paintingPath, "bomb.png", 64, 0, 1, 1); + painting(paintingPath, "plant.png", 80, 0, 1, 1); + painting(paintingPath, "wasteland.png", 96, 0, 1, 1); + + //32x16 + painting(paintingPath, "back.png", 0, 32, 2, 1); + painting(paintingPath, "courbet.png", 32, 32, 2, 1); + painting(paintingPath, "sea.png", 64, 32, 2, 1); + painting(paintingPath, "sunset.png", 96, 32, 2, 1); + painting(paintingPath, "creebet.png", 128, 32, 2, 1); + //16x3 + painting(paintingPath, "wanderer.png", 0, 64, 1, 2); + painting(paintingPath, "graham.png", 16, 64, 1, 2); + //64x48 + painting(paintingPath, "skeleton.png", 192, 64, 4, 3); + painting(paintingPath, "donkey_kong.png", 192, 112, 4, 3); + //64x32 + painting(paintingPath, "fighters.png", 0, 96, 4, 2); + //32x32 + painting(paintingPath, "match.png", 0, 128, 2, 2); + painting(paintingPath, "bust.png", 32, 128, 2, 2); + painting(paintingPath, "stage.png", 64, 128, 2, 2); + painting(paintingPath, "void.png", 96, 128, 2, 2); + painting(paintingPath, "skull_and_roses.png", 128, 128, 2, 2); + painting(paintingPath, "wither.png", 160, 128, 2, 2); + //64x64 + painting(paintingPath, "pointer.png", 0, 192, 4, 4); + painting(paintingPath, "pigscene.png", 64, 192, 4, 4); + painting(paintingPath, "burning_skull.png", 128, 192, 4, 4, true); + + } + + private void painting (Path paintingPath, String name, int x, int y, int scaleX, int scaleY) throws IOException + { + int defaultW = 16, defaultH = 16; + + if (paintingPath.resolve("paintings_kristoffer_zetterstrand.png").toFile().exists()) { + ImageConverter normal = new ImageConverter(256, 256, paintingPath.resolve("paintings_kristoffer_zetterstrand.png")); + + normal.newImage(defaultW * scaleX, defaultH* scaleY); + + normal.subImage(x, y, x + defaultW * scaleX, y + defaultH * scaleY, 0, 0); + normal.store(paintingPath.resolve(name)); + } + } + private void painting (Path paintingPath, String name, int x, int y, int scaleX, int scaleY, boolean delete) throws IOException + { + int defaultW = 16, defaultH = 16; + + if (paintingPath.resolve("paintings_kristoffer_zetterstrand.png").toFile().exists()) { + ImageConverter normal = new ImageConverter(256, 256, paintingPath.resolve("paintings_kristoffer_zetterstrand.png")); + + normal.newImage(defaultW * scaleX, defaultH* scaleY); + + normal.subImage(x, y, x + defaultW * scaleX, y + defaultH * scaleY, 0, 0); + normal.store(paintingPath.resolve(name)); + if (delete) paintingPath.resolve("paintings_kristoffer_zetterstrand.png").toFile().delete(); + } + + } + + } + +