From 476281176818991660102b37418263aef0a3b0cf Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Fri, 16 Jan 2026 15:31:57 +0100 Subject: [PATCH] Core - Update DLCTexturepack class --- PckStudio.Core/DLC/DLCManager.cs | 2 + PckStudio.Core/DLC/DLCTexturePackage.cs | 15 ++++++ PckStudio.Core/DLC/PckFileCompiler.cs | 71 +++++++++++++++++++------ 3 files changed, 73 insertions(+), 15 deletions(-) diff --git a/PckStudio.Core/DLC/DLCManager.cs b/PckStudio.Core/DLC/DLCManager.cs index b4df626f..e1f19da9 100644 --- a/PckStudio.Core/DLC/DLCManager.cs +++ b/PckStudio.Core/DLC/DLCManager.cs @@ -375,6 +375,8 @@ namespace PckStudio.Core.DLC itemAnimations: itemAnimations, blockAnimations: blockAnimations, sun: sun, moon: moon, + mediaArc: null, + misc: null, parentPackage: null); } diff --git a/PckStudio.Core/DLC/DLCTexturePackage.cs b/PckStudio.Core/DLC/DLCTexturePackage.cs index 409dae98..e2b89950 100644 --- a/PckStudio.Core/DLC/DLCTexturePackage.cs +++ b/PckStudio.Core/DLC/DLCTexturePackage.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using OMI.Formats.Archive; using OMI.Formats.Color; using PckStudio.Core.Colors; using PckStudio.Core.Extensions; @@ -73,6 +74,8 @@ namespace PckStudio.Core.DLC private EnvironmentData _environmentData; + private ConsoleArchive _mediaArc; + private Animation _blockEntityBreakAnimation; private IDictionary _itemAnimations; private IDictionary _blockAnimations; @@ -80,6 +83,7 @@ namespace PckStudio.Core.DLC private Image _moon; //! TODO: add resources from "res/misc/" + private readonly IDictionary _misc; internal DLCTexturePackage( string name, @@ -111,6 +115,8 @@ namespace PckStudio.Core.DLC IDictionary blockAnimations, Image sun, Image moon, + ConsoleArchive mediaArc, + IDictionary misc, IDLCPackage parentPackage) : base(name, identifier, parentPackage) { @@ -154,6 +160,8 @@ namespace PckStudio.Core.DLC _itemModelTextures = itemModelTextures; _mobModelTextures = mobModelTextures; + _mediaArc = mediaArc; + _misc = misc; SetTextureSizeForResolution(); } @@ -286,6 +294,8 @@ namespace PckStudio.Core.DLC blockAnimations: blockAnimations, sun: null, moon: null, + mediaArc: null, + misc: null, parentPackage: parentPackage ); } @@ -295,10 +305,13 @@ namespace PckStudio.Core.DLC internal Atlas GetParticleAtlas() => _particlesAtlas ?? AtlasResource.Get(AtlasResource.AtlasType.ParticleAtlas).GetDefaultAtlas(); internal Atlas GetPaintingAtlas() => _paintingAtlas ?? AtlasResource.Get(AtlasResource.AtlasType.PaintingAtlas).GetDefaultAtlas(); internal Atlas GetMoonPhaseAtlas() => _moonPhaseAtlas ?? AtlasResource.Get(AtlasResource.AtlasType.MoonPhaseAtlas).GetDefaultAtlas(); + internal IDictionary GetItemAnimations() => _itemAnimations; internal IDictionary GetBlockAnimations() => _blockAnimations; internal IEnumerable GetArmorSets() => new ArmorSet[] { _leatherArmorSet, _chainArmorSet, _ironArmorSet, _goldArmorSet, _diamondArmorSet, _turtleArmorSet }.Where(armorSet => armorSet is not null); internal Animation GetBlockEntityBreakAnimation() => _blockEntityBreakAnimation; + internal ConsoleArchive GetMediaArc() => _mediaArc; + internal EnvironmentData GetEnvironmentData() => _environmentData; private static IDictionary GetDefaultItemAnimations() { @@ -325,5 +338,7 @@ namespace PckStudio.Core.DLC internal IEnumerable> GetItemModelTextures() => _itemModelTextures; internal IEnumerable> GetMobModelTextures() => _mobModelTextures; + + internal IDictionary GetMisc() => _misc; } } \ No newline at end of file diff --git a/PckStudio.Core/DLC/PckFileCompiler.cs b/PckStudio.Core/DLC/PckFileCompiler.cs index 175e4d3f..d9d639a2 100644 --- a/PckStudio.Core/DLC/PckFileCompiler.cs +++ b/PckStudio.Core/DLC/PckFileCompiler.cs @@ -1,21 +1,20 @@ -using System; +/* + * Author: MikuX666 (Github: https://github.com/NessieHax) + * See License usage at the bottom of file! +*/ +using System; using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using DiscordRPC; using OMI; +using OMI.Formats.Archive; using OMI.Formats.GameRule; using OMI.Formats.Languages; -using OMI.Formats.Model; using OMI.Formats.Pck; -using OMI.Workers.Color; +using OMI.Workers.Archive; using OMI.Workers.GameRule; using OMI.Workers.Language; -using OMI.Workers.Model; using OMI.Workers.Pck; using PckStudio.Core.Extensions; using PckStudio.Core.Interfaces; @@ -80,6 +79,8 @@ namespace PckStudio.Core.DLC if (package is not DLCTexturePackage texturePackage) return DLCPackageContent.Empty; + string resourceFolderName = "res"; + PckFile texturePackInfoPck = new PckFile(); { Image comparison = texturePackage.Info?.ComparisonImg ?? Resources.Comparison; @@ -99,8 +100,8 @@ namespace PckStudio.Core.DLC texturePck.AddTexture(ResourceLocations.GetPathFromCategory(AtlasResource.GetId(AtlasResource.AtlasType.PaintingAtlas)), texturePackage.GetPaintingAtlas()); texturePck.AddTexture(ResourceLocations.GetPathFromCategory(AtlasResource.GetId(AtlasResource.AtlasType.MoonPhaseAtlas)), texturePackage.GetMoonPhaseAtlas()); - texturePck.AddTexture("res/terrain/sun.png", texturePackage.GetSunTexture()); - texturePck.AddTexture("res/terrain/moon.png", texturePackage.GetMoonTexture()); + texturePck.AddTexture($"{resourceFolderName}/terrain/sun.png", texturePackage.GetSunTexture()); + texturePck.AddTexture($"{resourceFolderName}/terrain/moon.png", texturePackage.GetMoonTexture()); string itemAnimationsPath = ResourceLocations.GetPathFromCategory(ResourceCategory.ItemAnimation); foreach (KeyValuePair animation in texturePackage.GetItemAnimations()) @@ -130,6 +131,12 @@ namespace PckStudio.Core.DLC asset.SetSerializedData(armorTexture.Value, ImageSerializer.DefaultSerializer); } + DLCTexturePackage.EnvironmentData environmentData = texturePackage.GetEnvironmentData(); + + texturePck.AddTexture($"{resourceFolderName}/environment/rain.png", environmentData.Rain); + texturePck.AddTexture($"{resourceFolderName}/environment/snow.png", environmentData.Snow); + texturePck.AddTexture($"{resourceFolderName}/environment/clouds.png", environmentData.Clouds); + { int i = 0; foreach (Animation.Frame frame in texturePackage.GetBlockEntityBreakAnimation().GetFrames()) @@ -160,19 +167,26 @@ namespace PckStudio.Core.DLC { foreach (KeyValuePair itemTexture in texturePackage.GetItemModelTextures()) { - texturePck.AddTexture($"res/{itemTexture.Key}.png", itemTexture.Value); + texturePck.AddTexture($"{resourceFolderName}/{itemTexture.Key}.png", itemTexture.Value); } foreach (KeyValuePair mobTexture in texturePackage.GetMobModelTextures()) { - texturePck.AddTexture($"res/{mobTexture.Key}.png", mobTexture.Value); + texturePck.AddTexture($"{resourceFolderName}/{mobTexture.Key}.png", mobTexture.Value); } } + + { + foreach (KeyValuePair item in texturePackage.GetMisc()) + { + texturePck.AddTexture($"{resourceFolderName}/misc/{item.Key}.png", item.Value); + } + } + } if (package.IsRootPackage) { - foreach (string language in LOCFile.ValidLanguages) - localisation.AddLanguage(language); + localisation.AddLanguage(_language); PckFile mainPck = CreateRootPckFile(package.Identifier, 0); localisation.AddLocKey(DLCManager.PACKAGE_DISPLAYNAME_ID, package.Name); localisation.AddLocKey(DLCTexturePackage.TEXTUREPACK_DESCRIPTION_ID, package.Description); @@ -184,9 +198,19 @@ namespace PckStudio.Core.DLC PckAsset loc = new PckAsset("languages.loc", PckAssetType.LocalisationFile); loc.SetData(new LOCFileWriter(localisation, 2)); + //! LOC file needs to be the first asset in the pack -_-.... don't ask why.. -null mainPck.InsertAsset(0, loc); - return new DLCPackageContent(package.Name, mainPck, new NamedData($"{res}Data.pck", texturePck), default); + + NamedData[] dataFiles = Array.Empty>(); + if (texturePackage.GetMediaArc() is ConsoleArchive arc) + { + MemoryStream stream = new MemoryStream(); + new ARCFileWriter(arc).WriteToStream(stream); + dataFiles = [new NamedData("media.arc", stream.ToArray())]; + } + + return new DLCPackageContent(package.Name, mainPck, new NamedData($"{res}Data.pck", texturePck), dataFiles); } return new DLCPackageContent(package.Name, texturePackInfoPck); @@ -238,3 +262,20 @@ namespace PckStudio.Core.DLC } } } +/* Copyright (c) 2026-present miku-666 + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1.The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. +**/ \ No newline at end of file