From d9d26cbc0c71f7de3f3e37c7870fc42d53c127e3 Mon Sep 17 00:00:00 2001 From: Xterionix Date: Mon, 9 Dec 2024 23:35:26 +0500 Subject: [PATCH] - Separate item and terrain atlas data --- .../resource-pack/resource-pack-collection.ts | 6 +++++ src/project/resource-pack/resource-pack.ts | 22 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/project/resource-pack/resource-pack-collection.ts b/src/project/resource-pack/resource-pack-collection.ts index 73685aca..c4d26d4d 100644 --- a/src/project/resource-pack/resource-pack-collection.ts +++ b/src/project/resource-pack/resource-pack-collection.ts @@ -42,6 +42,10 @@ export class ResourcePackCollection extends PackCollection { readonly sounds: DataSetConnector; /**The collection of textures*/ readonly textures: DataSetConnector; + /**The collection of textures from item_texture.json*/ + readonly itemTextures: DataSetConnector; + /**The collection of textures from terrain_texture.json*/ + readonly terrainTextures: DataSetConnector; /**Creates a new instances of the class*/ constructor() { @@ -60,6 +64,8 @@ export class ResourcePackCollection extends PackCollection { this.render_controllers = new DataSetConnector(this, (pack) => pack.render_controllers); this.sounds = new DataSetConnector(this, (pack) => pack.sounds); this.textures = new DataSetConnector(this, (pack) => pack.textures); + this.itemTextures = new DataSetConnector(this, (pack) => pack.itemTextures); + this.terrainTextures = new DataSetConnector(this, (pack) => pack.terrainTextures); } add(folder: string, context: MCProject | string, manifest: Manifest): ResourcePack { diff --git a/src/project/resource-pack/resource-pack.ts b/src/project/resource-pack/resource-pack.ts index aba30be6..f97b3f60 100644 --- a/src/project/resource-pack/resource-pack.ts +++ b/src/project/resource-pack/resource-pack.ts @@ -58,6 +58,10 @@ export class ResourcePack implements Container, Pack { readonly render_controllers: DataSet; /**The collection of textures*/ readonly textures: DataSet; + /**The collection of textures from item_texture.json*/ + readonly itemTextures: DataSet; + /**The collection of textures from terrain_texture.json*/ + readonly terrainTextures: DataSet; /** * Creates a new instance of ResourcePack @@ -80,6 +84,8 @@ export class ResourcePack implements Container, Pack { this.render_controllers = new DataSet(); this.sounds = new DataSet(); this.textures = new DataSet(); + this.itemTextures = new DataSet(); + this.terrainTextures = new DataSet(); } /** @@ -125,9 +131,11 @@ export class ResourcePack implements Container, Pack { return this.sounds.set(Sound.Process(doc)); case FileType.texture: + return this.textures.set(Texture.ProcessTextureAtlas(doc)); case FileType.texture_item_atlas: + return this.itemTextures.set(Texture.ProcessTextureAtlas(doc)); case FileType.texture_terrain_atlas: - return this.textures.set(Texture.ProcessTextureAtlas(doc)); + return this.terrainTextures.set(Texture.ProcessTextureAtlas(doc)); } return undefined; @@ -176,9 +184,11 @@ export class ResourcePack implements Container, Pack { return this.sounds; case FileType.texture: + return this.itemTextures; case FileType.texture_item_atlas: + return this.itemTextures; case FileType.texture_terrain_atlas: - return this.textures; + return this.terrainTextures; default: return undefined; @@ -203,6 +213,8 @@ export class ResourcePack implements Container, Pack { out = this.particles.deleteFolder(uri) || out; out = this.sounds.deleteFolder(uri) || out; out = this.textures.deleteFolder(uri) || out; + out = this.itemTextures.deleteFolder(uri) || out; + out = this.terrainTextures.deleteFolder(uri) || out; return out; } @@ -226,6 +238,8 @@ export class ResourcePack implements Container, Pack { out = this.particles.deleteFile(uri) || out; out = this.sounds.deleteFile(uri) || out; out = this.textures.deleteFile(uri) || out; + out = this.itemTextures.deleteFile(uri) || out; + out = this.terrainTextures.deleteFile(uri) || out; return out; } @@ -249,6 +263,8 @@ export class ResourcePack implements Container, Pack { if ((value = this.particles.find(predicate))) return value; if ((value = this.render_controllers.find(predicate))) return value; if ((value = this.sounds.find(predicate))) return value; + if ((value = this.itemTextures.find(predicate))) return value; + if ((value = this.terrainTextures.find(predicate))) return value; if ((value = this.textures.find(predicate))) return value; return value; @@ -271,6 +287,8 @@ export class ResourcePack implements Container, Pack { this.render_controllers.forEach(callbackfn); this.sounds.forEach(callbackfn); this.textures.forEach(callbackfn); + this.itemTextures.forEach(callbackfn) + this.terrainTextures.forEach(callbackfn) } }