use of org.spongepowered.api.entity.living.animal.Horse in project Skree by Skelril.
the class BuildWorldWrapper method onEntitySpawn.
@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
List<Entity> entities = event.getEntities();
Optional<BlockSpawnCause> optBlockCause = event.getCause().first(BlockSpawnCause.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)), SpawnTypes.DISPENSE);
event.setCancelled(true);
return;
}
if (entity instanceof Monster || (entity instanceof Horse && entity.get(Keys.HORSE_VARIANT).get().equals(HorseVariants.SKELETON_HORSE))) {
event.setCancelled(true);
return;
}
}
}
Aggregations