TrialSpawnerConfigFix .java

net.minecraft.util.datafix.fixes.TrialSpawnerConfigFix (class, 45 lines): members: fix. strings: "Trial Spawner config tag fixer", "loot_tables_to_eject".

net.minecraft.util.datafix.fixesclass45 linescommonextends NamedEntityWriteReadFix1.3 KB

API Surface (1)

<T> Dynamic<T> fix(final Dynamic<T> input)

String literals (12)

"Trial Spawner config tag fixer"
"minecraft:trial_spawner"
"spawn_range"
"total_mobs"
"simultaneous_mobs"
"total_mobs_added_per_player"
"simultaneous_mobs_added_per_player"
"ticks_between_spawn"
"spawn_potentials"
"loot_tables_to_eject"
"items_to_drop_when_ominous"
"normal_config"

Code Graph: Dependencies (1)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

TrialSpawnerConfigFix.java45 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.schemas.Schema;
4
import com.mojang.serialization.Dynamic;
5
import java.util.HashMap;
6
import java.util.List;
7
import java.util.Map;
8
import java.util.Optional;
9
10
public class TrialSpawnerConfigFix extends NamedEntityWriteReadFix {
11
	public TrialSpawnerConfigFix(final Schema outputSchema) {
12
		super(outputSchema, true, "Trial Spawner config tag fixer", References.BLOCK_ENTITY, "minecraft:trial_spawner");
13
	}
14
15
	private static <T> Dynamic<T> moveToConfigTag(Dynamic<T> input) {
16
		List<String> keysToMove = List.of(
17
			"spawn_range",
18
			"total_mobs",
19
			"simultaneous_mobs",
20
			"total_mobs_added_per_player",
21
			"simultaneous_mobs_added_per_player",
22
			"ticks_between_spawn",
23
			"spawn_potentials",
24
			"loot_tables_to_eject",
25
			"items_to_drop_when_ominous"
26
		);
27
		Map<Dynamic<T>, Dynamic<T>> map = new HashMap<>(keysToMove.size());
28
29
		for (String key : keysToMove) {
30
			Optional<Dynamic<T>> maybeValueForKey = input.get(key).get().result();
31
			if (maybeValueForKey.isPresent()) {
32
				map.put(input.createString(key), maybeValueForKey.get());
33
				input = input.remove(key);
34
			}
35
		}
36
37
		return map.isEmpty() ? input : input.set("normal_config", input.createMap(map));
38
	}
39
40
	@Override
41
	protected <T> Dynamic<T> fix(final Dynamic<T> input) {
42
		return moveToConfigTag(input);
43
	}
44
}
45

Decompiled Minecraft 26.3 source of TrialSpawnerConfigFix (net/minecraft/util/datafix/fixes/TrialSpawnerConfigFix.java) with Mojang official mappings, stored verbatim on the site.