si_12
我想实现从一个方块连出一条粒子线

并且随着玩家移动跟踪玩家

这个粒子线是有速度的

类似于Mythicmobs里面的



求助大佬



Sssss...
本帖最后由 Sssss... 于 2019-11-10 09:13 编辑

这个粒子线是有速度的
这句话是什么意思?
如果是跟踪玩家走过的路径的话
高频(频率可自定义)执行execute as @a run particle xxx

si_12
Sssss... 发表于 2019-11-10 09:10
这个粒子线是有速度的
这句话是什么意思?
如果是跟踪玩家走过的路径的话

就是粒子线是慢慢延伸的

Guojianwei
Sssss... 发表于 2019-11-10 09:10
这个粒子线是有速度的
这句话是什么意思?
如果是跟踪玩家走过的路径的话

666666666666666666666

Bryan33
本帖最后由 Bryan33 于 2019-11-10 11:05 编辑
  1.     /**
  2.      * 绘制追踪效果
  3.      * @param p 执行的插件
  4.      * @param from 出发点
  5.      * @param target 目标玩家
  6.      * @param speed 追踪速度 每tick飞行距离
  7.      * @param drawfunc 绘制函数
  8.      */
  9.     public static void draw(Plugin p, Location from, Player target, double speed, Consumer<Location> drawfunc) {
  10.         new BukkitRunnable() {
  11.             Location curr = from;
  12.             @Override
  13.             public void run() {
  14.                 if(target.getWorld() != curr.getWorld()){
  15.                     this.cancel();
  16.                     return;
  17.                 }
  18.                 if(curr.distanceSquared(target.getLocation()) < 0.1){
  19.                     this.cancel();
  20.                     return;
  21.                 }
  22.                 drawfunc.accept(curr);
  23.                 Vector vec = target.getLocation().toVector().subtract(curr.toVector());
  24.                 vec = vec.normalize().multiply(speed);
  25.                 curr = curr.add(vec);
  26.             }
  27.         }.runTaskTimer(p, 1, 1);
  28.     }
复制代码
  1. /**
  2.      * 绘制追踪效果 并且保留追踪线
  3.      *
  4.      * @param p 执行的插件
  5.      * @param from 出发点
  6.      * @param target 目标玩家
  7.      * @param speed 追踪速度 每tick飞行距离
  8.      * @param drawfunc 绘制函数
  9.      */
  10.     public static void draw2(Plugin p, Location from, Player target, double speed, Consumer<Location> drawfunc) {
  11.         new BukkitRunnable() {
  12.             Location curr = from;
  13.             List<Location> pass = new ArrayList<>();

  14.             @Override
  15.             public void run() {
  16.                 if (target.getWorld() != curr.getWorld()) {
  17.                     this.cancel();
  18.                     return;
  19.                 }
  20.                 if (curr.distanceSquared(target.getLocation()) < 0.1) {
  21.                     this.cancel();
  22.                     return;
  23.                 }
  24.                 pass.add(curr.clone());
  25.                 for (Location loc : pass) {
  26.                     drawfunc.accept(loc);
  27.                 }
  28.                 Vector vec = target.getLocation().toVector().subtract(curr.toVector());
  29.                 vec = vec.normalize().multiply(speed);
  30.                 curr = curr.add(vec);
  31.             }
  32.         }.runTaskTimer(p, 1, 1);
  33.     }
复制代码



si_12

谢谢大佬

83585384
rrrrrrrrrrrrrrrrrrrrrrrrrrr

83585384
.................

83585384
..........................

83585384
............................

83585384
...............................

83585384
.........................

Sssss...
对不起前面看错版块了
可以使用Runnable计划任务实现
即设置三个坐标变量 每次执行都向玩家方向移动一点并创建粒子

15251827082
可以的谢谢

清酒丶c
。。。。。。。。。。。。。

Kenneth_z
要慢慢延伸确实要计时器的