LevelHeightAccessor .java

net.minecraft.world.level.LevelHeightAccessor (interface): members: getSectionIndexFromSectionY, getSectionYFromSectionIndex, isOutsideBuildHeight, create.

net.minecraft.world.levelinterface69 linescommon1.6 KB

API Surface (2)

int getHeight()
int getMinY()

Code Graph: Dependencies (2)

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

Full Source

LevelHeightAccessor.java69 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.core.SectionPos;
5
6
public interface LevelHeightAccessor {
7
	int getHeight();
8
9
	int getMinY();
10
11
	default int getMaxY() {
12
		return this.getMinY() + this.getHeight() - 1;
13
	}
14
15
	default int getSectionsCount() {
16
		return this.getMaxSectionY() - this.getMinSectionY() + 1;
17
	}
18
19
	default int getMinSectionY() {
20
		return SectionPos.blockToSectionCoord(this.getMinY());
21
	}
22
23
	default int getMaxSectionY() {
24
		return SectionPos.blockToSectionCoord(this.getMaxY());
25
	}
26
27
	default boolean isInsideBuildHeight(final BlockPos pos) {
28
		return this.isInsideBuildHeight(pos.getY());
29
	}
30
31
	default boolean isInsideBuildHeight(final int blockY) {
32
		return blockY >= this.getMinY() && blockY <= this.getMaxY();
33
	}
34
35
	default boolean isOutsideBuildHeight(final BlockPos pos) {
36
		return this.isOutsideBuildHeight(pos.getY());
37
	}
38
39
	default boolean isOutsideBuildHeight(final int blockY) {
40
		return blockY < this.getMinY() || blockY > this.getMaxY();
41
	}
42
43
	default int getSectionIndex(final int blockY) {
44
		return this.getSectionIndexFromSectionY(SectionPos.blockToSectionCoord(blockY));
45
	}
46
47
	default int getSectionIndexFromSectionY(final int sectionY) {
48
		return sectionY - this.getMinSectionY();
49
	}
50
51
	default int getSectionYFromSectionIndex(final int sectionIndex) {
52
		return sectionIndex + this.getMinSectionY();
53
	}
54
55
	static LevelHeightAccessor create(final int minY, final int height) {
56
		return new LevelHeightAccessor() {
57
			@Override
58
			public int getHeight() {
59
				return height;
60
			}
61
62
			@Override
63
			public int getMinY() {
64
				return minY;
65
			}
66
		};
67
	}
68
}
69

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