use of gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable 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;
}))));
});
}
use of gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable 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;
}))));
}
use of gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable in project pollen by MoonflowerTeam.
the class LocalTextureTableLoader method reload.
@Override
public CompletableFuture<Void> reload(PreparableReloadListener.PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) {
return CompletableFuture.supplyAsync(() -> {
Map<ResourceLocation, GeometryModelTextureTable> textureLocations = new HashMap<>();
for (ResourceLocation textureTableLocation : resourceManager.listResources(this.folder, name -> name.endsWith(".json"))) {
ResourceLocation textureTableName = new ResourceLocation(textureTableLocation.getNamespace(), textureTableLocation.getPath().substring(this.folder.length(), textureTableLocation.getPath().length() - 5));
if (textureTableName.getPath().equals("hash_tables"))
continue;
try (Resource resource = resourceManager.getResource(textureTableLocation)) {
textureLocations.put(textureTableName, GeometryModelParser.parseTextures(new InputStreamReader(resource.getInputStream())));
} catch (Exception e) {
LOGGER.error("Failed to load texture table '" + textureTableName + "'", e);
}
}
LOGGER.info("Loaded " + textureLocations.size() + " model texture tables.");
return textureLocations;
}, backgroundExecutor).thenAcceptBothAsync(CompletableFuture.supplyAsync(() -> {
Set<String> hashTables = new HashSet<>();
for (String domain : resourceManager.getNamespaces()) {
ResourceLocation hashTableLocation = new ResourceLocation(domain, this.folder + "hash_tables.json");
if (!resourceManager.hasResource(hashTableLocation))
continue;
try (Resource resource = resourceManager.getResource(hashTableLocation)) {
hashTables.addAll(Arrays.asList(GSON.fromJson(new InputStreamReader(resource.getInputStream()), String[].class)));
} catch (Exception e) {
LOGGER.error("Failed to load texture hash table for " + domain, e);
}
}
LOGGER.info("Loaded " + hashTables.size() + " hash tables.");
return hashTables.toArray(new String[0]);
}, backgroundExecutor), (textureLocations, hashTables) -> {
this.textures.clear();
this.textures.putAll(textureLocations);
this.hashTables = hashTables;
}, gameExecutor).thenCompose(stage::wait);
}
Aggregations