org.bukkit.entity.EnderPearl#org.bukkit.entity.Snowball源码实例Demo

下面列出了org.bukkit.entity.EnderPearl#org.bukkit.entity.Snowball 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SkyWarsReloaded   文件: ParticleEffectListener.java
@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);
                               }
                           }
                       }
                   }
			 }
		 }
	 }
}
 
源代码2 项目: Skript   文件: ClassesTest.java
@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
	}
}
 
源代码3 项目: Thermos   文件: CraftLivingEntity.java
@Deprecated
public Snowball throwSnowball() {
    return launchProjectile(Snowball.class);
}
 
源代码4 项目: Thermos   文件: CraftLivingEntity.java
@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();
}
 
源代码5 项目: HeavySpleef   文件: FlagSnowballs.java
@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());
	}
}