Search in sources :

Example 1 with UnmodifiableBiomeVolume

use of org.spongepowered.api.world.extent.UnmodifiableBiomeVolume in project SpongeCommon by SpongePowered.

the class SpongeBiomeVolumeWorker method merge.

@Override
public void merge(BiomeVolume second, BiomeVolumeMerger merger, MutableBiomeVolume destination) {
    final Vector3i offsetSecond = align(second);
    final int xOffsetSecond = offsetSecond.getX();
    final int yOffsetSecond = offsetSecond.getY();
    final int zOffsetSecond = offsetSecond.getZ();
    final Vector3i offsetDestination = align(destination);
    final int xOffsetDestination = offsetDestination.getX();
    final int yOffsetDestination = offsetDestination.getY();
    final int zOffsetDestination = offsetDestination.getZ();
    final UnmodifiableBiomeVolume firstUnmodifiableArea = this.volume.getUnmodifiableBiomeView();
    final int xMin = firstUnmodifiableArea.getBiomeMin().getX();
    final int yMin = firstUnmodifiableArea.getBiomeMin().getY();
    final int zMin = firstUnmodifiableArea.getBiomeMin().getZ();
    final int xMax = firstUnmodifiableArea.getBiomeMax().getX();
    final int yMax = firstUnmodifiableArea.getBiomeMax().getY();
    final int zMax = firstUnmodifiableArea.getBiomeMax().getZ();
    final UnmodifiableBiomeVolume secondUnmodifiableArea = second.getUnmodifiableBiomeView();
    for (int z = zMin; z <= zMax; z++) {
        for (int y = yMin; y <= yMax; y++) {
            for (int x = xMin; x <= xMax; x++) {
                final BiomeType biome = merger.merge(firstUnmodifiableArea, x, y, z, secondUnmodifiableArea, x + xOffsetSecond, y + yOffsetSecond, z + zOffsetSecond);
                destination.setBiome(x + xOffsetDestination, y + yOffsetDestination, z + zOffsetDestination, biome);
            }
        }
    }
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType) UnmodifiableBiomeVolume(org.spongepowered.api.world.extent.UnmodifiableBiomeVolume) Vector3i(com.flowpowered.math.vector.Vector3i)

Example 2 with UnmodifiableBiomeVolume

use of org.spongepowered.api.world.extent.UnmodifiableBiomeVolume in project SpongeCommon by SpongePowered.

the class SpongeBiomeVolumeWorker method reduce.

@Override
public <T> T reduce(BiomeVolumeReducer<T> reducer, BiFunction<T, T, T> merge, T identity) {
    final UnmodifiableBiomeVolume unmodifiableArea = this.volume.getUnmodifiableBiomeView();
    final int xMin = unmodifiableArea.getBiomeMin().getX();
    final int yMin = unmodifiableArea.getBiomeMin().getY();
    final int zMin = unmodifiableArea.getBiomeMin().getZ();
    final int xMax = unmodifiableArea.getBiomeMax().getX();
    final int yMax = unmodifiableArea.getBiomeMax().getY();
    final int zMax = unmodifiableArea.getBiomeMax().getZ();
    T reduction = identity;
    for (int z = zMin; z <= zMax; z++) {
        for (int y = yMin; y <= yMax; y++) {
            for (int x = xMin; x <= xMax; x++) {
                reduction = reducer.reduce(unmodifiableArea, x, y, z, reduction);
            }
        }
    }
    return reduction;
}
Also used : UnmodifiableBiomeVolume(org.spongepowered.api.world.extent.UnmodifiableBiomeVolume)

Example 3 with UnmodifiableBiomeVolume

use of org.spongepowered.api.world.extent.UnmodifiableBiomeVolume in project SpongeCommon by SpongePowered.

the class SpongeBiomeVolumeWorker method map.

