Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public abstract class GridSpritesheetParticleTransformer implements TextureTransformer {
private final String[] javaPaths;
Expand Down Expand Up @@ -70,24 +72,41 @@ public GridSpritesheetParticleTransformer(String bedrockPath, int rows, int colu

@Override
public void transform(@NotNull TransformContext context) throws IOException {
BufferedImage image = new BufferedImage(columns * particleWidth, rows * particleHeight, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();

context.debug(String.format("Creating particle spritesheet %s", this.bedrockPath));
List<ItemData> itemDatas = new ArrayList<>();
boolean anyTexturePresent = false;

int k = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
Texture texture = context.pollOrPeekVanilla(KeyUtil.key(Key.MINECRAFT_NAMESPACE, javaPaths[k++]));
if (texture == null) {
context.warn("%s is missing. Please report this.".formatted(javaPaths[k]));
continue;
}
Key key = KeyUtil.key(Key.MINECRAFT_NAMESPACE, javaPaths[k++]);
Texture texture = context.pollOrPeekVanilla(key);
itemDatas.add(new ItemData(
key,
texture,
j * particleWidth,
i * particleHeight
));

if (texture != null) anyTexturePresent = true;
}
}

if (!anyTexturePresent) return;

BufferedImage javaImage = this.preProcessImage(this.readImage(texture));
context.debug(String.format("Creating particle spritesheet %s", this.bedrockPath));

BufferedImage image = new BufferedImage(columns * particleWidth, rows * particleHeight, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();

g.drawImage(javaImage, j * particleWidth, i * particleHeight, null);
for (ItemData itemData : itemDatas) {
if (itemData.texture() == null) {
context.warn("%s is missing. Please report this.".formatted(itemData.key()));
continue;
}

BufferedImage javaImage = this.preProcessImage(this.readImage(itemData.texture()));

g.drawImage(javaImage, itemData.x(), itemData.y(), null);
}

context.offer(KeyUtil.key(Key.MINECRAFT_NAMESPACE, this.bedrockPath), image, "png");
Expand All @@ -97,6 +116,8 @@ public BufferedImage preProcessImage(BufferedImage image) {
return image;
}

private record ItemData(Key key, Texture texture, int x, int y) {}

public static abstract class Row extends GridSpritesheetParticleTransformer {
public Row(String bedrockPath, int particleWidth, int particleHeight, String javaPath, int amount) {
super(bedrockPath, 1, amount, particleWidth, particleHeight, StringUtils.formatStringFor(javaPath, amount));
Expand Down
9 changes: 8 additions & 1 deletion converter/src/main/resources/mappings/textures.json
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@
"guardian/guardian_beam": "guardian_beam",
"guardian/guardian_elder": "guardian_elder",
"hoglin/zoglin": "zoglin/zoglin",
"hoglin/zoglin_baby": "zoglin/zoglin_baby",
"horse/donkey_baby": "horse2/donkey_baby",
"horse/horse_black_baby": "horse2/horse_black_baby",
"horse/horse_brown_baby": "horse2/horse_brown_baby",
Expand Down Expand Up @@ -1180,8 +1181,14 @@
},
"minecart/minecart": "minecart",
"panda": {
"aggressive_panda_baby": "panda_aggressive_baby",
"brown_panda_baby": "panda_brown_baby",
"lazy_panda_baby": "panda_lazy_baby",
"panda": "panda",
"panda_weak": "panda_sneezy"
"panda_weak": "panda_sneezy",
"playful_panda_baby": "panda_playful_baby",
"weak_panda_baby": "panda_weak_baby",
"worried_panda_baby": "panda_worried_baby"
},
"pig": {
"pig_temperate": "pig_v3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,11 @@ java:
- entity/zombie/husk_baby
- entity/zombie/zombie_baby
- entity/piglin/piglin_baby
- entity/strider/strider_cold_baby
- entity/strider/strider_baby
- entity/panda/panda_baby
- entity/hoglin/hoglin_baby
- entity/sniffer/snifflet
transformed-paths:
- block/copper_chain
- entity/conduit/base
Expand Down Expand Up @@ -1838,6 +1843,11 @@ bedrock:
- entity/zombie/husk_baby
- entity/zombie/zombie_baby
- entity/piglin/piglin_baby
- entity/strider/strider_cold_baby
- entity/strider/strider_baby
- entity/panda/panda_baby
- entity/hoglin/hoglin_baby
- entity/sniffer/snifflet
transformed-paths:
- blocks/chest_front
- blocks/chest_side
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=org.geysermc.pack
version=3.4.1-SNAPSHOT
version=3.4.2-SNAPSHOT
Loading