|
4 | 4 | import org.bukkit.Bukkit; |
5 | 5 | import org.bukkit.Location; |
6 | 6 | import org.bukkit.Particle; |
7 | | -import org.bukkit.World; |
8 | 7 | import org.bukkit.block.Block; |
9 | 8 | import org.bukkit.command.Command; |
10 | 9 | import org.bukkit.command.CommandSender; |
11 | 10 | import org.bukkit.entity.Player; |
12 | 11 | import org.bukkit.plugin.java.JavaPlugin; |
13 | 12 | import org.bukkit.util.Vector; |
14 | | -import top.zoyn.particlelib.pobject.Arc; |
15 | | -import top.zoyn.particlelib.pobject.Astroid; |
16 | | -import top.zoyn.particlelib.pobject.Circle; |
17 | | -import top.zoyn.particlelib.pobject.Grid; |
18 | | -import top.zoyn.particlelib.utils.projector.ThreeDProjector; |
19 | | -import top.zoyn.particlelib.utils.projector.TwoDProjector; |
| 13 | +import top.zoyn.particlelib.pobject.*; |
| 14 | +import top.zoyn.particlelib.utils.matrix.Matrixs; |
20 | 15 |
|
21 | 16 | import java.util.List; |
22 | 17 | import java.util.concurrent.atomic.AtomicInteger; |
23 | | -import java.util.function.BiFunction; |
24 | 18 |
|
25 | 19 | /** |
26 | 20 | * 粒子库主类 |
@@ -48,6 +42,51 @@ public static void sendLog(String message) { |
48 | 42 | Bukkit.getConsoleSender().sendMessage("§e[§6ParticleLib§e] " + message); |
49 | 43 | } |
50 | 44 |
|
| 45 | + /** |
| 46 | + * 围绕一个方块画出其边框 |
| 47 | + * |
| 48 | + * @param block 给定的方块 |
| 49 | + * @param particle 要显示的粒子 |
| 50 | + */ |
| 51 | + public static void showBorderAboutBlock(Block block, Particle particle) { |
| 52 | + Location low = block.getLocation(); |
| 53 | + Location high = low.clone().add(0, 1, 0); |
| 54 | + List<Location> lowers = Lists.newArrayList( |
| 55 | + low, |
| 56 | + low.clone().add(1, 0, 0), |
| 57 | + low.clone().add(1, 0, 1), |
| 58 | + low.clone().add(0, 0, 1)); |
| 59 | + List<Location> highers = Lists.newArrayList( |
| 60 | + high, |
| 61 | + high.clone().add(1, 0, 0), |
| 62 | + high.clone().add(1, 0, 1), |
| 63 | + high.clone().add(0, 0, 1)); |
| 64 | + for (int i = 0; i < lowers.size(); i++) { |
| 65 | + Location origin = lowers.get(i); |
| 66 | + Location top = highers.get(i); |
| 67 | + Location next; |
| 68 | + Location topNext; |
| 69 | + // 最后一个的时候 |
| 70 | + if (i == 3) { |
| 71 | + next = lowers.get(0); |
| 72 | + topNext = highers.get(0); |
| 73 | + } else { |
| 74 | + next = lowers.get(i + 1); |
| 75 | + topNext = highers.get(i + 1); |
| 76 | + } |
| 77 | + |
| 78 | + // 以下为画线操作 |
| 79 | + Vector vectorON = next.clone().subtract(origin).toVector().normalize(); |
| 80 | + Vector vectorOT = top.clone().subtract(origin).toVector().normalize(); |
| 81 | + Vector vectorTT = topNext.clone().subtract(top).toVector().normalize(); |
| 82 | + for (double j = 0; j < 1; j += 0.1) { |
| 83 | + low.getWorld().spawnParticle(particle, origin.clone().add(vectorON.clone().multiply(j)), 1, 0, 0, 0, 0); |
| 84 | + low.getWorld().spawnParticle(particle, origin.clone().add(vectorOT.clone().multiply(j)), 1, 0, 0, 0, 0); |
| 85 | + low.getWorld().spawnParticle(particle, top.clone().add(vectorTT.clone().multiply(j)), 1, 0, 0, 0, 0); |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + |
51 | 90 | /** |
52 | 91 | * 围绕一个方块画出其边框 |
53 | 92 | * |
@@ -123,19 +162,52 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String |
123 | 162 | // Bukkit.getScheduler().runTaskTimer(this, () -> showBorderAndGridAboutBlock(location.getBlock(), Particle.FIREWORKS_SPARK), 0L, 10L); |
124 | 163 |
|
125 | 164 |
|
126 | | -// Circle circle = new Circle(player.getLocation()); |
127 | | -// circle.setStep(10D); |
128 | | -// circle.setRadius(3D); |
129 | | -// circle.setPeriod(2); |
130 | | -// circle.play(); |
131 | | -// circle.alwaysPlayAsync(); |
132 | | - |
133 | | -// Astroid astroid = new Astroid(player.getLocation()); |
134 | | -// astroid.setParticle(Particle.FIREWORKS_SPARK); |
135 | | -// astroid.setRadius(1.3D); |
136 | | -// astroid.setStep(10D); |
137 | | -// astroid.setPeriod(1L); |
138 | | -// astroid.alwaysPlayAsync(); |
| 165 | + Circle circle = new Circle(player.getLocation()); |
| 166 | + circle.setStep(10D); |
| 167 | + |
| 168 | + Astroid astroid = new Astroid(player.getLocation()); |
| 169 | + astroid.setParticle(Particle.FIREWORKS_SPARK); |
| 170 | + astroid.setStep(10D); |
| 171 | + astroid.alwaysPlayAsync(); |
| 172 | + |
| 173 | + Heart heart = new Heart(player.getLocation()); |
| 174 | + heart.setXScaleRate(1.5D); |
| 175 | + heart.setYScaleRate(1.5D); |
| 176 | + heart.setParticle(Particle.FLAME); |
| 177 | + heart.setStep(0.05D); |
| 178 | + |
| 179 | + Heart heart2 = new Heart(player.getLocation()); |
| 180 | + heart2.setXScaleRate(1.5D); |
| 181 | + heart2.setYScaleRate(1.5D); |
| 182 | + heart2.addMatrix(Matrixs.rotate2D(90)); |
| 183 | + heart2.setParticle(Particle.FLAME); |
| 184 | + heart2.setStep(0.05D); |
| 185 | + |
| 186 | + Heart heart3 = new Heart(player.getLocation()); |
| 187 | + heart3.setXScaleRate(1.5D); |
| 188 | + heart3.setYScaleRate(1.5D); |
| 189 | + heart3.addMatrix(Matrixs.rotate2D(180)); |
| 190 | + heart3.setParticle(Particle.FLAME); |
| 191 | + heart3.setStep(0.05D); |
| 192 | + |
| 193 | + Heart heart4 = new Heart(player.getLocation()); |
| 194 | + heart4.setXScaleRate(1.5D); |
| 195 | + heart4.setYScaleRate(1.5D); |
| 196 | + heart4.addMatrix(Matrixs.rotate2D(270)); |
| 197 | + heart4.setParticle(Particle.FLAME); |
| 198 | + heart4.setStep(0.05D); |
| 199 | + |
| 200 | + EffectGroup group = new EffectGroup() |
| 201 | + .addEffect(circle) |
| 202 | + .addEffect(astroid) |
| 203 | + .addEffect(heart) |
| 204 | + .addEffect(heart2) |
| 205 | + .addEffect(heart3) |
| 206 | + .addEffect(heart4) |
| 207 | + .scale(2) |
| 208 | + .rotate(45) |
| 209 | + .setPeriod(1) |
| 210 | + .alwaysPlayAsync(); |
139 | 211 |
|
140 | 212 | // Arc arc = new Arc(player.getLocation()); |
141 | 213 | // arc.setAngle(360D); |
|
0 commit comments