use of org.spongepowered.api.world.extent.UnmodifiableBlockVolume in project SpongeCommon by SpongePowered.
the class SpongeBlockVolumeWorker method merge.
@Override
public void merge(BlockVolume second, BlockVolumeMerger merger, MutableBlockVolume 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 UnmodifiableBlockVolume firstUnmodifiableVolume = this.volume.getUnmodifiableBlockView();
final int xMin = firstUnmodifiableVolume.getBlockMin().getX();
final int yMin = firstUnmodifiableVolume.getBlockMin().getY();
final int zMin = firstUnmodifiableVolume.getBlockMin().getZ();
final int xMax = firstUnmodifiableVolume.getBlockMax().getX();
final int yMax = firstUnmodifiableVolume.getBlockMax().getY();
final int zMax = firstUnmodifiableVolume.getBlockMax().getZ();
final UnmodifiableBlockVolume secondUnmodifiableVolume = second.getUnmodifiableBlockView();
try (BasicPluginContext context = PluginPhase.State.BLOCK_WORKER.createPhaseContext().source(this).buildAndSwitch()) {
for (int z = zMin; z <= zMax; z++) {
for (int y = yMin; y <= yMax; y++) {
for (int x = xMin; x <= xMax; x++) {
final BlockState block = merger.merge(firstUnmodifiableVolume, x, y, z, secondUnmodifiableVolume, x + xOffsetSecond, y + yOffsetSecond, z + zOffsetSecond);
destination.setBlock(x + xOffsetDestination, y + yOffsetDestination, z + zOffsetDestination, block);
}
}
}
}
}
Aggregations