Search in sources :

Example 51 with Vector3i

use of org.spongepowered.math.vector.Vector3i 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 52 with Vector3i

use of org.spongepowered.math.vector.Vector3i 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)

Example 53 with Vector3i

use of org.spongepowered.math.vector.Vector3i in project SpongeCommon by SpongePowered.

the class MutableMapBlockEntityArchetypeBuffer method removeBlockEntity.

@Override
public void removeBlockEntity(final int x, final int y, final int z) {
    this.checkRange(x, y, z);
    this.blockEntities.remove(new Vector3i(x, y, z));
}
Also used : Vector3i(org.spongepowered.math.vector.Vector3i)

Example 54 with Vector3i

use of org.spongepowered.math.vector.Vector3i in project SpongeCommon by SpongePowered.

the class MutableMapBlockEntityArchetypeBuffer method addBlockEntity.

@Override
public void addBlockEntity(final int x, final int y, final int z, final BlockEntity blockEntity) {
    this.checkRange(x, y, z);
    this.blockEntities.put(new Vector3i(x, y, z), Objects.requireNonNull(blockEntity, "BlockEntity cannot be null").createArchetype());
}
Also used : Vector3i(org.spongepowered.math.vector.Vector3i)

Example 55 with Vector3i

use of org.spongepowered.math.vector.Vector3i in project SpongeCommon by SpongePowered.

the class ReferentSchematicVolume method setRawData.

@Override
public void setRawData(final int x, final int y, final int z, final DataView container) throws InvalidDataException {
    final Vector3i transformed = this.inverseTransform(x, y, z);
    this.consumeReference(a -> a.setRawData(transformed, container));
}
Also used : Vector3i(org.spongepowered.math.vector.Vector3i)

Aggregations

Vector3i (org.spongepowered.math.vector.Vector3i)59 Vector3d (org.spongepowered.math.vector.Vector3d)22 Nullable (org.checkerframework.checker.nullness.qual.Nullable)15 BlockPos (net.minecraft.core.BlockPos)14 BlockState (org.spongepowered.api.block.BlockState)14 Stream (java.util.stream.Stream)13 ChunkAccess (net.minecraft.world.level.chunk.ChunkAccess)12 StreamOptions (org.spongepowered.api.world.volume.stream.StreamOptions)12 MonotonicNonNull (org.checkerframework.checker.nullness.qual.MonotonicNonNull)11 VolumeElement (org.spongepowered.api.world.volume.stream.VolumeElement)11 Tuple (net.minecraft.util.Tuple)10 LevelChunk (net.minecraft.world.level.chunk.LevelChunk)10 VolumeStream (org.spongepowered.api.world.volume.stream.VolumeStream)10 Function (java.util.function.Function)9 Biome (org.spongepowered.api.world.biome.Biome)9 Collection (java.util.Collection)8 Objects (java.util.Objects)8 Optional (java.util.Optional)8 UUID (java.util.UUID)8 Entity (org.spongepowered.api.entity.Entity)8