TrialSpawnerConfigs .java

net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerConfigs (class, 323 lines): members: TRIAL_CHAMBER_SLOW_RANGED_POISON_SKELETON, Keys, keys.

net.minecraft.world.level.block.entity.trialspawnerclass323 linescommon14.2 KB

API Surface (2)

void bootstrap(final BootstrapContext<TrialSpawnerConfig> context)
TrialSpawnerConfigs.Keys of(final String id)

Fields & Constants (18)

TRIAL_CHAMBER_BREEZE
TRIAL_CHAMBER_MELEE_HUSK
TRIAL_CHAMBER_MELEE_SPIDER
TRIAL_CHAMBER_MELEE_ZOMBIE
TRIAL_CHAMBER_RANGED_POISON_SKELETON
TRIAL_CHAMBER_RANGED_SKELETON
TRIAL_CHAMBER_RANGED_STRAY
TRIAL_CHAMBER_SLOW_RANGED_POISON_SKELETON
TRIAL_CHAMBER_SLOW_RANGED_SKELETON
TRIAL_CHAMBER_SLOW_RANGED_STRAY
TRIAL_CHAMBER_SMALL_MELEE_BABY_ZOMBIE
TRIAL_CHAMBER_SMALL_MELEE_CAVE_SPIDER
TRIAL_CHAMBER_SMALL_MELEE_SILVERFISH
TRIAL_CHAMBER_SMALL_MELEE_SLIME
tagModifier
context
keys
normalConfig

String literals (18)

"trial_chamber/breeze"
"trial_chamber/melee/husk"
"trial_chamber/melee/spider"
"trial_chamber/melee/zombie"
"trial_chamber/ranged/poison_skeleton"
"trial_chamber/ranged/skeleton"
"trial_chamber/ranged/stray"
"trial_chamber/slow_ranged/poison_skeleton"
"trial_chamber/slow_ranged/skeleton"
"trial_chamber/slow_ranged/stray"
"trial_chamber/small_melee/baby_zombie"
"trial_chamber/small_melee/cave_spider"
"trial_chamber/small_melee/silverfish"
"trial_chamber/small_melee/slime"
"IsBaby"
"Size"
"/normal"
"/ominous"

Full Source

TrialSpawnerConfigs.java323 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block.entity.trialspawner;
2
3
import java.util.Optional;
4
import java.util.function.Consumer;
5
import net.minecraft.core.registries.BuiltInRegistries;
6
import net.minecraft.core.registries.Registries;
7
import net.minecraft.data.worldgen.BootstrapContext;
8
import net.minecraft.nbt.CompoundTag;
9
import net.minecraft.resources.Identifier;
10
import net.minecraft.resources.ResourceKey;
11
import net.minecraft.util.random.WeightedList;
12
import net.minecraft.world.entity.Entity;
13
import net.minecraft.world.entity.EntityType;
14
import net.minecraft.world.entity.EntityTypes;
15
import net.minecraft.world.entity.EquipmentTable;
16
import net.minecraft.world.level.SpawnData;
17
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
18
import net.minecraft.world.level.storage.loot.LootTable;
19
import org.jspecify.annotations.Nullable;
20
21
public class TrialSpawnerConfigs {
22
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_BREEZE = TrialSpawnerConfigs.Keys.of("trial_chamber/breeze");
23
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_MELEE_HUSK = TrialSpawnerConfigs.Keys.of("trial_chamber/melee/husk");
24
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_MELEE_SPIDER = TrialSpawnerConfigs.Keys.of("trial_chamber/melee/spider");
25
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_MELEE_ZOMBIE = TrialSpawnerConfigs.Keys.of("trial_chamber/melee/zombie");
26
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_RANGED_POISON_SKELETON = TrialSpawnerConfigs.Keys.of("trial_chamber/ranged/poison_skeleton");
27
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_RANGED_SKELETON = TrialSpawnerConfigs.Keys.of("trial_chamber/ranged/skeleton");
28
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_RANGED_STRAY = TrialSpawnerConfigs.Keys.of("trial_chamber/ranged/stray");
29
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_SLOW_RANGED_POISON_SKELETON = TrialSpawnerConfigs.Keys.of(
30
		"trial_chamber/slow_ranged/poison_skeleton"
31
	);
32
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_SLOW_RANGED_SKELETON = TrialSpawnerConfigs.Keys.of("trial_chamber/slow_ranged/skeleton");
33
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_SLOW_RANGED_STRAY = TrialSpawnerConfigs.Keys.of("trial_chamber/slow_ranged/stray");
34
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_SMALL_MELEE_BABY_ZOMBIE = TrialSpawnerConfigs.Keys.of("trial_chamber/small_melee/baby_zombie");
35
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_SMALL_MELEE_CAVE_SPIDER = TrialSpawnerConfigs.Keys.of("trial_chamber/small_melee/cave_spider");
36
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_SMALL_MELEE_SILVERFISH = TrialSpawnerConfigs.Keys.of("trial_chamber/small_melee/silverfish");
37
	private static final TrialSpawnerConfigs.Keys TRIAL_CHAMBER_SMALL_MELEE_SLIME = TrialSpawnerConfigs.Keys.of("trial_chamber/small_melee/slime");
38
39
	public static void bootstrap(final BootstrapContext<TrialSpawnerConfig> context) {
40
		register(
41
			context,
42
			TRIAL_CHAMBER_BREEZE,
43
			TrialSpawnerConfig.builder()
44
				.simultaneousMobs(1.0F)
45
				.simultaneousMobsAddedPerPlayer(0.5F)
46
				.ticksBetweenSpawn(20)
47
				.totalMobs(2.0F)
48
				.totalMobsAddedPerPlayer(1.0F)
49
				.spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.BREEZE)))
