Skip to content

Commit

Permalink
Added painting conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryBorek committed Mar 7, 2020
1 parent a8e9c7d commit 45b7ccf
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/net/hypixel/resourcepack/PackConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void convert(Pack pack) throws IOException {
chest(imagePath, "ender");



}

private void chest(Path imagePath, String name) throws IOException
Expand Down
91 changes: 91 additions & 0 deletions src/main/java/net/hypixel/resourcepack/impl/PaintingConverter.java
Original file line number Diff line number Diff line change
@@ -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();
}

}

}


0 comments on commit 45b7ccf

Please sign in to comment.