Compare commits

...

16 Commits

Author SHA1 Message Date
Govindas f08c74cfb9 Fix 2.6.4 Skript support & fix compilation 2023-03-08 17:33:41 +02:00
bi0qaw a69f531562
Update README.md 2018-01-20 18:36:01 +01:00
bi0qaw b6220bf829 Added biosphere-test.sk 2018-01-20 18:20:05 +01:00
bi0qaw c4a3ae2146 Merge branch 'master' of https://github.com/bi0qaw/biosphere2 2018-01-20 18:18:23 +01:00
bi0qaw 377512f8fc Update to 1.0.2
Added:
 - Location Box
 - Location Box Outline
 - Vector Box
 - Vector Box Outline
2018-01-20 18:18:00 +01:00
bi0qaw c086762065
Update README.md 2017-11-26 19:10:10 +01:00
bi0qaw f12d32dd27
Update gallery.sk 2017-11-26 18:37:47 +01:00
bi0qaw 10ce8a6da6
Update gallery.sk 2017-11-26 01:22:42 +01:00
bi0qaw cbf367538e
Create gallery.sk 2017-11-26 01:21:40 +01:00
bi0qaw 0e39e01c8b
Update README.md 2017-11-25 18:05:01 +01:00
bi0qaw 719aa85317
Update README.md 2017-11-25 18:04:43 +01:00
bi0qaw a649463bd0 Update to 1.0.1 2017-11-25 18:02:35 +01:00
bi0qaw b39b60cf74 Merge remote-tracking branch 'remotes/origin/master' 2017-11-25 17:51:00 +01:00
bi0qaw e36f3041c2 Update to 1.0.1 2017-11-25 17:49:24 +01:00
bi0qaw d5c3c110fc
Create README.md 2017-11-25 17:42:51 +01:00
bi0qaw b9db7accef
Create LICENSE 2017-11-22 19:37:11 +01:00
128 changed files with 1275 additions and 167 deletions

21
LICENSE Executable file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 bi0qaw
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

13
README.md Executable file
View File

