From 201f7eaf15e864e74fe65cba6193aa4369eb5b57 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 6 Oct 2021 19:45:49 +0200 Subject: [PATCH] Adds a class for storing a portal's location data --- .../stargate/portal/PortalLocation.java | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 src/main/java/net/knarcraft/stargate/portal/PortalLocation.java diff --git a/src/main/java/net/knarcraft/stargate/portal/PortalLocation.java b/src/main/java/net/knarcraft/stargate/portal/PortalLocation.java new file mode 100644 index 0000000..7f0eb0b --- /dev/null +++ b/src/main/java/net/knarcraft/stargate/portal/PortalLocation.java @@ -0,0 +1,159 @@ +package net.knarcraft.stargate.portal; + +import net.knarcraft.stargate.container.BlockLocation; +import net.knarcraft.stargate.container.RelativeBlockVector; +import org.bukkit.block.BlockFace; + +/** + * Keeps track of location related data for a portal + */ +public class PortalLocation { + + private BlockLocation topLeft; + private int modX; + private int modZ; + private float yaw; + private BlockLocation signLocation; + private RelativeBlockVector buttonVector; + private BlockFace buttonFacing; + + /** + * Gets the top-left block of the portal + * + * @return

The top-left block of the portal

+ */ + public BlockLocation getTopLeft() { + return topLeft; + } + + /** + * Gets the x-modifier for the portal + * + * @return

The x-modifier for the portal

+ */ + public int getModX() { + return modX; + } + + /** + * Gets the z-modifier for the portal + * + * @return

The z-modifier for the portal

+ */ + public int getModZ() { + return modZ; + } + + /** + * Gets the yaw for looking outwards from the portal + * + * @return

The portal's yaw

+ */ + public float getYaw() { + return yaw; + } + + /** + * Gets the location of the portal's sign + * @return

The location of the portal's sign

+ */ + public BlockLocation getSignLocation() { + return signLocation; + } + + /** + * The relative block vector pointing to the portal's button + * @return

The relative location of the portal's button

+ */ + public RelativeBlockVector getButtonVector() { + return buttonVector; + } + + /** + * Gets the block face determining the button's direction + * @return

The button's block face

+ */ + public BlockFace getButtonFacing() { + return buttonFacing; + } + + /** + * Sets the portal's top-left location + * + *

Assuming the portal is a square, the top-left block is the top-left block when looking at the portal at the + * side with the portal's sign.

+ * + * @param topLeft

The new top-left block of the portal's square structure

+ * @return

The portal location Object

+ */ + public PortalLocation setTopLeft(BlockLocation topLeft) { + this.topLeft = topLeft; + return this; + } + + /** + * Sets the portal's x-modifier + * + * @param modX

The portal's new x-modifier

+ * @return

The portal location Object

+ */ + public PortalLocation setModX(int modX) { + this.modX = modX; + return this; + } + + /** + * Sets the portal's z-modifier + * + * @param modZ

The portal's new z-modifier

+ * @return

The portal location Object

+ */ + public PortalLocation setModZ(int modZ) { + this.modZ = modZ; + return this; + } + + /** + * Sets the portal's yaw + * + *

The portal's yaw is the yaw a player would get when looking directly out from the portal

+ * + * @param yaw

The portal's new yaw

+ * @return

The portal location Object

+ */ + public PortalLocation setYaw(float yaw) { + this.yaw = yaw; + return this; + } + + /** + * Sets the location of the portal's sign + * @param signLocation

The new sign location

+ * @return

The portal location Object

+ */ + public PortalLocation setSignLocation(BlockLocation signLocation) { + this.signLocation = signLocation; + return this; + } + + /** + * Sets the relative location of the portal's button + * @param buttonVector

The new relative button location

+ * @return

The portal location Object

+ */ + public PortalLocation setButtonVector(RelativeBlockVector buttonVector) { + this.buttonVector = buttonVector; + return this; + } + + /** + * Sets the block face for the direction the portal button is facing + * @param buttonFacing

The new block face of the portal's button

+ * @return

The portal location Object

+ */ + public PortalLocation setButtonFacing(BlockFace buttonFacing) { + this.buttonFacing = buttonFacing; + return this; + } + +}