VanillaMaterialRules .java

net.minecraft.data.worldgen.material.VanillaMaterialRules (class, 43 lines): members: BEDROCK_FLOOR, BEDROCK_ROOF, air, BEDROCK, bootstrap. imports: Block.

net.minecraft.data.worldgen.materialclass43 linescommon1.8 KB

API Surface (2)

void bootstrap(final BootstrapContext<MaterialRule> context)
MaterialRule air()

Fields & Constants (3)

BEDROCK_FLOOR
BEDROCK_ROOF
BEDROCK

String literals (2)

"bedrock_floor"
"bedrock_roof"

Full Source

VanillaMaterialRules.java43 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.data.worldgen.material;
2
3
import net.minecraft.core.registries.Registries;
4
import net.minecraft.data.worldgen.BootstrapContext;
5
import net.minecraft.resources.Identifier;
6
import net.minecraft.resources.ResourceKey;
7
import net.minecraft.world.level.block.Block;
8
import net.minecraft.world.level.block.Blocks;
9
import net.minecraft.world.level.levelgen.VerticalAnchor;
10
import net.minecraft.world.level.levelgen.material.MaterialRules;
11
import net.minecraft.world.level.levelgen.material.rule.MaterialRule;
12
13
public class VanillaMaterialRules {
14
	public static final ResourceKey<MaterialRule> BEDROCK_FLOOR = createKey("bedrock_floor");
15
	public static final ResourceKey<MaterialRule> BEDROCK_ROOF = createKey("bedrock_roof");
16
	private static final MaterialRule BEDROCK = makeStateRule(Blocks.BEDROCK);
17
18
	private static ResourceKey<MaterialRule> createKey(final String name) {
19
		return ResourceKey.create(Registries.MATERIAL_RULE, Identifier.withDefaultNamespace(name));
20
	}
21
22
	private static MaterialRule makeStateRule(final Block block) {
23
		return MaterialRules.state(block.defaultBlockState());
24
	}
25
26
	public static void bootstrap(final BootstrapContext<MaterialRule> context) {
27
		context.register(
28
			BEDROCK_FLOOR, MaterialRules.ifTrue(MaterialRules.verticalGradient("bedrock_floor", VerticalAnchor.bottom(), VerticalAnchor.aboveBottom(5)), BEDROCK)
29
		);
30
		context.register(
31
			BEDROCK_ROOF,
32
			MaterialRules.ifTrue(MaterialRules.not(MaterialRules.verticalGradient("bedrock_roof", VerticalAnchor.belowTop(5), VerticalAnchor.top())), BEDROCK)
33
		);
34
		OverworldMaterialRules.bootstrap(context);
35
		NetherMaterialRules.bootstrap(context);
36
		EndMaterialRules.bootstrap(context);
37
	}
38
39
	public static MaterialRule air() {
40
		return MaterialRules.state(Blocks.AIR.defaultBlockState());
41
	}
42
}
43

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