mirror of
https://github.com/GeyserMC/PackConverter.git
synced 2025-12-19 14:59:21 +00:00
Merge pull request #43 from GeyserMC/feat/1.21.9
This commit is contained in:
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 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.pack.converter.type.texture.transformer.type.block;
|
||||||
|
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.geysermc.pack.converter.type.texture.transformer.TextureTransformer;
|
||||||
|
import org.geysermc.pack.converter.type.texture.transformer.TransformContext;
|
||||||
|
import org.geysermc.pack.converter.util.ImageUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import team.unnamed.creative.texture.Texture;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChainTransformer implements TextureTransformer {
|
||||||
|
private static final List<ChainData> CHAIN_DATA = List.of(
|
||||||
|
new ChainData("chain"),
|
||||||
|
new ChainData("copper_chain"),
|
||||||
|
new ChainData("exposed_copper_chain"),
|
||||||
|
new ChainData("weathered_copper_chain"),
|
||||||
|
new ChainData("oxidized_copper_chain")
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final String JAVA_NAME = "block/%s.png";
|
||||||
|
private static final String BEDROCK_1 = "blocks/%s1.png";
|
||||||
|
private static final String BEDROCK_2 = "blocks/%s2.png";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transform(@NotNull TransformContext context) throws IOException {
|
||||||
|
for (ChainData chainData : CHAIN_DATA) {
|
||||||
|
Key javaKey = Key.key(Key.MINECRAFT_NAMESPACE, JAVA_NAME.formatted(chainData.name()));
|
||||||
|
|
||||||
|
Texture javaTexture = context.poll(javaKey);
|
||||||
|
if (javaTexture == null) continue;
|
||||||
|
|
||||||
|
BufferedImage javaImage = this.readImage(javaTexture);
|
||||||
|
|
||||||
|
float scale = javaImage.getHeight() / 16f;
|
||||||
|
|
||||||
|
Key bedrock1Key = Key.key(Key.MINECRAFT_NAMESPACE, BEDROCK_1.formatted(chainData.name()));
|
||||||
|
Key bedrock2Key = Key.key(Key.MINECRAFT_NAMESPACE, BEDROCK_2.formatted(chainData.name()));
|
||||||
|
|
||||||
|
BufferedImage bedrock1Image = new BufferedImage(javaImage.getWidth(), javaImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
BufferedImage bedrock2Image = new BufferedImage(javaImage.getWidth(), javaImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
||||||
|
// Yes, 2 than 1, since the numbers are in the wrong order on bedrock, fun.
|
||||||
|
bedrock2Image.getGraphics().drawImage(
|
||||||
|
ImageUtil.crop(
|
||||||
|
javaImage,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(int) (3 * scale),
|
||||||
|
javaImage.getHeight()
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
bedrock1Image.getGraphics().drawImage(
|
||||||
|
ImageUtil.crop(
|
||||||
|
javaImage,
|
||||||
|
(int) (3 * scale),
|
||||||
|
0,
|
||||||
|
(int) (6 * scale),
|
||||||
|
javaImage.getHeight()
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
context.offer(bedrock1Key, bedrock1Image, "png");
|
||||||
|
context.offer(bedrock2Key, bedrock2Image, "png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ChainData(String name) {}
|
||||||
|
}
|
||||||
@@ -45,7 +45,11 @@ public class ChestDoubleTransformer implements TextureTransformer {
|
|||||||
private static final List<ChestData> CHEST_DATA = List.of(
|
private static final List<ChestData> CHEST_DATA = List.of(
|
||||||
new ChestData("entity/chest/normal_left.png", "entity/chest/normal_right.png", "entity/chest/double_normal.png"),
|
new ChestData("entity/chest/normal_left.png", "entity/chest/normal_right.png", "entity/chest/double_normal.png"),
|
||||||
new ChestData("entity/chest/trapped_left.png", "entity/chest/trapped_right.png", "entity/chest/trapped_double.png"),
|
new ChestData("entity/chest/trapped_left.png", "entity/chest/trapped_right.png", "entity/chest/trapped_double.png"),
|
||||||
new ChestData("entity/chest/christmas_left.png", "entity/chest/christmas_right.png", "entity/chest/christmas_double.png")
|
new ChestData("entity/chest/christmas_left.png", "entity/chest/christmas_right.png", "entity/chest/christmas_double.png"),
|
||||||
|
new ChestData("entity/chest/copper_left.png", "entity/chest/copper_right.png", "entity/chest/copper_default_double.png"),
|
||||||
|
new ChestData("entity/chest/copper_exposed_left.png", "entity/chest/copper_exposed_right.png", "entity/chest/copper_exposed_double.png"),
|
||||||
|
new ChestData("entity/chest/copper_weathered_left.png", "entity/chest/copper_weathered_right.png", "entity/chest/copper_weathered_double.png"),
|
||||||
|
new ChestData("entity/chest/copper_oxidized_left.png", "entity/chest/copper_oxidized_right.png", "entity/chest/copper_oxidized_double.png")
|
||||||
);
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019-2023 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.pack.converter.type.texture.transformer.type.block;
|
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
|
||||||
import net.kyori.adventure.key.Key;
|
|
||||||
import org.geysermc.pack.converter.type.texture.transformer.TextureTransformer;
|
|
||||||
import org.geysermc.pack.converter.type.texture.transformer.TransformContext;
|
|
||||||
import org.geysermc.pack.converter.util.ImageUtil;
|
|
||||||
import org.geysermc.pack.converter.util.KeyUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import team.unnamed.creative.texture.Texture;
|
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@AutoService(TextureTransformer.class)
|
|
||||||
public class ChestFrontTransformer implements TextureTransformer {
|
|
||||||
private static final List<ChestData> CHESTS = List.of(
|
|
||||||
new ChestData("entity/chest/normal.png", "blocks/chest_front.png"),
|
|
||||||
new ChestData("entity/chest/trapped.png", "blocks/trapped_chest_front.png"),
|
|
||||||
new ChestData("entity/chest/ender.png", "blocks/ender_chest_front.png")
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void transform(@NotNull TransformContext context) throws IOException {
|
|
||||||
for (ChestData chest : CHESTS) {
|
|
||||||
Texture texture = context.peek(KeyUtil.key(Key.MINECRAFT_NAMESPACE, chest.javaName()));
|
|
||||||
if (texture == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.debug(String.format("Creating chest front texture %s", chest.bedrockName()));
|
|
||||||
|
|
||||||
BufferedImage fromImage = ImageUtil.ensureMinWidth(this.readImage(texture), 64);
|
|
||||||
|
|
||||||
int factor = fromImage.getWidth() / 64;
|
|
||||||
|
|
||||||
BufferedImage newImage = new BufferedImage((14 * factor), (14 * factor), BufferedImage.TYPE_INT_ARGB);
|
|
||||||
Graphics graphics = newImage.getGraphics();
|
|
||||||
|
|
||||||
graphics.drawImage(ImageUtil.crop(fromImage, (14 * factor), (14 * factor), (14 * factor), (5 * factor)), 0, 0, null);
|
|
||||||
graphics.drawImage(ImageUtil.crop(fromImage, (14 * factor), (34 * factor), (14 * factor), (9 * factor)), 0, (5 * factor), null);
|
|
||||||
graphics.drawImage(ImageUtil.crop(fromImage , factor, factor, (2 * factor), (4 * factor)), (6 * factor), (3 * factor), null);
|
|
||||||
|
|
||||||
context.offer(KeyUtil.key(Key.MINECRAFT_NAMESPACE, chest.bedrockName()), newImage, "png");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
record ChestData(@NotNull String javaName, @NotNull String bedrockName) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2023 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.pack.converter.type.texture.transformer.type.block;
|
||||||
|
|
||||||
|
import com.google.auto.service.AutoService;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.geysermc.pack.converter.type.texture.transformer.TextureTransformer;
|
||||||
|
import org.geysermc.pack.converter.type.texture.transformer.TransformContext;
|
||||||
|
import org.geysermc.pack.converter.util.ImageUtil;
|
||||||
|
import org.geysermc.pack.converter.util.KeyUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import team.unnamed.creative.texture.Texture;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AutoService(TextureTransformer.class)
|
||||||
|
public class ChestInventoryTransformer implements TextureTransformer {
|
||||||
|
private static final List<ChestData> CHESTS = List.of(
|
||||||
|
new ChestData(
|
||||||
|
"entity/chest/normal.png",
|
||||||
|
"blocks/chest_front.png",
|
||||||
|
"blocks/chest_side.png",
|
||||||
|
"blocks/chest_top.png"
|
||||||
|
),
|
||||||
|
new ChestData(
|
||||||
|
"entity/chest/trapped.png",
|
||||||
|
"blocks/trapped_chest_front.png",
|
||||||
|
null, // Bedrock uses normal chest stuff here, so we can just skip this
|
||||||
|
null
|
||||||
|
),
|
||||||
|
new ChestData(
|
||||||
|
"entity/chest/ender.png",
|
||||||
|
"blocks/ender_chest_front.png",
|
||||||
|
"blocks/ender_chest_side.png",
|
||||||
|
"blocks/ender_chest_top.png"
|
||||||
|
),
|
||||||
|
new ChestData(
|
||||||
|
"entity/chest/copper.png",
|
||||||
|
"blocks/copper_chest_inventory_front.png",
|
||||||
|
"blocks/copper_chest_inventory_side.png",
|
||||||
|
"blocks/copper_chest_inventory_top.png"
|
||||||
|
),
|
||||||
|
new ChestData(
|
||||||
|
"entity/chest/copper_exposed.png",
|
||||||
|
"blocks/exposed_copper_chest_inventory_front.png",
|
||||||
|
"blocks/exposed_copper_chest_inventory_side.png",
|
||||||
|
"blocks/exposed_copper_chest_inventory_top.png"
|
||||||
|
),
|
||||||
|
new ChestData(
|
||||||
|
"entity/chest/copper_weathered.png",
|
||||||
|
"blocks/weathered_copper_chest_inventory_front.png",
|
||||||
|
"blocks/weathered_copper_chest_inventory_side.png",
|
||||||
|
"blocks/weathered_copper_chest_inventory_top.png"
|
||||||
|
),
|
||||||
|
new ChestData(
|
||||||
|
"entity/chest/copper_oxidized.png",
|
||||||
|
"blocks/oxidized_copper_chest_inventory_front.png",
|
||||||
|
"blocks/oxidized_copper_chest_inventory_side.png",
|
||||||
|
"blocks/oxidized_copper_chest_inventory_top.png"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transform(@NotNull TransformContext context) throws IOException {
|
||||||
|
for (ChestData chest : CHESTS) {
|
||||||
|
Texture texture = context.peek(KeyUtil.key(Key.MINECRAFT_NAMESPACE, chest.javaName()));
|
||||||
|
if (texture == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.debug(String.format("Creating chest inventory textures %s", chest.javaName()));
|
||||||
|
|
||||||
|
BufferedImage fromImage = ImageUtil.ensureMinWidth(this.readImage(texture), 64);
|
||||||
|
|
||||||
|
float scale = fromImage.getWidth() / 64f;
|
||||||
|
|
||||||
|
BufferedImage frontImage = new BufferedImage((int) (14 * scale), (int) (14 * scale), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
Graphics graphics = frontImage.getGraphics();
|
||||||
|
|
||||||
|
graphics.drawImage(ImageUtil.crop(fromImage, (int) (14 * scale), (int) (14 * scale), (int) (14 * scale), (int) (5 * scale)), 0, 0, null);
|
||||||
|
graphics.drawImage(ImageUtil.crop(fromImage, (int) (14 * scale), (int) (34 * scale), (int) (14 * scale), (int) (9 * scale)), 0, (int) (5 * scale), null);
|
||||||
|
graphics.drawImage(ImageUtil.crop(fromImage, (int) scale, (int) scale, (int) (2 * scale), (int) (4 * scale)), (int) (6 * scale), (int) (3 * scale), null);
|
||||||
|
|
||||||
|
context.offer(KeyUtil.key(Key.MINECRAFT_NAMESPACE, chest.bedrockFront()), frontImage, "png");
|
||||||
|
|
||||||
|
if (chest.bedrockSide() != null) {
|
||||||
|
BufferedImage sideImage = new BufferedImage((int) (14 * scale), (int) (14 * scale), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
||||||
|
graphics = sideImage.getGraphics();
|
||||||
|
graphics.drawImage(ImageUtil.crop(fromImage, (int) (28 * scale), (int) (14 * scale), (int) (14 * scale), (int) (5 * scale)), 0, 0, null);
|
||||||
|
graphics.drawImage(ImageUtil.crop(fromImage, (int) (28 * scale), (int) (34 * scale), (int) (14 * scale), (int) (9 * scale)), 0, (int) (5 * scale), null);
|
||||||
|
|
||||||
|
context.offer(KeyUtil.key(Key.MINECRAFT_NAMESPACE, chest.bedrockSide()), sideImage, "png");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chest.bedrockTop() != null) {
|
||||||
|
BufferedImage topImage = new BufferedImage((int) (14 * scale), (int) (14 * scale), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
||||||
|
graphics = topImage.getGraphics();
|
||||||
|
graphics.drawImage(ImageUtil.crop(fromImage, (int) (28 * scale), 0, (int) (14 * scale), (int) (14 * scale)), 0, 0, null);
|
||||||
|
|
||||||
|
context.offer(KeyUtil.key(Key.MINECRAFT_NAMESPACE, chest.bedrockTop()), topImage, "png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
record ChestData(@NotNull String javaName, @NotNull String bedrockFront, @Nullable String bedrockSide, @Nullable String bedrockTop) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,6 +39,7 @@ import java.awt.Graphics;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@AutoService(TextureTransformer.class)
|
@AutoService(TextureTransformer.class)
|
||||||
public class ChestNormalTransformer implements TextureTransformer {
|
public class ChestNormalTransformer implements TextureTransformer {
|
||||||
@@ -48,7 +49,15 @@ public class ChestNormalTransformer implements TextureTransformer {
|
|||||||
"christmas",
|
"christmas",
|
||||||
"ender",
|
"ender",
|
||||||
"normal",
|
"normal",
|
||||||
"trapped"
|
"trapped",
|
||||||
|
"copper",
|
||||||
|
"copper_exposed",
|
||||||
|
"copper_weathered",
|
||||||
|
"copper_oxidized"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final Map<String, String> MAPPINGS = Map.of(
|
||||||
|
"copper", "copper_default"
|
||||||
);
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -87,7 +96,7 @@ public class ChestNormalTransformer implements TextureTransformer {
|
|||||||
|
|
||||||
graphics.drawImage(ImageUtil.crop(chestImage, 0, 0, (6 * factor), (6 * factor)), 0, 0, null);
|
graphics.drawImage(ImageUtil.crop(chestImage, 0, 0, (6 * factor), (6 * factor)), 0, 0, null);
|
||||||
|
|
||||||
context.offer(KeyUtil.key(Key.MINECRAFT_NAMESPACE, CHEST_PATH + "/" + variant + ".png"), newChestImage, "png");
|
context.offer(KeyUtil.key(Key.MINECRAFT_NAMESPACE, CHEST_PATH + "/" + MAPPINGS.getOrDefault(variant, variant) + ".png"), newChestImage, "png");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
* Copyright (c) 2025 GeyserMC. http://geysermc.org
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -24,54 +24,36 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.pack.converter.type.texture.transformer.type.block;
|
package org.geysermc.pack.converter.type.texture.transformer.type.entity;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import org.geysermc.pack.converter.type.texture.transformer.TextureTransformer;
|
import org.geysermc.pack.converter.type.texture.transformer.TextureTransformer;
|
||||||
import org.geysermc.pack.converter.type.texture.transformer.TransformContext;
|
import org.geysermc.pack.converter.type.texture.transformer.TransformContext;
|
||||||
import org.geysermc.pack.converter.util.ImageUtil;
|
|
||||||
import org.geysermc.pack.converter.util.KeyUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import team.unnamed.creative.texture.Texture;
|
import team.unnamed.creative.texture.Texture;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@AutoService(TextureTransformer.class)
|
public class CopperGolemTransformer implements TextureTransformer {
|
||||||
public class ChestSideTransformer implements TextureTransformer {
|
private static final Key POPPY = Key.key(Key.MINECRAFT_NAMESPACE, "block/poppy.png");
|
||||||
private static final List<ChestData> CHESTS = List.of(
|
private static final Key COPPER_POPPY = Key.key(Key.MINECRAFT_NAMESPACE, "entity/copper_golem/copper_golem_flower.png");
|
||||||
new ChestData("entity/chest/normal.png", "blocks/chest_side.png"),
|
|
||||||
new ChestData("entity/chest/ender.png", "blocks/ender_chest_side.png")
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(@NotNull TransformContext context) throws IOException {
|
public void transform(@NotNull TransformContext context) throws IOException {
|
||||||
for (ChestData chest : CHESTS) {
|
if (context.isTexturePresent(POPPY)) {
|
||||||
Texture texture = context.peek(KeyUtil.key(Key.MINECRAFT_NAMESPACE, chest.javaName()));
|
Texture texture = context.peek(POPPY);
|
||||||
if (texture == null) {
|
if (texture == null) return;
|
||||||
continue;
|
BufferedImage javaImage = this.readImage(texture);
|
||||||
}
|
|
||||||
|
|
||||||
context.debug(String.format("Creating chest side texture %s", chest.bedrockName()));
|
float scale = javaImage.getHeight() / 16f;
|
||||||
|
|
||||||
BufferedImage fromImage = ImageUtil.ensureMinWidth(this.readImage(texture), 64);
|
BufferedImage bedrockImage = new BufferedImage((int) (scale * 4), (int) (scale * 4), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
||||||
int factor = fromImage.getWidth() / 64;
|
bedrockImage.getGraphics().drawImage(javaImage, (int) (44 * scale), (int) (33 * scale), null);
|
||||||
|
|
||||||
BufferedImage newImage = new BufferedImage((14 * factor), (14 * factor), BufferedImage.TYPE_INT_ARGB);
|
context.offer(COPPER_POPPY, bedrockImage, "png");
|
||||||
|
|
||||||
Graphics graphics = newImage.getGraphics();
|
|
||||||
graphics.drawImage(ImageUtil.crop(fromImage, (28 * factor), (14 * factor), (14 * factor), (5 * factor)), 0, 0, null);
|
|
||||||
graphics.drawImage(ImageUtil.crop(fromImage, (28 * factor), (34 * factor), (14 * factor), (9 * factor)), 0, (5 * factor), null);
|
|
||||||
|
|
||||||
context.offer(KeyUtil.key(Key.MINECRAFT_NAMESPACE, chest.bedrockName()), newImage, "png");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
record ChestData(@NotNull String javaName, @NotNull String bedrockName) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public class BaseParticleTransformer implements TextureTransformer {
|
|||||||
new MultiTextureData("particle/note", "particle/critical_hit", "particle/enchanted_hit"),
|
new MultiTextureData("particle/note", "particle/critical_hit", "particle/enchanted_hit"),
|
||||||
new MultiTextureData("particle/heart", "particle/angry", "particle/glint", null), // TODO: Villager?
|
new MultiTextureData("particle/heart", "particle/angry", "particle/glint", null), // TODO: Villager?
|
||||||
new MultiTextureData(null, null, "particle/glow"),
|
new MultiTextureData(null, null, "particle/glow"),
|
||||||
new MultiTextureData("particle/drip_hang", "particle/drip_fall", "particle/drip_land"),
|
new MultiTextureData("particle/drip_hang", "particle/drip_fall", "particle/drip_land", null, "particle/copper_fire_flame", null), // TODO: Copper lava??
|
||||||
new AtlasTextureData("effect", 8),
|
new AtlasTextureData("effect", 8),
|
||||||
new AtlasTextureData("spell", 8),
|
new AtlasTextureData("spell", 8),
|
||||||
new AtlasTextureData("explosion", 16),
|
new AtlasTextureData("explosion", 16),
|
||||||
|
|||||||
@@ -982,6 +982,14 @@
|
|||||||
"chest_boat/oak": "boat/chest_boat_oak",
|
"chest_boat/oak": "boat/chest_boat_oak",
|
||||||
"chest_boat/pale_oak": "boat/chest_boat_pale_oak",
|
"chest_boat/pale_oak": "boat/chest_boat_pale_oak",
|
||||||
"chest_boat/spruce": "boat/chest_boat_spruce",
|
"chest_boat/spruce": "boat/chest_boat_spruce",
|
||||||
|
"copper_golem/copper_golem": "copper_golem/copper_golem",
|
||||||
|
"copper_golem/copper_golem_eyes": "copper_golem/copper_golem_eyes",
|
||||||
|
"copper_golem/exposed_copper_golem": "copper_golem/copper_golem_exposed",
|
||||||
|
"copper_golem/exposed_copper_golem_eyes": "copper_golem/copper_golem_eyes_exposed",
|
||||||
|
"copper_golem/weathered_copper_golem": "copper_golem/copper_golem_weathered",
|
||||||
|
"copper_golem/weathered_copper_golem_eyes": "copper_golem/copper_golem_eyes_weathered",
|
||||||
|
"copper_golem/oxidized_copper_golem": "copper_golem/copper_golem_oxidized",
|
||||||
|
"copper_golem/oxidized_copper_golem_eyes": "copper_golem/copper_golem_eyes_oxidized",
|
||||||
"creeper/creeper": ["creeper/creeper", "skulls/creeper"],
|
"creeper/creeper": ["creeper/creeper", "skulls/creeper"],
|
||||||
"end_crystal/end_crystal": "endercrystal/endercrystal",
|
"end_crystal/end_crystal": "endercrystal/endercrystal",
|
||||||
"end_crystal/end_crystal_beam": "endercrystal/endercrystal_beam",
|
"end_crystal/end_crystal_beam": "endercrystal/endercrystal_beam",
|
||||||
@@ -1152,6 +1160,7 @@
|
|||||||
"ghast/happy_ghast": "happy_ghast/happy_ghast",
|
"ghast/happy_ghast": "happy_ghast/happy_ghast",
|
||||||
"ghast/happy_ghast_baby": "happy_ghast/ghastling",
|
"ghast/happy_ghast_baby": "happy_ghast/ghastling",
|
||||||
"ghast/happy_ghast_ropes": "happy_ghast/happy_ghast_ropes",
|
"ghast/happy_ghast_ropes": "happy_ghast/happy_ghast_ropes",
|
||||||
|
|
||||||
"equipment/happy_ghast_body/black_harness": "harness/harness_black",
|
"equipment/happy_ghast_body/black_harness": "harness/harness_black",
|
||||||
"equipment/happy_ghast_body/blue_harness": "harness/harness_blue",
|
"equipment/happy_ghast_body/blue_harness": "harness/harness_blue",
|
||||||
"equipment/happy_ghast_body/brown_harness": "harness/harness_brown",
|
"equipment/happy_ghast_body/brown_harness": "harness/harness_brown",
|
||||||
@@ -1167,7 +1176,12 @@
|
|||||||
"equipment/happy_ghast_body/purple_harness": "harness/harness_purple",
|
"equipment/happy_ghast_body/purple_harness": "harness/harness_purple",
|
||||||
"equipment/happy_ghast_body/red_harness": "harness/harness_red",
|
"equipment/happy_ghast_body/red_harness": "harness/harness_red",
|
||||||
"equipment/happy_ghast_body/white_harness": "harness/harness_white",
|
"equipment/happy_ghast_body/white_harness": "harness/harness_white",
|
||||||
"equipment/happy_ghast_body/yellow_harness": "harness/harness_yellow"
|
"equipment/happy_ghast_body/yellow_harness": "harness/harness_yellow",
|
||||||
|
|
||||||
|
"equipment/horse_body/copper": "horse2/armor/horse_armor_copper",
|
||||||
|
"equipment/horse_body/iron": "horse2/armor/horse_armor_iron",
|
||||||
|
"equipment/horse_body/gold": "horse2/armor/horse_armor_gold",
|
||||||
|
"equipment/horse_body/diamond": "horse2/armor/horse_armor_diamond"
|
||||||
},
|
},
|
||||||
"environment": {
|
"environment": {
|
||||||
"clouds": "clouds",
|
"clouds": "clouds",
|
||||||
@@ -1292,7 +1306,7 @@
|
|||||||
"cooked_porkchop": "porkchop_cooked",
|
"cooked_porkchop": "porkchop_cooked",
|
||||||
"cooked_rabbit": "rabbit_cooked",
|
"cooked_rabbit": "rabbit_cooked",
|
||||||
"cooked_salmon": "fish_salmon_cooked",
|
"cooked_salmon": "fish_salmon_cooked",
|
||||||
"cyan_dye": "dye_powder_cyan",
|
"cyan_dye": "dye_powder_cyan_new",
|
||||||
"dandelion_yellow": "dye_powder_yellow",
|
"dandelion_yellow": "dye_powder_yellow",
|
||||||
"dark_oak_door": "door_dark_oak",
|
"dark_oak_door": "door_dark_oak",
|
||||||
"enchanted_book": "book_enchanted",
|
"enchanted_book": "book_enchanted",
|
||||||
@@ -1316,8 +1330,8 @@
|
|||||||
"golden_pickaxe": "gold_pickaxe",
|
"golden_pickaxe": "gold_pickaxe",
|
||||||
"golden_shovel": "gold_shovel",
|
"golden_shovel": "gold_shovel",
|
||||||
"golden_sword": "gold_sword",
|
"golden_sword": "gold_sword",
|
||||||
"gray_dye": "dye_powder_gray",
|
"gray_dye": "dye_powder_gray_new",
|
||||||
"green_dye": "dye_powder_green",
|
"green_dye": "dye_powder_green_new",
|
||||||
"hopper_minecart": "minecart_hopper",
|
"hopper_minecart": "minecart_hopper",
|
||||||
"ink_sac": "dye_powder_black",
|
"ink_sac": "dye_powder_black",
|
||||||
"iron_door": "door_iron",
|
"iron_door": "door_iron",
|
||||||
@@ -1340,11 +1354,11 @@
|
|||||||
"light_13": "light_block_13",
|
"light_13": "light_block_13",
|
||||||
"light_14": "light_block_14",
|
"light_14": "light_block_14",
|
||||||
"light_15": "light_block_15",
|
"light_15": "light_block_15",
|
||||||
"light_blue_dye": "dye_powder_light_blue",
|
"light_blue_dye": "dye_powder_light_blue_new",
|
||||||
"light_gray_dye": "dye_powder_silver",
|
"light_gray_dye": "dye_powder_silver_new",
|
||||||
"lime_dye": "dye_powder_lime",
|
"lime_dye": "dye_powder_lime_new",
|
||||||
"lingering_potion": "potion_bottle_lingering",
|
"lingering_potion": "potion_bottle_lingering",
|
||||||
"magenta_dye": "dye_powder_magenta",
|
"magenta_dye": "dye_powder_magenta_new",
|
||||||
"map": "map_empty",
|
"map": "map_empty",
|
||||||
"melon_seeds": "seeds_melon",
|
"melon_seeds": "seeds_melon",
|
||||||
"milk_bucket": "bucket_milk",
|
"milk_bucket": "bucket_milk",
|
||||||
@@ -1363,8 +1377,8 @@
|
|||||||
"music_disc_ward": "record_ward",
|
"music_disc_ward": "record_ward",
|
||||||
"mutton": "mutton_raw",
|
"mutton": "mutton_raw",
|
||||||
"oak_door": "door_wood",
|
"oak_door": "door_wood",
|
||||||
"orange_dye": "dye_powder_orange",
|
"orange_dye": "dye_powder_orange_new",
|
||||||
"pink_dye": "dye_powder_pink",
|
"pink_dye": "dye_powder_pink_new",
|
||||||
"poisonous_potato": "potato_poisonous",
|
"poisonous_potato": "potato_poisonous",
|
||||||
"porkchop": "porkchop_raw",
|
"porkchop": "porkchop_raw",
|
||||||
"potion": "potion_bottle_empty",
|
"potion": "potion_bottle_empty",
|
||||||
@@ -1372,9 +1386,9 @@
|
|||||||
"pufferfish": "fish_pufferfish_raw",
|
"pufferfish": "fish_pufferfish_raw",
|
||||||
"pufferfish_bucket": "bucket_pufferfish",
|
"pufferfish_bucket": "bucket_pufferfish",
|
||||||
"pumpkin_seeds": "seeds_pumpkin",
|
"pumpkin_seeds": "seeds_pumpkin",
|
||||||
"purple_dye": "dye_powder_purple",
|
"purple_dye": "dye_powder_purple_new",
|
||||||
"rabbit": "rabbit_raw",
|
"rabbit": "rabbit_raw",
|
||||||
"red_dye": "dye_powder_red",
|
"red_dye": "dye_powder_red_new",
|
||||||
"redstone": "redstone_dust",
|
"redstone": "redstone_dust",
|
||||||
"rose_red": "dye_powder_red",
|
"rose_red": "dye_powder_red",
|
||||||
"salmon": "fish_salmon_raw",
|
"salmon": "fish_salmon_raw",
|
||||||
@@ -1395,7 +1409,7 @@
|
|||||||
"wooden_sword": "wood_sword",
|
"wooden_sword": "wood_sword",
|
||||||
"writable_book": "book_writable",
|
"writable_book": "book_writable",
|
||||||
"written_book": "book_written",
|
"written_book": "book_written",
|
||||||
"yellow_dye": "dye_powder_yellow",
|
"yellow_dye": "dye_powder_yellow_new",
|
||||||
"oak_boat": "boat_oak",
|
"oak_boat": "boat_oak",
|
||||||
"acacia_boat": "boat_acacia",
|
"acacia_boat": "boat_acacia",
|
||||||
"birch_boat": "boat_birch",
|
"birch_boat": "boat_birch",
|
||||||
@@ -1710,6 +1724,7 @@
|
|||||||
"cave_spider_spawn_egg": "spawn_eggs/spawn_egg_cave_spider",
|
"cave_spider_spawn_egg": "spawn_eggs/spawn_egg_cave_spider",
|
||||||
"chicken_spawn_egg": "spawn_eggs/spawn_egg_chicken",
|
"chicken_spawn_egg": "spawn_eggs/spawn_egg_chicken",
|
||||||
"cod_spawn_egg": "spawn_eggs/spawn_egg_cod",
|
"cod_spawn_egg": "spawn_eggs/spawn_egg_cod",
|
||||||
|
"copper_golem_spawn_egg": "spawn_eggs/spawn_egg_copper_golem",
|
||||||
"cow_spawn_egg": "spawn_eggs/spawn_egg_cow",
|
"cow_spawn_egg": "spawn_eggs/spawn_egg_cow",
|
||||||
"creaking_spawn_egg": "spawn_eggs/spawn_egg_creaking",
|
"creaking_spawn_egg": "spawn_eggs/spawn_egg_creaking",
|
||||||
"creeper_spawn_egg": "spawn_eggs/spawn_egg_creeper",
|
"creeper_spawn_egg": "spawn_eggs/spawn_egg_creeper",
|
||||||
@@ -1828,6 +1843,7 @@
|
|||||||
"trims": {
|
"trims": {
|
||||||
"color_palettes/amethyst": "color_palettes/amethyst",
|
"color_palettes/amethyst": "color_palettes/amethyst",
|
||||||
"color_palettes/copper": "color_palettes/copper",
|
"color_palettes/copper": "color_palettes/copper",
|
||||||
|
"color_palettes/copper_darker": "color_palettes/copper_darker",
|
||||||
"color_palettes/diamond": "color_palettes/diamond",
|
"color_palettes/diamond": "color_palettes/diamond",
|
||||||
"color_palettes/diamond_darker": "color_palettes/diamond_darker",
|
"color_palettes/diamond_darker": "color_palettes/diamond_darker",
|
||||||
"color_palettes/emerald": "color_palettes/emerald",
|
"color_palettes/emerald": "color_palettes/emerald",
|
||||||
@@ -1888,6 +1904,8 @@
|
|||||||
|
|
||||||
"entity/equipment/humanoid/chainmail": "models/armor/chain_1",
|
"entity/equipment/humanoid/chainmail": "models/armor/chain_1",
|
||||||
"entity/equipment/humanoid_leggings/chainmail": "models/armor/chain_2",
|
"entity/equipment/humanoid_leggings/chainmail": "models/armor/chain_2",
|
||||||
|
"entity/equipment/humanoid/copper": "models/armor/copper_1",
|
||||||
|
"entity/equipment/humanoid_leggings/copper": "models/armor/copper_2",
|
||||||
"entity/equipment/humanoid/iron": "models/armor/iron_1",
|
"entity/equipment/humanoid/iron": "models/armor/iron_1",
|
||||||
"entity/equipment/humanoid_leggings/iron": "models/armor/iron_2",
|
"entity/equipment/humanoid_leggings/iron": "models/armor/iron_2",
|
||||||
"entity/equipment/humanoid/gold": "models/armor/gold_1",
|
"entity/equipment/humanoid/gold": "models/armor/gold_1",
|
||||||
@@ -1897,6 +1915,7 @@
|
|||||||
"entity/equipment/humanoid/netherite": "models/armor/netherite_1",
|
"entity/equipment/humanoid/netherite": "models/armor/netherite_1",
|
||||||
"entity/equipment/humanoid_leggings/netherite": "models/armor/netherite_2",
|
"entity/equipment/humanoid_leggings/netherite": "models/armor/netherite_2",
|
||||||
"entity/equipment/humanoid/turtle_scute": "models/armor/turtle_1",
|
"entity/equipment/humanoid/turtle_scute": "models/armor/turtle_1",
|
||||||
|
"entity/equipment/wings/elytra": "models/armor/elytra",
|
||||||
|
|
||||||
"gui/sprites/hud/locator_bar_background": "ui/locator_bg",
|
"gui/sprites/hud/locator_bar_background": "ui/locator_bg",
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user