Skip to content

Commit

Permalink
Adds Positionable and Spatial
Browse files Browse the repository at this point in the history
  • Loading branch information
anjoismysign committed Aug 11, 2024
1 parent 4a3dc0b commit 993531d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/us/mytheria/bloblib/entities/Positionable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package us.mytheria.bloblib.entities;

import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

public interface Positionable {
double getX();

double getY();

double getZ();

@NotNull
default Vector toVector() {
return new Vector(getX(), getY(), getZ());
}
}
24 changes: 24 additions & 0 deletions src/main/java/us/mytheria/bloblib/entities/Spatial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package us.mytheria.bloblib.entities;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface Spatial extends Positionable {
float getYaw();

float getPitch();

@NotNull
default Location toLocation() {
return toLocation(null);
}

@NotNull
default Location toLocation(@Nullable World world) {
Vector vector = toVector();
return new Location(world, vector.getX(), vector.getY(), vector.getZ(), getYaw(), getPitch());
}
}

0 comments on commit 993531d

Please sign in to comment.