Ir.Nep
本帖最后由 Ir.Nep 于 2020-7-3 08:25 编辑
aa0307bb 发表于 2020-7-3 03:09
问一下,spawnparticle()要产生blockcrack颗粒

如果要产生掉落沙对应方块被破坏时的粒子效果,这个spawn ...

extra不用填,只填data
方块被破坏的粒子是Particle.BLOCK_CRACK
对应spawnParticle中data要填MaterialData

  1. spawnParticle(Particle.BLOCK_CRACK, 位置, 数量, new MaterialData(Material.你的方块材质, 附加值));
复制代码


注意1.13开始BLOCK_CRACK的对应data改用BlockData
建议在传入data前使用Particle.BLOCK_CRACK.getDataType()判断返回值(返回的是data应该传入的实例的类型)


aa0307bb
Ir.Nep 发表于 2020-7-3 08:23
extra不用填,只填data
方块被破坏的粒子是Particle.BLOCK_CRACK
对应spawnParticle中data要填MaterialDat ...

spawnParticle的参数填起来好像十分多变(?
这些是在哪可以查到的(好像API查不到(?

Ir.Nep
aa0307bb 发表于 2020-7-3 17:14
spawnParticle的参数填起来好像十分多变(?
这些是在哪可以查到的(好像API查不到(? ...

https://hub.spigotmc.org/javadoc ... -double-double-int-

从这里开始往下14个方法都是spawnPartcle的重载方法

William_Shi
aa0307bb 发表于 2020-7-3 17:14
spawnParticle的参数填起来好像十分多变(?
这些是在哪可以查到的(好像API查不到(? ...

spawnParticle
<T> void spawnParticle​(@NotNull
                       @NotNull Particle particle,
                       @NotNull
                       @NotNull Location location,
                       int count,
                       @Nullable
                       T data)
Spawns the particle (the number of times specified by count) at the target location.
Type Parameters:
T - type of particle data (see Particle.getDataType()
Parameters:
particle - the particle to spawn
location - the location to spawn at
count - the number of particles
data - the data to use for the particle or null, the type of this depends on Particle.getDataType()

人家泛型都说清楚了
T - type of particle data (see Particle.getDataType()

@NotNull Class<?>        getDataType​()       
Returns the required data type for the particle

那你看到Class<?>难道不输出一下class simplename 试试看?
而且输出这个根本不需要开服
你直接新建一个ant项目,main方法直接输出就行了吧,不是很快么
再不济你写个测试插件丢服务端输出

William_Shi

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        System.out.println(Particle.BLOCK_CRACK.getDataType().getSimpleName());
    }

run:
BlockData
BUILD SUCCESSFUL (total time: 1 second)

所以泛型传参BlockData,完事了(1.15.2

aa0307bb
本帖最后由 aa0307bb 于 2020-7-4 02:33 编辑
William_Shi 发表于 2020-7-3 20:07
/**
     * @param args the command line arguments
     */

感谢指引
顺着思路摸了一下瓜
  1. for(Particle p : Particle.values()) {                        
  2.                         System.out.println(p+":"+p.getDataType().getSimpleName());
  3.                 }
复制代码


就可以一劳永逸了


第一页 上一页