@Override
public void map(BiomeVolumeMapper mapper, MutableBiomeVolume destination) {
    final Vector3i offset = align(destination);
    final int xOffset = offset.getX();
    final int yOffset = offset.getY();
    final int zOffset = offset.getZ();
    final UnmodifiableBiomeVolume unmodifiableArea = this.volume.getUnmodifiableBiomeView();
    final int xMin = unmodifiableArea.getBiomeMin().getX();
    final int yMin = unmodifiableArea.getBiomeMin().getY();
    final int zMin = unmodifiableArea.getBiomeMin().getZ();
    final int xMax = unmodifiableArea.getBiomeMax().getX();
    final int yMax = unmodifiableArea.getBiomeMax().getY();
    final int zMax = unmodifiableArea.getBiomeMax().getZ();
    for (int z = zMin; z <= zMax; z++) {
        for (int y = yMin; y <= yMax; y++) {
            for (int x = xMin; x <= xMax; x++) {
                final BiomeType biome = mapper.map(unmodifiableArea, x, y, z);
                destination.setBiome(x + xOffset, y + yOffset, z + zOffset, biome);
            }
        }
    }
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType) UnmodifiableBiomeVolume(org.spongepowered.api.world.extent.UnmodifiableBiomeVolume) Vector3i(com.flowpowered.math.vector.Vector3i)

Example 4 with UnmodifiableBiomeVolume

use of org.spongepowered.api.world.extent.UnmodifiableBiomeVolume in project LanternServer by LanternPowered.

the class LanternBiomeVolumeWorker method reduce.

@Override
public <T> T reduce(BiomeVolumeReducer<T> reducer, BiFunction<T, T, T> merge, T identity) {
    final UnmodifiableBiomeVolume unmodifiableArea = this.volume.getUnmodifiableBiomeView();
    final int xMin = unmodifiableArea.getBiomeMin().getX();
    final int yMin = unmodifiableArea.getBiomeMin().getY();
    final int zMin = unmodifiableArea.getBiomeMin().getZ();
    final int xMax = unmodifiableArea.getBiomeMax().getX();
    final int yMax = unmodifiableArea.getBiomeMax().getY();
    final int zMax = unmodifiableArea.getBiomeMax().getZ();
    T reduction = identity;
    for (int z = zMin; z <= zMax; z++) {
        for (int y = yMin; y <= yMax; y++) {
            for (int x = xMin; x <= xMax; x++) {
                reduction = reducer.reduce(unmodifiableArea, x, y, z, reduction);
            }
        }
    }
    return reduction;
}
Also used : UnmodifiableBiomeVolume(org.spongepowered.api.world.extent.UnmodifiableBiomeVolume)

Example 5 with UnmodifiableBiomeVolume

use of org.spongepowered.api.world.extent.UnmodifiableBiomeVolume in project LanternServer by LanternPowered.

the class LanternBiomeVolumeWorker method map.

@Override
public void map(BiomeVolumeMapper mapper, MutableBiomeVolume destination) {
    final Vector3i offset = align(destination);
    final int xOffset = offset.getX();
    final int yOffset = offset.getY();
    final int zOffset = offset.getZ();
    final UnmodifiableBiomeVolume unmodifiableArea = this.volume.getUnmodifiableBiomeView();
    final int xMin = unmodifiableArea.getBiomeMin().getX();
    final int yMin = unmodifiableArea.getBiomeMin().getY();
    final int zMin = unmodifiableArea.getBiomeMin().getZ();
    final int xMax = unmodifiableArea.getBiomeMax().getX();
    final int yMax = unmodifiableArea.getBiomeMax().getY();
    final int zMax = unmodifiableArea.getBiomeMax().getZ();
    for (int z = zMin; z <= zMax; z++) {
        for (int y = yMin; y <= yMax; y++) {
            for (int x = xMin; x <= xMax; x++) {
                final BiomeType biome = mapper.map(unmodifiableArea, x, y, z);
                destination.setBiome(x + xOffset, y + yOffset, z + zOffset, biome);
            }
        }
    }
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType) UnmodifiableBiomeVolume(org.spongepowered.api.world.extent.UnmodifiableBiomeVolume) Vector3i(com.flowpowered.math.vector.Vector3i)

Aggregations

UnmodifiableBiomeVolume (org.spongepowered.api.world.extent.UnmodifiableBiomeVolume)6 Vector3i (com.flowpowered.math.vector.Vector3i)4 BiomeType (org.spongepowered.api.world.biome.BiomeType)4