From 377512f8fc417cdbd73a1c638742f13144306c3b Mon Sep 17 00:00:00 2001 From: bi0qaw Date: Sat, 20 Jan 2018 18:18:00 +0100 Subject: [PATCH] Update to 1.0.2 Added: - Location Box - Location Box Outline - Vector Box - Vector Box Outline --- pom.xml | 2 +- .../io/github/bi0qaw/biosphere/Biosphere.java | 12 +++-- .../biosphere/expression/ExprLocationBox.java | 50 ++++++++++++++++++ .../expression/ExprLocationBoxOutline.java | 52 +++++++++++++++++++ .../expression/ExprLocationPolygon.java | 4 +- .../ExprLocationPolygonOutline.java | 6 +-- .../biosphere/expression/ExprVectorBox.java | 50 ++++++++++++++++++ .../expression/ExprVectorBoxOutline.java | 52 +++++++++++++++++++ .../expression/ExprVectorPolygon.java | 4 +- .../expression/ExprVectorPolygonOutline.java | 4 +- .../bi0qaw/biosphere/util/LocationLib.java | 10 ++++ .../bi0qaw/biosphere/util/VectorLib.java | 34 ++++++++++++ .../bi0qaw/biosphere/util/VectorMath.java | 14 +++++ src/main/resources/plugin.yml | 2 +- 14 files changed, 281 insertions(+), 15 deletions(-) create mode 100644 src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationBox.java create mode 100644 src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationBoxOutline.java create mode 100644 src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorBox.java create mode 100644 src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorBoxOutline.java diff --git a/pom.xml b/pom.xml index 44b73b2..814c150 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.bi0qaw biosphere2 - 1.0.1 + 1.0.2 diff --git a/src/main/java/io/github/bi0qaw/biosphere/Biosphere.java b/src/main/java/io/github/bi0qaw/biosphere/Biosphere.java index e13c43c..5272d74 100644 --- a/src/main/java/io/github/bi0qaw/biosphere/Biosphere.java +++ b/src/main/java/io/github/bi0qaw/biosphere/Biosphere.java @@ -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(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(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%"); @@ -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(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(ExprLocationPolygon.class, Location.class, ExpressionType.SIMPLE, "polygon[s] at %locations% with %integer% (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(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 %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(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]]"); @@ -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(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(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%"); @@ -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(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(ExprVectorPolygon.class, Vector.class, ExpressionType.SIMPLE, "[vector ]polygon with %integer% (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(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 %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(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]]"); diff --git a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationBox.java b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationBox.java new file mode 100644 index 0000000..06a8036 --- /dev/null +++ b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationBox.java @@ -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 { + + private Expression location1; + private Expression 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 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) expressions[0]; + location2 = (Expression) expressions[1]; + return true; + } +} diff --git a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationBoxOutline.java b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationBoxOutline.java new file mode 100644 index 0000000..4775008 --- /dev/null +++ b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationBoxOutline.java @@ -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 { + + private Expression location1; + private Expression location2; + private Expression 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 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) expressions[0]; + location2 = (Expression) expressions[1]; + density = (Expression) expressions[2]; + return true; + } +} diff --git a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationPolygon.java b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationPolygon.java index 7adf973..bb18232 100755 --- a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationPolygon.java +++ b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationPolygon.java @@ -23,7 +23,7 @@ import ch.njol.util.Kleenean; public class ExprLocationPolygon extends SimpleExpression{ private Expression locations; - private Expression points; + private Expression points; private Expression radius; @Override @@ -40,7 +40,7 @@ public class ExprLocationPolygon extends SimpleExpression{ @Override public boolean init(Expression[] expr, int arg1, Kleenean arg2, ParseResult arg3) { locations = (Expression) expr[0]; - points = (Expression) expr[1]; + points = (Expression) expr[1]; radius = (Expression) expr[2]; return true; } diff --git a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationPolygonOutline.java b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationPolygonOutline.java index 35c8dcf..e654eaa 100755 --- a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationPolygonOutline.java +++ b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprLocationPolygonOutline.java @@ -21,7 +21,7 @@ import ch.njol.util.Kleenean; public class ExprLocationPolygonOutline extends SimpleExpression{ private Expression locations; - private Expression points; + private Expression points; private Expression radius; private Expression density; @@ -39,7 +39,7 @@ public class ExprLocationPolygonOutline extends SimpleExpression{ @Override public boolean init(Expression[] expr, int arg1, Kleenean arg2, ParseResult arg3) { locations = (Expression) expr[0]; - points = (Expression) expr[1]; + points = (Expression) expr[1]; radius = (Expression) expr[2]; density = (Expression) expr[3]; return true; @@ -53,7 +53,7 @@ public class ExprLocationPolygonOutline extends SimpleExpression{ @Override @Nullable protected Location[] get(Event e) { - int p = points.getSingle(e).intValue(); + int p = points.getSingle(e).intValue(); double r = radius.getSingle(e).doubleValue(); double d = density.getSingle(e).doubleValue(); return LocationLib.getPolygonOutline(locations.getArray(e), p, r, d); diff --git a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorBox.java b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorBox.java new file mode 100644 index 0000000..9f8224e --- /dev/null +++ b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorBox.java @@ -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{ + + private Expression vector1; + private Expression 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 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) expressions[0]; + vector2 = (Expression) expressions[1]; + return true; + } +} diff --git a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorBoxOutline.java b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorBoxOutline.java new file mode 100644 index 0000000..adf18c2 --- /dev/null +++ b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorBoxOutline.java @@ -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{ + + private Expression vector1; + private Expression vector2; + private Expression 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 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) expressions[0]; + vector2 = (Expression) expressions[1]; + density = (Expression) expressions[2]; + return true; + } +} diff --git a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorPolygon.java b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorPolygon.java index 09e80bd..97144b7 100644 --- a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorPolygon.java +++ b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorPolygon.java @@ -20,7 +20,7 @@ import javax.annotation.Nullable; "#shows particles in the shape of a triangle at the player"}) public class ExprVectorPolygon extends SimpleExpression{ - private Expression vertices; + private Expression vertices; private Expression radius; @Override @@ -36,7 +36,7 @@ public class ExprVectorPolygon extends SimpleExpression{ @SuppressWarnings("unchecked") @Override public boolean init(Expression[] expr, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) { - vertices = (Expression) expr[0]; + vertices = (Expression) expr[0]; radius = (Expression) expr[1]; return true; } diff --git a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorPolygonOutline.java b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorPolygonOutline.java index 7a23364..e7cb1dd 100644 --- a/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorPolygonOutline.java +++ b/src/main/java/io/github/bi0qaw/biosphere/expression/ExprVectorPolygonOutline.java @@ -20,7 +20,7 @@ import javax.annotation.Nullable; "#shows particles in the shape of a hexagon (6 points) at the player"}) public class ExprVectorPolygonOutline extends SimpleExpression { - private Expression vertices; + private Expression vertices; private Expression radius; private Expression density; @@ -37,7 +37,7 @@ public class ExprVectorPolygonOutline extends SimpleExpression { @SuppressWarnings("unchecked") @Override public boolean init(Expression[] expr, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) { - vertices = (Expression) expr[0]; + vertices = (Expression) expr[0]; radius = (Expression) expr[1]; density = (Expression) expr[2]; return true; diff --git a/src/main/java/io/github/bi0qaw/biosphere/util/LocationLib.java b/src/main/java/io/github/bi0qaw/biosphere/util/LocationLib.java index 61b0d06..d016bd9 100644 --- a/src/main/java/io/github/bi0qaw/biosphere/util/LocationLib.java +++ b/src/main/java/io/github/bi0qaw/biosphere/util/LocationLib.java @@ -14,6 +14,16 @@ public class LocationLib { 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) { Vector[] cube = VectorLib.getCube(radius); return offset(locations, cube); diff --git a/src/main/java/io/github/bi0qaw/biosphere/util/VectorLib.java b/src/main/java/io/github/bi0qaw/biosphere/util/VectorLib.java index 5504687..b40fbd7 100644 --- a/src/main/java/io/github/bi0qaw/biosphere/util/VectorLib.java +++ b/src/main/java/io/github/bi0qaw/biosphere/util/VectorLib.java @@ -3,6 +3,7 @@ package io.github.bi0qaw.biosphere.util; import org.bukkit.Location; import org.bukkit.util.Vector; +import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -81,6 +82,39 @@ public class VectorLib { 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 vecs = new ArrayList(); + 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) { Vector[] vectors = new Vector[8]; double d = radius / SQRT2; diff --git a/src/main/java/io/github/bi0qaw/biosphere/util/VectorMath.java b/src/main/java/io/github/bi0qaw/biosphere/util/VectorMath.java index a706afd..d61a361 100644 --- a/src/main/java/io/github/bi0qaw/biosphere/util/VectorMath.java +++ b/src/main/java/io/github/bi0qaw/biosphere/util/VectorMath.java @@ -33,6 +33,20 @@ public class VectorMath { 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) { if (((Double) vector.getX()).equals((double) 0) && ((Double) vector.getZ()).equals((double) 0)){ return 0; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index cbd4d4e..ef8ce8b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ name: Biosphere2 main: io.github.bi0qaw.biosphere.Biosphere author: bi0qaw -version: 1.0.1 \ No newline at end of file +version: 1.0.2 \ No newline at end of file