Search in sources :

Example 1 with GeometryModelTexture

use of gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture in project pollen by MoonflowerTeam.

the class GeometryTextureSpriteUploader method prepare.

@Override
protected TextureAtlas.Preparations prepare(ResourceManager resourceManager, ProfilerFiller profiler) {
    try (OnlineRepository onlineRepository = new OnlineRepository(this.hashTables)) {
        profiler.startTick();
        profiler.push("stitching");
        Stopwatch stopwatch = Stopwatch.createUnstarted();
        this.beginStitch(System.currentTimeMillis(), stopwatch);
        TextureAtlas.Preparations sheetData = this.textureAtlas.prepareToStitch(new OnlineResourceManager(resourceManager, onlineRepository, this.textures.stream().filter(texture -> texture.getType() == GeometryModelTexture.Type.ONLINE).collect(Collectors.toSet())), this.textures.stream().filter(texture -> texture.getType() == GeometryModelTexture.Type.LOCATION || texture.getType() == GeometryModelTexture.Type.ONLINE).map(GeometryModelTexture::getLocation).distinct(), profiler, Minecraft.getInstance().options.mipmapLevels);
        this.endStitch(stopwatch);
        profiler.pop();
        profiler.endTick();
        return sheetData;
    }
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) JsonObject(com.google.gson.JsonObject) Resource(net.minecraft.server.packs.resources.Resource) Arrays(java.util.Arrays) TextureAtlas(net.minecraft.client.renderer.texture.TextureAtlas) Stopwatch(com.google.common.base.Stopwatch) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) MetadataSectionSerializer(net.minecraft.server.packs.metadata.MetadataSectionSerializer) Pollen(gg.moonflower.pollen.core.Pollen) FileCache(gg.moonflower.pollen.pinwheel.api.client.FileCache) SimplePreparableReloadListener(net.minecraft.server.packs.resources.SimplePreparableReloadListener) HashSet(java.util.HashSet) Pair(org.apache.commons.lang3.tuple.Pair) Minecraft(net.minecraft.client.Minecraft) Locale(java.util.Locale) Map(java.util.Map) GsonHelper(net.minecraft.util.GsonHelper) GeometryModelTextureTable(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable) Path(java.nio.file.Path) PackResources(net.minecraft.server.packs.PackResources) ExecutorService(java.util.concurrent.ExecutorService) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ApiStatus(org.jetbrains.annotations.ApiStatus) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller) Predicate(java.util.function.Predicate) GeometryModelTexture(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture) Collection(java.util.Collection) ResourceManager(net.minecraft.server.packs.resources.ResourceManager) Set(java.util.Set) IOException(java.io.IOException) TextureManager(net.minecraft.client.renderer.texture.TextureManager) FileInputStream(java.io.FileInputStream) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Base32(org.apache.commons.codec.binary.Base32) TimeUnit(java.util.concurrent.TimeUnit) GeometryAtlasTexture(gg.moonflower.pollen.pinwheel.api.client.texture.GeometryAtlasTexture) Nullable(org.jetbrains.annotations.Nullable) Util(net.minecraft.Util) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Stream(java.util.stream.Stream) BufferedReader(java.io.BufferedReader) LogManager(org.apache.logging.log4j.LogManager) FilenameUtils(org.apache.commons.io.FilenameUtils) InputStream(java.io.InputStream) GeometryModelTexture(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture) TextureAtlas(net.minecraft.client.renderer.texture.TextureAtlas) Stopwatch(com.google.common.base.Stopwatch)

Example 2 with GeometryModelTexture

use of gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture in project pollen by MoonflowerTeam.

the class DeveloperHalo method registerTextures.

