NetherFeatures .java

net.minecraft.data.worldgen.features.NetherFeatures (class, 352 lines): members: WARPED_FOREST_VEGETION, SPRING_NETHER_CLOSED, SPRING_LAVA_NETHER, DELTA.

net.minecraft.data.worldgen.featuresclass352 linescommon15.7 KB

API Surface (1)

void bootstrap(final BootstrapContext<Feature> context)

Fields & Constants (19)

DELTA
SMALL_BASALT_COLUMNS
LARGE_BASALT_COLUMNS
BASALT_BLOBS
BLACKSTONE_BLOBS
GLOWSTONE_EXTRA
NYLIUM_BONEMEAL
CRIMSON_FOREST_VEGETATION
WARPED_FOREST_VEGETION
NETHER_SPROUTS
TWISTING_VINES
WEEPING_VINES
CRIMSON_ROOTS
BASALT_PILLAR
SPRING_LAVA_NETHER
SPRING_NETHER_CLOSED
SPRING_NETHER_OPEN
FIRE
SOUL_FIRE

String literals (19)

"delta"
"small_basalt_columns"
"large_basalt_columns"
"basalt_blobs"
"blackstone_blobs"
"glowstone_extra"
"nylium_bonemeal"
"crimson_forest_vegetation"
"warped_forest_vegetation"
"nether_sprouts"
"twisting_vines"
"weeping_vines"
"crimson_roots"
"basalt_pillar"
"spring_lava_nether"
"spring_nether_closed"
"spring_nether_open"
"patch_fire"
"patch_soul_fire"

Full Source