50
				.build(),
51
			TrialSpawnerConfig.builder()
52
				.simultaneousMobsAddedPerPlayer(0.5F)
53
				.ticksBetweenSpawn(20)
54
				.totalMobs(4.0F)
55
				.totalMobsAddedPerPlayer(1.0F)
56
				.spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.BREEZE)))
57
				.lootTablesToEject(
58
					WeightedList.<ResourceKey<LootTable>>builder()
59
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
60
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
61
						.build()
62
				)
63
				.build()
64
		);
65
		register(
66
			context,
67
			TRIAL_CHAMBER_MELEE_HUSK,
68
			trialChamberBase().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.HUSK))).build(),
69
			trialChamberBase()
70
				.spawnPotentialsDefinition(WeightedList.of(spawnDataWithEquipment(EntityTypes.HUSK, BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_MELEE)))
71
				.lootTablesToEject(
72
					WeightedList.<ResourceKey<LootTable>>builder()
73
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
74
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
75
						.build()
76
				)
77
				.build()
78
		);
79
		register(
80
			context,
81
			TRIAL_CHAMBER_MELEE_SPIDER,
82
			trialChamberBase().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.SPIDER))).build(),
83
			trialChamberMeleeOminous()
84
				.spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.SPIDER)))
85
				.lootTablesToEject(
86
					WeightedList.<ResourceKey<LootTable>>builder()
87
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
88
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
89
						.build()
90
				)
91
				.build()
92
		);
93
		register(
94
			context,
95
			TRIAL_CHAMBER_MELEE_ZOMBIE,
96
			trialChamberBase().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.ZOMBIE))).build(),
97
			trialChamberBase()
98
				.lootTablesToEject(
99
					WeightedList.<ResourceKey<LootTable>>builder()
100
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
101
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
102
						.build()
103
				)
104
				.spawnPotentialsDefinition(WeightedList.of(spawnDataWithEquipment(EntityTypes.ZOMBIE, BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_MELEE)))
105
				.build()
106
		);
107
		register(
108
			context,
109
			TRIAL_CHAMBER_RANGED_POISON_SKELETON,
110
			trialChamberBase().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.BOGGED))).build(),
111
			trialChamberBase()
112
				.lootTablesToEject(
113
					WeightedList.<ResourceKey<LootTable>>builder()
114
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
115
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
116
						.build()
117
				)
118
				.spawnPotentialsDefinition(WeightedList.of(spawnDataWithEquipment(EntityTypes.BOGGED, BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_RANGED)))
119
				.build()
120
		);
121
		register(
122
			context,
123
			TRIAL_CHAMBER_RANGED_SKELETON,
124
			trialChamberBase().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.SKELETON))).build(),
125
			trialChamberBase()
126
				.lootTablesToEject(
127
					WeightedList.<ResourceKey<LootTable>>builder()
128
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
129
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
130
						.build()
131
				)
132
				.spawnPotentialsDefinition(WeightedList.of(spawnDataWithEquipment(EntityTypes.SKELETON, BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_RANGED)))
133
				.build()
134
		);
135
		register(
136
			context,
137
			TRIAL_CHAMBER_RANGED_STRAY,
138
			trialChamberBase().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.STRAY))).build(),
