PistonMath .java

net.minecraft.world.level.block.piston.PistonMath (class, 28 lines): members: getMovementArea. imports: AABB.

net.minecraft.world.level.block.pistonclass28 linescommon1.1 KB

API Surface (1)

AABB getMovementArea(final AABB aabb, final Direction direction, final double amount)

Code Graph: Dependencies (2)

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

Full Source

PistonMath.java28 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block.piston;
2
3
import net.minecraft.core.Direction;
4
import net.minecraft.world.phys.AABB;
5
6
public class PistonMath {
7
	public static AABB getMovementArea(final AABB aabb, final Direction direction, final double amount) {
8
		double delta = amount * direction.getAxisDirection().getStep();
9
		double min = Math.min(delta, 0.0);
10
		double max = Math.max(delta, 0.0);
11
		switch (direction) {
12
			case WEST:
13
				return new AABB(aabb.minX + min, aabb.minY, aabb.minZ, aabb.minX + max, aabb.maxY, aabb.maxZ);
14
			case EAST:
15
				return new AABB(aabb.maxX + min, aabb.minY, aabb.minZ, aabb.maxX + max, aabb.maxY, aabb.maxZ);
16
			case DOWN:
17
				return new AABB(aabb.minX, aabb.minY + min, aabb.minZ, aabb.maxX, aabb.minY + max, aabb.maxZ);
18
			case UP:
19
			default:
20
				return new AABB(aabb.minX, aabb.maxY + min, aabb.minZ, aabb.maxX, aabb.maxY + max, aabb.maxZ);
21
			case NORTH:
22
				return new AABB(aabb.minX, aabb.minY, aabb.minZ + min, aabb.maxX, aabb.maxY, aabb.minZ + max);
23
			case SOUTH:
24
				return new AABB(aabb.minX, aabb.minY, aabb.maxZ + min, aabb.maxX, aabb.maxY, aabb.maxZ + max);
25
		}
26
	}
27
}
28

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