Skip to content

Commit

Permalink
fix atlas. (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek authored Oct 15, 2024
1 parent 1b4b3d3 commit 3afdd4f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,10 @@ public Collection<FileResource> merge(final Collection<FileResource> resources)
mergedModels.add(builder.build());
}

final Collection<FileResource> mergedResources = mergedAtlases
final Collection<FileResource> mergedResources = mergedModels
.stream()
.map(FileResources::atlas)
.map(FileResources::model)
.collect(Collectors.toList());
mergedResources.addAll(
mergedModels.stream().map(FileResources::model).collect(Collectors.toList())
);
mergedResources.addAll(remaining);
return mergedResources;
}
Expand Down
11 changes: 0 additions & 11 deletions common/src/main/java/net/infumia/pack/FileResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Arrays;
import java.util.Collection;
import team.unnamed.creative.atlas.Atlas;
import team.unnamed.creative.base.Writable;
import team.unnamed.creative.font.Font;
import team.unnamed.creative.model.Model;
Expand All @@ -23,16 +22,6 @@ public static FileResource texture(final Texture texture) {
return new FileResourceTexture(texture);
}

/**
* Creates a {@link FileResource} for the specified atlas.
*
* @param atlas the atlas to create a file resource for. Cannot be null.
* @return a {@link FileResource} representing the atlas.
*/
public static FileResource atlas(final Atlas atlas) {
return new FileResourceAtlas(atlas);
}

/**
* Creates a {@link FileResource} for the specified font.
*
Expand Down
9 changes: 7 additions & 2 deletions common/src/main/java/net/infumia/pack/Internal.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ final class Internal {
static final Key DEFAULT_SPACES_TEXTURE_KEY = Key.key(Internal.DEFAULT_NAMESPACE, "spaces");
static final int SEPARATOR_WIDTH = 1;

static Key keyWithPngExtension(final Key key) {
static Key toTextureKey(final Key key) {
//noinspection PatternValidation
return Key.key(key.namespace(), key.value().concat(".png"));
return Key.key(key.namespace(), "item/" + key.value().concat(".png"));
}

static Key toItemKey(final Key key) {
//noinspection PatternValidation
return Key.key(key.namespace(), "item/" + key.value());
}

static Writable resourceFromJar(final String fileName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class ResourceProducerSpacesBitmap extends ResourceProducerSpacesAbstract

ResourceProducerSpacesBitmap(final Key fontKey, final Key textureKey, final Writable writable) {
super(fontKey);
this.textureKey = Internal.keyWithPngExtension(textureKey);
this.textureKey = Internal.toTextureKey(textureKey);
this.writable = writable;
}

Expand Down
18 changes: 6 additions & 12 deletions common/src/main/java/net/infumia/pack/ResourceProducers.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.infumia.pack;

import net.kyori.adventure.key.Key;
import team.unnamed.creative.atlas.Atlas;
import team.unnamed.creative.atlas.AtlasSource;
import team.unnamed.creative.base.Writable;
import team.unnamed.creative.font.Font;
import team.unnamed.creative.model.ItemOverride;
Expand Down Expand Up @@ -101,7 +99,11 @@ public static FileResource item(
Model.model()
.key(itemKey)
.parent(Model.ITEM_GENERATED)
.textures(ModelTextures.builder().layers(ModelTexture.ofKey(itemKey)).build())
.textures(
ModelTextures.builder()
.layers(ModelTexture.ofKey(Internal.toItemKey(itemKey)))
.build()
)
.build()
),
FileResources.model(
Expand All @@ -118,15 +120,7 @@ public static FileResource item(
)
.build()
),
FileResources.texture(
Texture.texture(Internal.keyWithPngExtension(itemKey), itemImage)
),
FileResources.atlas(
Atlas.atlas()
.key(Atlas.BLOCKS)
.sources(AtlasSource.directory(itemKey.namespace(), itemKey.namespace() + "/"))
.build()
)
FileResources.texture(Texture.texture(Internal.toTextureKey(itemKey), itemImage))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void add(final PackGeneratorContext context) {
final String path = this.parent(context) + texture;
return FileResources.texture(
Texture.texture(
Key.key(key.namespace(), path),
Key.key(key.namespace(), "item/" + path),
Writable.path(context.rootDirectory().resolve(path))
)
);
Expand Down

0 comments on commit 3afdd4f

Please sign in to comment.