Search in sources :

Example 6 with SpongeVolumeStream

use of org.spongepowered.common.world.volume.SpongeVolumeStream in project SpongeCommon by SpongePowered.

the class SpongeArchetypeVolume method entityArchetypeStream.

@Override
public VolumeStream<ArchetypeVolume, EntityArchetype> entityArchetypeStream(final Vector3i min, final Vector3i max, final StreamOptions options) {
    final Vector3i blockMin = this.min();
    final Vector3i blockMax = this.max();
    VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options);
    final Stream<VolumeElement<ArchetypeVolume, EntityArchetype>> stateStream = this.entities.entityArchetypeStream(min, max, options).toStream().map(element -> VolumeElement.of(this, element::type, element.position()));
    return new SpongeVolumeStream<>(stateStream, () -> this);
}
Also used : Vector3i(org.spongepowered.math.vector.Vector3i) VolumeElement(org.spongepowered.api.world.volume.stream.VolumeElement) SpongeVolumeStream(org.spongepowered.common.world.volume.SpongeVolumeStream)

Example 7 with SpongeVolumeStream

use of org.spongepowered.common.world.volume.SpongeVolumeStream in project SpongeCommon by SpongePowered.

the class SpongeArchetypeVolume method blockStateStream.

@Override
public VolumeStream<ArchetypeVolume, BlockState> blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options) {
    final Vector3i blockMin = this.min();
    final Vector3i blockMax = this.max();
    VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options);
    final ArrayMutableBlockBuffer buffer;
    if (options.carbonCopy()) {
        buffer = this.blocks.copy();
    } else {
        buffer = this.blocks;
    }
    final Stream<VolumeElement<ArchetypeVolume, BlockState>> stateStream = IntStream.range(min.x(), max.x() + 1).mapToObj(x -> IntStream.range(min.z(), max.z() + 1).mapToObj(z -> IntStream.range(min.y(), max.y() + 1).mapToObj(y -> VolumeElement.of((ArchetypeVolume) this, () -> buffer.block(x, y, z), new Vector3d(x, y, z)))).flatMap(Function.identity())).flatMap(Function.identity());
    return new SpongeVolumeStream<>(stateStream, () -> this);
}
Also used : IntStream(java.util.stream.IntStream) NonNull(org.checkerframework.checker.nullness.qual.NonNull) ServerWorld(org.spongepowered.api.world.server.ServerWorld) RegistryHolder(org.spongepowered.api.registry.RegistryHolder) FluidState(org.spongepowered.api.fluid.FluidState) ArrayMutableBlockBuffer(org.spongepowered.common.world.volume.buffer.block.ArrayMutableBlockBuffer) VolumeElement(org.spongepowered.api.world.volume.stream.VolumeElement) SpawnType(org.spongepowered.api.event.cause.entity.SpawnType) Function(java.util.function.Function) Supplier(java.util.function.Supplier) VolumeApplicators(org.spongepowered.api.world.volume.stream.VolumeApplicators) Biome(org.spongepowered.api.world.biome.Biome) PaletteTypes(org.spongepowered.api.world.schematic.PaletteTypes) AbstractVolumeBuffer(org.spongepowered.common.world.volume.buffer.AbstractVolumeBuffer) Map(java.util.Map) SpongeVolumeStream(org.spongepowered.common.world.volume.SpongeVolumeStream) PluginPhase(org.spongepowered.common.event.tracking.phase.plugin.PluginPhase) ArchetypeVolume(org.spongepowered.api.world.volume.archetype.ArchetypeVolume) BlockEntityArchetype(org.spongepowered.api.block.entity.BlockEntityArchetype) VolumeStream(org.spongepowered.api.world.volume.stream.VolumeStream) BlockEntityArchetypeVolume(org.spongepowered.api.world.volume.archetype.block.entity.BlockEntityArchetypeVolume) VolumePositionTranslators(org.spongepowered.api.world.volume.stream.VolumePositionTranslators) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Sponge(org.spongepowered.api.Sponge) StreamOptions(org.spongepowered.api.world.volume.stream.StreamOptions) Palette(org.spongepowered.api.world.schematic.Palette) PhaseTracker(org.spongepowered.common.event.tracking.PhaseTracker) ObjectArrayMutableEntityArchetypeBuffer(org.spongepowered.common.world.volume.buffer.archetype.entity.ObjectArrayMutableEntityArchetypeBuffer) RegistryTypes(org.spongepowered.api.registry.RegistryTypes) BlockState(org.spongepowered.api.block.BlockState) Transformation(org.spongepowered.api.util.transformation.Transformation) MutableMapBlockEntityArchetypeBuffer(org.spongepowered.common.world.volume.buffer.archetype.blockentity.MutableMapBlockEntityArchetypeBuffer) Objects(java.util.Objects) Stream(java.util.stream.Stream) Vector3d(org.spongepowered.math.vector.Vector3d) PhaseContext(org.spongepowered.common.event.tracking.PhaseContext) VolumeStreamUtils(org.spongepowered.common.world.volume.VolumeStreamUtils) BlockChangeFlags(org.spongepowered.api.world.BlockChangeFlags) BlockType(org.spongepowered.api.block.BlockType) EntityArchetypeEntry(org.spongepowered.api.world.volume.archetype.entity.EntityArchetypeEntry) Optional(java.util.Optional) VolumeCollectors(org.spongepowered.api.world.volume.stream.VolumeCollectors) ByteArrayMutableBiomeBuffer(org.spongepowered.common.world.volume.buffer.biome.ByteArrayMutableBiomeBuffer) EntityArchetype(org.spongepowered.api.entity.EntityArchetype) Vector3i(org.spongepowered.math.vector.Vector3i) ArchetypeVolume(org.spongepowered.api.world.volume.archetype.ArchetypeVolume) BlockEntityArchetypeVolume(org.spongepowered.api.world.volume.archetype.block.entity.BlockEntityArchetypeVolume) Vector3d(org.spongepowered.math.vector.Vector3d) Vector3i(org.spongepowered.math.vector.Vector3i) ArrayMutableBlockBuffer(org.spongepowered.common.world.volume.buffer.block.ArrayMutableBlockBuffer) VolumeElement(org.spongepowered.api.world.volume.stream.VolumeElement) SpongeVolumeStream(org.spongepowered.common.world.volume.SpongeVolumeStream)

Example 8 with SpongeVolumeStream

use of org.spongepowered.common.world.volume.SpongeVolumeStream in project SpongeCommon by SpongePowered.

the class SpongeArchetypeVolume method biomeStream.

@Override
public VolumeStream<ArchetypeVolume, Biome> biomeStream(final Vector3i min, final Vector3i max, final StreamOptions options) {
    final Vector3i blockMin = this.min();
    final Vector3i blockMax = this.max();
    VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options);
    final Stream<VolumeElement<ArchetypeVolume, Biome>> stateStream = this.biomes.biomeStream(min, max, options).toStream().map(element -> VolumeElement.of(this, element::type, element.position()));
    return new SpongeVolumeStream<>(stateStream, () -> this);
}
Also used : Vector3i(org.spongepowered.math.vector.Vector3i) VolumeElement(org.spongepowered.api.world.volume.stream.VolumeElement) SpongeVolumeStream(org.spongepowered.common.world.volume.SpongeVolumeStream)

Aggregations

VolumeElement (org.spongepowered.api.world.volume.stream.VolumeElement)8 SpongeVolumeStream (org.spongepowered.common.world.volume.SpongeVolumeStream)8 Vector3i (org.spongepowered.math.vector.Vector3i)8 Function (java.util.function.Function)5 IntStream (java.util.stream.IntStream)5 Stream (java.util.stream.Stream)5 Palette (org.spongepowered.api.world.schematic.Palette)5 StreamOptions (org.spongepowered.api.world.volume.stream.StreamOptions)5 VolumeStream (org.spongepowered.api.world.volume.stream.VolumeStream)5 VolumeStreamUtils (org.spongepowered.common.world.volume.VolumeStreamUtils)5 BlockState (org.spongepowered.api.block.BlockState)4 BlockType (org.spongepowered.api.block.BlockType)4 FluidState (org.spongepowered.api.fluid.FluidState)4 Vector3d (org.spongepowered.math.vector.Vector3d)4 Objects (java.util.Objects)3 AbstractBlockBuffer (org.spongepowered.common.world.volume.buffer.block.AbstractBlockBuffer)3 ArrayMutableBlockBuffer (org.spongepowered.common.world.volume.buffer.block.ArrayMutableBlockBuffer)3 Collection (java.util.Collection)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2