Skip to content

Commit 98f5863

Browse files
Fix GridSpritesheetParticleTransformer, add a few textures (#61)
* Fix GridSpritesheetParticleTransformer, add a few textures * Invert anyTexturePresent check --------- Co-authored-by: Eclipse <eclipse@eclipseisoffline.xyz>
1 parent a561e15 commit 98f5863

4 files changed

Lines changed: 51 additions & 13 deletions

File tree

converter/src/main/java/org/geysermc/pack/converter/type/texture/transformer/type/particle/GridSpritesheetParticleTransformer.java

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import java.awt.*;
3838
import java.awt.image.BufferedImage;
3939
import java.io.IOException;
40+
import java.util.ArrayList;
41+
import java.util.List;
4042

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

7173
@Override
7274
public void transform(@NotNull TransformContext context) throws IOException {
73-
BufferedImage image = new BufferedImage(columns * particleWidth, rows * particleHeight, BufferedImage.TYPE_INT_ARGB);
74-
Graphics g = image.getGraphics();
75-
76-
context.debug(String.format("Creating particle spritesheet %s", this.bedrockPath));
75+
List<ItemData> itemDatas = new ArrayList<>();
76+
boolean anyTexturePresent = false;
7777

7878
int k = 0;
7979
for (int i = 0; i < rows; i++) {
8080
for (int j = 0; j < columns; j++) {
81-
Texture texture = context.pollOrPeekVanilla(KeyUtil.key(Key.MINECRAFT_NAMESPACE, javaPaths[k++]));
82-
if (texture == null) {
83-
context.warn("%s is missing. Please report this.".formatted(javaPaths[k]));
84-
continue;
85-
}
81+
Key key = KeyUtil.key(Key.MINECRAFT_NAMESPACE, javaPaths[k++]);
82+
Texture texture = context.pollOrPeekVanilla(key);
83+
itemDatas.add(new ItemData(
84+
key,
85+
texture,
86+
j * particleWidth,
87+
i * particleHeight
88+
));
89+
90+
if (texture != null) anyTexturePresent = true;
91+
}
92+
}
93+
94+
if (!anyTexturePresent) return;
8695

87-
BufferedImage javaImage = this.preProcessImage(this.readImage(texture));
96+
context.debug(String.format("Creating particle spritesheet %s", this.bedrockPath));
97+
98+
BufferedImage image = new BufferedImage(columns * particleWidth, rows * particleHeight, BufferedImage.TYPE_INT_ARGB);
99+
Graphics g = image.getGraphics();
88100

89-
g.drawImage(javaImage, j * particleWidth, i * particleHeight, null);
101+
for (ItemData itemData : itemDatas) {
102+
if (itemData.texture() == null) {
103+
context.warn("%s is missing. Please report this.".formatted(itemData.key()));
104+
continue;
90105
}
106+
107+
BufferedImage javaImage = this.preProcessImage(this.readImage(itemData.texture()));
108+
109+
g.drawImage(javaImage, itemData.x(), itemData.y(), null);
91110
}
92111

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

119+
private record ItemData(Key key, Texture texture, int x, int y) {}
120+
100121
public static abstract class Row extends GridSpritesheetParticleTransformer {
101122
public Row(String bedrockPath, int particleWidth, int particleHeight, String javaPath, int amount) {
102123
super(bedrockPath, 1, amount, particleWidth, particleHeight, StringUtils.formatStringFor(javaPath, amount));

converter/src/main/resources/mappings/textures.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@
11401140
"guardian/guardian_beam": "guardian_beam",
11411141
"guardian/guardian_elder": "guardian_elder",
11421142
"hoglin/zoglin": "zoglin/zoglin",
1143+
"hoglin/zoglin_baby": "zoglin/zoglin_baby",
11431144
"horse/donkey_baby": "horse2/donkey_baby",
11441145
"horse/horse_black_baby": "horse2/horse_black_baby",
11451146
"horse/horse_brown_baby": "horse2/horse_brown_baby",
@@ -1180,8 +1181,14 @@
11801181
},
11811182
"minecart/minecart": "minecart",
11821183
"panda": {
1184+
"aggressive_panda_baby": "panda_aggressive_baby",
1185+
"brown_panda_baby": "panda_brown_baby",
1186+
"lazy_panda_baby": "panda_lazy_baby",
11831187
"panda": "panda",
1184-
"panda_weak": "panda_sneezy"
1188+
"panda_weak": "panda_sneezy",
1189+
"playful_panda_baby": "panda_playful_baby",
1190+
"weak_panda_baby": "panda_weak_baby",
1191+
"worried_panda_baby": "panda_worried_baby"
11851192
},
11861193
"pig": {
11871194
"pig_temperate": "pig_v3"

converter/src/main/resources/mappings/textures.json.asset_mapper_meta.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,11 @@ java:
547547
- entity/zombie/husk_baby
548548
- entity/zombie/zombie_baby
549549
- entity/piglin/piglin_baby
550+
- entity/strider/strider_cold_baby
551+
- entity/strider/strider_baby
552+
- entity/panda/panda_baby
553+
- entity/hoglin/hoglin_baby
554+
- entity/sniffer/snifflet
550555
transformed-paths:
551556
- block/copper_chain
552557
- entity/conduit/base
@@ -1838,6 +1843,11 @@ bedrock:
18381843
- entity/zombie/husk_baby
18391844
- entity/zombie/zombie_baby
18401845
- entity/piglin/piglin_baby
1846+
- entity/strider/strider_cold_baby
1847+
- entity/strider/strider_baby
1848+
- entity/panda/panda_baby
1849+
- entity/hoglin/hoglin_baby
1850+
- entity/sniffer/snifflet
18411851
transformed-paths:
18421852
- blocks/chest_front
18431853
- blocks/chest_side

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
group=org.geysermc.pack
2-
version=3.4.1-SNAPSHOT
2+
version=3.4.2-SNAPSHOT

0 commit comments

Comments
 (0)