NetherFeatures.java352 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.data.worldgen.features;
2
3
import java.util.List;
4
import java.util.Optional;
5
import net.minecraft.core.Direction;
6
import net.minecraft.core.Holder;
7
import net.minecraft.core.HolderGetter;
8
import net.minecraft.core.HolderSet;
9
import net.minecraft.core.registries.Registries;
10
import net.minecraft.data.worldgen.BootstrapContext;
11
import net.minecraft.data.worldgen.placement.NetherPlacements;
12
import net.minecraft.data.worldgen.placement.PlacementUtils;
13
import net.minecraft.references.BlockItemIds;
14
import net.minecraft.resources.ResourceKey;
15
import net.minecraft.tags.BlockTags;
16
import net.minecraft.util.random.Weighted;
17
import net.minecraft.util.random.WeightedList;
18
import net.minecraft.util.valueproviders.ConstantInt;
19
import net.minecraft.util.valueproviders.IntProvider;
20
import net.minecraft.util.valueproviders.TrapezoidInt;
21
import net.minecraft.util.valueproviders.UniformInt;
22
import net.minecraft.util.valueproviders.WeightedListInt;
23
import net.minecraft.world.level.block.Block;
24
import net.minecraft.world.level.block.Blocks;
25
import net.minecraft.world.level.block.GrowingPlantHeadBlock;
26
import net.minecraft.world.level.block.state.BlockState;
27
import net.minecraft.world.level.levelgen.VerticalAnchor;
28
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
29
import net.minecraft.world.level.levelgen.feature.BlockColumnFeature;
30
import net.minecraft.world.level.levelgen.feature.DeltaFeature;
31
import net.minecraft.world.level.levelgen.feature.Feature;
32
import net.minecraft.world.level.levelgen.feature.NoOpFeature;
33
import net.minecraft.world.level.levelgen.feature.OverlayFeature;
34
import net.minecraft.world.level.levelgen.feature.ProjectedRandomPatchySquare;
35
import net.minecraft.world.level.levelgen.feature.RandomNeighborSpreadFeature;
36
import net.minecraft.world.level.levelgen.feature.ReplaceBlobsFeature;
37
import net.minecraft.world.level.levelgen.feature.SimpleBlockFeature;
38
import net.minecraft.world.level.levelgen.feature.SingleBlockPillarFeature;
39
import net.minecraft.world.level.levelgen.feature.SpringFeature;
40
import net.minecraft.world.level.levelgen.feature.SteppedColumnClusterFeature;
41
import net.minecraft.world.level.levelgen.feature.WeightedRandomSelectorFeature;
42
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
43
import net.minecraft.world.level.levelgen.feature.stateproviders.RandomizedIntStateProvider;
44
import net.minecraft.world.level.levelgen.feature.stateproviders.RuleBasedStateProvider;
45
import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider;
46
import net.minecraft.world.level.levelgen.placement.BlockPredicateFilter;
47
import net.minecraft.world.level.levelgen.placement.CountPlacement;
48
import net.minecraft.world.level.levelgen.placement.OffsetPlacement;
49
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
50
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
51
import net.minecraft.world.level.levelgen.placement.RarityFilter;
52
import net.minecraft.world.level.material.Fluids;
53
54
public class NetherFeatures {
55
	public static final ResourceKey<Feature> DELTA = FeatureUtils.createKey("delta");
56
	public static final ResourceKey<Feature> SMALL_BASALT_COLUMNS = FeatureUtils.createKey("small_basalt_columns");
57
	public static final ResourceKey<Feature> LARGE_BASALT_COLUMNS = FeatureUtils.createKey("large_basalt_columns");
58
	public static final ResourceKey<Feature> BASALT_BLOBS = FeatureUtils.createKey("basalt_blobs");
59
	public static final ResourceKey<Feature> BLACKSTONE_BLOBS = FeatureUtils.createKey("blackstone_blobs");
60
	public static final ResourceKey<Feature> GLOWSTONE_EXTRA = FeatureUtils.createKey("glowstone_extra");
61
	public static final ResourceKey<Feature> NYLIUM_BONEMEAL = FeatureUtils.createKey("nylium_bonemeal");
62
	public static final ResourceKey<Feature> CRIMSON_FOREST_VEGETATION = FeatureUtils.createKey("crimson_forest_vegetation");
63
	public static final ResourceKey<Feature> WARPED_FOREST_VEGETION = FeatureUtils.createKey("warped_forest_vegetation");
64
	public static final ResourceKey<Feature> NETHER_SPROUTS = FeatureUtils.createKey("nether_sprouts");
65
	public static final ResourceKey<Feature> TWISTING_VINES = FeatureUtils.createKey("twisting_vines");
66
	public static final ResourceKey<Feature> WEEPING_VINES = FeatureUtils.createKey("weeping_vines");
67
	public static final ResourceKey<Feature> CRIMSON_ROOTS = FeatureUtils.createKey("crimson_roots");
68
	public static final ResourceKey<Feature> BASALT_PILLAR = FeatureUtils.createKey("basalt_pillar");
69
	public static final ResourceKey<Feature> SPRING_LAVA_NETHER = FeatureUtils.createKey("spring_lava_nether");
70
	public static final ResourceKey<Feature> SPRING_NETHER_CLOSED = FeatureUtils.createKey("spring_nether_closed");
71
	public static final ResourceKey<Feature> SPRING_NETHER_OPEN = FeatureUtils.createKey("spring_nether_open");
72
	public static final ResourceKey<Feature> FIRE = FeatureUtils.createKey("patch_fire");
73
	public static final ResourceKey<Feature> SOUL_FIRE = FeatureUtils.createKey("patch_soul_fire");
74
75
	public static void bootstrap(final BootstrapContext<Feature> context) {
76
		HolderGetter<Block> blocks = context.lookup(Registries.BLOCK);
77
		context.register(DELTA, new DeltaFeature(Blocks.LAVA.defaultBlockState(), Blocks.MAGMA_BLOCK.defaultBlockState(), UniformInt.of(3, 7), UniformInt.of(0, 2)));
78
		BlockPredicate replacedByBasaltColumns = BlockPredicate.anyOf(
79
			BlockPredicate.ONLY_IN_AIR_PREDICATE,
80
			BlockPredicate.allOf(BlockPredicate.matchesBlocks(Blocks.LAVA), BlockPredicate.heightRange(VerticalAnchor.bottom(), VerticalAnchor.seaLevel()))
81
		);
82
		context.register(
83
			SMALL_BASALT_COLUMNS,
84
			new WeightedRandomSelectorFeature(
85
				WeightedList.of(
86
					new Weighted<>(
87
						PlacementUtils.inlinePlaced(
88
							new SteppedColumnClusterFeature(
89
								BlockStateProvider.holderOf(Blocks.BASALT),
90
								BlockPredicate.matchesBlocks(Blocks.BASALT),
91
								replacedByBasaltColumns,
92
								blocks.getOrThrow(BlockTags.CANNOT_PLACE_BASALT_PILLAR_ON),
93
								ConstantInt.of(5),
94
								ConstantInt.of(50),
95
								ConstantInt.of(1),
96
								UniformInt.of(1, 4)
97
							)
98
						),
99
						9
100
					),
101
					new Weighted<>(
102
						PlacementUtils.inlinePlaced(
103
							new SteppedColumnClusterFeature(
104
								BlockStateProvider.holderOf(Blocks.BASALT),
105
								BlockPredicate.matchesBlocks(Blocks.BASALT),
106
								replacedByBasaltColumns,
107
								blocks.getOrThrow(BlockTags.CANNOT_PLACE_BASALT_PILLAR_ON),
108
								ConstantInt.of(8),
109
								ConstantInt.of(15),
110
								ConstantInt.of(1),
111
								UniformInt.of(1, 4)
112
							)
113
						),
114
						1
115
					)
116
				)
117
			)
118
		);
119
		context.register(
120
			LARGE_BASALT_COLUMNS,
121
			new WeightedRandomSelectorFeature(
122
				WeightedList.of(
123
					new Weighted<>(
124
						PlacementUtils.inlinePlaced(
125
							new SteppedColumnClusterFeature(
126
								BlockStateProvider.holderOf(Blocks.BASALT),
127
								BlockPredicate.matchesBlocks(Blocks.BASALT),
128
								replacedByBasaltColumns,
129
								blocks.getOrThrow(BlockTags.CANNOT_PLACE_BASALT_PILLAR_ON),
130
								ConstantInt.of(5),
131
								ConstantInt.of(50),
132
								UniformInt.of(2, 3),
133
								UniformInt.of(5, 10)
134
							)
135
						),
136
						9
137
					),
138
					new Weighted<>(
139
						PlacementUtils.inlinePlaced(
140
							new SteppedColumnClusterFeature(
141
								BlockStateProvider.holderOf(Blocks.BASALT),
142
								BlockPredicate.matchesBlocks(Blocks.BASALT),
143
								replacedByBasaltColumns,
144
								blocks.getOrThrow(BlockTags.CANNOT_PLACE_BASALT_PILLAR_ON),
145
								ConstantInt.of(8),
146
								ConstantInt.of(15),
147
								UniformInt.of(2, 3),
148
								UniformInt.of(5, 10)
149
							)
150
						),
151
						1
152
					)
153
				)
154
			)
155
		);
156
		context.register(BASALT_BLOBS, new ReplaceBlobsFeature(Blocks.NETHERRACK.defaultBlockState(), Blocks.BASALT.defaultBlockState(), UniformInt.of(3, 7)));
157
		context.register(BLACKSTONE_BLOBS, new ReplaceBlobsFeature(Blocks.NETHERRACK.defaultBlockState(), Blocks.BLACKSTONE.defaultBlockState(), UniformInt.of(3, 7)));
158
		context.register(
159
			GLOWSTONE_EXTRA,
160
			new RandomNeighborSpreadFeature(
161
				BlockStateProvider.holderOf(Blocks.GLOWSTONE),
162
				HolderSet.direct(blocks.getOrThrow(BlockItemIds.GLOWSTONE.block())),
163
				BlockPredicate.ONLY_IN_AIR_PREDICATE,
164
				ConstantInt.of(1500),
165
				TrapezoidInt.triangle(7),
166
				UniformInt.of(-11, 0)
167
			)
168
		);
169
		PlacementModifier[] netherForestBonemealSpread = new PlacementModifier[]{
170
			CountPlacement.of(9), OffsetPlacement.ofTriangle(2, 0), BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE)
171
		};
172
		SimpleBlockFeature crimsonVegetation = new SimpleBlockFeature(
173
			new WeightedStateProvider(
174
				WeightedList.<BlockState>builder()
175
					.add(Blocks.CRIMSON_ROOTS.defaultBlockState(), 87)
176
					.add(Blocks.CRIMSON_FUNGUS.defaultBlockState(), 11)
177
					.add(Blocks.WARPED_FUNGUS.defaultBlockState(), 1)
178
			)
179
		);
180
		context.register(CRIMSON_FOREST_VEGETATION, crimsonVegetation);
181
		SimpleBlockFeature warpedVegetation = new SimpleBlockFeature(
182
			new WeightedStateProvider(
183
				WeightedList.<BlockState>builder()
184
					.add(Blocks.WARPED_ROOTS.defaultBlockState(), 85)
185
					.add(Blocks.CRIMSON_ROOTS.defaultBlockState(), 1)
186
					.add(Blocks.WARPED_FUNGUS.defaultBlockState(), 13)
187
					.add(Blocks.CRIMSON_FUNGUS.defaultBlockState(), 1)
188
			)
189
		);
190
		context.register(WARPED_FOREST_VEGETION, warpedVegetation);
191
		SimpleBlockFeature netherSprouts = new SimpleBlockFeature(BlockStateProvider.of(Blocks.NETHER_SPROUTS));
192
		context.register(NETHER_SPROUTS, netherSprouts);
193
		Feature crimsonNyliumBonemeal = new OverlayFeature(HolderSet.direct(PlacementUtils.inlinePlaced(crimsonVegetation, netherForestBonemealSpread)));
194
		Feature warpedNyliumBonemeal = new OverlayFeature(
195
			HolderSet.direct(
196
				PlacementUtils.inlinePlaced(warpedVegetation, netherForestBonemealSpread),
197
				PlacementUtils.inlinePlaced(netherSprouts, netherForestBonemealSpread),
198
				PlacementUtils.inlinePlaced(
199
					new WeightedRandomSelectorFeature(
200
						WeightedList.<Holder<PlacedFeature>>builder()
201
							.add(
202
								PlacementUtils.inlinePlaced(
203
									createVines(1, 2, Direction.UP, Blocks.TWISTING_VINES_PLANT, Blocks.TWISTING_VINES), NetherPlacements.spreadTwistingVines(3, 1)
204
								),
205
								1
206
							)
207
							.add(PlacementUtils.inlinePlaced(new NoOpFeature()), 7)
208
							.build()
209
					)
210
				)
211
			)
212
		);
213
		context.register(
214
			NYLIUM_BONEMEAL,
215
			new OverlayFeature(
216
				HolderSet.direct(
217
					PlacementUtils.inlinePlaced(crimsonNyliumBonemeal, BlockPredicateFilter.forPredicate(BlockPredicate.matchesBlocks(Direction.DOWN, Blocks.CRIMSON_NYLIUM))),
218
					PlacementUtils.inlinePlaced(warpedNyliumBonemeal, BlockPredicateFilter.forPredicate(BlockPredicate.matchesBlocks(Direction.DOWN, Blocks.WARPED_NYLIUM)))
219
				)
220
			)
221
		);
222
		context.register(TWISTING_VINES, createVines(1, 8, Direction.UP, Blocks.TWISTING_VINES_PLANT, Blocks.TWISTING_VINES));
223
		context.register(
224
			WEEPING_VINES,
225
			new OverlayFeature(
226
				HolderSet.direct(
227
					PlacementUtils.inlinePlaced(
228
						new RandomNeighborSpreadFeature(
229
							BlockStateProvider.holderOf(Blocks.NETHER_WART_BLOCK),
230
							HolderSet.direct(blocks.getOrThrow(BlockItemIds.NETHERRACK.block()), blocks.getOrThrow(BlockItemIds.NETHER_WART_BLOCK.block())),
231
							BlockPredicate.ONLY_IN_AIR_PREDICATE,
232
							ConstantInt.of(200),
233
							TrapezoidInt.triangle(5),
234
							TrapezoidInt.of(-4, 1, 3)
235
						)
236
					),
237
					PlacementUtils.inlinePlaced(
238
						createVines(2, 9, Direction.DOWN, Blocks.WEEPING_VINES_PLANT, Blocks.WEEPING_VINES),
239
						CountPlacement.of(100),
240
						OffsetPlacement.of(TrapezoidInt.triangle(7), TrapezoidInt.of(-4, 1, 3)),
241
						BlockPredicateFilter.forPredicate(
242
							BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.UP, Blocks.NETHERRACK, Blocks.NETHER_WART_BLOCK))
243
						)
244
					)
245
				)
246
			)
