mirror of
https://github.com/GeyserMC/PackConverter.git
synced 2025-12-20 15:29:15 +00:00
Add more banner converters
This commit is contained in:
@@ -54,6 +54,7 @@ public class ConverterHandler {
|
|||||||
converterList.add(FoxConverter.class);
|
converterList.add(FoxConverter.class);
|
||||||
converterList.add(HorseConverter.class);
|
converterList.add(HorseConverter.class);
|
||||||
converterList.add(IconsConverter.class);
|
converterList.add(IconsConverter.class);
|
||||||
|
converterList.add(BannerPatternBlackConverter.class);
|
||||||
converterList.add(MapIconsConverter.class);
|
converterList.add(MapIconsConverter.class);
|
||||||
converterList.add(PistonArmConverter.class);
|
converterList.add(PistonArmConverter.class);
|
||||||
converterList.add(RedstoneDustConverter.class);
|
converterList.add(RedstoneDustConverter.class);
|
||||||
@@ -78,6 +79,7 @@ public class ConverterHandler {
|
|||||||
//converterList.add(ArrowConverter.class); // This is disabled as its broken and the intended output it just the original
|
//converterList.add(ArrowConverter.class); // This is disabled as its broken and the intended output it just the original
|
||||||
|
|
||||||
converterList.add(EnchantedItemGlintConverter.class);
|
converterList.add(EnchantedItemGlintConverter.class);
|
||||||
|
converterList.add(BannerPatternPreviewMaxSizeConverter.class);
|
||||||
converterList.add(PngToTgaConverter.class);
|
converterList.add(PngToTgaConverter.class);
|
||||||
converterList.add(CopyConverter.class);
|
converterList.add(CopyConverter.class);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/PackConverter
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.packconverter.api.converters;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.geysermc.packconverter.api.PackConverter;
|
||||||
|
import org.geysermc.packconverter.api.utils.ImageUtils;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BannerPatternBlackConverter extends AbstractConverter {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static final List<Object[]> defaultData = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/border.png",
|
||||||
|
"textures/entity/banner/bricks.png",
|
||||||
|
"textures/entity/banner/circle.png",
|
||||||
|
"textures/entity/banner/creeper.png",
|
||||||
|
"textures/entity/banner/cross.png",
|
||||||
|
"textures/entity/banner/curly_border.png",
|
||||||
|
"textures/entity/banner/diagonal_left.png",
|
||||||
|
"textures/entity/banner/diagonal_right.png",
|
||||||
|
"textures/entity/banner/diagonal_up_left.png",
|
||||||
|
"textures/entity/banner/diagonal_up_right.png",
|
||||||
|
"textures/entity/banner/flower.png",
|
||||||
|
"textures/entity/banner/gradient.png",
|
||||||
|
"textures/entity/banner/gradient_up.png",
|
||||||
|
"textures/entity/banner/half_horizontal.png",
|
||||||
|
"textures/entity/banner/half_horizontal_bottom.png",
|
||||||
|
"textures/entity/banner/half_vertical.png",
|
||||||
|
"textures/entity/banner/half_vertical_right.png",
|
||||||
|
"textures/entity/banner/mojang.png",
|
||||||
|
"textures/entity/banner/piglin.png",
|
||||||
|
"textures/entity/banner/rhombus.png",
|
||||||
|
"textures/entity/banner/skull.png",
|
||||||
|
"textures/entity/banner/small_stripes.png",
|
||||||
|
"textures/entity/banner/square_bottom_left.png",
|
||||||
|
"textures/entity/banner/square_bottom_right.png",
|
||||||
|
"textures/entity/banner/square_top_left.png",
|
||||||
|
"textures/entity/banner/square_top_right.png",
|
||||||
|
"textures/entity/banner/straight_cross.png",
|
||||||
|
"textures/entity/banner/stripe_bottom.png",
|
||||||
|
"textures/entity/banner/stripe_center.png",
|
||||||
|
"textures/entity/banner/stripe_downleft.png",
|
||||||
|
"textures/entity/banner/stripe_downright.png",
|
||||||
|
"textures/entity/banner/stripe_left.png",
|
||||||
|
"textures/entity/banner/stripe_middle.png",
|
||||||
|
"textures/entity/banner/stripe_right.png",
|
||||||
|
"textures/entity/banner/stripe_top.png",
|
||||||
|
"textures/entity/banner/triangle_bottom.png",
|
||||||
|
"textures/entity/banner/triangle_top.png",
|
||||||
|
"textures/entity/banner/triangles_bottom.png",
|
||||||
|
"textures/entity/banner/triangles_top.png"});
|
||||||
|
}
|
||||||
|
|
||||||
|
public BannerPatternBlackConverter(PackConverter packConverter, Path storage, Object[] data) {
|
||||||
|
super(packConverter, storage, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractConverter> convert() {
|
||||||
|
try {
|
||||||
|
String from = (String) this.data[0];
|
||||||
|
|
||||||
|
File patternFile = storage.resolve(from).toFile();
|
||||||
|
if (!patternFile.exists()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedImage patternImage = ImageIO.read(patternFile);
|
||||||
|
|
||||||
|
for (int x = 0; x < patternImage.getWidth(); x++) {
|
||||||
|
for (int y = 0; y < patternImage.getHeight(); y++) {
|
||||||
|
Color c = new Color(patternImage.getRGB(x, y), true);
|
||||||
|
if (c.getRGB() == 0 && c.getRed() == 0 && c.getGreen() == 0 && c.getBlue() == 0 && c.getAlpha() == 255) {
|
||||||
|
patternImage.setRGB(x, y, Color.TRANSLUCENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageUtils.write(patternImage, "png", patternFile);
|
||||||
|
|
||||||
|
System.out.print(String.format("Fix banner pattern black %s", from));
|
||||||
|
} catch (IOException e) { }
|
||||||
|
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/PackConverter
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.packconverter.api.converters;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.geysermc.packconverter.api.PackConverter;
|
||||||
|
import org.geysermc.packconverter.api.utils.ImageUtils;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BannerPatternPreviewMaxSizeConverter extends AbstractConverter {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static final List<Object[]> defaultData = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner_base.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/border.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/bricks.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/circle.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/creeper.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/cross.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/curly_border.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/diagonal_left.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/diagonal_right.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/diagonal_up_left.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/diagonal_up_right.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/flower.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/gradient.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/gradient_up.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/half_horizontal.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/half_horizontal_bottom.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/half_vertical.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/half_vertical_right.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/mojang.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/piglin.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/rhombus.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/skull.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/small_stripes.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/square_bottom_left.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/square_bottom_right.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/square_top_left.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/square_top_right.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/straight_cross.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/stripe_bottom.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/stripe_center.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/stripe_downleft.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/stripe_downright.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/stripe_left.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/stripe_middle.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/stripe_right.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/stripe_top.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/triangle_bottom.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/triangle_top.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/triangles_bottom.png", 64});
|
||||||
|
defaultData.add(new Object[] {"textures/entity/banner/triangles_top.png", 64});
|
||||||
|
}
|
||||||
|
|
||||||
|
public BannerPatternPreviewMaxSizeConverter(PackConverter packConverter, Path storage, Object[] data) {
|
||||||
|
super(packConverter, storage, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractConverter> convert() {
|
||||||
|
try {
|
||||||
|
String from = (String) this.data[0];
|
||||||
|
Integer max_width = (Integer) this.data[1];
|
||||||
|
|
||||||
|
File patternFile = storage.resolve(from).toFile();
|
||||||
|
if (!patternFile.exists()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedImage patternImage = ImageIO.read(patternFile);
|
||||||
|
|
||||||
|
patternImage = ImageUtils.ensureMaxWidth(patternImage, max_width);
|
||||||
|
|
||||||
|
ImageUtils.write(patternImage, "png", patternFile);
|
||||||
|
|
||||||
|
System.out.println(String.format("Fix banner pattern preview max size %s", from));
|
||||||
|
} catch (IOException e) { }
|
||||||
|
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -88,7 +88,7 @@ public class ImageUtils {
|
|||||||
*/
|
*/
|
||||||
public static BufferedImage ensureMinWidth(BufferedImage img, int minWidth) {
|
public static BufferedImage ensureMinWidth(BufferedImage img, int minWidth) {
|
||||||
if (img.getWidth() < minWidth) {
|
if (img.getWidth() < minWidth) {
|
||||||
return scale(img, (minWidth / img.getWidth()));
|
return scale(img, ((float) minWidth / img.getWidth()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
@@ -103,7 +103,37 @@ public class ImageUtils {
|
|||||||
*/
|
*/
|
||||||
public static BufferedImage ensureMinHeight(BufferedImage img, int minHeight) {
|
public static BufferedImage ensureMinHeight(BufferedImage img, int minHeight) {
|
||||||
if (img.getHeight() < minHeight) {
|
if (img.getHeight() < minHeight) {
|
||||||
return scale(img, (minHeight / img.getHeight()));
|
return scale(img, ((float) minHeight / img.getHeight()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scale the image so it has a width that is at less than the max
|
||||||
|
*
|
||||||
|
* @param img
|
||||||
|
* @param maxWidth
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BufferedImage ensureMaxWidth(BufferedImage img, int maxWidth) {
|
||||||
|
if (img.getWidth() > maxWidth) {
|
||||||
|
return scale(img, ((float) maxWidth / img.getWidth()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scale the image so it has a height that is at less than the max
|
||||||
|
*
|
||||||
|
* @param img
|
||||||
|
* @param maxHeight
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BufferedImage ensureMaxHeight(BufferedImage img, int maxHeight) {
|
||||||
|
if (img.getHeight() > maxHeight) {
|
||||||
|
return scale(img, ((float) maxHeight / img.getWidth()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
|
|||||||
Reference in New Issue
Block a user