aa0307bb
①尝试过这样生成掉落物↓ 但是报错(另外,1.12想产生 染料掉落物,但是查遍https://helpch.at/docs/1.12.2/org/bukkit/Material.html没有Material.Dye)
  1. Item i = (Item) loc.getWorld().spawnEntity(loc,EntityType.DROPPED_ITEM);
  2.                 ItemStack is = new ItemStack(Material.ELYTRA);
  3.                 i.setItemStack(is);
复制代码
②烟花是生成了,但是FireworkMeta和FireworkEffect不知道该怎么设置
  1. Firework fw = (Firework) loc.getWorld().spawnEntity(loc,EntityType.FIREWORK);
复制代码



天辉胡萝卜
请仔细阅读文档。。。

1. 1.12时代染料我记得是Material.INK_SACK
生成掉落物直接用World#dropItemNaturally

2. 文档上写明了用builder构建

  1. FireworkEffect.Builder builder = FireworkEffect.builder();
  2. fireworkmeta.addEffect(builder.flicker(true).withColor(Color.BLUE).build());
  3. fireworkmeta.addEffect(builder.trail(true).build());
  4. fireworkmeta.addEffect(builder.withFade(Color.RED).build());
  5. fireworkmeta.addEffect(builder.with(FireworkEffect.Type.CREEPER).build());
  6. fireworkmeta.setPower(0);//maybe here is the thing I need to change?
  7. firework.setFireworkMeta(fireworkmeta);
复制代码

aa0307bb
疾风暗影 发表于 2020-7-4 14:46
请仔细阅读文档。。。

1. 1.12时代染料我记得是Material.INK_SACK

是用.setMetaData设置数据值吗?这个怎么用?
void setMetadata(java.lang.String metadataKey,
                 MetadataValue newMetadataValue)



  1. FireworkEffect.Builder builder = FireworkEffect.builder();
  2. fireworkmeta.addEffect(builder.flicker(true).withColor(Color.BLUE).build());
  3. fireworkmeta.addEffect(builder.trail(true).build());
  4. fireworkmeta.addEffect(builder.withFade(Color.RED).build());
  5. fireworkmeta.addEffect(builder.with(FireworkEffect.Type.CREEPER).build());
  6. fireworkmeta.setPower(0);//maybe here is the thing I need to change?
  7. firework.setFireworkMeta(fireworkmeta);
复制代码

这个哪找到的,我咋就找不到……

天辉胡萝卜
aa0307bb 发表于 2020-7-4 15:01
是用.setMetaData设置数据值吗?这个怎么用?

1. datavalues,请 看 文 档

2. Javadoc中FireworkEffect自带的例子

aa0307bb
疾风暗影 发表于 2020-7-4 15:09
1. datavalues,请 看 文 档

2. Javadoc中FireworkEffect自带的例子

1.没有datavalues这东西呀

  1.                 ItemStack is = new ItemStack(Material.INK_SACK);
  2.                 ItemMeta im = is.getItemMeta();
  3.                 is.setData(new MaterialData(Material.INK_SACK,(byte)5));
  4.                 Item i = loc.getWorld().dropItemNaturally(loc, is);
复制代码

换了方法,但这样子为啥就不能生成紫色染料(数据值是5)呢……

2. https://helpch.at/docs/1.12.2/org/bukkit/FireworkEffect.html 没有呀

天辉胡萝卜
aa0307bb 发表于 2020-7-4 15:36
1.没有datavalues这东西呀

1.
ItemStack​(int type, int amount, short datavalues)


2.
你不会一直看的是自动生成的api doc吧。。

天辉胡萝卜
aa0307bb 发表于 2020-7-4 15:36
1.没有datavalues这东西呀

至于第一个问题,MaterialData不存储颜色值

Java Doc中提到
Wools and dyes don't store their info in MaterialData, they store it in their durability. The durability of a Colorable object determines its color. Being that this is the case, you will need to modify the durability in order to do anything to the color. The only place you can set the durability outside of the constructor is the setDurability method.

aa0307bb
你不会一直看的是自动生成的api doc吧

一直都是看
https://bukkit.windit.net/javadoc/

https://helpch.at/docs/

不知道是不是你说的"自动生成的api doc"

aa0307bb
疾风暗影 发表于 2020-7-4 15:42
至于第一个问题,MaterialData不存储颜色值

Java Doc中提到

另外问一下,
setTicksLived(5960)
设置掉落物2秒后消失是对的吧?(但实际上我的并不是