247
		);
248
		context.register(CRIMSON_ROOTS, new SimpleBlockFeature(BlockStateProvider.of(Blocks.CRIMSON_ROOTS)));
249
		context.register(
250
			BASALT_PILLAR,
251
			new OverlayFeature(
252
				HolderSet.direct(
253
					PlacementUtils.inlinePlaced(
254
						new SingleBlockPillarFeature(
255
							BlockStateProvider.holderOf(Blocks.BASALT),
256
							BlockPredicate.ONLY_IN_AIR_PREDICATE,
257
							Direction.DOWN,
258
							1.0F,
259
							Optional.of(
260
								PlacementUtils.inlinePlaced(
261
									new OverlayFeature(
262
										HolderSet.direct(
263
											PlacementUtils.inlinePlaced(
264
												new ProjectedRandomPatchySquare(
265
													Holder.direct(
266
														RuleBasedStateProvider.ifTrueThenProvide(BlockPredicate.not(BlockPredicate.matchesTag(Direction.DOWN, BlockTags.AIR)), Blocks.BASALT)
267
													),
268
													BlockPredicate.ONLY_IN_AIR_PREDICATE,
269
													ConstantInt.of(3),
270
													3
271
												),
272
												OffsetPlacement.of(0, -1, 0)
273
											),
274
											PlacementUtils.inlinePlaced(
275
												new SimpleBlockFeature(BlockStateProvider.of(Blocks.BASALT)), RarityFilter.onAverageOnceEvery(2), OffsetPlacement.of(1, 0, 0)
276
											),
277
											PlacementUtils.inlinePlaced(
278
												new SimpleBlockFeature(BlockStateProvider.of(Blocks.BASALT)), RarityFilter.onAverageOnceEvery(2), OffsetPlacement.of(-1, 0, 0)
279
											),
280
											PlacementUtils.inlinePlaced(
281
												new SimpleBlockFeature(BlockStateProvider.of(Blocks.BASALT)), RarityFilter.onAverageOnceEvery(2), OffsetPlacement.of(0, 0, 1)
282
											),
283
											PlacementUtils.inlinePlaced(
284
												new SimpleBlockFeature(BlockStateProvider.of(Blocks.BASALT)), RarityFilter.onAverageOnceEvery(2), OffsetPlacement.of(0, 0, -1)
285
											)
286
										)
287
									)
288
								)
289
							)
290
						)
291
					),
292
					PlacementUtils.inlinePlaced(
293
						new SingleBlockPillarFeature(BlockStateProvider.holderOf(Blocks.BASALT), BlockPredicate.ONLY_IN_AIR_PREDICATE, Direction.DOWN, 0.9F),
294
						OffsetPlacement.of(1, 0, 0)
295
					),
296
					PlacementUtils.inlinePlaced(
297
						new SingleBlockPillarFeature(BlockStateProvider.holderOf(Blocks.BASALT), BlockPredicate.ONLY_IN_AIR_PREDICATE, Direction.DOWN, 0.9F),
298
						OffsetPlacement.of(-1, 0, 0)
299
					),
300
					PlacementUtils.inlinePlaced(
301
						new SingleBlockPillarFeature(BlockStateProvider.holderOf(Blocks.BASALT), BlockPredicate.ONLY_IN_AIR_PREDICATE, Direction.DOWN, 0.9F),
302
						OffsetPlacement.of(0, 0, 1)
303
					),
304
					PlacementUtils.inlinePlaced(
305
						new SingleBlockPillarFeature(BlockStateProvider.holderOf(Blocks.BASALT), BlockPredicate.ONLY_IN_AIR_PREDICATE, Direction.DOWN, 0.9F),
306
						OffsetPlacement.of(0, 0, -1)
307
					)
308
				)
309
			)
310
		);
