diff --git a/PCK-Studio/External/Format/BlockBenchModel.cs b/PCK-Studio/External/Format/BlockBenchModel.cs index 27c78b56..c6c85e9d 100644 --- a/PCK-Studio/External/Format/BlockBenchModel.cs +++ b/PCK-Studio/External/Format/BlockBenchModel.cs @@ -16,16 +16,31 @@ using PckStudio.Internal; namespace PckStudio.External.Format { - internal class Meta + internal static class BlockBenchFormatInfos + { + internal static readonly string FormatVersion = "4.5"; + + internal static BlockBenchFormatInfo Free { get; } = new BlockBenchFormatInfo(FormatVersion, "free", true); + internal static BlockBenchFormatInfo BedrockEntity { get; } = new BlockBenchFormatInfo(FormatVersion, "bedrock", true); + } + + internal sealed class BlockBenchFormatInfo { [JsonProperty("format_version")] - internal string FormatVersion; + internal string FormatVersion { get; } [JsonProperty("model_format")] - internal string ModelFormat; + internal string ModelFormat { get; } [JsonProperty("box_uv")] - internal bool UseBoxUv; + internal bool UseBoxUv { get; } + + internal BlockBenchFormatInfo(string formatVersion, string modelFormat, bool useBoxUv) + { + FormatVersion = formatVersion; + ModelFormat = modelFormat; + UseBoxUv = useBoxUv; + } } internal class Element @@ -309,7 +324,7 @@ namespace PckStudio.External.Format internal string Name; [JsonProperty("meta")] - internal Meta Metadata; + internal BlockBenchFormatInfo Format; [JsonProperty("model_identifier")] internal string ModelIdentifier { get; set; } = ""; @@ -329,7 +344,7 @@ namespace PckStudio.External.Format [JsonProperty("textures")] internal Texture[] Textures; - internal static BlockBenchModel Create(string name, Size textureResolution, IEnumerable textures) + internal static BlockBenchModel Create(BlockBenchFormatInfo formatInfo, string name, Size textureResolution, IEnumerable textures) { return new BlockBenchModel() { @@ -337,12 +352,7 @@ namespace PckStudio.External.Format Textures = textures.ToArray(), TextureResolution = textureResolution, ModelIdentifier = "", - Metadata = new Meta() - { - FormatVersion = "4.5", - ModelFormat = "free", - UseBoxUv = true, - } + Format = formatInfo, }; } } diff --git a/PCK-Studio/Internal/GameModelImporter.cs b/PCK-Studio/Internal/GameModelImporter.cs index 83409789..9f6c4a7d 100644 --- a/PCK-Studio/Internal/GameModelImporter.cs +++ b/PCK-Studio/Internal/GameModelImporter.cs @@ -46,7 +46,7 @@ namespace PckStudio.Internal private void ExportBlockBenchModel(string fileName, GameModelInfo modelInfo) { - BlockBenchModel blockBenchModel = BlockBenchModel.Create(modelInfo.Model.Name, modelInfo.Model.TextureSize, modelInfo.Textures.Select(nt => (Texture)nt)); + BlockBenchModel blockBenchModel = BlockBenchModel.Create(BlockBenchFormatInfos.BedrockEntity, modelInfo.Model.Name, modelInfo.Model.TextureSize, modelInfo.Textures.Select(nt => (Texture)nt)); Dictionary outliners = new Dictionary(5); List elements = new List(modelInfo.Model.Parts.Count); diff --git a/PCK-Studio/Internal/SkinModelImporter.cs b/PCK-Studio/Internal/SkinModelImporter.cs index 470aee8e..6d734328 100644 --- a/PCK-Studio/Internal/SkinModelImporter.cs +++ b/PCK-Studio/Internal/SkinModelImporter.cs @@ -162,7 +162,7 @@ namespace PckStudio.Internal internal static void ExportBlockBenchModel(string fileName, SkinModelInfo modelInfo) { Image exportTexture = FixTexture(modelInfo); - BlockBenchModel blockBenchModel = BlockBenchModel.Create(Path.GetFileNameWithoutExtension(fileName), new Size(64, exportTexture.Width == exportTexture.Height ? 64 : 32), [exportTexture]); + BlockBenchModel blockBenchModel = BlockBenchModel.Create(BlockBenchFormatInfos.Free, Path.GetFileNameWithoutExtension(fileName), new Size(64, exportTexture.Width == exportTexture.Height ? 64 : 32), [exportTexture]); Dictionary outliners = new Dictionary(5); List elements = new List(modelInfo.AdditionalBoxes.Count);