@Override
public void registerTextures(BiConsumer<ResourceLocation, GeometryModelTextureTable> textureConsumer) {
    this.halos.forEach((key, value) -> {
        textureConsumer.accept(new ResourceLocation(Pollen.MOD_ID, key), value.getTextureTable());
        textureConsumer.accept(new ResourceLocation(Pollen.MOD_ID, key + "_emissive"), new GeometryModelTextureTable(value.getTextureTable().getTextureDefinitions().entrySet().stream().collect(Collectors.<Map.Entry<String, GeometryModelTexture[]>, String, GeometryModelTexture[]>toMap(Map.Entry::getKey, entry -> {
            GeometryModelTexture[] textures = new GeometryModelTexture[entry.getValue().length];
            for (int i = 0; i < textures.length; i++) {
                GeometryModelTexture texture = entry.getValue()[i];
                textures[i] = GeometryModelTexture.texture(texture).setGlowing(true).build();
            }
            return textures;
        }))));
    });
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) JsonObject(com.google.gson.JsonObject) Entitlement(gg.moonflower.pollen.core.client.entitlement.Entitlement) GeometryModelTexture(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture) Pollen(gg.moonflower.pollen.core.Pollen) Collectors(java.util.stream.Collectors) ArrayEntry(gg.moonflower.pollen.core.client.screen.button.ArrayEntry) Consumer(java.util.function.Consumer) Nullable(org.jetbrains.annotations.Nullable) EntitlementEntry(gg.moonflower.pollen.core.client.screen.button.EntitlementEntry) TextComponent(net.minecraft.network.chat.TextComponent) Codec(com.mojang.serialization.Codec) Locale(java.util.Locale) Map(java.util.Map) GsonHelper(net.minecraft.util.GsonHelper) BiConsumer(java.util.function.BiConsumer) RecordCodecBuilder(com.mojang.serialization.codecs.RecordCodecBuilder) GeometryModelTextureTable(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable) ApiStatus(org.jetbrains.annotations.ApiStatus) GeometryModelTexture(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture) ResourceLocation(net.minecraft.resources.ResourceLocation) Map(java.util.Map) GeometryModelTextureTable(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable)

Example 3 with GeometryModelTexture

use of gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture in project pollen by MoonflowerTeam.

the class Halo method registerTextures.

@Override
public void registerTextures(BiConsumer<ResourceLocation, GeometryModelTextureTable> textureConsumer) {
    textureConsumer.accept(this.getRegistryName(), this.data.getTextureTable());
    textureConsumer.accept(new ResourceLocation(this.getRegistryName().getNamespace(), this.getRegistryName().getPath() + "_emissive"), new GeometryModelTextureTable(this.data.getTextureTable().getTextureDefinitions().entrySet().stream().collect(Collectors.<Map.Entry<String, GeometryModelTexture[]>, String, GeometryModelTexture[]>toMap(Map.Entry::getKey, entry -> {
        GeometryModelTexture[] textures = new GeometryModelTexture[entry.getValue().length];
        for (int i = 0; i < textures.length; i++) {
            GeometryModelTexture texture = entry.getValue()[i];
            textures[i] = GeometryModelTexture.texture(texture).setGlowing(true).build();
        }
        return textures;
    }))));
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) Nullable(org.jetbrains.annotations.Nullable) Entitlement(gg.moonflower.pollen.core.client.entitlement.Entitlement) Codec(com.mojang.serialization.Codec) GeometryModelTexture(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) GeometryModelTextureTable(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable) Collectors(java.util.stream.Collectors) ApiStatus(org.jetbrains.annotations.ApiStatus) GeometryModelTexture(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture) ResourceLocation(net.minecraft.resources.ResourceLocation) Map(java.util.Map) GeometryModelTextureTable(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable)

Aggregations

GeometryModelTexture (gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTexture)3 GeometryModelTextureTable (gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 ResourceLocation (net.minecraft.resources.ResourceLocation)3 ApiStatus (org.jetbrains.annotations.ApiStatus)3 Nullable (org.jetbrains.annotations.Nullable)3 JsonObject (com.google.gson.JsonObject)2 Codec (com.mojang.serialization.Codec)2 Pollen (gg.moonflower.pollen.core.Pollen)2 Entitlement (gg.moonflower.pollen.core.client.entitlement.Entitlement)2 Locale (java.util.Locale)2 BiConsumer (java.util.function.BiConsumer)2 GsonHelper (net.minecraft.util.GsonHelper)2 Stopwatch (com.google.common.base.Stopwatch)1 RecordCodecBuilder (com.mojang.serialization.codecs.RecordCodecBuilder)1 ArrayEntry (gg.moonflower.pollen.core.client.screen.button.ArrayEntry)1 EntitlementEntry (gg.moonflower.pollen.core.client.screen.button.EntitlementEntry)1 FileCache (gg.moonflower.pollen.pinwheel.api.client.FileCache)1 GeometryAtlasTexture (gg.moonflower.pollen.pinwheel.api.client.texture.GeometryAtlasTexture)1