SubShape .java

net.minecraft.world.phys.shapes.SubShape (class, 52 lines): members: startX, startZ, endX, endY, endZ, firstFull, lastFull, startY, isFull, fill, parent.

net.minecraft.world.phys.shapesclass52 linescommonextends DiscreteVoxelShape1.5 KB

API Surface (4)

boolean isFull(final int x, final int y, final int z)
void fill(final int x, final int y, final int z)
int firstFull(final Direction.Axis axis)
int lastFull(final Direction.Axis axis)

Fields & Constants (7)

parent
startX
startY
startZ
endX
endY
endZ

Code Graph: Dependencies (3)

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

Full Source

SubShape.java52 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.phys.shapes;
2
3
import net.minecraft.core.Direction;
4
import net.minecraft.util.Mth;
5
6
public final class SubShape extends DiscreteVoxelShape {
7
	private final DiscreteVoxelShape parent;
8
	private final int startX;
9
	private final int startY;
10
	private final int startZ;
11
	private final int endX;
12
	private final int endY;
13
	private final int endZ;
14
15
	SubShape(final DiscreteVoxelShape parent, final int startX, final int startY, final int startZ, final int endX, final int endY, final int endZ) {
16
		super(endX - startX, endY - startY, endZ - startZ);
17
		this.parent = parent;
18
		this.startX = startX;
19
		this.startY = startY;
20
		this.startZ = startZ;
21
		this.endX = endX;
22
		this.endY = endY;
23
		this.endZ = endZ;
24
	}
25
26
	@Override
27
	public boolean isFull(final int x, final int y, final int z) {
28
		return this.parent.isFull(this.startX + x, this.startY + y, this.startZ + z);
29
	}
30
31
	@Override
32
	public void fill(final int x, final int y, final int z) {
33
		this.parent.fill(this.startX + x, this.startY + y, this.startZ + z);
34
	}
35
36
	@Override
37
	public int firstFull(final Direction.Axis axis) {
38
		return this.clampToShape(axis, this.parent.firstFull(axis));
39
	}
40
41
	@Override
42
	public int lastFull(final Direction.Axis axis) {
43
		return this.clampToShape(axis, this.parent.lastFull(axis));
44
	}
45
46
	private int clampToShape(final Direction.Axis axis, final int parentResult) {
47
		int start = axis.choose(this.startX, this.startY, this.startZ);
48
		int end = axis.choose(this.endX, this.endY, this.endZ);
49
		return Mth.clamp(parentResult, start, end) - start;
50
	}
51
}
52

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