@ -0,0 +1,13 @@
# Biosphere2
Biosphere2 is a [Skript](https://github.com/bensku/Skript) addon that adds concise syntax to the [Skript](https://github.com/bensku/Skript) language for all kind of location and vector manipulations.
#### Current Version: [1.0.2](https://github.com/bi0qaw/biosphere2/releases) (2018-1-20)
Head over to the [wiki](https://github.com/bi0qaw/biosphere2/wiki) for an extensive documentation of Biosphere2's features.
Syntax documentation can also be found on:
* [Skript Hub](http://skripthub.net/docs/?addon=Biosphere2)
* [skUnity](https://docs.skunity.com/syntax/search/addon:Biosphere2)
Examples are up and can be found in the [Gallery](https://github.com/bi0qaw/biosphere2/wiki/Gallery)
Use the [issue tracker](https://github.com/bi0qaw/biosphere2/issues) to report any bugs or for other discussion. You can alternatively also create a post on the [skUnity forums](https://forums.skunity.com/forums/#skript). Feel also free to join the [Discord](https://discord.gg/4zesrPH) chat.

14
biosphere2.iml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
<platformType>PAPER</platformType>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>

48
pom.xml Normal file → Executable file
View File

@ -6,58 +6,50 @@
<groupId>io.github.bi0qaw</groupId>
<artifactId>biosphere2</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0.3</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>bensku-repo</id>
<url>https://raw.githubusercontent.com/bensku/mvn-repo/master</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo</url>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>destroystokyo-repo</id>
<id>mvnrepository</id>
<url>https://mvnrepository.com</url>
</repository>
<repository>
<id>PaperMC</id>
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>jitpack-repo</id>
<url>https://jitpack.io</url>
<id>sk89q</id>
<url>http://maven.sk89q.com/repo</url>
</repository>
</repositories>
<dependencies>
<!--Skript-->
<dependency>
<groupId>ch.njol</groupId>
<artifactId>skript</artifactId>
<version>2.2-dev32</version>
<scope>compile</scope>
<groupId>com.github.SkriptLang</groupId>
<artifactId>Skript</artifactId>
<version>2.6.1</version>
<scope>provided</scope>
</dependency>
<!--Spigot API-->
<dependency>
@ -66,6 +58,12 @@
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

256
scripts/biosphere-test.sk Executable file
View File

@ -0,0 +1,256 @@
command /biosphere-test:
trigger:
set {_num} to 180 in radian
send "---------------------------"
send "in radian"
send "%{_num}% == 3.14"
set {_num} to 3.14 in degree
send "---------------------------"
send "in degree"
send "%{_num}% == 179.91"
set {_frame} to frame of player
send "---------------------------"
send "frame of player"
send "%{_frame}% == frame:yaw: %yaw of player%, pitch: %pitch of player%"
set {_yaw} to frame yaw of {_frame}
set {_pitch} to frame pitch of {_frame}
send "---------------------------"
send "yaw/pitch of frame"
send "yaw: %{_yaw}%, pitch: %{_pitch}% == yaw: %yaw of player%, pitch: %pitch of player%"
set frame yaw of {_frame} to 50
set frame pitch of {_frame} to -80
set {_yaw} to frame yaw of {_frame}
set {_pitch} to frame pitch of {_frame}
send "---------------------------"
send "set yaw/pitch of frame"
send "yaw: %{_yaw}%, pitch: %{_pitch}% == yaw: 50, pitch: -80"
add 10 to frame yaw of {_frame}
remove 10 from frame pitch of {_frame}
set {_yaw} to frame yaw of {_frame}
set {_pitch} to frame pitch of {_frame}
send "---------------------------"
send "add/remove yaw/pitch of frame"
send "yaw: %{_yaw}%, pitch: %{_pitch}% == yaw: 60, pitch: -90"
set {_frame} to frame with yaw 40 and pitch 10
set {_yaw} to frame yaw of {_frame}
set {_pitch} to frame pitch of {_frame}
send "---------------------------"
send "frame from yaw and pitch"
send "yaw: %{_yaw}%, pitch: %{_pitch}% == yaw: 40, pitch: 10"
set {_world} to world of player
set {_l::1} to location(1, 2, 3, {_world})
set {_l::2} to location(3, 2, 1, {_world})
set {_l::3} to location(2, 2, 2, {_world})
set {_midpoint} to midpoint of {_l::*}
send "---------------------------"
send "midpoint of locations"
send "%{_midpoint}% == %{_l::3}%"
set {_l1} to location(0, 10, 20, {_world})
set {_l2} to location(10, 20, 30, {_world})
set {_l::*} to linear coordinate 0.1 from {_l1} to {_l2}
set {_coord} to location(1, 11, 21, {_world})
send "---------------------------"
send "location linear coordinate"
send "%{_l::1}% == %{_coord}%"
set {_l::*} to cylinder coordinate at {_l1} with radius 2, yaw 90, height 3
set {_loc2} to location(-2, 13, 20, {_world})
send "---------------------------"
send "location cylindrical coordinate"
send "%{_l::1}% == %{_loc2}%"
set {_l::*} to spherical coordinate at {_l1} with radius 3*sqrt(2), yaw 90 and pitch 45
set {_loc2} to location(-3, 7, 20, {_world})
send "---------------------------"
send "location spherical coordinate"
send "%{_l::1}% == %{_loc2}%"
set {_origin} to location(0, 0, 0, {_world})
send "---------------------------"
send "location rotate around x/y/z axis"
set {_l::*} to {_l1} rotated around x-axis at {_origin} with angle 90
set {_loc2} to location(0, 20, -10, {_world})
send "%{_l::1}% == %{_loc2}%"
set {_l::*} to {_l1} rotated around y-axis at {_origin} with angle 90
set {_loc2} to location(-20, 10, 0, {_world})
send "%{_l::1}% == %{_loc2}%"
set {_l::*} to {_l1} rotated around z-axis at {_origin} with angle 90
set {_loc2} to location(10, 0, 20, {_world})
send "%{_l::1}% == %{_loc2}%"
set {_l::*} to {_l1} reflected at {_origin}
set {_loc2} to location(0, -10, -20, {_world})
set {_l2::*} to {_l1} reflected at {_origin} in direction vector 0, -1, 1
set {_loc3} to location(0, 10, -20, {_world})
send "---------------------------"
send "location reflection"
send "%{_l::1}% == %{_loc2}%"
send "%{_l2::1}% == %{_loc3}%"
set {_l::*} to {_l2} scaled at {_origin} by -1
set {_loc2} to location(-10, -20, -30, {_world})
set {_l2::*} to {_l2} scaled at {_origin} by -1 and direction vector 1, 2, 3
set {_loc3} to location(-10, -40, -90, {_world})
send "---------------------------"
send "location scaling"
send "%{_l::1}% == %{_loc2}%"
send "%{_l2::1}% == %{_loc3}%"
set {_l::*} to {_l1} with center {_origin} moved to {_l2}
set {_loc2} to location(10, 30, 50, {_world})
send "---------------------------"
send "location shift/move"
send "%{_l::1}% == %{_loc2}%"
set {_l} to {_l1} offset by vector 1, 2, 3
set {_loc} to location(1, 12, 23, {_world})
send "---------------------------"
send "location offset"
send "%{_l}% == %{_loc}%"
set {_v1} to vector 1, 0, 0 in frame of player
set {_v2} to vector from player to location 1 in front of player
send "---------------------------"
send "vector in frame"
send "%{_v1}% == %{_v2}%"
set {_v::1} to vector 1, 2, 3
set {_v::2} to vector 3, 2, 1
set {_v::3} to vector 2, 2, 2
set {_midpoint} to vector midpoint of {_v::*}
set {_vec} to vector 2, 2, 2
send "---------------------------"
send "vector midpoint"
send "%{_midpoint}% == %{_vec}%"
set {_v::*} to vector 1, 2, 3 moved by vector 1, 2, 3
set {_vec} to vector 2, 4, 6
send "---------------------------"
send "vector moved"
send "%{_v::1}% == %{_vec}%"
set {_v::*} to vector vector 2, 4, 6 reflected at vector 1, 2, 3
set {_v2} to vector 0, 0, 0
set {_v1::*} to vector vector 2, 4, 6 reflected at vector 1, 2, 3 in direction vector 1, 2, 3
set {_v3} to vector 0, -2, -6
send "---------------------------"
send "vector reflection"
send "%{_v::1}% == %{_v2}%"
send "%{_v1::1}% == %{_v3}%"
set {_v1} to vector 1, 2, 3 rotated around vector 1, 0, 0 with angle 90
set {_v2} to vector 1, 2, 3 rotated around vector 0, 1, 0 with angle 90
set {_v3} to vector 1, 2, 3 rotated around vector 0, 0, 1 with angle 90
send "---------------------------"
send "vector rotate axis"
send "%{_v1}% == %vector 1, 3, -2%"
send "%{_v2}% == %vector -3, 2, 1%"
send "%{_v3}% == %vector 2, -1, 3%"
set {_v1} to vector 1, 2, 3 rotated around x-axis with angle 90
set {_v2} to vector 1, 2, 3 rotated around y-axis with angle 90
set {_v3} to vector 1, 2, 3 rotated around z-axis with angle 90
send "---------------------------"
send "vector rotate x/y/z-axis"
send "%{_v1}% == %vector 1, 3, -2%"
send "%{_v2}% == %vector -3, 2, 1%"
send "%{_v3}% == %vector 2, -1, 3%"
set {_v1} to vector 1, 2, 3 scaled by 2
set {_v2} to vector 1, 2, 3 scaled by 2 with direction vector 1, 2, 3
send "---------------------------"
send "vector scale"
send "%{_v1}% == %vector 2, 4, 6%"
send "%{_v2}% == %vector 2, 8, 18%"
command /bs-test <text> <text>:
trigger:
if arg-1 is "l", "loc" or "location":
set {_l} to location 5 in front of player
set {_l1} to location 5 in front and 5 left of player
set {_l2} to location 5 in front and 5 right of player
if arg-2 is "box":
set {_box::*} to box between location 2.5 left and 2.5 in front of player and location 2.5 right, 7.5 in front and 5 above player
send "%{_box::*}%/"
show happy villager at {_box::*}
else if arg-2 is "box-outline":
set {_box::*} to box outline between location 2.5 left and 2.5 in front of player and location 2.5 right, 7.5 in front and 5 above player with density 5
show happy villager at {_box::*}
else if arg-2 is "circle":
set {_circle::*} to circle at {_l} with radius 3 and density 5
show happy villager at {_circle::*}
else if arg-2 is "cube":
set {_cube::*} to cube at {_l} with radius 3
show happy villager at {_cube::*}
else if arg-2 is "cube-outline":
set {_cubeoutline::*} to cube outline at {_l} with radius 3 and density 5
show happy villager at {_cubeoutline::*}
else if arg-2 is "helix":
set {_helix::*} to helix at {_l} with radius 2, height 5, step 1 and density 5
show happy villager at {_helix::*}
else if arg-2 is "line":
set {_line::*} to line from {_l1} to {_l2} with density 5
show happy villager at {_line::*}
else if arg-2 is "linked":
set {_l::1} to {_l1}
set {_l::2} to {_l2}
set {_linked::*} to {_l::*} linked with density 5
show happy villager at {_linked::*}
else if arg-2 is "path":
set {_poly::*} to polygon at {_l} with 7 points and radius 3
set {_path::*} to path between {_poly::*} with density 5
show happy villager at {_path::*}
else if arg-2 is "poly" or "polygon":
set {_poly::*} to polygon at {_l} with 10 points and radius 3
show happy villager at {_poly::*}
else if arg-2 is "poly-outline" or "polygon-outline":
set {_polyoutline::*} to polygon outline at {_l} with 10 vertices, radius 3 and density 5
show happy villager at {_polyoutline::*}
else if arg-2 is "sphere":
set {_sphere::*} to sphere at {_l} with radius 3 and density 5
show happy villager at {_sphere::*}
else if arg-2 is "random-sphere":
set {_randomsphere::*} to random sphere at {_l} with radius 3 and density 5
show happy villager at {_randomsphere::*}
else:
send "circle, cube, cube-outline, helix, line, linked, path, polygon, polygon-outline, sphere and random-sphere"
else if arg-1 is "v", "vec" or "vector":
set {_l} to location 5 in front of player
set {_l1} to location 5 in front and 5 left of player
set {_l2} to location 5 in front and 5 right of player
if arg-2 is "box":
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 {_l} offset by {_box::*}
else if arg-2 is "box-outline":
set {_box::*} 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 {_l} offset by {_box::*}
else if arg-2 is "circle":
set {_circle::*} to circle with radius 3 and density 5
show happy villager at {_l} offset by {_circle::*}
else if arg-2 is "cube":
set {_cube::*} to cube with radius 3
show happy villager at {_l} offset by {_cube::*}
else if arg-2 is "cube-outline":
set {_cubeoutline::*} to cube outline with radius 3 and density 5
show happy villager at {_l} offset by {_cubeoutline::*}
else if arg-2 is "helix":
set {_helix::*} to helix with radius 2, height 5, step 1 and density 5
show happy villager at {_l} offset by {_helix::*}
else if arg-2 is "line":
set {_v} to vector from {_l1} to {_l2}
set {_line::*} to line with length vector length of {_v} and density 5
set {_yaw} to vector yaw of {_v}
set {_frame} to frame with yaw {_yaw} and pitch 0
show happy villager at {_l1} offset by {_line::*} in {_frame}
else if arg-2 is "linked":
set {_v::1} to vector from player to {_l1}
set {_v::2} to vector from player to {_l2}
set {_linked::*} to vectors {_v::*} linked with density 5
show happy villager at player offset by {_linked::*}
else if arg-2 is "path":
set {_poly::*} to polygon with 7 points and radius 3
set {_path::*} to vector path between {_poly::*} with density 5
show happy villager at {_l} offset by {_path::*}
else if arg-2 is "polygon":
set {_polygon::*} to polygon with 10 points and radius 3
show happy villager at {_l} offset by {_polygon::*}
else if arg-2 is "polygon-outline":
set {_polygonoutline::*} to vector polygon outline with 10 points, radius 3 and density 5
show happy villager at {_l} offset by {_polygonoutline::*}
else if arg-2 is "sphere":
set {_sphere::*} to sphere with radius 3 and density 5
show happy villager at {_l} offset by {_sphere::*}
else if arg-2 is "random-sphere":
set {_randomsphere::*} to random sphere with radius 3 and density 5
show happy villager at {_l} offset by {_randomsphere::*}
else:
send "circle, cube, cube-outline, helix, line, linked, path, polygon, polygon-outline, sphere and random-sphere"
else:
send "/bs-test location <shape>"
send "/bs-test vector <shape>"

241
scripts/gallery.sk Executable file
View File

@ -0,0 +1,241 @@
function hsvtorgb(col: text, h: number, sat: number, val: number) :: number:
set {_h} to mod({_h}, 360)
if {_sat} > 1:
set {_sat} to 1
else if {_sat} < 0:
set {_sat} to 0
if {_val} > 1:
set {_val} to 1
else if {_val} < 0:
set {_val} to 0
set {_c} to {_val} * {_sat}
set {_hh} to {_h}/60
set {_t} to mod({_hh}, 2) - 1
set {_x} to {_c} * (1 - abs({_t}))
set {_m} to {_v} - {_c}
set {_ret} to {_m}
if {_col} is "red" or "r":
if {_hh} < 1:
add {_c} to {_ret}
else if {_hh} < 2:
add {_x} to {_ret}
else if {_hh} < 4:
set {_ret} to {_ret}
else if {_hh} < 5:
add {_x} to {_ret}
else if {_hh} < 6:
add {_c} to {_ret}
else if {_col} is "green" or "g":
if {_hh} < 1:
add {_x} to {_ret}
else if {_hh} < 2:
add {_c} to {_ret}
else if {_hh} < 3:
add {_c} to {_ret}
else if {_hh} < 4:
add {_x} to {_ret}
else if {_col} is "blue" or "b":
if {_hh} < 2:
set {_ret} to {_ret}
else if {_hh} < 3:
add {_x} to {_ret}
else if {_hh} < 5:
add {_c} to {_ret}
else if {_hh} < 6:
add {_x} to {_ret}
return 0-{_ret}
function rgb(r: number, g: number, b: number, locs: locations):
loop {_locs::*}:
set {_x} to x-coordinate of loop-value
set {_y} to y-coordinate of loop-value
set {_z} to z-coordinate of loop-value
execute command "/particle reddust %{_x}% %{_y}% %{_z}% %{_r}% %{_g}% %{_b}% 1"
function rainbow(h: number, locs: locations):
set {_r} to hsvtorgb("r", {_h}, 1, 1)
set {_g} to hsvtorgb("g", {_h}, 1, 1)
set {_b} to hsvtorgb("b", {_h}, 1, 1)
rgb({_r}, {_g}, {_b}, {_locs::*})
command /color-circles:
trigger:
set {_circle::*} to circle with radius 1 and density 5
set {_line::*} to vector line from vector 0, 2, 0 to vector 0, 0, 0 with density 4
loop {_line::*}:
set {_hue} to random number between 0 and 360
set {_locs::*} to player offset by loop-value offset by {_circle::*}
rainbow({_hue}, {_locs::*})
wait 1 tick
set gamemode of player to spectator
wait 2 seconds
set gamemode of player to creative
command /line-circle:
trigger:
set {_circle::*} to circle with radius 5 and density 1
set {_bigcircle::*} to {_circle::*} scaled by 1.5
loop size of {_circle::*} times:
add vector line from {_circle::%loop-number%} to {_bigcircle::%loop-number%} with density 5 to {_lines::*}
show happy villager at location 8 in front of player offset by {_lines::*}
command /line-circle-2:
trigger:
set {_circle::*} to circle with radius 2.5 and density 2
set {_bigcircle::*} to {_circle::*} scaled by 3
set {_size} to size of {_circle::*}
loop {_size} times:
add vector line from {_circle::%loop-number%} to {_bigcircle::%loop-number%} with density 5 to {_lines::%loop-number%::*}
set {run} to true
while {run} is true:
set {_hue} to 50
loop {_size} times:
set {_locs::*} to location 8 in front of player offset by {_lines::%loop-number%::*}
add 10 to {_hue}
rainbow({_hue}, {_locs::*})
if {run} is true:
wait 1 tick
else:
stop trigger
command /line-vortex:
trigger:
set {_circle::*} to circle with radius 3 and density 2
add {_circle::*} to {_circle::*}
set {_bigcircle::*} to {_circle::*} scaled by 2
loop size of {_circle::*} / 2 times:
add vector line from {_circle::%loop-number%} to {_bigcircle::%loop-number + 7%} with density 5 to {_lines::*}
show happy villager at location 8 in front of player offset by {_lines::*}
command /line-vortex-2:
trigger:
set {_circle::*} to circle with radius 3 and density 2
add {_circle::*} to {_circle::*}
set {_bigcircle::*} to {_circle::*} scaled by 2
set {_smallcircle::*} to {_circle::*} scaled by 0.5
loop size of {_circle::*} / 2 times:
add vector line from {_circle::%loop-number%} to {_bigcircle::%loop-number + 7%} with density 5 to {_lines::*}
add vector line from {_circle::%loop-number%} to {_smallcircle::%loop-number + 7%} with density 5 to {_lines::*}
show happy villager at location 8 in front of player offset by {_lines::*}
command /miniblock-halo <integer>:
trigger:
set {_size} to ceil(100/arg 1) * arg 1
set {_circle::*} to polygon with {_size} points and radius 0.6
add {_circle::*} to {_circle::*}
set {_armorstandoffset} to vector 0.3, 1.5, -0.2
set {_loc} to player offset by {_circle::1}
set {_x} to x-coordinate of {_loc}
set {_y} to y-coordinate of {_loc}
set {_z} to z-coordinate of {_loc}
loop arg-1 times:
execute command "/summon armor_stand %{_x}% %{_y}% %{_z}% {Invisible:1b,Small:1b,Invulnerable:1b,NoBasePlate:1b,NoGravity:1b,Marker:1b,ArmorItems:[{},{},{},{}],HandItems:[{id:red_glazed_terracotta,Count:1b},{}],CustomName:biosphere2-%loop-number%}"
set {_numadd} to {_size} / arg 1
set {run} to true
while {run} is true:
loop arg-1 times:
set {_num::%loop-number-1%} to (loop-number-1 - 1) * {_numadd}
loop {_size} times:
loop arg-1 times:
add 1 to {_num::%loop-number-2%}
set {_loc} to player offset by {_armorstandoffset} offset by {_circle::%{_num::%loop-number-2%}%}
set {_x} to x-coordinate of {_loc}
set {_y} to y-coordinate of {_loc}
set {_z} to z-coordinate of {_loc}
execute command "/tp @e[name=biosphere2-%loop-number-2%] %{_x}% %{_y}% %{_z}%"
if {run} is true:
wait 1 tick
else:
stop trigger
command /rainbow-halo:
trigger:
set {_circle::*} to circle with radius 0.75 and density 5
set {_hue} to 0
set {run} to true
while {run} is true:
loop {_circle::*}:
set {_loc} to location 2 above player offset by loop-value in frame of player
rainbow({_hue}, {_loc})
add 5 to {_hue}
if {_hue} > 360:
set {_hue} to {_hue} - 360
if {run} is true:
wait 2 ticks
else:
stop trigger
command /rainbow-yaw-helix:
trigger:
set {_helix::*} to helix with radius 1, height 2, step 0.25 and density 10
set {_hue} to 0
set {run} to true
while {run} is true:
loop {_helix::*}:
set {_loc} to player offset by loop-value
set {_yaw} to yaw of player
rainbow({_yaw}, {_loc}) # Shows a colored particle at {_loc}
if {run} is true:
wait 1 tick
else:
stop trigger
function rainbow_lines(p: player):
set {_yaw} to random number from 0 to 360
set {_startheight} to random number from -0.5 to 1.5
set {_endheight} to {_startheight} + random number from 1 to 2
set {_hue} to random number from 0 to 360
set {_start} to cylindrical vector with radius 0.75, yaw {_yaw} and height {_startheight}
set {_end} to cylindrical vector with radius 0.75, yaw {_yaw} and height {_endheight}
set {_line::*} to vector line from {_start} to {_end} with density 5
loop {_line::*}:
set {_loc} to {_p} offset by loop-value
rainbow({_hue}, {_loc}) # Shows a colored particle at {_loc}
if {run} is true:
wait 1 tick
else:
stop loop
command /rainbow-lines:
trigger:
set {_line::*} to vector line from vector 0, 0, 0 to vector 0, 1, 0 with density 5
set {_size} to size of {_line::*}
set {run} to true
while {run} is true:
chance of 50%:
rainbow_lines(player) # Shows a colored particle line at {_loc}
wait 5 ticks
command /star <integer=5>:
trigger:
set {_poly::*} to polygon with arg-1 points and radius 5
add {_poly::*} to {_poly::*} # This allows me to use loop-number + 2 without exceeding the list size in the loop
loop arg-1 times:
add vector line from {_poly::%loop-number%} to {_poly::%loop-number + 2%} with density 5 to {_star::*}
show happy villager at location 5 in front of player offset by {_star::*}
command /star-2 <integer=5>:
trigger:
set {_poly::*} to polygon with arg-1 points and radius 5
add {_poly::*} to {_poly::*} # This allows me to use loop-number + 2 without exceeding the list size in the loop
loop arg-1 times:
add vector line from {_poly::%loop-number%} to {_poly::%loop-number + 2%} with density 5 to {_star::*}
add vector line from {_poly::%loop-number%} to {_poly::%loop-number + 4%} with density 5 to {_star::*}
show happy villager at location 5 in front of player offset by {_star::*}
command /star-player <integer=7>:
trigger:
set {_poly::*} to polygon with arg-1 points and radius 5
add {_poly::*} to {_poly::*} # This allows me to use loop-number + 2 without exceeding the list size in the loop
loop arg-1 times:
add vector line from {_poly::%loop-number%} to {_poly::%loop-number + 2%} with density 5 to {_star::*}
set {_star::*} to {_star::*} rotated around z-axis by -90
show happy villager at location 7 in front of player's head offset by {_star::*} in frame of player
command /stopeffect:
trigger:
clear {run}
execute command "/kill @e[name=biosphere2]"
loop 30 times:
execute command "/kill @e[name=biosphere2-%loop-number%]"

48
src/main/java/io/github/bi0qaw/biosphere/Biosphere.java Normal file → Executable file
View File

@ -1,74 +1,74 @@
package io.github.bi0qaw.biosphere;
import io.github.bi0qaw.biosphere.expression.*;
import ch.njol.skript.Skript;
import ch.njol.skript.SkriptAddon;
import ch.njol.skript.lang.ExpressionType;
import io.github.bi0qaw.biosphere.expression.*;
import io.github.bi0qaw.biosphere.type.FrameType;
import io.github.bi0qaw.biosphere.util.Frame;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.type.FrameType;
import io.github.bi0qaw.biosphere.util.Frame;
public class Biosphere extends JavaPlugin {
private static Biosphere plugin;
public void onEnable(){
plugin = this;
Skript.registerAddon(this);
SkriptAddon addon = Skript.registerAddon(this);
new FrameType();
Skript.registerExpression(ExprDegToRad.class, Number.class, ExpressionType.PROPERTY, "%number% [in] rad[ian]");
Skript.registerExpression(ExprRadToDeg.class, Number.class, ExpressionType.PROPERTY, "%number% [in] deg[ree]");
Skript.registerExpression(ExprFrameFromEntity.class, Frame.class, ExpressionType.SIMPLE, new String[]{"frame of %entity%", "%entity%['s] frame"});
Skript.registerExpression(ExprFrameFromEntity.class, Frame.class, ExpressionType.SIMPLE, "frame of %entity%", "%entity%['s] frame");
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%");
Skript.registerExpression(ExprLocationCylinderLoc.class, Location.class, ExpressionType.SIMPLE, "cylinder coordinate[s] at %locations% with radius %number%(,| and) yaw %number%(,| and) height %number%");
Skript.registerExpression(ExprLocationHelix.class, Location.class, ExpressionType.SIMPLE, "heli(x|xes|ces) at %locations% with radius %number%(,| and) height %number%(,| and) step[(height|size)] %number%(,| and) density %number%");
Skript.registerExpression(ExprLocationLine.class, Location.class, ExpressionType.SIMPLE, "line[s] from %locations% to %location% with density %number%");
Skript.registerExpression(ExprLocationLine.class, Location.class, ExpressionType.SIMPLE, "line[s] (between|from) %locations% (and|to) %location% with density %number%");
Skript.registerExpression(ExprLocationLineLoc.class, Location.class, ExpressionType.SIMPLE, "line[ar] (coordinate[s]|position[s]|location[s]) %number% from %locations% to %location%");
Skript.registerExpression(ExprLocationLinkAll.class, Location.class, ExpressionType.SIMPLE, "%locations% (linked|connected) with density %number%");
Skript.registerExpression(ExprLocationMidpoint.class, Location.class, ExpressionType.SIMPLE, "[location ]midpoint of %locations%");
Skript.registerExpression(ExprLocationMove.class, Location.class, ExpressionType.SIMPLE, new String[]{"%locations% with center %location% (moved|shifted) to %location%", "%locations% with center %location% (moved|shifted) to %location%"});
Skript.registerExpression(ExprLocationOffset.class, Location.class, ExpressionType.SIMPLE, "%locations% offset by %vectors%");
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(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 %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]]");
Skript.registerExpression(ExprLocationScale.class, Location.class, ExpressionType.SIMPLE, "%locations% scaled at %location% by %number%[ (in|with|and) direction %-vector%]");
Skript.registerExpression(ExprLocationScale.class, Location.class, ExpressionType.SIMPLE, "%locations% scaled at %location% by %number%[ (in|with|and) direction [of ]%-vector%]");
Skript.registerExpression(ExprLocationSphere.class, Location.class, ExpressionType.SIMPLE, "sphere[s] at %locations% with radius %number%(,| and) density %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(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%");
Skript.registerExpression(ExprVectorHelix.class, Vector.class, ExpressionType.SIMPLE, "[vector ]helix with radius %number%(,| and) height %number%(,| and) step[(height|size)] %number%(,| and) density %number%");
Skript.registerExpression(ExprVectorInFrame.class, Vector.class, ExpressionType.SIMPLE, "[vector ]%vectors% in %frame%");
Skript.registerExpression(ExprVectorLine.class, Vector.class, ExpressionType.SIMPLE, "[vector ]line with length %number%(,| and) density %number%");
Skript.registerExpression(ExprVectorLineBetweenVectors.class, Vector.class, ExpressionType.SIMPLE, "vector line between %vector% and %vector% with density %number%");
Skript.registerExpression(ExprVectorLineBetweenVectors.class, Vector.class, ExpressionType.SIMPLE, "vector line (between|from) %vector% (and|to) %vector% with density %number%");
Skript.registerExpression(ExprVectorLinkAll.class, Vector.class, ExpressionType.SIMPLE, "vector[s] %vectors% (linked|connected) with density %number%");
Skript.registerExpression(ExprVectorMidpoint.class, Vector.class, ExpressionType.SIMPLE, "vector midpoint of %vectors%");
Skript.registerExpression(ExprVectorMove.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% moved by %vector%");
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(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 %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]]");
Skript.registerExpression(ExprVectorScale.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% scaled by %number%[ (in|with|and) direction %-vector%]");
Skript.registerExpression(ExprVectorScale.class, Vector.class, ExpressionType.SIMPLE, "[vector[s] ]%vectors% scaled by %number%[ (in|with|and) direction [of ]%-vector%]");
Skript.registerExpression(ExprVectorSphere.class, Vector.class, ExpressionType.SIMPLE, "[vector ]sphere with radius %number%(,| and) density %number%");
Skript.registerExpression(ExprVectorSphereRand.class, Vector.class, ExpressionType.SIMPLE, "[vector ]random sphere with radius %number%(,| and) density %number%");
}
public static Biosphere getPlugin() {
return plugin;
}
}

View File

@ -4,7 +4,7 @@ import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.VectorLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.VectorLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -3,18 +3,15 @@ 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 io.github.bi0qaw.biosphere.util.LocationLib;
import io.github.bi0qaw.biosphere.util.VectorLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.LocationLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
@Name("Location Cube Outline")
@Description("Creates a list of locations in the shape of a cube, including the corners and vertices of the cube. 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.")

View File

@ -7,7 +7,7 @@ import io.github.bi0qaw.biosphere.util.LocationLib;
import io.github.bi0qaw.biosphere.util.VectorMath;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -7,7 +7,7 @@ import io.github.bi0qaw.biosphere.util.LocationLib;
import io.github.bi0qaw.biosphere.util.VectorLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -3,21 +3,14 @@ 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 io.github.bi0qaw.biosphere.util.LocationLib;
import io.github.bi0qaw.biosphere.util.VectorLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import io.github.bi0qaw.biosphere.util.LocationLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
@Name("Location Line")
@Description("Creates a list of locations in the shape of a line. 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.")

View File

@ -9,8 +9,7 @@ import io.github.bi0qaw.biosphere.util.VectorMath;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;

View File

@ -3,17 +3,15 @@ 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 io.github.bi0qaw.biosphere.util.LocationLib;
import io.github.bi0qaw.biosphere.util.TrigLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
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;
import org.jetbrains.annotations.Nullable;
@Name("Location Link All")
@Description("Creates a list of locations linking multiple locations with lines. 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.")

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.TrigLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -6,7 +6,7 @@ import ch.njol.skript.doc.Name;
import io.github.bi0qaw.biosphere.util.LocationLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -0,0 +1,51 @@
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 Path")
@Description("Creates a path between the locations. 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 {_polygon::*} to polygon at player with 7 points and radius 3",
"set {_path::*} to path between {_polygon::*} with density 5",
"show happy villager at {_path::*}"})
public class ExprLocationPath extends SimpleExpression<Location> {
private Expression<Location> locations;
private Expression<Number> density;
@Override
protected Location[] get(Event event) {
return LocationLib.getPath(locations.getArray(event), density.getSingle(event).doubleValue());
}
@Override
public boolean isSingle() {
return locations.isSingle();
}
@Override
public Class<? extends Location> getReturnType() {
return Location.class;
}
@Override
public String toString(Event event, boolean b) {
return "path between" + locations.toString(event, b) + "with density " + density.toString(event, b);
}
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
locations = (Expression<Location>) expressions[0];
density = (Expression<Number>) expressions[1];
return true;
}
}

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.TrigLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
@ -23,7 +23,7 @@ import ch.njol.util.Kleenean;
public class ExprLocationPolygon extends SimpleExpression<Location>{
private Expression<Location> locations;
private Expression<Integer> points;
private Expression<Number> points;
private Expression<Number> radius;
@Override
@ -40,7 +40,7 @@ public class ExprLocationPolygon extends SimpleExpression<Location>{
@Override
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, ParseResult arg3) {
locations = (Expression<Location>) expr[0];
points = (Expression<Integer>) expr[1];
points = (Expression<Number>) expr[1];
radius = (Expression<Number>) expr[2];
return true;
}

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.TrigLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
@ -21,7 +21,7 @@ import ch.njol.util.Kleenean;
public class ExprLocationPolygonOutline extends SimpleExpression<Location>{
private Expression<Location> locations;
private Expression<Integer> points;
private Expression<Number> points;
private Expression<Number> radius;
private Expression<Number> density;
@ -39,7 +39,7 @@ public class ExprLocationPolygonOutline extends SimpleExpression<Location>{
@Override
public boolean init(Expression<?>[] expr, int arg1, Kleenean arg2, ParseResult arg3) {
locations = (Expression<Location>) expr[0];
points = (Expression<Integer>) expr[1];
points = (Expression<Number>) expr[1];
radius = (Expression<Number>) expr[2];
density = (Expression<Number>) expr[3];
return true;
@ -53,7 +53,7 @@ public class ExprLocationPolygonOutline extends SimpleExpression<Location>{
@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);

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.TrigLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -7,7 +7,7 @@ import io.github.bi0qaw.biosphere.util.LocationLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;

View File

@ -7,7 +7,7 @@ import io.github.bi0qaw.biosphere.util.LocationLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.TrigLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.TrigLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -9,7 +9,7 @@ import io.github.bi0qaw.biosphere.util.VectorMath;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -8,7 +8,7 @@ import io.github.bi0qaw.biosphere.util.TrigLib;
import org.bukkit.Location;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -4,7 +4,7 @@ import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Circle")
@Description("Creates a list of vectors in the shape of a circle")

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Cube")
@Description("Creates a list of vectors in the shape of a cube (only the corners!). To get a list of locations including the cube edges use cube outline.")

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Cube Outline")
@Description("Creates a list of vectors in the shape of a polygon 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.")

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Helix")
@Description("Creates a list of vectors in the shape of a helix. The step parameter determines how many blocks the helix will go upwards in one rotation. 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.")

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Line")
@Description("Creates a list of vectors in the shape of a line. 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.")

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Link All")
@Description("Creates a list of vectors linking multiple vectors with lines. 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.")

View File

@ -7,11 +7,11 @@ 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;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Midpoint")
@Description("Gives the midpoint between vectors.")

View File

@ -11,12 +11,12 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Offset")
@Description("Offset vectors by other vectors.")
@Examples({"set {_circle::*} to circle with radius 1 and density 5",
"set {_offset::*} to {_circle::*} offset by vector 1, 2, 3",
"set {_offset::*} to {_circle::*} moved by vector 1, 2, 3",
"#Moves the circle from the origin (vector 0, 0, 0) to the position at 1, 2, 3"})
public class ExprVectorMove extends SimpleExpression<Vector> {
@ -54,6 +54,6 @@ public class ExprVectorMove extends SimpleExpression<Vector> {
for (Vector v: o) {
totalOffset.add(v);
}
return VectorLib.offset(vectors.getArray(e).clone(), totalOffset);
return VectorLib.move(VectorLib.clone(vectors.getArray(e)), totalOffset);
}
}

View File

@ -0,0 +1,53 @@
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 Offset")
@Description("Adds each offset to all vectors")
@Examples({"#creates a 8 circles on the vertices of a cube and displays them with particles around the player",
"set {_cube::*} to cube with radius 3",
"set {_circle::*} to circle with radius 2 and density 5",
"set {_cube-circles::*} to vectors {_cube::*} offset by {_circle::*}",
"show happy villager at player offset by {_cube-circles::*}"})
public class ExprVectorOffset extends SimpleExpression<Vector> {
private Expression<Vector> vectors;
private Expression<Vector> offsets;
@Override
protected Vector[] get(Event event) {
return VectorLib.offset(vectors.getArray(event), offsets.getArray(event));
}
@Override
public boolean isSingle() {
return vectors.isSingle() && offsets.isSingle();
}
@Override
public Class<? extends Vector> getReturnType() {
return Vector.class;
}
@Override
public String toString(Event event, boolean b) {
return "vector " + vectors.toString(event, b) + " offset by " + offsets.toString(event, b);
}
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
vectors = (Expression<Vector>) expressions[0];
offsets = (Expression<Vector>) expressions[1];
return true;
}
}

View File

@ -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 Path")
@Description("Creates a path between vectors. 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 {_polygon::*} to polygon with 7 points and radius 3",
"set {_path::*} to vector path between {_polygon::*} with density 5",
"show happy villager at player offset by {_path::*}"})
public class ExprVectorPath extends SimpleExpression<Vector>{
private Expression<Vector> vectors;
private Expression<Number> density;
@Override
protected Vector[] get(Event event) {
return VectorLib.getPath(vectors.getArray(event), density.getSingle(event).doubleValue());
}
@Override
public boolean isSingle() {
return vectors.isSingle();
}
@Override
public Class<? extends Vector> getReturnType() {
return Vector.class;
}
@Override
public String toString(Event event, boolean b) {
return "vector path between " + vectors.toString(event, b) + " with density " + density.toString(event, b);
}
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
vectors = (Expression<Vector>) expressions[0];
density = (Expression<Number>) expressions[1];
return true;
}
}

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Polygon")
@Description("Creates a list of vectors in the shape of a polygon (only the corners!). If you want a polygon with edges use polygon outline.")
@ -20,7 +20,7 @@ import javax.annotation.Nullable;
"#shows particles in the shape of a triangle at the player"})
public class ExprVectorPolygon extends SimpleExpression<Vector>{
private Expression<Integer> vertices;
private Expression<Number> vertices;
private Expression<Number> radius;
@Override
@ -36,7 +36,7 @@ public class ExprVectorPolygon extends SimpleExpression<Vector>{
@SuppressWarnings("unchecked")
@Override
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];
return true;
}

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Polygon Outline")
@Description("Creates a list of vectors in the shape of a polygon 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.")
@ -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<Vector> {
private Expression<Integer> vertices;
private Expression<Number> vertices;
private Expression<Number> radius;
private Expression<Number> density;
@ -37,7 +37,7 @@ public class ExprVectorPolygonOutline extends SimpleExpression<Vector> {
@SuppressWarnings("unchecked")
@Override
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];
density = (Expression<Number>) expr[2];
return true;

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Reflection")
@Description("Mirrors vectors in another vector. The direction parameter applies an additional scaling for each axis.")
@ -50,11 +50,12 @@ public class ExprVectorReflection extends SimpleExpression<Vector> {
@Override
@Nullable
protected Vector[] get(Event e) {
Vector[] clones = VectorLib.clone(vectors.getArray(e));
if (direction == null) {
return VectorLib.pointReflection(vectors.getArray(e).clone(), center.getSingle(e));
return VectorLib.pointReflection(clones, center.getSingle(e));
}
else {
return VectorLib.reflection(vectors.getArray(e).clone(), center.getSingle(e), direction.getSingle(e));
return VectorLib.reflection(clones, center.getSingle(e), direction.getSingle(e));
}
}
}

View File

@ -12,7 +12,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Rotate")
@Description("Rotates vectors around a rotation center and a rotation axis by an angle.")
@ -56,7 +56,7 @@ public class ExprVectorRotate extends SimpleExpression<Vector> {
float a = angle.getSingle(e).floatValue();
a = -a; //Skript uses clockwise and VectorMath anti-clockwise rotation
Vector ax = axis.getSingle(e).clone().normalize();
return VectorLib.rotate(vectors.getArray(e).clone(), ax, a);
return VectorLib.rotate(VectorLib.clone(vectors.getArray(e)), ax, a);
}
}

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Rotate XYZ")
@Description("Rotates vectors around a rotation center and rotation axis by an angle.")
@ -54,14 +54,15 @@ public class ExprVectorRotateXYZ extends SimpleExpression<Vector> {
protected Vector[] get(Event e) {
float a = angle.getSingle(e).floatValue();
a = -a; //Skript uses clockwise and VectorMath anti-clockwise rotation
Vector[] clones = VectorLib.clone(vectors.getArray(e));
if (axis == 1) {
return VectorLib.rotateX(vectors.getArray(e).clone(), a);
return VectorLib.rotateX(clones, a);
}
else if (axis == 2) {
return VectorLib.rotateY(vectors.getArray(e).clone(), a);
return VectorLib.rotateY(clones, a);
}
else {
return VectorLib.rotateZ(vectors.getArray(e).clone(), a);
return VectorLib.rotateZ(clones, a);
}
}

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Scale")
@Description("Scales vectors by a scaling factor and an optional direction. The direction parameter adds an additional scaling along the x-, y- and z-axis.")
@ -59,10 +59,10 @@ public class ExprVectorScale extends SimpleExpression<Vector> {
protected Vector[] get(Event e) {
double f = factor.getSingle(e).doubleValue();
if (direction == null) {
return VectorLib.scale(vectors.getArray(e).clone(), f);
return VectorLib.scale(VectorLib.clone(vectors.getArray(e).clone()), f);
}
else {
return VectorLib.scaleDirectional(vectors.getArray(e).clone(), direction.getSingle(e), f);
return VectorLib.scaleDirectional(VectorLib.clone(vectors.getArray(e)), direction.getSingle(e), f);
}
}
}

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Sphere")
@Description("Creates a list of vectors in the shape of a sphere. 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.")

View File

@ -11,7 +11,7 @@ import org.bukkit.event.Event;
import org.bukkit.util.Vector;
import io.github.bi0qaw.biosphere.util.VectorLib;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Name("Vector Random Sphere")
@Description("Creates a list of vectors in the shape of a sphere. The locations are randomly distributed on the sphere surface.")

View File

@ -11,7 +11,6 @@ import ch.njol.yggdrasil.Fields;
import io.github.bi0qaw.biosphere.util.Frame;
import io.github.bi0qaw.biosphere.util.VectorMath;
import java.io.NotSerializableException;
import java.io.StreamCorruptedException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -20,15 +19,15 @@ public class FrameType {
public FrameType(){}
static {
Classes.registerClass(new ClassInfo<Frame>(Frame.class, "frame")
Classes.registerClass(new ClassInfo<>(Frame.class, "frame")
.user("frames?")
.name("Frame")
.description("Reference frame that can be used to get vectors relative to some direction.")
.usage(new String[]{"frame of %entity%", "frame with yaw %number% and pitch %number%"})
.examples(new String[]{"set {_frame} to frame of player", "set {_circle::*} to circle with radius 1 and density 5",
"show happy villager at player's head offset by {_circle::*} in frame of player",
"#shows a particle circle around the player's head with the yaw and pitch of the player"})
.defaultExpression(new EventValueExpression<Frame>(Frame.class))
.usage("frame of %entity%", "frame with yaw %number% and pitch %number%")
.examples("set {_frame} to frame of player", "set {_circle::*} to circle with radius 1 and density 5",
"show happy villager at player's head offset by {_circle::*} in frame of player",
"#shows a particle circle around the player's head with the yaw and pitch of the player")
.defaultExpression(new EventValueExpression<>(Frame.class))
.parser(new Parser<Frame>() {
private final Pattern parsePattern = Pattern.compile("frame:(-?\\d+(\\.\\d+)?),(-?\\d+(\\.\\d+)?)"
@ -63,12 +62,6 @@ public class FrameType {
float pitch = VectorMath.skriptPitch(f.getPitch());
return "frame:" + Skript.toString(yaw) + "," + Skript.toString(pitch);
}
@Override
public String getVariableNamePattern() {
return "frame:(-?\\d+(\\.\\d+)?),(-?\\d+(\\.\\d+)?)";
}
@Override
public String getDebugMessage(Frame f) {
float yaw = VectorMath.skriptYaw(f.getYaw());
@ -78,7 +71,7 @@ public class FrameType {
})
.serializer(new Serializer<Frame>() {
@Override
public Fields serialize(Frame f) throws NotSerializableException {
public Fields serialize(Frame f) {
final Fields fields = new Fields();
float yaw = VectorMath.skriptYaw(f.getYaw());
float pitch = VectorMath.skriptPitch(f.getPitch());
@ -88,12 +81,12 @@ public class FrameType {
}
@Override
public void deserialize(Frame f, Fields fields) throws StreamCorruptedException, NotSerializableException {
public void deserialize(Frame f, Fields fields) {
assert false;
}
@Override
protected Frame deserialize(Fields f) throws StreamCorruptedException, NotSerializableException {
protected Frame deserialize(Fields f) throws StreamCorruptedException {
float yaw = VectorMath.fromSkriptYaw(f.getPrimitive("yaw", float.class));
float pitch = VectorMath.fromSkriptPitch(f.getPrimitive("pitch", float.class));
return new Frame().setFromYawPitch(yaw, pitch);

View File

View File

@ -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);
@ -45,7 +55,6 @@ public class LocationLib {
}
public static Location[] getLineCoordinate(Location[] locations, Location end, double position) {
Location[] coordinates = new Location[locations.length];
Vector delta;
int i = 0;
for (Location l: locations) {
@ -56,6 +65,17 @@ public class LocationLib {
return locations;
}
public static Location[] getPath(Location[] locations, double density) {
if (locations.length > 0) {
Vector[] path = VectorLib.getPath(VectorLib.toVector(locations), density);
World world = locations[0].getWorld();
return toLocation(path, world);
}
else {
return new Location[]{};
}
}
public static Location[] getPolygon(Location[] locations, int points, double radius) {
Vector[] polygon = VectorLib.getPolygon(points, radius);
return offset(locations, polygon);
@ -85,14 +105,8 @@ public class LocationLib {
if (locations.length > 0) {
Vector[] vectors = VectorLib.toVector(locations);
Vector[] linked = VectorLib.linkAll(vectors, density);
Location[] linkedLocations = new Location[linked.length];
World world = locations[0].getWorld();
int i = 0;
for (Vector v: linked) {
linkedLocations[i] = v.toLocation(world);
i++;
}
return linkedLocations;
return toLocation(linked, world);
}
else {
return new Location[] {};

View File

@ -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;
@ -50,6 +51,18 @@ public class VectorLib {
return getPolygon(n, radius);
}
public static Vector[] getPath(Vector[] vectors, double density) {
List<Vector> path = new ArrayList<Vector>();
int length = vectors.length;
if (length < 2) {
return vectors;
}
for (int i = 0; i < length - 1; i++) {
path.addAll(Arrays.asList(linkLine(vectors[i], vectors[i+1], density)));
}
return path.toArray(new Vector[path.size()]);
}
public static Vector[] getPolygon(int points, double radius) {
float deltaAngle = 360 / (float) points;
Vector[] vectors = new Vector[points];
@ -69,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<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) {
Vector[] vectors = new Vector[8];
double d = radius / SQRT2;
@ -106,7 +152,7 @@ public class VectorLib {
}
public static Vector[] getHelix(double radius, double height, double step, double density) {
int points = (int) ( height * 2 * Math.PI * radius * density);
int points = (int) ( Math.abs(height) * 2 * Math.PI * Math.abs(radius) * density);
double deltaAngle = 360 * height / (step * points);
double deltaHeight = height / points;
Vector[] vectors = new Vector[points];
@ -118,11 +164,10 @@ public class VectorLib {
public static Vector[] linkAll(Vector[] vectors, double density) {
List<Vector> vecs = new ArrayList<Vector>();
for (Vector v1 : vectors) {
for (Vector v2 : vectors) {
if (!v1.equals(v2)) {
vecs.addAll(Arrays.asList(linkLine(v1, v2, density)));
}
int length = vectors.length;
for (int i = 0; i < length - 1; i++) {
for (int j = i + 1; j < length ; j++) {
vecs.addAll(Arrays.asList(linkLine(vectors[i], vectors[j], density)));
}
}
return vecs.toArray(new Vector[vecs.size()]);
@ -137,13 +182,25 @@ public class VectorLib {
return midpoint;
}
public static Vector[] offset(Vector[] vectors, Vector offset) {
public static Vector[] move(Vector[] vectors, Vector offset) {
for (Vector v: vectors) {
v.add(offset);
}
return vectors;
}
public static Vector[] offset(Vector[] vectors, Vector[] offsets) {
Vector[] offset = new Vector[vectors.length * offsets.length];
int i = 0;
for (Vector v: vectors) {
for (Vector o: offsets) {
offset[i] = v.clone().add(o);
i++;
}
}
return offset;
}
public static Vector[] pointReflection(Vector[] vectors, Vector center) {
for (Vector v: vectors) {
v.subtract(center).multiply(-1).add(center);
@ -160,28 +217,28 @@ public class VectorLib {
public static Vector[] rotate(Vector[] vectors, Vector axis, double angle) {
for (Vector v: vectors) {
v = VectorMath.rot(v, axis, angle);
VectorMath.rot(v, axis, angle);
}
return vectors;
}
public static Vector[] rotateX(Vector[] vectors, double angle) {
for (Vector v: vectors) {
v = VectorMath.rotX(v, angle);
VectorMath.rotX(v, angle);
}
return vectors;
}
public static Vector[] rotateY(Vector[] vectors, double angle) {
for (Vector v: vectors) {
v = VectorMath.rotY(v, angle);
VectorMath.rotY(v, angle);
}
return vectors;
}
public static Vector[] rotateZ(Vector[] vectors, double angle) {
for (Vector v: vectors) {
v = VectorMath.rotZ(v, angle);
VectorMath.rotZ(v, angle);
}
return vectors;
}
@ -241,4 +298,14 @@ public class VectorLib {
}
return vectors;
}
public static Vector[] clone(Vector[] vectors) {
Vector[] clones = new Vector[vectors.length];
int i = 0;
for (Vector v: vectors) {
clones[i] = v.clone();
i++;
}
return clones;
}
}

View File

@ -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;

6
src/main/resources/plugin.yml Normal file → Executable file
View File

@ -1,4 +1,6 @@
name: Biosphere2
main: io.github.bi0qaw.biosphere.Biosphere
author: bi0qaw
version: 1.0.0
author: bi0qaw, Govindas
version: 1.0.3
api-version: 1.13
depend: [Skript]

BIN
target/biosphere2-1.0.3.jar Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More