ArrayVoxelShape .java

net.minecraft.world.phys.shapes.ArrayVoxelShape (class, 46 lines): members: xs, ys, zs, getCoords. imports: DoubleArrayList, DoubleList, Util, Direction.

net.minecraft.world.phys.shapesclass46 linescommonextends VoxelShape1.4 KB

API Surface (1)

DoubleList getCoords(final Direction.Axis axis)

Fields & Constants (3)

xs
ys
zs

Code Graph: Dependencies (4)

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

Full Source

ArrayVoxelShape.java46 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.phys.shapes;
2
3
import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
4
import it.unimi.dsi.fastutil.doubles.DoubleList;
5
import java.util.Arrays;
6
import net.minecraft.core.Direction;
7
import net.minecraft.util.Util;
8
9
public class ArrayVoxelShape extends VoxelShape {
10
	private final DoubleList xs;
11
	private final DoubleList ys;
12
	private final DoubleList zs;
13
14
	ArrayVoxelShape(final DiscreteVoxelShape shape, final double[] xs, final double[] ys, final double[] zs) {
15
		this(
16
			shape,
17
			DoubleArrayList.wrap(Arrays.copyOf(xs, shape.getXSize() + 1)),
18
			DoubleArrayList.wrap(Arrays.copyOf(ys, shape.getYSize() + 1)),
19
			DoubleArrayList.wrap(Arrays.copyOf(zs, shape.getZSize() + 1))
20
		);
21
	}
22
23
	ArrayVoxelShape(final DiscreteVoxelShape shape, final DoubleList xs, final DoubleList ys, final DoubleList zs) {
24
		super(shape);
25
		int xSize = shape.getXSize() + 1;
26
		int ySize = shape.getYSize() + 1;
27
		int zSize = shape.getZSize() + 1;
28
		if (xSize == xs.size() && ySize == ys.size() && zSize == zs.size()) {
29
			this.xs = xs;
30
			this.ys = ys;
31
			this.zs = zs;
32
		} else {
33
			throw (IllegalArgumentException)Util.pauseInIde(new IllegalArgumentException("Lengths of point arrays must be consistent with the size of the VoxelShape."));
34
		}
35
	}
36
37
	@Override
38
	public DoubleList getCoords(final Direction.Axis axis) {
39
		return switch (axis) {
40
			case X -> this.xs;
41
			case Y -> this.ys;
42
			case Z -> this.zs;
43
		};
44
	}
45
}
46

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