Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions api/src/main/java/net/countercraft/movecraft/TrackedLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import net.countercraft.movecraft.craft.Craft;
import net.countercraft.movecraft.util.MathUtils;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;

import java.util.HashSet;

public class TrackedLocation {
private MovecraftLocation offSet;
private final Craft craft;
Expand All @@ -20,6 +23,21 @@ public TrackedLocation(@NotNull Craft craft, @NotNull MovecraftLocation location
offSet = location.subtract(midPoint);
}

/**
* Creates a new TrackedLocation instance which tracks a location about a craft's midpoint.
* @param craft The craft that's that tied to the location.
* @param location The absolute position to track. This location will be stored as a relative
* location to the craft's central hitbox.
* @param key The namespaced key that references a set of tracked locations stored within the craft.
*/
public TrackedLocation(@NotNull Craft craft, @NotNull MovecraftLocation location, @NotNull NamespacedKey key) {
this(craft, location);
if (craft.getTrackedLocations().get(key) == null) {
craft.getTrackedLocations().put(key, new HashSet<>());
}
craft.getTrackedLocations().get(key).add(this);
}

/**
* Rotates the stored location.
* @param rotation A clockwise or counter-clockwise direction to rotate.
Expand All @@ -44,4 +62,12 @@ public MovecraftLocation getAbsoluteLocation() {
public MovecraftLocation getOffSet() {
return offSet;
}

/**
* Gets the craft associated with the tracked location.
* @return Returns the craft.
*/
public Craft getCraft() {
return craft;
}
}
Loading