package net.knarcraft.stargate.utility; import net.knarcraft.stargate.BlockLocation; import net.knarcraft.stargate.RelativeBlockVector; import org.bukkit.Location; /** * This class helps with direction-dependent (modX, modZ) calculations */ public final class DirectionHelper { private DirectionHelper() { } /** * Gets the block at a relative block vector location * * @param vector

The relative block vector

* @return

The block at the given relative position

*/ public static BlockLocation getBlockAt(BlockLocation topLeft, RelativeBlockVector vector, int modX, int modZ) { return topLeft.modRelative(vector.getRight(), vector.getDepth(), vector.getDistance(), modX, 1, modZ); } /** * Adds a relative block vector to a location, accounting for direction * @param location

The location to adjust

* @param right

The amount of blocks to the right to adjust

* @param depth

The amount of blocks upward to adjust

* @param distance

The distance outward to adjust

* @param modX

The x modifier to use

* @param modZ

The z modifier to use

* @return

The altered location

*/ public static Location adjustLocation(Location location, double right, double depth, double distance, int modX, int modZ) { return location.add(-right * modX + distance * modZ, depth, -right * modZ + -distance * modX); } }