Search in sources :

Example 1 with SkeletonHorse

use of org.spongepowered.api.entity.living.animal.SkeletonHorse in project Skree by Skelril.

the class BuildWorldWrapper method onEntitySpawn.

@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
    List<Entity> entities = event.getEntities();
    Optional<BlockSnapshot> optBlockCause = event.getCause().first(BlockSnapshot.class);
    for (Entity entity : entities) {
        if (!isApplicable(entity)) {
            continue;
        }
        if (entity instanceof Lightning) {
            ((Lightning) entity).setEffect(true);
            continue;
        }
        if (entity instanceof Egg && optBlockCause.isPresent()) {
            new ItemDropper(entity.getLocation()).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.EGG)));
            event.setCancelled(true);
            return;
        }
        if (entity instanceof Monster || (entity instanceof SkeletonHorse)) {
            event.setCancelled(true);
            return;
        }
    }
}
Also used : Entity(org.spongepowered.api.entity.Entity) Egg(org.spongepowered.api.entity.projectile.Egg) ItemDropper(com.skelril.nitro.item.ItemDropper) Lightning(org.spongepowered.api.entity.weather.Lightning) Monster(org.spongepowered.api.entity.living.monster.Monster) BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) SkeletonHorse(org.spongepowered.api.entity.living.animal.SkeletonHorse) Listener(org.spongepowered.api.event.Listener)

Aggregations

ItemDropper (com.skelril.nitro.item.ItemDropper)1 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)1 Entity (org.spongepowered.api.entity.Entity)1 SkeletonHorse (org.spongepowered.api.entity.living.animal.SkeletonHorse)1 Monster (org.spongepowered.api.entity.living.monster.Monster)1 Egg (org.spongepowered.api.entity.projectile.Egg)1 Lightning (org.spongepowered.api.entity.weather.Lightning)1 Listener (org.spongepowered.api.event.Listener)1