TheEndBiomeSource .java

net.minecraft.world.level.biome.TheEndBiomeSource (class): members: highlands, midlands, barrens, islands, collectPossibleBiomes, createResolver, end.

net.minecraft.world.level.biomeclass86 linescommonextends BiomeSource2.9 KB

API Surface (4)

TheEndBiomeSource create(final HolderGetter<Biome> biomes)
Stream<Holder<Biome>> collectPossibleBiomes()
MapCodec<TheEndBiomeSource> codec()
BiomeResolver createResolver(final Climate.Sampler sampler)

Fields & Constants (6)

CODEC
end
highlands
midlands
islands
barrens

Full Source

TheEndBiomeSource.java86 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.biome;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import java.util.stream.Stream;
6
import net.minecraft.core.Holder;
7
import net.minecraft.core.HolderGetter;
8
import net.minecraft.core.QuartPos;
9
import net.minecraft.core.SectionPos;
10
import net.minecraft.resources.RegistryOps;
11
12
public class TheEndBiomeSource extends BiomeSource {
13
	public static final MapCodec<TheEndBiomeSource> CODEC = RecordCodecBuilder.mapCodec(
14
		i -> i.group(
15
				RegistryOps.retrieveElement(Biomes.THE_END),
16
				RegistryOps.retrieveElement(Biomes.END_HIGHLANDS),
17
				RegistryOps.retrieveElement(Biomes.END_MIDLANDS),
18
				RegistryOps.retrieveElement(Biomes.SMALL_END_ISLANDS),
19
				RegistryOps.retrieveElement(Biomes.END_BARRENS)
20
			)
21
			.apply(i, i.stable(TheEndBiomeSource::new))
22
	);
23
	private final Holder<Biome> end;
24
	private final Holder<Biome> highlands;
25
	private final Holder<Biome> midlands;
26
	private final Holder<Biome> islands;
27
	private final Holder<Biome> barrens;
28
29
	public static TheEndBiomeSource create(final HolderGetter<Biome> biomes) {
30
		return new TheEndBiomeSource(
31
			biomes.getOrThrow(Biomes.THE_END),
32
			biomes.getOrThrow(Biomes.END_HIGHLANDS),
33
			biomes.getOrThrow(Biomes.END_MIDLANDS),
34
			biomes.getOrThrow(Biomes.SMALL_END_ISLANDS),
35
			biomes.getOrThrow(Biomes.END_BARRENS)
36
		);
37
	}
38
39
	private TheEndBiomeSource(
40
		final Holder<Biome> end, final Holder<Biome> highlands, final Holder<Biome> midlands, final Holder<Biome> islands, final Holder<Biome> barrens
41
	) {
42
		this.end = end;
43
		this.highlands = highlands;
44
		this.midlands = midlands;
45
		this.islands = islands;
46
		this.barrens = barrens;
47
	}
48
49
	@Override
50
	protected Stream<Holder<Biome>> collectPossibleBiomes() {
51
		return Stream.of(this.end, this.highlands, this.midlands, this.islands, this.barrens);
52
	}
53
54
	@Override
55
	protected MapCodec<TheEndBiomeSource> codec() {
56
		return CODEC;
57
	}
58
59
	@Override
60
	public BiomeResolver createResolver(final Climate.Sampler sampler) {
61
		return (quartX, quartY, quartZ) -> this.getNoiseBiome(quartX, quartY, quartZ, sampler);
62
	}
63
64
	private Holder<Biome> getNoiseBiome(final int quartX, final int quartY, final int quartZ, final Climate.Sampler sampler) {
65
		int blockX = QuartPos.toBlock(quartX);
66
		int blockY = QuartPos.toBlock(quartY);
67
		int blockZ = QuartPos.toBlock(quartZ);
68
		int chunkX = SectionPos.blockToSectionCoord(blockX);
69
		int chunkZ = SectionPos.blockToSectionCoord(blockZ);
70
		if ((long)chunkX * chunkX + (long)chunkZ * chunkZ <= 4096L) {
71
			return this.end;
72
		} else {
73
			int weirdBlockX = (SectionPos.blockToSectionCoord(blockX) * 2 + 1) * 8;
74
			int weirdBlockZ = (SectionPos.blockToSectionCoord(blockZ) * 2 + 1) * 8;
75
			double heightValue = sampler.erosion().sampleValue(weirdBlockX, blockY, weirdBlockZ);
76
			if (heightValue > 0.25) {
77
				return this.highlands;
78
			} else if (heightValue >= -0.0625) {
79
				return this.midlands;
80
			} else {
81
				return heightValue < -0.21875 ? this.islands : this.barrens;
82
			}
83
		}
84
	}
85
}
86

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