①尝试过这样生成掉落物↓ 但是报错(另外,1.12想产生 染料掉落物,但是查遍https://helpch.at/docs/1.12.2/org/bukkit/Material.html没有Material.Dye)
复制代码②烟花是生成了,但是FireworkMeta和FireworkEffect不知道该怎么设置
复制代码
- Item i = (Item) loc.getWorld().spawnEntity(loc,EntityType.DROPPED_ITEM);
 
-                 ItemStack is = new ItemStack(Material.ELYTRA);
 
- i.setItemStack(is);
- Firework fw = (Firework) loc.getWorld().spawnEntity(loc,EntityType.FIREWORK);
请仔细阅读文档。。。
1. 1.12时代染料我记得是Material.INK_SACK
生成掉落物直接用World#dropItemNaturally
2. 文档上写明了用builder构建
复制代码
1. 1.12时代染料我记得是Material.INK_SACK
生成掉落物直接用World#dropItemNaturally
2. 文档上写明了用builder构建
- FireworkEffect.Builder builder = FireworkEffect.builder();
 
- fireworkmeta.addEffect(builder.flicker(true).withColor(Color.BLUE).build());
 
- fireworkmeta.addEffect(builder.trail(true).build());
 
- fireworkmeta.addEffect(builder.withFade(Color.RED).build());
 
- fireworkmeta.addEffect(builder.with(FireworkEffect.Type.CREEPER).build());
 
- fireworkmeta.setPower(0);//maybe here is the thing I need to change?
 
- firework.setFireworkMeta(fireworkmeta);
疾风暗影 发表于 2020-7-4 14:46
请仔细阅读文档。。。
1. 1.12时代染料我记得是Material.INK_SACK
是用.setMetaData设置数据值吗?这个怎么用?
void setMetadata(java.lang.String metadataKey,
MetadataValue newMetadataValue)
另
- FireworkEffect.Builder builder = FireworkEffect.builder();
 
- fireworkmeta.addEffect(builder.flicker(true).withColor(Color.BLUE).build());
 
- fireworkmeta.addEffect(builder.trail(true).build());
 
- fireworkmeta.addEffect(builder.withFade(Color.RED).build());
 
- fireworkmeta.addEffect(builder.with(FireworkEffect.Type.CREEPER).build());
 
- fireworkmeta.setPower(0);//maybe here is the thing I need to change?
 
- firework.setFireworkMeta(fireworkmeta);
这个哪找到的,我咋就找不到……
aa0307bb 发表于 2020-7-4 15:01
是用.setMetaData设置数据值吗?这个怎么用?
1. datavalues,请 看 文 档
2. Javadoc中FireworkEffect自带的例子
疾风暗影 发表于 2020-7-4 15:09
1. datavalues,请 看 文 档
2. Javadoc中FireworkEffect自带的例子
1.没有datavalues这东西呀
-                 ItemStack is = new ItemStack(Material.INK_SACK);
 
-                 ItemMeta im = is.getItemMeta();
 
-                 is.setData(new MaterialData(Material.INK_SACK,(byte)5));
 
- 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.
你不会一直看的是自动生成的api doc吧
一直都是看
https://bukkit.windit.net/javadoc/
和
https://helpch.at/docs/
不知道是不是你说的"自动生成的api doc"
疾风暗影 发表于 2020-7-4 15:42
至于第一个问题,MaterialData不存储颜色值
Java Doc中提到
另外问一下,
setTicksLived(5960)