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
* @returnThe 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 locationThe location to adjust
* @param rightThe amount of blocks to the right to adjust
* @param depthThe amount of blocks upward to adjust
* @param distanceThe distance outward to adjust
* @param modXThe x modifier to use
* @param modZThe z modifier to use
* @returnThe 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); } }