AtlasProvider .java

net.minecraft.client.data.AtlasProvider (class): members: TRIM_PALETTE_KEY, pathProvider, getName, run. strings: "environment/celestial", "gui/sprites".

net.minecraft.client.dataclass116 linesclient4.5 KB

Implements

API Surface (2)

CompletableFuture<?> run(final CachedOutput cache)
String getName()

Fields & Constants (2)

TRIM_PALETTE_KEY
pathProvider

String literals (10)

"trim_base"
"atlases"
"gui/sprites"
"mob_effect"
"mob_effect/"
"map/decorations"
"painting"
"particle"
"environment/celestial"
"Atlas Definitions"

Same Package (2)

Full Source

AtlasProvider.java116 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.data;
2
3
import java.util.Arrays;
4
import java.util.List;
5
import java.util.concurrent.CompletableFuture;
6
import java.util.stream.Collectors;
7
import net.fabricmc.api.EnvType;
8
import net.fabricmc.api.Environment;
9
import net.minecraft.client.data.models.ItemModelGenerators;
10
import net.minecraft.client.renderer.Sheets;
11
import net.minecraft.client.renderer.SpriteMapper;
12
import net.minecraft.client.renderer.blockentity.BellRenderer;
13
import net.minecraft.client.renderer.blockentity.ConduitRenderer;
14
import net.minecraft.client.renderer.blockentity.EnchantTableRenderer;
15
import net.minecraft.client.renderer.texture.atlas.SpriteSource;
16
import net.minecraft.client.renderer.texture.atlas.SpriteSources;
17
import net.minecraft.client.renderer.texture.atlas.sources.DirectoryLister;
18
import net.minecraft.client.renderer.texture.atlas.sources.PalettedPermutations;
19
import net.minecraft.client.renderer.texture.atlas.sources.SingleFile;
20
import net.minecraft.client.resources.model.sprite.SpriteId;
21
import net.minecraft.data.AtlasIds;
22
import net.minecraft.data.CachedOutput;
23
import net.minecraft.data.DataProvider;
24
import net.minecraft.data.PackOutput;
25
import net.minecraft.data.PackOutput.PathProvider;
26
import net.minecraft.data.PackOutput.Target;
27
import net.minecraft.resources.Identifier;
28
import net.minecraft.world.item.equipment.trim.TrimMaterials.Palette;
29
30
@Environment(EnvType.CLIENT)
31
public class AtlasProvider implements DataProvider {
32
	private static final Identifier TRIM_PALETTE_KEY = Identifier.withDefaultNamespace("trim_base");
33
	private final PathProvider pathProvider;
34
35
	public AtlasProvider(final PackOutput output) {
36
		this.pathProvider = output.createPathProvider(Target.RESOURCE_PACK, "atlases");
37
	}
38
39
	private static SpriteSource forMaterial(final SpriteId sprite) {
40
		return new SingleFile(sprite.texture());
41
	}
42
43
	private static SpriteSource forMapper(final SpriteMapper mapper) {
44
		return new DirectoryLister(mapper.prefix(), mapper.prefix() + "/");
45
	}
46
47
	private static List<SpriteSource> simpleMapper(final SpriteMapper mapper) {
48
		return List.of(forMapper(mapper));
49
	}
50
51
	private static List<SpriteSource> noPrefixMapper(final String directory) {
52
		return List.of(new DirectoryLister(directory, ""));
53
	}
54
55
	private static List<SpriteSource> blocksList() {
56
		return List.of(
57
			forMapper(Sheets.BLOCKS_MAPPER), forMapper(ConduitRenderer.MAPPER), forMaterial(BellRenderer.BELL_TEXTURE), forMaterial(EnchantTableRenderer.BOOK_TEXTURE)
58
		);
59
	}
60
61
	private static List<SpriteSource> itemsList() {
62
		return List.of(
63
			forMapper(Sheets.ITEMS_MAPPER),
64
			new PalettedPermutations(
65
				List.of(
66
					ItemModelGenerators.TRIM_PREFIX_HELMET,
67
					ItemModelGenerators.TRIM_PREFIX_CHESTPLATE,
68
					ItemModelGenerators.TRIM_PREFIX_LEGGINGS,
69
					ItemModelGenerators.TRIM_PREFIX_BOOTS
70
				),
71
				TRIM_PALETTE_KEY,
72
				Arrays.stream(Palette.values()).collect(Collectors.toMap(Palette::suffix, Palette::id))
73
			)
74
		);
75
	}
76
77
	private static List<SpriteSource> bannerPatterns() {
78
		return List.of(forMapper(Sheets.BANNER_MAPPER));
79
	}
80
81
	private static List<SpriteSource> shieldPatterns() {
82
		return List.of(forMapper(Sheets.SHIELD_MAPPER));
83
	}
84
85
	private static List<SpriteSource> guiSprites() {
86
		return List.of(new DirectoryLister("gui/sprites", ""), new DirectoryLister("mob_effect", "mob_effect/"));
87
	}
88
89
	@Override
90
	public CompletableFuture<?> run(final CachedOutput cache) {
91
		return CompletableFuture.allOf(
92
			this.storeAtlas(cache, AtlasIds.BANNER_PATTERNS, bannerPatterns()),
93
			this.storeAtlas(cache, AtlasIds.BLOCKS, blocksList()),
94
			this.storeAtlas(cache, AtlasIds.ITEMS, itemsList()),
95
			this.storeAtlas(cache, AtlasIds.CHESTS, simpleMapper(Sheets.CHEST_MAPPER)),
96
			this.storeAtlas(cache, AtlasIds.DECORATED_POT, simpleMapper(Sheets.DECORATED_POT_MAPPER)),
97
			this.storeAtlas(cache, AtlasIds.GUI, guiSprites()),
98
			this.storeAtlas(cache, AtlasIds.MAP_DECORATIONS, noPrefixMapper("map/decorations")),
99
			this.storeAtlas(cache, AtlasIds.PAINTINGS, noPrefixMapper("painting")),
100
			this.storeAtlas(cache, AtlasIds.PARTICLES, noPrefixMapper("particle")),
101
			this.storeAtlas(cache, AtlasIds.SHIELD_PATTERNS, shieldPatterns()),
102
			this.storeAtlas(cache, AtlasIds.SHULKER_BOXES, simpleMapper(Sheets.SHULKER_MAPPER)),
103
			this.storeAtlas(cache, AtlasIds.CELESTIALS, noPrefixMapper("environment/celestial"))
104
		);
105
	}
106
107
	private CompletableFuture<?> storeAtlas(final CachedOutput cache, final Identifier atlasId, final List<SpriteSource> contents) {
108
		return DataProvider.saveStable(cache, SpriteSources.FILE_CODEC, contents, this.pathProvider.json(atlasId));
109
	}
110
111
	@Override
112
	public String getName() {
113
		return "Atlas Definitions";
114
	}
115
}
116

Decompiled Minecraft 26.3 source of AtlasProvider (net/minecraft/client/data/AtlasProvider.java) with Mojang official mappings, stored verbatim on the site.