139
			trialChamberBase()
140
				.lootTablesToEject(
141
					WeightedList.<ResourceKey<LootTable>>builder()
142
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
143
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
144
						.build()
145
				)
146
				.spawnPotentialsDefinition(WeightedList.of(spawnDataWithEquipment(EntityTypes.STRAY, BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_RANGED)))
147
				.build()
148
		);
149
		register(
150
			context,
151
			TRIAL_CHAMBER_SLOW_RANGED_POISON_SKELETON,
152
			trialChamberSlowRanged().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.BOGGED))).build(),
153
			trialChamberSlowRanged()
154
				.lootTablesToEject(
155
					WeightedList.<ResourceKey<LootTable>>builder()
156
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
157
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
158
						.build()
159
				)
160
				.spawnPotentialsDefinition(WeightedList.of(spawnDataWithEquipment(EntityTypes.BOGGED, BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_RANGED)))
161
				.build()
162
		);
163
		register(
164
			context,
165
			TRIAL_CHAMBER_SLOW_RANGED_SKELETON,
166
			trialChamberSlowRanged().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.SKELETON))).build(),
167
			trialChamberSlowRanged()
168
				.lootTablesToEject(
169
					WeightedList.<ResourceKey<LootTable>>builder()
170
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
171
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
172
						.build()
173
				)
174
				.spawnPotentialsDefinition(WeightedList.of(spawnDataWithEquipment(EntityTypes.SKELETON, BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_RANGED)))
175
				.build()
176
		);
177
		register(
178
			context,
179
			TRIAL_CHAMBER_SLOW_RANGED_STRAY,
180
			trialChamberSlowRanged().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.STRAY))).build(),
181
			trialChamberSlowRanged()
182
				.lootTablesToEject(
183
					WeightedList.<ResourceKey<LootTable>>builder()
184
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
185
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
186
						.build()
187
				)
188
				.spawnPotentialsDefinition(WeightedList.of(spawnDataWithEquipment(EntityTypes.STRAY, BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_RANGED)))
189
				.build()
190
		);
191
		register(
192
			context,
193
			TRIAL_CHAMBER_SMALL_MELEE_BABY_ZOMBIE,
194
			TrialSpawnerConfig.builder()
195
				.simultaneousMobsAddedPerPlayer(0.5F)
196
				.ticksBetweenSpawn(20)
197
				.spawnPotentialsDefinition(WeightedList.of(customSpawnDataWithEquipment(EntityTypes.ZOMBIE, tag -> tag.putBoolean("IsBaby", true), null)))
198
				.build(),
199
			TrialSpawnerConfig.builder()
200
				.simultaneousMobsAddedPerPlayer(0.5F)
201
				.ticksBetweenSpawn(20)
202
				.lootTablesToEject(
203
					WeightedList.<ResourceKey<LootTable>>builder()
204
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
205
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
206
						.build()
207
				)
208
				.spawnPotentialsDefinition(
209
					WeightedList.of(customSpawnDataWithEquipment(EntityTypes.ZOMBIE, tag -> tag.putBoolean("IsBaby", true), BuiltInLootTables.EQUIPMENT_TRIAL_CHAMBER_MELEE))
210
				)
211
				.build()
212
		);
213
		register(
214
			context,
215
			TRIAL_CHAMBER_SMALL_MELEE_CAVE_SPIDER,
216
			trialChamberBase().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.CAVE_SPIDER))).build(),
217
			trialChamberMeleeOminous()
218
				.lootTablesToEject(
219
					WeightedList.<ResourceKey<LootTable>>builder()
220
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
221
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
222
						.build()
223
				)
224
				.spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.CAVE_SPIDER)))
225
				.build()
226
		);
227
		register(
228
			context,
229
			TRIAL_CHAMBER_SMALL_MELEE_SILVERFISH,
230
			trialChamberBase().spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.SILVERFISH))).build(),
231
			trialChamberMeleeOminous()
232
				.lootTablesToEject(
233
					WeightedList.<ResourceKey<LootTable>>builder()
234
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
235
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
236
						.build()
237
				)
238
				.spawnPotentialsDefinition(WeightedList.of(spawnData(EntityTypes.SILVERFISH)))
239
				.build()
240
		);
