Skip to content

Commit

Permalink
- Separate item and terrain atlas data (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xterionix authored Dec 9, 2024
1 parent 8287a27 commit b5582d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/project/resource-pack/resource-pack-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export class ResourcePackCollection extends PackCollection<ResourcePack> {
readonly sounds: DataSetConnector<Sound.Sound, ResourcePack>;
/**The collection of textures*/
readonly textures: DataSetConnector<Texture.Texture, ResourcePack>;
/**The collection of textures from item_texture.json*/
readonly itemTextures: DataSetConnector<Texture.Texture, ResourcePack>;
/**The collection of textures from terrain_texture.json*/
readonly terrainTextures: DataSetConnector<Texture.Texture, ResourcePack>;

/**Creates a new instances of the class*/
constructor() {
Expand All @@ -60,6 +64,8 @@ export class ResourcePackCollection extends PackCollection<ResourcePack> {
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 {
Expand Down
22 changes: 20 additions & 2 deletions src/project/resource-pack/resource-pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export class ResourcePack implements Container, Pack {
readonly render_controllers: DataSet<RenderController.RenderController>;
/**The collection of textures*/
readonly textures: DataSet<Texture.Texture>;
/**The collection of textures from item_texture.json*/
readonly itemTextures: DataSet<Texture.Texture>;
/**The collection of textures from terrain_texture.json*/
readonly terrainTextures: DataSet<Texture.Texture>;

/**
* Creates a new instance of ResourcePack
Expand All @@ -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();
}

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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)
}
}

Expand Down

0 comments on commit b5582d8

Please sign in to comment.