org.bukkit.entity.Egg Java Examples

The following examples show how to use org.bukkit.entity.Egg. 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 vote down vote up
@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: PlayerEggThrowEvent.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public PlayerEggThrowEvent(final Player player, final Egg egg, final boolean hatching, final byte numHatches, final EntityType hatchingType) {
    super(player);
    this.egg = egg;
    this.hatching = hatching;
    this.numHatches = numHatches;
    this.hatchType = hatchingType;
}
 
Example #3
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static String getTranslationKey(Entity entity) {
    if(entity instanceof TNTPrimed) {
        return "tile.tnt.name";
    } else if(entity instanceof Egg) {
        return "item.egg.name";
    } else {
        final String id = EntityTypes.b(((CraftEntity) entity).getHandle());
        return "entity." + (id != null ? id : "generic") + ".name";
    }
}
 
Example #4
Source File: CraftLivingEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Deprecated
public Egg throwEgg() {
    return launchProjectile(Egg.class);
}
 
Example #5
Source File: CraftLivingEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@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 #6
Source File: PlayerEggThrowEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the egg involved in this event.
 *
 * @return the egg involved in this event
 */
public Egg getEgg() {
    return egg;
}