Skip to content

Commit f1ed4d6

Browse files
committed
update: 更新星形线和心形线的内容
1 parent 6eee6e4 commit f1ed4d6

3 files changed

Lines changed: 134 additions & 24 deletions

File tree

src/top/zoyn/particlelib/ParticleLib.java

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import org.bukkit.entity.Player;
99
import org.bukkit.plugin.java.JavaPlugin;
1010
import top.zoyn.particlelib.pobject.Arc;
11+
import top.zoyn.particlelib.pobject.Astroid;
1112
import top.zoyn.particlelib.pobject.Circle;
13+
import top.zoyn.particlelib.pobject.Heart;
1214
import top.zoyn.particlelib.utils.matrix.Matrixs;
1315

1416
import java.util.concurrent.atomic.AtomicInteger;
@@ -53,26 +55,13 @@ public void onDisable() {
5355
@Override
5456
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
5557
Player player = (Player) sender;
56-
if (args.length != 0) {
57-
if (args[0].equalsIgnoreCase("loc1")) {
58-
loc1 = player.getLocation();
59-
return true;
60-
}
61-
if (args[0].equalsIgnoreCase("loc2")) {
62-
loc2 = player.getLocation();
63-
return true;
64-
}
65-
66-
if (args[0].equalsIgnoreCase("circle")) {
67-
circle.setOrigin(player.getLocation());
68-
return true;
69-
}
70-
71-
if (args[0].equalsIgnoreCase("cancel")) {
72-
circle.turnOffTask();
73-
return true;
74-
}
75-
}
58+
//
59+
// Astroid astroid = new Astroid(player.getLocation());
60+
// astroid.setParticle(Particle.FIREWORKS_SPARK);
61+
// astroid.show();
62+
//
63+
// Heart heart = new Heart(player.getLocation());
64+
// heart.alwaysShowAsync();
7665

7766
// Polygon polygon = new Polygon(3, player.getLocation());
7867
// polygon.setParticle(Particle.VILLAGER_HAPPY);
@@ -85,10 +74,10 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
8574
// polygon.setStep(0.5);
8675
// polygon.alwaysShowAsync();
8776

88-
Arc arc = new Arc(player.getLocation(), 90D);
89-
arc.setMatrix(Matrixs.eyes(2, 2).multiply(2));
90-
arc.setStep(10);
91-
arc.alwaysShowAsync();
77+
// Arc arc = new Arc(player.getLocation(), 90D);
78+
// arc.setMatrix(Matrixs.eyes(2, 2).multiply(2));
79+
// arc.setStep(10);
80+
// arc.alwaysShowAsync();
9281

9382
// Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
9483
// if (angle.get() == 360) {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package top.zoyn.particlelib.pobject;
2+
3+
import org.bukkit.Location;
4+
5+
/**
6+
* 表示一个星形线
7+
*
8+
* @author Zoyn
9+
*/
10+
public class Astroid extends ParticleObject {
11+
12+
private double radius;
13+
14+
/**
15+
* 构造一个星形线
16+
*
17+
* @param origin 原点
18+
*/
19+
public Astroid(Location origin) {
20+
this(1D, origin);
21+
}
22+
23+
/**
24+
* 构造一个星形线
25+
*
26+
* @param radius 半径
27+
* @param origin 原点
28+
*/
29+
public Astroid(double radius, Location origin) {
30+
this.radius = radius;
31+
setOrigin(origin);
32+
}
33+
34+
public double getRadius() {
35+
return radius;
36+
}
37+
38+
public void setRadius(double radius) {
39+
this.radius = radius;
40+
}
41+
42+
@Override
43+
public void show() {
44+
for (double t = 0.0D; t < 360.0D; t++) {
45+
double radians = Math.toRadians(t);
46+
// 计算公式
47+
double x = Math.pow(this.radius * Math.cos(radians), 3.0D);
48+
double z = Math.pow(this.radius * Math.sin(radians), 3.0D);
49+
50+
spawnParticle(getOrigin().clone().add(x, 0, z));
51+
}
52+
}
53+
54+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package top.zoyn.particlelib.pobject;
2+
3+
import org.bukkit.Color;
4+
import org.bukkit.Location;
5+
import org.bukkit.Particle;
6+
7+
/**
8+
* 表示一颗心
9+
*/
10+
public class Heart extends ParticleObject {
11+
12+
private double xScaleRate;
13+
private double yScaleRate;
14+
15+
/**
16+
* 构造一个小心心
17+
*
18+
* @param origin 原点
19+
*/
20+
public Heart(Location origin) {
21+
this(0.9, 1, origin);
22+
}
23+
24+
/**
25+
* 构造一个星形线
26+
*
27+
* @param xScaleRate X轴缩放比率
28+
* @param yScaleRate Y轴缩放比率
29+
* @param origin 原点
30+
*/
31+
public Heart(double xScaleRate, double yScaleRate, Location origin) {
32+
this.xScaleRate = xScaleRate;
33+
this.yScaleRate = yScaleRate;
34+
setOrigin(origin);
35+
36+
// 小心心
37+
setParticle(Particle.REDSTONE);
38+
setData(new Particle.DustOptions(Color.RED, 2f));
39+
}
40+
41+
public double getXScaleRate() {
42+
return xScaleRate;
43+
}
44+
45+
public void setXScaleRate(double xScaleRate) {
46+
this.xScaleRate = xScaleRate;
47+
}
48+
49+
public double getYScaleRate() {
50+
return yScaleRate;
51+
}
52+
53+
public void setYScaleRate(double yScaleRate) {
54+
this.yScaleRate = yScaleRate;
55+
}
56+
57+
@Override
58+
public void show() {
59+
for (double t = 0.0D; t < 360.0D; t++) {
60+
double x = xScaleRate * 16 * Math.pow(Math.sin(t), 3);
61+
double z = yScaleRate * 13 * Math.cos(t) - 5 * Math.cos(2 * t) - 2 * Math.cos(3 * t) - Math.cos(4 * t);
62+
63+
spawnParticle(getOrigin().clone().add(x, 0, z));
64+
}
65+
}
66+
67+
}

0 commit comments

Comments
 (0)