Skip to content

Commit 54e0ccd

Browse files
committed
更新: 给向量工具添加一些方法
1 parent 837ea83 commit 54e0ccd

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

src/main/java/top/zoyn/particlelib/ParticleLib.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
package top.zoyn.particlelib;
22

3-
import com.google.common.collect.Lists;
43
import org.bukkit.Bukkit;
54
import org.bukkit.Location;
6-
import org.bukkit.Particle;
75
import org.bukkit.command.Command;
86
import org.bukkit.command.CommandSender;
97
import org.bukkit.entity.Player;
108
import org.bukkit.plugin.java.JavaPlugin;
11-
import top.zoyn.particlelib.pobject.Wing;
12-
13-
import java.util.List;
149

1510
/**
1611
* 粒子库主类
@@ -50,6 +45,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
5045
Player player = (Player) sender;
5146
Location origin = player.getLocation();
5247

48+
5349
// List<String> points = Lists.newArrayList();
5450
// points.add(" aaaaa");
5551
// points.add(" aaaaa");

src/main/java/top/zoyn/particlelib/utils/VectorUtils.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package top.zoyn.particlelib.utils;
22

3+
import org.bukkit.Location;
34
import org.bukkit.util.Vector;
45

56
/**
@@ -9,6 +10,27 @@
910
*/
1011
public class VectorUtils {
1112

13+
public static Vector getLeftDirection(Location location) {
14+
return rotateAroundAxisY(location.getDirection().clone(), 90);
15+
}
16+
17+
public static Vector getRightDirection(Location location) {
18+
return rotateAroundAxisY(location.getDirection().clone(), -90);
19+
}
20+
21+
/**
22+
* 得到一个单位为 1 的向上的向量
23+
*
24+
* @return {@link Vector}
25+
*/
26+
public static Vector getUpVector() {
27+
return getUpVector(1);
28+
}
29+
30+
public static Vector getUpVector(double multiply) {
31+
return new Vector(0, 1, 0).multiply(multiply);
32+
}
33+
1234
public static Vector rotateAroundAxisX(Vector v, double angle) {
1335
angle = Math.toRadians(angle);
1436
double cos = Math.cos(angle);

0 commit comments

Comments
 (0)