311
		context.register(
312
			SPRING_LAVA_NETHER,
313
			new SpringFeature(
314
				Fluids.LAVA.defaultFluidState(),
315
				true,
316
				4,
317
				1,
318
				HolderSet.direct(Block::builtInRegistryHolder, Blocks.NETHERRACK, Blocks.SOUL_SAND, Blocks.GRAVEL, Blocks.MAGMA_BLOCK, Blocks.BLACKSTONE)
319
			)
320
		);
321
		context.register(
322
			SPRING_NETHER_CLOSED, new SpringFeature(Fluids.LAVA.defaultFluidState(), false, 5, 0, HolderSet.direct(Block::builtInRegistryHolder, Blocks.NETHERRACK))
323
		);
324
		context.register(
325
			SPRING_NETHER_OPEN, new SpringFeature(Fluids.LAVA.defaultFluidState(), false, 4, 1, HolderSet.direct(Block::builtInRegistryHolder, Blocks.NETHERRACK))
326
		);
327
		context.register(FIRE, new SimpleBlockFeature(BlockStateProvider.of(Blocks.FIRE)));
328
		context.register(SOUL_FIRE, new SimpleBlockFeature(BlockStateProvider.of(Blocks.SOUL_FIRE)));
329
	}
330
331
	private static Feature createVines(final int minHeight, final int maxHeight, final Direction direction, final Block mainBlock, final Block tipBlock) {
332
		IntProvider mainHeight = new WeightedListInt(
333
			WeightedList.<IntProvider>builder()
334
				.add(UniformInt.of(minHeight - 1, maxHeight - 1), 10)
335
				.add(UniformInt.of(minHeight, maxHeight * 2 - 1), 2)
336
				.add(ConstantInt.of(minHeight - 1), 3)
337
				.build()
338
		);
339
		return new BlockColumnFeature(
340
			List.of(
341
				BlockColumnFeature.layer(mainHeight, BlockStateProvider.of(mainBlock)),
342
				BlockColumnFeature.layer(
343
					ConstantInt.of(1), new RandomizedIntStateProvider(BlockStateProvider.of(tipBlock), GrowingPlantHeadBlock.AGE, UniformInt.of(17, 25))
344
				)
345
			),
346
			direction,
347
			BlockPredicate.ONLY_IN_AIR_PREDICATE,
348
			true
349
		);
350
	}
351
}
352

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