org.bukkit.entity.Snowball Java Examples
The following examples show how to use
org.bukkit.entity.Snowball.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParticleEffectListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler public void projectileLaunch(ProjectileLaunchEvent e) { Projectile projectile = e.getEntity(); if (projectile instanceof Snowball || projectile instanceof Egg || projectile instanceof Arrow) { if (projectile.getShooter() instanceof Player) { Player player = (Player) projectile.getShooter(); GameMap gMap = MatchManager.get().getPlayerMap(player); if (gMap != null) { PlayerStat ps = PlayerStat.getPlayerStats(player.getUniqueId()); if (ps != null) { String key = ps.getProjectileEffect(); ProjectileEffectOption peo = (ProjectileEffectOption) ProjectileEffectOption.getPlayerOptionByKey(key); if (peo != null) { List<ParticleEffect> effects = peo.getEffects(); if (key != null && effects != null) { if (!key.equalsIgnoreCase("none")) { SkyWarsReloaded.getOM().addProjectile(projectile, effects); } } } } } } } }
Example #2
Source File: ClassesTest.java From Skript with GNU General Public License v3.0 | 5 votes |
@Test public void test() { final Object[] random = { // Java (byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37, "String", // Skript SkriptColor.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER, new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000), new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}), new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50), // Bukkit - simple classes only GameMode.ADVENTURE, InventoryType.CHEST, DamageCause.FALL, // there is also at least one variable for each class on my test server which are tested whenever the server shuts down. }; for (final Object o : random) { Classes.serialize(o); // includes a deserialisation test } }
Example #3
Source File: CraftLivingEntity.java From Thermos with GNU General Public License v3.0 | 4 votes |
@Deprecated public Snowball throwSnowball() { return launchProjectile(Snowball.class); }
Example #4
Source File: CraftLivingEntity.java From Thermos with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) { net.minecraft.world.World world = ((CraftWorld) getWorld()).getHandle(); net.minecraft.entity.Entity launch = null; if (Snowball.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntitySnowball(world, getHandle()); } else if (Egg.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityEgg(world, getHandle()); } else if (EnderPearl.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.item.EntityEnderPearl(world, getHandle()); } else if (Arrow.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityArrow(world, getHandle(), 1); } else if (ThrownPotion.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1))); } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.item.EntityExpBottle(world, getHandle()); } else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof net.minecraft.entity.player.EntityPlayer) { launch = new net.minecraft.entity.projectile.EntityFishHook(world, (net.minecraft.entity.player.EntityPlayer) getHandle()); } else if (Fireball.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection().multiply(10); if (SmallFireball.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } else if (WitherSkull.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } else { launch = new net.minecraft.entity.projectile.EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } ((net.minecraft.entity.projectile.EntityFireball) launch).projectileSource = this; launch.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } Validate.notNull(launch, "Projectile not supported"); if (velocity != null) { ((T) launch.getBukkitEntity()).setVelocity(velocity); } world.spawnEntityInWorld(launch); return (T) launch.getBukkitEntity(); }
Example #5
Source File: FlagSnowballs.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") @EventHandler public void onProjectileHit(ProjectileHitEvent event) { Projectile projectile = event.getEntity(); if (!(projectile instanceof Snowball)) { return; } ProjectileSource shooter = projectile.getShooter(); if (!(shooter instanceof Player)) { return; } SpleefPlayer player = getHeavySpleef().getSpleefPlayer(shooter); GameManager manager = getHeavySpleef().getGameManager(); Game game; if ((game = manager.getGame(player)) == null) { return; } Location location = projectile.getLocation(); Vector start = location.toVector(); Vector dir = projectile.getVelocity().normalize(); BlockIterator iterator = new BlockIterator(projectile.getWorld(), start, dir, 0, 4); Block blockHit = null; while (iterator.hasNext()) { blockHit = iterator.next(); if (blockHit.getType() != Material.AIR) { break; } } if (!game.canSpleef(blockHit)) { //Cannot remove this block return; } projectile.remove(); game.addBlockBroken(player, blockHit); blockHit.setType(Material.AIR); if (game.getPropertyValue(GameProperty.PLAY_BLOCK_BREAK)) { blockHit.getWorld().playEffect(blockHit.getLocation(), Effect.STEP_SOUND, blockHit.getTypeId()); } }