Update to 1.0.2
Added: - Location Box - Location Box Outline - Vector Box - Vector Box Outline
This commit is contained in:
parent
a649463bd0
commit
377512f8fc
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>io.github.bi0qaw</groupId>
|
<groupId>io.github.bi0qaw</groupId>
|
||||||
<artifactId>biosphere2</artifactId>
|
<artifactId>biosphere2</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.0.2</version>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -27,6 +27,8 @@ public class Biosphere extends JavaPlugin {
|
|||||||
Skript.registerExpression(ExprFrameFromYawPitch.class, Frame.class, ExpressionType.SIMPLE, "frame with yaw %number% and pitch %number%");
|
Skript.registerExpression(ExprFrameFromYawPitch.class, Frame.class, ExpressionType.SIMPLE, "frame with yaw %number% and pitch %number%");
|
||||||
Skript.registerExpression(ExprFrameYawPitch.class, Number.class, ExpressionType.PROPERTY, "frame (0¦yaw|1¦pitch) of %frame%");
|
Skript.registerExpression(ExprFrameYawPitch.class, Number.class, ExpressionType.PROPERTY, "frame (0¦yaw|1¦pitch) of %frame%");
|
||||||
|
|
||||||
|
Skript.registerExpression(ExprLocationBox.class, Location.class, ExpressionType.SIMPLE, "box between %location% and %location%");
|
||||||
|
Skript.registerExpression(ExprLocationBoxOutline.class, Location.class, ExpressionType.SIMPLE, "box outline between %location% and %location% with density %number%");
|
||||||
Skript.registerExpression(ExprLocationCircle.class, Location.class, ExpressionType.SIMPLE, "circle[s] at %locations%[ with] radius %number%(,| and) density %number%");
|
Skript.registerExpression(ExprLocationCircle.class, Location.class, ExpressionType.SIMPLE, "circle[s] at %locations%[ with] radius %number%(,| and) density %number%");
|
||||||
Skript.registerExpression(ExprLocationCube.class, Location.class, ExpressionType.SIMPLE, "cube[s] at %locations% with radius %number%");
|
Skript.registerExpression(ExprLocationCube.class, Location.class, ExpressionType.SIMPLE, "cube[s] at %locations% with radius %number%");
|
||||||
Skript.registerExpression(ExprLocationCubeOutline.class, Location.class, ExpressionType.SIMPLE, "cube[s] outline[s] at %locations% with radius %number%(,| and) density %number%");
|
Skript.registerExpression(ExprLocationCubeOutline.class, Location.class, ExpressionType.SIMPLE, "cube[s] outline[s] at %locations% with radius %number%(,| and) density %number%");
|
||||||
@ -39,8 +41,8 @@ public class Biosphere extends JavaPlugin {
|
|||||||
Skript.registerExpression(ExprLocationMove.class, Location.class, ExpressionType.SIMPLE, "%locations% with center %location% (moved|shifted) to %location%", "%locations% with center %location% (moved|shifted) to %location%");
|
Skript.registerExpression(ExprLocationMove.class, Location.class, ExpressionType.SIMPLE, "%locations% with center %location% (moved|shifted) to %location%", "%locations% with center %location% (moved|shifted) to %location%");
|
||||||
Skript.registerExpression(ExprLocationOffset.class, Location.class, ExpressionType.SIMPLE, "[location[s]] %locations% offset by %vectors%");
|
Skript.registerExpression(ExprLocationOffset.class, Location.class, ExpressionType.SIMPLE, "[location[s]] %locations% offset by %vectors%");
|
||||||
Skript.registerExpression(ExprLocationPath.class, Location.class, ExpressionType.SIMPLE, "[location ]path between %locations% with density %number%");
|
Skript.registerExpression(ExprLocationPath.class, Location.class, ExpressionType.SIMPLE, "[location ]path between %locations% with density %number%");
|
||||||
Skript.registerExpression(ExprLocationPolygon.class, Location.class, ExpressionType.SIMPLE, "polygon[s] at %locations% with %integer% (vertex|vertices|vertexes|points)(,| and) radius %number%");
|
Skript.registerExpression(ExprLocationPolygon.class, Location.class, ExpressionType.SIMPLE, "polygon[s] at %locations% with %number% (vertex|vertices|vertexes|points)(,| and) radius %number%");
|
||||||
Skript.registerExpression(ExprLocationPolygonOutline.class, Location.class, ExpressionType.SIMPLE, "polygon[s] outline[s] at %locations% with %integer% (vertex|vertices|vertexes|points)(,| and) radius %number%(,| and) density %number%");
|
Skript.registerExpression(ExprLocationPolygonOutline.class, Location.class, ExpressionType.SIMPLE, "polygon[s] outline[s] at %locations% with %number% (vertex|vertices|vertexes|points)(,| and) radius %number%(,| and) density %number%");
|
||||||
Skript.registerExpression(ExprLocationReflection.class, Location.class, ExpressionType.SIMPLE, "%locations% (mirrored|reflected) at %location%[ (in|with) direction [of ]%-vector%]");
|
Skript.registerExpression(ExprLocationReflection.class, Location.class, ExpressionType.SIMPLE, "%locations% (mirrored|reflected) at %location%[ (in|with) direction [of ]%-vector%]");
|
||||||
Skript.registerExpression(ExprLocationRotate.class, Location.class, ExpressionType.SIMPLE, "%locations% rotated around %vector% at %location% (with angle|by) %number%[ degree[s]]");
|
Skript.registerExpression(ExprLocationRotate.class, Location.class, ExpressionType.SIMPLE, "%locations% rotated around %vector% at %location% (with angle|by) %number%[ degree[s]]");
|
||||||
Skript.registerExpression(ExprLocationRotXYZ.class, Location.class, ExpressionType.SIMPLE, "%locations% rotated around (1¦x|2¦y|3¦z)(-| )axis at %location% (with angle|by) %number%[ degree[s]]");
|
Skript.registerExpression(ExprLocationRotXYZ.class, Location.class, ExpressionType.SIMPLE, "%locations% rotated around (1¦x|2¦y|3¦z)(-| )axis at %location% (with angle|by) %number%[ degree[s]]");
|
||||||
@ -49,6 +51,8 @@ public class Biosphere extends JavaPlugin {
|
|||||||
Skript.registerExpression(ExprLocationSphereLoc.class, Location.class, ExpressionType.SIMPLE, "spher(e|ic[al]) (coordinate[s]|position[s]|location[s]) at %locations% with radius %number%(,| and) yaw %number%(,| and) pitch %number%");
|
Skript.registerExpression(ExprLocationSphereLoc.class, Location.class, ExpressionType.SIMPLE, "spher(e|ic[al]) (coordinate[s]|position[s]|location[s]) at %locations% with radius %number%(,| and) yaw %number%(,| and) pitch %number%");
|
||||||
Skript.registerExpression(ExprLocationSphereRand.class, Location.class, ExpressionType.SIMPLE, "random sphere[s] at %locations% with radius %number%(,| and) density %number%");
|
Skript.registerExpression(ExprLocationSphereRand.class, Location.class, ExpressionType.SIMPLE, "random sphere[s] at %locations% with radius %number%(,| and) density %number%");
|
||||||
|
|
||||||
|
Skript.registerExpression(ExprVectorBox.class, Vector.class, ExpressionType.SIMPLE, "vector box between %vector% and %vector%");
|
||||||
|
Skript.registerExpression(ExprVectorBoxOutline.class, Vector.class, ExpressionType.SIMPLE, "vector box outline between %vector% and %vector% with density %number%");
|
||||||
Skript.registerExpression(ExprVectorCircle.class, Vector.class, ExpressionType.SIMPLE, "[vector ]circle with radius %number%(,| and) density %number%");
|
Skript.registerExpression(ExprVectorCircle.class, Vector.class, ExpressionType.SIMPLE, "[vector ]circle with radius %number%(,| and) density %number%");
|
||||||
Skript.registerExpression(ExprVectorCube.class, Vector.class, ExpressionType.SIMPLE, "[vector ]cube with radius %number%");
|
Skript.registerExpression(ExprVectorCube.class, Vector.class, ExpressionType.SIMPLE, "[vector ]cube with radius %number%");
|
||||||
Skript.registerExpression(ExprVectorCubeOutline.class, Vector.class, ExpressionType.SIMPLE, "[vector ]cube outline with radius %number%(,| and) density %number%");
|
Skript.registerExpression(ExprVectorCubeOutline.class, Vector.class, ExpressionType.SIMPLE, "[vector ]cube outline with radius %number%(,| and) density %number%");
|
||||||
@ -61,8 +65,8 @@ public class Biosphere extends JavaPlugin {
|
|||||||
Skript.registerExpression(ExprVectorMove.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% moved by %vectors%");
|
Skript.registerExpression(ExprVectorMove.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% moved by %vectors%");
|
||||||
Skript.registerExpression(ExprVectorOffset.class, Vector.class, ExpressionType.SIMPLE, "vector[s] %vectors% offset by %vectors%");
|
Skript.registerExpression(ExprVectorOffset.class, Vector.class, ExpressionType.SIMPLE, "vector[s] %vectors% offset by %vectors%");
|
||||||
Skript.registerExpression(ExprVectorPath.class, Vector.class, ExpressionType.SIMPLE, "vector[s] path between %vectors% with density %number%");
|
Skript.registerExpression(ExprVectorPath.class, Vector.class, ExpressionType.SIMPLE, "vector[s] path between %vectors% with density %number%");
|
||||||
Skript.registerExpression(ExprVectorPolygon.class, Vector.class, ExpressionType.SIMPLE, "[vector ]polygon with %integer% (vertex|vertices|vertexes|points)(,| and) radius %number%");
|
Skript.registerExpression(ExprVectorPolygon.class, Vector.class, ExpressionType.SIMPLE, "[vector ]polygon with %number% (vertex|vertices|vertexes|points)(,| and) radius %number%");
|
||||||
Skript.registerExpression(ExprVectorPolygonOutline.class, Vector.class, ExpressionType.SIMPLE, "[vector ]polygon outline with %integer% (vertex|vertices|vertexes|points)(,| and) radius %number%(,|and) density %number%");
|
Skript.registerExpression(ExprVectorPolygonOutline.class, Vector.class, ExpressionType.SIMPLE, "[vector ]polygon outline with %number% (vertex|vertices|vertexes|points)(,| and) radius %number%(,|and) density %number%");
|
||||||
Skript.registerExpression(ExprVectorReflection.class, Vector.class, ExpressionType.SIMPLE, "vector[s] %vectors% (mirrored|reflected) at %vector%[ (in|with) direction [of ]%-vector%]");
|
Skript.registerExpression(ExprVectorReflection.class, Vector.class, ExpressionType.SIMPLE, "vector[s] %vectors% (mirrored|reflected) at %vector%[ (in|with) direction [of ]%-vector%]");
|
||||||
Skript.registerExpression(ExprVectorRotate.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% rotated around %vector% (with angle|by) %number%[ degree[s]]");
|
Skript.registerExpression(ExprVectorRotate.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% rotated around %vector% (with angle|by) %number%[ degree[s]]");
|
||||||
Skript.registerExpression(ExprVectorRotateXYZ.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% rotated around (1¦x|2¦y|3¦z)(-| )axis (with angle|by) %number%[ degree[s]]");
|
Skript.registerExpression(ExprVectorRotateXYZ.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% rotated around (1¦x|2¦y|3¦z)(-| )axis (with angle|by) %number%[ degree[s]]");
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package io.github.bi0qaw.biosphere.expression;
|
||||||
|
|
||||||
|
import ch.njol.skript.doc.Description;
|
||||||
|
import ch.njol.skript.doc.Examples;
|
||||||
|
import ch.njol.skript.doc.Name;
|
||||||
|
import ch.njol.skript.lang.Expression;
|
||||||
|
import ch.njol.skript.lang.SkriptParser;
|
||||||
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
|
import ch.njol.util.Kleenean;
|
||||||
|
import io.github.bi0qaw.biosphere.util.LocationLib;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
|
||||||
|
@Name("Location Box")
|
||||||
|
@Description("Creates a list of locations in the shape of a box (only the corners!).")
|
||||||
|
@Examples({"set {_box::*} to box between player and location 5 right, 5 in front and 5 above player",
|
||||||
|
"show happy villager at {_box::*}"})
|
||||||
|
public class ExprLocationBox extends SimpleExpression<Location> {
|
||||||
|
|
||||||
|
private Expression<Location> location1;
|
||||||
|
private Expression<Location> location2;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Location[] get(Event event) {
|
||||||
|
return LocationLib.getBox(location1.getSingle(event), location2.getSingle(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Location> getReturnType() {
|
||||||
|
return Location.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(Event event, boolean b) {
|
||||||
|
return "box between " + location1.toString(event, b) + " and " + location2.toString(event, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
|
||||||
|
location1 = (Expression<Location>) expressions[0];
|
||||||
|
location2 = (Expression<Location>) expressions[1];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package io.github.bi0qaw.biosphere.expression;
|
||||||
|
|
||||||
|
import ch.njol.skript.doc.Description;
|
||||||
|
import ch.njol.skript.doc.Examples;
|
||||||
|
import ch.njol.skript.doc.Name;
|
||||||
|
import ch.njol.skript.lang.Expression;
|
||||||
|
import ch.njol.skript.lang.SkriptParser;
|
||||||
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
|
import ch.njol.util.Kleenean;
|
||||||
|
import io.github.bi0qaw.biosphere.util.LocationLib;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
|
||||||
|
@Name("Location Box Outline")
|
||||||
|
@Description("Creates a list of vectors in the shape of a box including corners and edges. The density value controls the amount of points. A higher number increases the amount of points. A density of 1 corresponds to 1 point per block.")
|
||||||
|
@Examples({"set {_boxoutline::*} to box outline between player and location 5 right, 5 in front and 5 above player with density 5",
|
||||||
|
"show happy villager at {_boxoutline::*}"})
|
||||||
|
public class ExprLocationBoxOutline extends SimpleExpression<Location> {
|
||||||
|
|
||||||
|
private Expression<Location> location1;
|
||||||
|
private Expression<Location> location2;
|
||||||
|
private Expression<Number> density;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Location[] get(Event event) {
|
||||||
|
return LocationLib.getBoxOutline(location1.getSingle(event), location2.getSingle(event), density.getSingle(event).doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Location> getReturnType() {
|
||||||
|
return Location.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(Event event, boolean b) {
|
||||||
|
return "box outline between " + location1.toString(event, b) + " and " + location2.toString(event, b) + " with denstiy " + density.toString(event, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
|
||||||
|
location1 = (Expression<Location>) expressions[0];
|
||||||
|
location2 = (Expression<Location>) expressions[1];
|
||||||
|
density = (Expression<Number>) expressions[2];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@ import ch.njol.util.Kleenean;
|
|||||||
public class ExprLocationPolygon extends SimpleExpression<Location>{
|
public class ExprLocationPolygon extends SimpleExpression<Location>{
|
||||||
|
|
||||||
private Expression<Location> locations;
|
private Expression<Location> locations;
|
||||||
private Expression<Integer> points;
|
private Expression<Number> points;
|
||||||
private Expression<Number> radius;
|
private Expression<Number> radius;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -40,7 +40,7 @@ public class ExprLocationPolygon extends SimpleExpression<Location>{
|
|||||||
@Override
|
@Override
|
||||||
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, ParseResult arg3) {
|
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, ParseResult arg3) {
|
||||||
locations = (Expression<Location>) expr[0];
|
locations = (Expression<Location>) expr[0];
|
||||||
points = (Expression<Integer>) expr[1];
|
points = (Expression<Number>) expr[1];
|
||||||
radius = (Expression<Number>) expr[2];
|
radius = (Expression<Number>) expr[2];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import ch.njol.util.Kleenean;
|
|||||||
public class ExprLocationPolygonOutline extends SimpleExpression<Location>{
|
public class ExprLocationPolygonOutline extends SimpleExpression<Location>{
|
||||||
|
|
||||||
private Expression<Location> locations;
|
private Expression<Location> locations;
|
||||||
private Expression<Integer> points;
|
private Expression<Number> points;
|
||||||
private Expression<Number> radius;
|
private Expression<Number> radius;
|
||||||
private Expression<Number> density;
|
private Expression<Number> density;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class ExprLocationPolygonOutline extends SimpleExpression<Location>{
|
|||||||
@Override
|
@Override
|
||||||
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, ParseResult arg3) {
|
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, ParseResult arg3) {
|
||||||
locations = (Expression<Location>) expr[0];
|
locations = (Expression<Location>) expr[0];
|
||||||
points = (Expression<Integer>) expr[1];
|
points = (Expression<Number>) expr[1];
|
||||||
radius = (Expression<Number>) expr[2];
|
radius = (Expression<Number>) expr[2];
|
||||||
density = (Expression<Number>) expr[3];
|
density = (Expression<Number>) expr[3];
|
||||||
return true;
|
return true;
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package io.github.bi0qaw.biosphere.expression;
|
||||||
|
|
||||||
|
import ch.njol.skript.doc.Description;
|
||||||
|
import ch.njol.skript.doc.Examples;
|
||||||
|
import ch.njol.skript.doc.Name;
|
||||||
|
import ch.njol.skript.lang.Expression;
|
||||||
|
import ch.njol.skript.lang.SkriptParser;
|
||||||
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
|
import ch.njol.util.Kleenean;
|
||||||
|
import io.github.bi0qaw.biosphere.util.VectorLib;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
|
||||||
|
@Name("Vector Box")
|
||||||
|
@Description("Creates a list of vectors in the shape of a box (only the corners!).")
|
||||||
|
@Examples({"set {_box::*} to vector box between vector -2.5, -2.5, -2.5 and vector 2.5, 2.5, 2.5",
|
||||||
|
"show happy villager at player's head offset by {_box::*}"})
|
||||||
|
public class ExprVectorBox extends SimpleExpression<Vector>{
|
||||||
|
|
||||||
|
private Expression<Vector> vector1;
|
||||||
|
private Expression<Vector> vector2;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Vector[] get(Event event) {
|
||||||
|
return VectorLib.getBox(vector1.getSingle(event), vector2.getSingle(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Vector> getReturnType() {
|
||||||
|
return Vector.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(Event event, boolean b) {
|
||||||
|
return "vector box between " + vector1.toString(event, b) + " and " + vector2.toString(event, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
|
||||||
|
vector1 = (Expression<Vector>) expressions[0];
|
||||||
|
vector2 = (Expression<Vector>) expressions[1];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package io.github.bi0qaw.biosphere.expression;
|
||||||
|
|
||||||
|
import ch.njol.skript.doc.Description;
|
||||||
|
import ch.njol.skript.doc.Examples;
|
||||||
|
import ch.njol.skript.doc.Name;
|
||||||
|
import ch.njol.skript.lang.Expression;
|
||||||
|
import ch.njol.skript.lang.SkriptParser;
|
||||||
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
|
import ch.njol.util.Kleenean;
|
||||||
|
import io.github.bi0qaw.biosphere.util.VectorLib;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
|
||||||
|
@Name("Vector Box Outline")
|
||||||
|
@Description("Creates a list of vectors in the shape of a box including corners and edges. The density value controls the amount of points. A higher number increases the amount of points. A density of 1 corresponds to 1 point per block.")
|
||||||
|
@Examples({"set {_boxoutline::*} to vector box outline between vector -2.5, -2.5, -2.5 and vector 2.5, 2.5, 2.5 with density 5",
|
||||||
|
"show happy villager at player's head offset by {_boxoutline::*}"})
|
||||||
|
public class ExprVectorBoxOutline extends SimpleExpression<Vector>{
|
||||||
|
|
||||||
|
private Expression<Vector> vector1;
|
||||||
|
private Expression<Vector> vector2;
|
||||||
|
private Expression<Number> density;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Vector[] get(Event event) {
|
||||||
|
return VectorLib.getBoxOutline(vector1.getSingle(event), vector2.getSingle(event), density.getSingle(event).doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Vector> getReturnType() {
|
||||||
|
return Vector.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(Event event, boolean b) {
|
||||||
|
return "vector box outline between " + vector1.toString(event, b) + " and " + vector2.toString(event, b) + " with density " + density.toString(event, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
|
||||||
|
vector1 = (Expression<Vector>) expressions[0];
|
||||||
|
vector2 = (Expression<Vector>) expressions[1];
|
||||||
|
density = (Expression<Number>) expressions[2];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ import javax.annotation.Nullable;
|
|||||||
"#shows particles in the shape of a triangle at the player"})
|
"#shows particles in the shape of a triangle at the player"})
|
||||||
public class ExprVectorPolygon extends SimpleExpression<Vector>{
|
public class ExprVectorPolygon extends SimpleExpression<Vector>{
|
||||||
|
|
||||||
private Expression<Integer> vertices;
|
private Expression<Number> vertices;
|
||||||
private Expression<Number> radius;
|
private Expression<Number> radius;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,7 +36,7 @@ public class ExprVectorPolygon extends SimpleExpression<Vector>{
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
|
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
|
||||||
vertices = (Expression<Integer>) expr[0];
|
vertices = (Expression<Number>) expr[0];
|
||||||
radius = (Expression<Number>) expr[1];
|
radius = (Expression<Number>) expr[1];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import javax.annotation.Nullable;
|
|||||||
"#shows particles in the shape of a hexagon (6 points) at the player"})
|
"#shows particles in the shape of a hexagon (6 points) at the player"})
|
||||||
public class ExprVectorPolygonOutline extends SimpleExpression<Vector> {
|
public class ExprVectorPolygonOutline extends SimpleExpression<Vector> {
|
||||||
|
|
||||||
private Expression<Integer> vertices;
|
private Expression<Number> vertices;
|
||||||
private Expression<Number> radius;
|
private Expression<Number> radius;
|
||||||
private Expression<Number> density;
|
private Expression<Number> density;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class ExprVectorPolygonOutline extends SimpleExpression<Vector> {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
|
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
|
||||||
vertices = (Expression<Integer>) expr[0];
|
vertices = (Expression<Number>) expr[0];
|
||||||
radius = (Expression<Number>) expr[1];
|
radius = (Expression<Number>) expr[1];
|
||||||
density = (Expression<Number>) expr[2];
|
density = (Expression<Number>) expr[2];
|
||||||
return true;
|
return true;
|
||||||
|
@ -14,6 +14,16 @@ public class LocationLib {
|
|||||||
return offset(locations, circle);
|
return offset(locations, circle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Location[] getBox(Location location1, Location location2) {
|
||||||
|
Vector[] box = VectorLib.getBox(location1.toVector(), location2.toVector());
|
||||||
|
return toLocation(box, location1.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Location[] getBoxOutline(Location location1, Location location2, double density) {
|
||||||
|
Vector[] boxoutline = VectorLib.getBoxOutline(location1.toVector(), location2.toVector(), density);
|
||||||
|
return toLocation(boxoutline, location1.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
public static Location[] getCube(Location[] locations, double radius) {
|
public static Location[] getCube(Location[] locations, double radius) {
|
||||||
Vector[] cube = VectorLib.getCube(radius);
|
Vector[] cube = VectorLib.getCube(radius);
|
||||||
return offset(locations, cube);
|
return offset(locations, cube);
|
||||||
|
@ -3,6 +3,7 @@ package io.github.bi0qaw.biosphere.util;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -81,6 +82,39 @@ public class VectorLib {
|
|||||||
return vectors.toArray(new Vector[vectors.size()]);
|
return vectors.toArray(new Vector[vectors.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector[] getBox(Vector vector1, Vector vector2) {
|
||||||
|
Vector[] vectors = new Vector[8];
|
||||||
|
Vector lower = VectorMath.getLower(vector1, vector2);
|
||||||
|
Vector upper = VectorMath.getUpper(vector1, vector2);
|
||||||
|
vectors[0] = lower.clone();
|
||||||
|
vectors[1] = new Vector(upper.getX(), lower.getY(), lower.getZ());
|
||||||
|
vectors[2] = new Vector(lower.getX(), upper.getY(), lower.getZ());
|
||||||
|
vectors[3] = new Vector(lower.getX(), lower.getY(), upper.getZ());
|
||||||
|
vectors[4] = new Vector(upper.getX(), upper.getY(), lower.getZ());
|
||||||
|
vectors[5] = new Vector(upper.getX(), lower.getY(), upper.getZ());
|
||||||
|
vectors[6] = new Vector(lower.getX(), upper.getY(), upper.getZ());
|
||||||
|
vectors[7] = upper.clone();
|
||||||
|
return vectors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector[] getBoxOutline(Vector vector1, Vector vector2, double density) {
|
||||||
|
Vector[] box = getBox(vector1, vector2);
|
||||||
|
List<Vector> vecs = new ArrayList<Vector>();
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[0], box[1], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[0], box[2], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[0], box[3], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[1], box[4], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[1], box[5], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[2], box[4], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[2], box[6], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[3], box[5], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[3], box[6], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[4], box[7], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[5], box[7], density)));
|
||||||
|
vecs.addAll(Arrays.asList(linkLine(box[6], box[7], density)));
|
||||||
|
return vecs.toArray(new Vector[vecs.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
public static Vector[] getCube(double radius) {
|
public static Vector[] getCube(double radius) {
|
||||||
Vector[] vectors = new Vector[8];
|
Vector[] vectors = new Vector[8];
|
||||||
double d = radius / SQRT2;
|
double d = radius / SQRT2;
|
||||||
|
@ -33,6 +33,20 @@ public class VectorMath {
|
|||||||
return new Vector(x,0, z).multiply(div).setY(y);
|
return new Vector(x,0, z).multiply(div).setY(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector getLower(Vector vector1, Vector vector2) {
|
||||||
|
double x = Math.min(vector1.getX(), vector2.getX());
|
||||||
|
double y = Math.min(vector1.getY(), vector2.getY());
|
||||||
|
double z = Math.min(vector1.getZ(), vector2.getZ());
|
||||||
|
return new Vector(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector getUpper(Vector vector1, Vector vector2) {
|
||||||
|
double x = Math.max(vector1.getX(), vector2.getX());
|
||||||
|
double y = Math.max(vector1.getY(), vector2.getY());
|
||||||
|
double z = Math.max(vector1.getZ(), vector2.getZ());
|
||||||
|
return new Vector(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
public static float getYaw(Vector vector) {
|
public static float getYaw(Vector vector) {
|
||||||
if (((Double) vector.getX()).equals((double) 0) && ((Double) vector.getZ()).equals((double) 0)){
|
if (((Double) vector.getX()).equals((double) 0) && ((Double) vector.getZ()).equals((double) 0)){
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name: Biosphere2
|
name: Biosphere2
|
||||||
main: io.github.bi0qaw.biosphere.Biosphere
|
main: io.github.bi0qaw.biosphere.Biosphere
|
||||||
author: bi0qaw
|
author: bi0qaw
|
||||||
version: 1.0.1
|
version: 1.0.2
|
Loading…
Reference in New Issue
Block a user