Created
June 16, 2025 22:08
-
-
Save Zeitheron/a4a28f651bef3e842c824f04d327b02e to your computer and use it in GitHub Desktop.
This is a simple converter that takes in a 80x16 texture, reading first two 16x16 sprites as full-frame and no-frame, and constructs the rest of sprites for Fusion Minecraft mod sprite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.imageio.ImageIO; | |
import java.awt.*; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
public class FusionPieceTexture | |
{ | |
public static void main(String[] args) | |
{ | |
File[] dir = new File(args[0]) | |
.listFiles(f -> f.isFile() && !f.isHidden() && f.getName().endsWith(".png")); | |
if(dir == null) | |
{ | |
System.out.println("Folder " + args[0] + " does not exist."); | |
return; | |
} | |
for(File file : dir) | |
{ | |
try | |
{ | |
System.out.println("process " + file); | |
var img = ImageIO.read(file); | |
process(img); | |
ImageIO.write(img, "png", file); | |
} catch(Throwable e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
} | |
static final Color TRANSPARENT = new Color(0, 0, 0, 0); | |
private static void process(BufferedImage img) | |
{ | |
var gfx = img.createGraphics(); | |
{ | |
gfx.setBackground(TRANSPARENT); | |
gfx.translate(32, 0); | |
gfx.clearRect(0, 0, 48, 16); | |
var noBorder = img.getSubimage(16, 0, 16, 16); | |
// Vertical slide | |
gfx.drawImage(noBorder, 0, 0, null); | |
gfx.drawImage(img.getSubimage(0, 0, 1, 16), 0, 0, null); | |
gfx.drawImage(img.getSubimage(15, 0, 1, 16), 15, 0, null); | |
// Horizontal slide | |
gfx.translate(16, 0); | |
gfx.drawImage(noBorder, 0, 0, null); | |
gfx.drawImage(img.getSubimage(0, 0, 16, 1), 0, 0, null); | |
gfx.drawImage(img.getSubimage(0, 15, 16, 1), 0, 15, null); | |
// Corners | |
gfx.translate(16, 0); | |
gfx.drawImage(noBorder, 0, 0, null); | |
gfx.drawImage(img.getSubimage(0, 0, 1, 1), 0, 0, null); | |
gfx.drawImage(img.getSubimage(15, 0, 1, 1), 15, 0, null); | |
gfx.drawImage(img.getSubimage(15, 15, 1, 1), 15, 15, null); | |
gfx.drawImage(img.getSubimage(0, 15, 1, 1), 0, 15, null); | |
} | |
gfx.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment