Search in sources :

Example 1 with NonNullArrayList

use of org.spongepowered.common.util.NonNullArrayList in project SpongeCommon by SpongePowered.

the class MixinWorldServer method spawnEntities.

@Override
public Collection<Entity> spawnEntities(Iterable<? extends Entity> entities) {
    List<Entity> entitiesToSpawn = new NonNullArrayList<>();
    entities.forEach(entitiesToSpawn::add);
    final SpawnEntityEvent.Custom event = SpongeEventFactory.createSpawnEntityEventCustom(Sponge.getCauseStackManager().getCurrentCause(), entitiesToSpawn);
    if (Sponge.getEventManager().post(event)) {
        return ImmutableList.of();
    }
    for (Entity entity : event.getEntities()) {
        this.forceSpawnEntity(entity);
    }
    return event.getEntities().stream().filter(Entity::isLoaded).collect(ImmutableList.toImmutableList());
}
Also used : Entity(org.spongepowered.api.entity.Entity) IMixinEntity(org.spongepowered.common.interfaces.entity.IMixinEntity) TileEntity(org.spongepowered.api.block.tileentity.TileEntity) IMixinTileEntity(org.spongepowered.common.interfaces.block.tile.IMixinTileEntity) NonNullArrayList(org.spongepowered.common.util.NonNullArrayList) SpawnEntityEvent(org.spongepowered.api.event.entity.SpawnEntityEvent)

Aggregations

TileEntity (org.spongepowered.api.block.tileentity.TileEntity)1 Entity (org.spongepowered.api.entity.Entity)1 SpawnEntityEvent (org.spongepowered.api.event.entity.SpawnEntityEvent)1 IMixinTileEntity (org.spongepowered.common.interfaces.block.tile.IMixinTileEntity)1 IMixinEntity (org.spongepowered.common.interfaces.entity.IMixinEntity)1 NonNullArrayList (org.spongepowered.common.util.NonNullArrayList)1