WaypointStyleProvider .java

net.minecraft.client.data.models.WaypointStyleProvider (class): members: pathProvider, getName, run. strings: "Waypoint Style Definitions", "default_0".

net.minecraft.client.data.modelsclass75 linesclient2.3 KB

Implements

API Surface (2)

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

Fields & Constants (1)

pathProvider

String literals (8)

"waypoint_style"
"default_0"
"default_1"
"default_2"
"default_3"
"bowtie"
"Tried to register waypoint style twice for id: "
"Waypoint Style Definitions"

Full Source

WaypointStyleProvider.java75 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.data.models;
2
3
import java.util.HashMap;
4
import java.util.List;
5
import java.util.Map;
6
import java.util.concurrent.CompletableFuture;
7
import java.util.function.BiConsumer;
8
import net.fabricmc.api.EnvType;
9
import net.fabricmc.api.Environment;
10
import net.minecraft.client.resources.WaypointStyle;
11
import net.minecraft.data.CachedOutput;
12
import net.minecraft.data.DataProvider;
13
import net.minecraft.data.PackOutput;
14
import net.minecraft.data.PackOutput.PathProvider;
15
import net.minecraft.data.PackOutput.Target;
16
import net.minecraft.resources.Identifier;
17
import net.minecraft.resources.ResourceKey;
18
import net.minecraft.world.waypoints.WaypointStyleAsset;
19
import net.minecraft.world.waypoints.WaypointStyleAssets;
20
21
@Environment(EnvType.CLIENT)
22
public class WaypointStyleProvider implements DataProvider {
23
	private final PathProvider pathProvider;
24
25
	public WaypointStyleProvider(final PackOutput output) {
26
		this.pathProvider = output.createPathProvider(Target.RESOURCE_PACK, "waypoint_style");
27
	}
28
29
	private static void bootstrap(final BiConsumer<ResourceKey<WaypointStyleAsset>, WaypointStyle> consumer) {
30
		consumer.accept(
31
			WaypointStyleAssets.DEFAULT,
32
			new WaypointStyle(
33
				128,
34
				332,
35
				List.of(
36
					Identifier.withDefaultNamespace("default_0"),
37
					Identifier.withDefaultNamespace("default_1"),
38
					Identifier.withDefaultNamespace("default_2"),
39
					Identifier.withDefaultNamespace("default_3")
40
				)
41
			)
42
		);
43
		consumer.accept(
44
			WaypointStyleAssets.BOWTIE,
45
			new WaypointStyle(
46
				64,
47
				332,
48
				List.of(
49
					Identifier.withDefaultNamespace("bowtie"),
50
					Identifier.withDefaultNamespace("default_0"),
51
					Identifier.withDefaultNamespace("default_1"),
52
					Identifier.withDefaultNamespace("default_2"),
53
					Identifier.withDefaultNamespace("default_3")
54
				)
55
			)
56
		);
57
	}
58
59
	@Override
60
	public CompletableFuture<?> run(final CachedOutput cache) {
61
		Map<ResourceKey<WaypointStyleAsset>, WaypointStyle> waypointStyles = new HashMap<>();
62
		bootstrap((id, asset) -> {
63
			if (waypointStyles.putIfAbsent(id, asset) != null) {
64
				throw new IllegalStateException("Tried to register waypoint style twice for id: " + id);
65
			}
66
		});
67
		return DataProvider.saveAll(cache, WaypointStyle.CODEC, this.pathProvider::json, waypointStyles);
68
	}
69
70
	@Override
71
	public String getName() {
72
		return "Waypoint Style Definitions";
73
	}
74
}
75

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