EndIslandFeature .java

net.minecraft.world.level.levelgen.feature.EndIslandFeature (record, 38 lines): record. members: place, codec, CODEC. imports: ChunkGenerator.

net.minecraft.world.level.levelgen.featurerecord38 linescommon1.1 KB

Implements

API Surface (2)

MapCodec<EndIslandFeature> codec()
boolean place(final WorldGenLevel level, final ChunkGenerator chunkGenerator, final RandomSource random, final BlockPos origin)

Fields & Constants (1)

CODEC

Code Graph: Dependencies (7)

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

Full Source

EndIslandFeature.java38 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.feature;
2
3
import com.mojang.serialization.MapCodec;
4
import net.minecraft.core.BlockPos;
5
import net.minecraft.util.Mth;
6
import net.minecraft.util.RandomSource;
7
import net.minecraft.world.level.WorldGenLevel;
8
import net.minecraft.world.level.block.Blocks;
9
import net.minecraft.world.level.chunk.ChunkGenerator;
10
11
public record EndIslandFeature() implements Feature {
12
	public static final MapCodec<EndIslandFeature> CODEC = MapCodec.unit(EndIslandFeature::new);
13
14
	@Override
15
	public MapCodec<EndIslandFeature> codec() {
16
		return CODEC;
17
	}
18
19
	@Override
20
	public boolean place(final WorldGenLevel level, final ChunkGenerator chunkGenerator, final RandomSource random, final BlockPos origin) {
21
		float size = random.nextInt(3) + 4.0F;
22
23
		for (int y = 0; size > 0.5F; y--) {
24
			for (int x = Mth.floor(-size); x <= Mth.ceil(size); x++) {
25
				for (int z = Mth.floor(-size); z <= Mth.ceil(size); z++) {
26
					if (x * x + z * z <= (size + 1.0F) * (size + 1.0F)) {
27
						this.setBlock(level, origin.offset(x, y, z), Blocks.END_STONE.defaultBlockState());
28
					}
29
				}
30
			}
31
32
			size -= random.nextInt(2) + 0.5F;
33
		}
34
35
		return true;
36
	}
37
}
38

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