本文整理汇总了Java中org.bukkit.inventory.meta.FireworkMeta.clearEffects方法的典型用法代码示例。如果您正苦于以下问题:Java FireworkMeta.clearEffects方法的具体用法?Java FireworkMeta.clearEffects怎么用?Java FireworkMeta.clearEffects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.FireworkMeta
的用法示例。
在下文中一共展示了FireworkMeta.clearEffects方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void playFirework(Player p, Location loc, Color color1, Color color2, FireworkEffect.Type type) {
loc.add(0.5, 1, 0.5);
Firework fw = p.getWorld().spawn(loc, Firework.class);
FireworkMeta fwmeta = ((org.bukkit.entity.Firework) fw).getFireworkMeta();
FireworkEffect.Builder builder = FireworkEffect.builder();
builder.withFlicker();
builder.withFade(color2);
builder.withColor(color1);
builder.with(type);
fwmeta.clearEffects();
Field f;
try {
f = fwmeta.getClass().getDeclaredField("power");
f.setAccessible(true);
f.set(fwmeta, -1);
} catch (Exception e) {
return;
}
fwmeta.addEffect(builder.build());
fw.setFireworkMeta(fwmeta);
}
示例2: makePacket
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
* Make a packet object
*
* @param location Location to play firework effect at
* @param fireworkEffect FireworkEffect to play
* @return Packet constructed by the parameters
*/
private static Object makePacket(Location location, FireworkEffect fireworkEffect) {
try {
Firework firework = location.getWorld().spawn(location, Firework.class);
FireworkMeta data = firework.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(fireworkEffect);
firework.setFireworkMeta(data);
Object nmsFirework = ReflectionUtil.getHandle(firework);
firework.remove();
return PACKET_PLAY_OUT_ENTITY_STATUS.newInstance(nmsFirework, (byte) 17);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例3: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void playFirework(Location loc, FireworkEffect fe) throws Exception {
World world = loc.getWorld();
Firework fw = (Firework) world.spawn(loc, Firework.class);
Object nms_world = null;
Object nms_firework = null;
if (world_getHandle == null) {
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
if (nms_world_broadcastEntityEffect == null) {
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(),
"broadcastEntityEffect");
}
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(fe);
fw.setFireworkMeta(data);
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {
nms_firework, (byte) 17 });
fw.remove();
}
示例4: processMeta
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
@Override
public void processMeta(Player player, ItemMeta m) {
super.processMeta(player, m);
FireworkMeta meta = (FireworkMeta) m;
meta.clearEffects();
meta.addEffects(effects);
if(power != null)
meta.setPower(power.resolve(player));
}
示例5: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
* <p>
* This method provides a version independent way to instantly explode {@code FireworkEffect}s at a given location.
* It uses {@link org.bukkit.entity.Entity#setTicksLived(int) setTicksLived} to accomplish this.
* </p>
* @param location The location at which to display the firework effects.
* @param effects The firework effects to render.
*/
public static void playFirework(Location location, FireworkEffect... effects) {
Validate.notNull(location, "The location of the effect must not be null.");
Validate.notNull(location.getWorld(), "The location must not have a null world.");
Validate.noNullElements(effects, "Null firework effects are not allowed.");
// Bukkity load (CraftFirework)
World world = location.getWorld();
Firework fw = world.spawn(location, Firework.class);
/*
* Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effects
data.addEffects(effects);
// set the meta
fw.setFireworkMeta(data);
// Set the "ticks flown" to a high value - game will remove everything after playing the effect
fw.setTicksLived(123);
}
示例6: spawnFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public static void spawnFirework(Location l, FireworkEffect fe) {
Firework fw = l.getWorld().spawn(l, Firework.class);
FireworkMeta fwm = fw.getFireworkMeta();
fwm.clearEffects();
fwm.addEffect(fe);
try {
Field f = fwm.getClass().getDeclaredField("power");
f.setAccessible(true);
f.set(fwm, Integer.valueOf(-2));
} catch (Exception e) {
}
fw.setFireworkMeta(fwm);
}
示例7: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
* Play a pretty firework at the location with the FireworkEffect when called
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public static void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing around with things
*/
if(world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if(nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17});
// remove from the game
fw.remove();
}
示例8: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
* Play a pretty firework at the location with the FireworkEffect when called
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing around with things
*/
if(world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if(nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17});
// remove from the game
// fw.
fw.remove();
}
示例9: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
* Play a firework effect at the specified location.
*
* @param world the bukkit world the effect will be displayed
* @param loc the location in the world the effect will be displayed
* @param fe the {@link org.bukkit.FireworkEffect} what will be used
* @throws Exception the exception
*/
public void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
Firework fw = world.spawn(loc, Firework.class);
Object nmsWorld = null;
Object nmsFirework = null;
if (worldHandler == null) {
worldHandler = getMethod(world.getClass(), "getHandle");
fireworkHandler = getMethod(fw.getClass(), "getHandle");
}
nmsWorld = worldHandler.invoke(world, (Object[]) null);
nmsFirework = fireworkHandler.invoke(fw, (Object[]) null);
if (nmsWorldBroadcastEntityEffect == null) {
nmsWorldBroadcastEntityEffect = getMethod(nmsWorld.getClass(), "broadcastEntityEffect");
}
//Load firework metadata
FireworkMeta data = fw.getFireworkMeta();
//clear firework effects to allow reuse
data.clearEffects();
//Set power of firework to 1
data.setPower((random.nextInt(200) + 101) / 100);
//add the effect
data.addEffect(fe);
fw.setFireworkMeta(data);
/*
* Now broadcast the firework and kill the firework object
*
*/
nmsWorldBroadcastEntityEffect.invoke(nmsWorld, nmsFirework, (byte) 17);
//Remove the object from game
fw.remove();
}
示例10: run
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void run() {
double speed = this.arrow.getVelocity().length();
if ((this.arrow.isOnGround()) || (this.arrow.isDead()) || (this.target.isDead())) {
cancel();
Firework f = (Firework) this.arrow.getWorld().spawn(this.arrow.getLocation(), Firework.class);
List<Color> colors = new ArrayList<Color>();
colors.add(Color.RED);
colors.add(Color.YELLOW);
colors.add(Color.ORANGE);
FireworkMeta fm = f.getFireworkMeta();
fm.clearEffects();
fm.setPower(1);
fm.addEffect(FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(colors).withFade().flicker(true).trail(true).build());
f.setFireworkMeta(fm);
f.detonate();
this.target.getWorld().playEffect(this.target.getLocation(), Effect.ENDER_SIGNAL, 0);
this.arrow.getWorld().playSound(this.arrow.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 25, 0.75F);
this.arrow.getWorld().playSound(this.arrow.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 25, 10F);
return;
}
Vector toTarget = this.target.getLocation().clone().add(new Vector(0.0D, 0.5D, 0.0D)).subtract(this.arrow.getLocation()).toVector();
Vector dirVelocity = this.arrow.getVelocity().clone().normalize();
Vector dirToTarget = toTarget.clone().normalize();
double angle = dirVelocity.angle(dirToTarget);
double newSpeed = 0.9D * speed + 0.14D;
if (((this.target instanceof Player)) && (this.arrow.getLocation().distance(this.target.getLocation()) < 8.0D)) {
Player player = (Player) this.target;
if (player.isBlocking()) {
newSpeed = speed * 0.6D;
}
}
Vector newVelocity;
if (angle < 0.12D) {
newVelocity = dirVelocity.clone().multiply(newSpeed);
} else {
Vector newDir = dirVelocity.clone().multiply((angle - 0.12D) / angle).add(dirToTarget.clone().multiply(0.12D / angle));
newDir.normalize();
newVelocity = newDir.clone().multiply(newSpeed);
}
this.arrow.setVelocity(newVelocity.add(new Vector(0.0D, 0.03D, 0.0D)));
this.arrow.getWorld().playEffect(this.arrow.getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
}
示例11: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing
* around with things
*/
if (world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if (nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a
* pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks
* object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] { nms_firework, (byte) 17 });
// remove from the game
fw.remove();
}
示例12: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
* Play a pretty firework at the location with the FireworkEffect when
* called
*
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public void playFirework(World world, Location loc, FireworkEffect fe)
throws Exception {
// Bukkity load (CraftFirework)
Firework fw = (Firework) world.spawn(loc, Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing
* around with things
*/
if (world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if (nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(),
"broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a
* pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks
* object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {
nms_firework, (byte) 17 });
// remove from the game
fw.remove();
}
示例13: playFirework
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
* Play a pretty firework at the location with the FireworkEffect when called
* @param world
* @param loc
* @param fe
* @throws Exception
*/
public void playFirework(World world, Location loc, FireworkEffect fe) throws Exception {
// Bukkity load (CraftFirework)
org.bukkit.entity.Firework fw = (org.bukkit.entity.Firework) world.spawn(loc, org.bukkit.entity.Firework.class);
// the net.minecraft.server.World
Object nms_world = null;
Object nms_firework = null;
/*
* The reflection part, this gives us access to funky ways of messing around with things
*/
if(world_getHandle == null) {
// get the methods of the craftbukkit objects
world_getHandle = getMethod(world.getClass(), "getHandle");
firework_getHandle = getMethod(fw.getClass(), "getHandle");
}
// invoke with no arguments
nms_world = world_getHandle.invoke(world, (Object[]) null);
nms_firework = firework_getHandle.invoke(fw, (Object[]) null);
// null checks are fast, so having this seperate is ok
if(nms_world_broadcastEntityEffect == null) {
// get the method of the nms_world
nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect");
}
/*
* Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
*/
// metadata load
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
// clear existing
data.clearEffects();
// power of one
data.setPower(1);
// add the effect
data.addEffect(fe);
// set the meta
fw.setFireworkMeta(data);
/*
* Finally, we broadcast the entity effect then kill our fireworks object
*/
// invoke with arguments
nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17});
// remove from the game
fw.remove();
}
示例14: sendParticleEffect
import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public static void sendParticleEffect(final Location location, final int reinforcementValue, final int reinforcementValueCoefficient) {
World world = location.getWorld();
Firework firework = world.spawn(new Location(world, location.getBlockX() + 0.5d, location.getBlockY() + 0.5d, location.getBlockZ() + 0.5d), Firework.class);
FireworkMeta fireworkMeta = firework.getFireworkMeta();
fireworkMeta.clearEffects();
fireworkMeta.setPower(1);
Color color;
// Normalize the RV so that the change from RVC to 0 is gradual.
int numberOfColors = 6;
double fadeInterval = reinforcementValueCoefficient / numberOfColors;
int fadeStage = (int) Math.floor(reinforcementValue / fadeInterval);
switch (fadeStage) {
case 0:
// If the block is not reinforced, but has just been damaged as a reinforced block (presumably due to the grace period), then we play the "nearly broken" effect.
color = Color.RED;
break;
case 1:
color = Color.ORANGE;
break;
case 2:
color = Color.YELLOW;
break;
case 3:
color = Color.GREEN;
break;
case 4:
color = Color.BLUE;
break;
default:
color = Color.PURPLE;
break;
}
fireworkMeta.addEffects(FireworkEffect.builder().withColor(color).with(FireworkEffect.Type.BALL).build());
firework.setFireworkMeta(fireworkMeta);
try {
Object nms_world = getMethod(world.getClass(), "getHandle").invoke(world);
getMethod(nms_world.getClass(), "broadcastEntityEffect").invoke(nms_world, getMethod(firework.getClass(), "getHandle").invoke(firework), (byte) 17);
firework.remove();
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}