diff --git a/.gitignore b/.gitignore index de7a159..b9bb98e 100644 --- a/.gitignore +++ b/.gitignore @@ -239,3 +239,5 @@ gradle-app.setting # Copyright header files .idea/* !.idea/copyright/ + +test/ diff --git a/gradle.properties b/gradle.properties index 062172d..30cb3a9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group = org.geysermc.pack -version = 3.3.1-SNAPSHOT \ No newline at end of file +version = 3.3.2-SNAPSHOT \ No newline at end of file diff --git a/pack-schema/api/src/main/java/org/geysermc/pack/bedrock/resource/BedrockResourcePack.java b/pack-schema/api/src/main/java/org/geysermc/pack/bedrock/resource/BedrockResourcePack.java index 5842ad3..798f4de 100644 --- a/pack-schema/api/src/main/java/org/geysermc/pack/bedrock/resource/BedrockResourcePack.java +++ b/pack-schema/api/src/main/java/org/geysermc/pack/bedrock/resource/BedrockResourcePack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org + * Copyright (c) 2019-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 @@ -33,6 +33,7 @@ import org.geysermc.pack.bedrock.resource.models.entity.ModelEntity; import org.geysermc.pack.bedrock.resource.render_controllers.RenderControllers; import org.geysermc.pack.bedrock.resource.sounds.SoundDefinitions; import org.geysermc.pack.bedrock.resource.sounds.sounddefinitions.Sounds; +import org.geysermc.pack.bedrock.resource.textures.FlipbookTexture; import org.geysermc.pack.bedrock.resource.textures.ItemTexture; import org.geysermc.pack.bedrock.resource.textures.TerrainTexture; import org.geysermc.pack.bedrock.resource.textures.itemtexture.TextureData; @@ -45,6 +46,7 @@ import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -72,6 +74,7 @@ public class BedrockResourcePack { private SoundDefinitions soundDefinitions; private Languages languages; private Map renderControllers; + private Map flipbookTextures; private Map blockModels; private Map entityModels; @@ -163,6 +166,26 @@ public class BedrockResourcePack { this.terrainTexture = terrainTexture; } + + /** + * Get the flipbook textures of the resource pack. + * + * @return the flipbook textures of the resource pack + */ + @Nullable + public Map flipbookTextures() { + return this.flipbookTextures; + } + + /** + * Set the flipbook textures of the resource pack. + * + * @param flipbookTextures the flipbook textures of the resource pack + */ + public void flipbookTextures(@Nullable Map flipbookTextures) { + this.flipbookTextures = flipbookTextures; + } + /** * Get the attachables of the resource pack. * @@ -338,6 +361,19 @@ public class BedrockResourcePack { this.terrainTexture.textureData().put(id, data); } + public void addFlipbookTexture(@NotNull String id, @NotNull String textureLocation, @NotNull int ticksPerFrame) { + if (this.flipbookTextures == null) { + this.flipbookTextures = new HashMap<>(); + } + + FlipbookTexture texture = new FlipbookTexture(); + texture.atlasTile(id); + texture.flipbookTexture(textureLocation); + texture.ticksPerFrame(ticksPerFrame); + + this.flipbookTextures.put(id, texture); + } + /** * Add an attachable to the resource pack. * @@ -487,6 +523,10 @@ public class BedrockResourcePack { exportJson(GSON, this.directory.resolve("textures/terrain_texture.json"), this.terrainTexture); } + if (this.flipbookTextures != null) { + exportJson(GSON, this.directory.resolve("textures/flipbook_textures.json"), this.flipbookTextures.values()); + } + if (this.attachables != null) { for (Map.Entry attachable : this.attachables.entrySet()) { exportJson(GSON, this.directory.resolve(attachable.getKey()), attachable.getValue()); diff --git a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/textures/FlipbookTexture.java b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/textures/FlipbookTexture.java new file mode 100644 index 0000000..2c1867e --- /dev/null +++ b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/textures/FlipbookTexture.java @@ -0,0 +1,43 @@ +package org.geysermc.pack.bedrock.resource.textures; + +import com.google.gson.annotations.SerializedName; + +/** + * Flipbook Texture Entry + *

+ * An entry in the flipbook texture file that specifies an animated texture. + */ +public class FlipbookTexture { + @SerializedName("atlas_tile") + public String atlasTile; + + @SerializedName("flipbook_texture") + public String flipbookTexture; + + @SerializedName("ticks_per_frame") + public int ticksPerFrame; + + public String atlasTile() { + return this.atlasTile; + } + + public void atlasTile(String atlasTile) { + this.atlasTile = atlasTile; + } + + public String flipbookTexture() { + return this.flipbookTexture; + } + + public void flipbookTexture(String flipbookTexture) { + this.flipbookTexture = flipbookTexture; + } + + public int ticksPerFrame() { + return this.ticksPerFrame; + } + + public void ticksPerFrame(int ticksPerFrame) { + this.ticksPerFrame = ticksPerFrame; + } +} diff --git a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/textures/FlipbookTextures.java b/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/textures/FlipbookTextures.java deleted file mode 100644 index 2c4af88..0000000 --- a/pack-schema/bedrock/src/main/java/org/geysermc/pack/bedrock/resource/textures/FlipbookTextures.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.geysermc.pack.bedrock.resource.textures; - -/** - * Flipbook Texture File - *

- * The file that specifies animated textures. - */ -public class FlipbookTextures { -}