241
		register(
242
			context,
243
			TRIAL_CHAMBER_SMALL_MELEE_SLIME,
244
			trialChamberBase()
245
				.spawnPotentialsDefinition(
246
					WeightedList.<SpawnData>builder()
247
						.add(customSpawnData(EntityTypes.SLIME, tag -> tag.putByte("Size", (byte)1)), 3)
248
						.add(customSpawnData(EntityTypes.SLIME, tag -> tag.putByte("Size", (byte)2)), 1)
249
						.build()
250
				)
251
				.build(),
252
			trialChamberMeleeOminous()
253
				.lootTablesToEject(
254
					WeightedList.<ResourceKey<LootTable>>builder()
255
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_KEY, 3)
256
						.add(BuiltInLootTables.SPAWNER_OMINOUS_TRIAL_CHAMBER_CONSUMABLES, 7)
257
						.build()
258
				)
259
				.spawnPotentialsDefinition(
260
					WeightedList.<SpawnData>builder()
261
						.add(customSpawnData(EntityTypes.SLIME, tag -> tag.putByte("Size", (byte)1)), 3)
262
						.add(customSpawnData(EntityTypes.SLIME, tag -> tag.putByte("Size", (byte)2)), 1)
263
						.build()
264
				)
265
				.build()
266
		);
267
	}
268
269
	private static <T extends Entity> SpawnData spawnData(final EntityType<T> type) {
270
		return customSpawnDataWithEquipment(type, tag -> {}, null);
271
	}
272
273
	private static <T extends Entity> SpawnData customSpawnData(final EntityType<T> type, final Consumer<CompoundTag> tagModifier) {
274
		return customSpawnDataWithEquipment(type, tagModifier, null);
275
	}
276
277
	private static <T extends Entity> SpawnData spawnDataWithEquipment(final EntityType<T> type, final ResourceKey<LootTable> equipmentLootTable) {
278
		return customSpawnDataWithEquipment(type, tag -> {}, equipmentLootTable);
279
	}
280
281
	private static <T extends Entity> SpawnData customSpawnDataWithEquipment(
282
		final EntityType<T> type, final Consumer<CompoundTag> tagModifier, final @Nullable ResourceKey<LootTable> equipmentLootTable
283
	) {
284
		CompoundTag tag = new CompoundTag();
285
		tag.putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(type).toString());
286
		tagModifier.accept(tag);
287
		Optional<EquipmentTable> table = Optional.ofNullable(equipmentLootTable).map(lootTable -> new EquipmentTable((ResourceKey<LootTable>)lootTable, 0.0F));
288
		return new SpawnData(tag, Optional.empty(), table);
289
	}
290
291
	private static void register(
292
		final BootstrapContext<TrialSpawnerConfig> context,
293
		final TrialSpawnerConfigs.Keys keys,
294
		final TrialSpawnerConfig normalConfig,
295
		final TrialSpawnerConfig ominousConfig
296
	) {
297
		context.register(keys.normal, normalConfig);
298
		context.register(keys.ominous, ominousConfig);
299
	}
300
301
	private static ResourceKey<TrialSpawnerConfig> registryKey(final String id) {
302
		return ResourceKey.create(Registries.TRIAL_SPAWNER_CONFIG, Identifier.withDefaultNamespace(id));
303
	}
304
305
	private static TrialSpawnerConfig.Builder trialChamberMeleeOminous() {
306
		return TrialSpawnerConfig.builder().simultaneousMobs(4.0F).simultaneousMobsAddedPerPlayer(0.5F).ticksBetweenSpawn(20).totalMobs(12.0F);
307
	}
308
309
	private static TrialSpawnerConfig.Builder trialChamberSlowRanged() {
310
		return TrialSpawnerConfig.builder().simultaneousMobs(4.0F).simultaneousMobsAddedPerPlayer(2.0F).ticksBetweenSpawn(160);
311
	}
312
313
	private static TrialSpawnerConfig.Builder trialChamberBase() {
314
		return TrialSpawnerConfig.builder().simultaneousMobs(3.0F).simultaneousMobsAddedPerPlayer(0.5F).ticksBetweenSpawn(20);
315
	}
316
317
	private record Keys(ResourceKey<TrialSpawnerConfig> normal, ResourceKey<TrialSpawnerConfig> ominous) {
318
		public static TrialSpawnerConfigs.Keys of(final String id) {
319
			return new TrialSpawnerConfigs.Keys(TrialSpawnerConfigs.registryKey(id + "/normal"), TrialSpawnerConfigs.registryKey(id + "/ominous"));
320
		}
321
	}
322
}
323

Decompiled Minecraft 26.3 source of TrialSpawnerConfigs (net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerConfigs.java) with Mojang official mappings, stored verbatim on the site.