mirror of
https://github.com/GeyserMC/PackConverter.git
synced 2025-12-24 01:09:20 +00:00
Add support for flipbook texture map creation
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -239,3 +239,5 @@ gradle-app.setting
|
|||||||
# Copyright header files
|
# Copyright header files
|
||||||
.idea/*
|
.idea/*
|
||||||
!.idea/copyright/
|
!.idea/copyright/
|
||||||
|
|
||||||
|
test/
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
group = org.geysermc.pack
|
group = org.geysermc.pack
|
||||||
version = 3.3.1-SNAPSHOT
|
version = 3.3.2-SNAPSHOT
|
||||||
@@ -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
|
* 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
|
||||||
@@ -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.render_controllers.RenderControllers;
|
||||||
import org.geysermc.pack.bedrock.resource.sounds.SoundDefinitions;
|
import org.geysermc.pack.bedrock.resource.sounds.SoundDefinitions;
|
||||||
import org.geysermc.pack.bedrock.resource.sounds.sounddefinitions.Sounds;
|
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.ItemTexture;
|
||||||
import org.geysermc.pack.bedrock.resource.textures.TerrainTexture;
|
import org.geysermc.pack.bedrock.resource.textures.TerrainTexture;
|
||||||
import org.geysermc.pack.bedrock.resource.textures.itemtexture.TextureData;
|
import org.geysermc.pack.bedrock.resource.textures.itemtexture.TextureData;
|
||||||
@@ -45,6 +46,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -72,6 +74,7 @@ public class BedrockResourcePack {
|
|||||||
private SoundDefinitions soundDefinitions;
|
private SoundDefinitions soundDefinitions;
|
||||||
private Languages languages;
|
private Languages languages;
|
||||||
private Map<String, RenderControllers> renderControllers;
|
private Map<String, RenderControllers> renderControllers;
|
||||||
|
private Map<String, FlipbookTexture> flipbookTextures;
|
||||||
|
|
||||||
private Map<String, ModelEntity> blockModels;
|
private Map<String, ModelEntity> blockModels;
|
||||||
private Map<String, ModelEntity> entityModels;
|
private Map<String, ModelEntity> entityModels;
|
||||||
@@ -163,6 +166,26 @@ public class BedrockResourcePack {
|
|||||||
this.terrainTexture = terrainTexture;
|
this.terrainTexture = terrainTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the flipbook textures of the resource pack.
|
||||||
|
*
|
||||||
|
* @return the flipbook textures of the resource pack
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Map<String, FlipbookTexture> 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<String, FlipbookTexture> flipbookTextures) {
|
||||||
|
this.flipbookTextures = flipbookTextures;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the attachables of the resource pack.
|
* Get the attachables of the resource pack.
|
||||||
*
|
*
|
||||||
@@ -338,6 +361,19 @@ public class BedrockResourcePack {
|
|||||||
this.terrainTexture.textureData().put(id, data);
|
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.
|
* 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);
|
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) {
|
if (this.attachables != null) {
|
||||||
for (Map.Entry<String, Attachables> attachable : this.attachables.entrySet()) {
|
for (Map.Entry<String, Attachables> attachable : this.attachables.entrySet()) {
|
||||||
exportJson(GSON, this.directory.resolve(attachable.getKey()), attachable.getValue());
|
exportJson(GSON, this.directory.resolve(attachable.getKey()), attachable.getValue());
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package org.geysermc.pack.bedrock.resource.textures;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flipbook Texture Entry
|
||||||
|
* <p>
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package org.geysermc.pack.bedrock.resource.textures;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flipbook Texture File
|
|
||||||
* <p>
|
|
||||||
* The file that specifies animated textures.
|
|
||||||
*/
|
|
||||||
public class FlipbookTextures {
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user