Skip to content

Commit 723d5c2

Browse files
committed
Add overload with BlockChangeFlag to ArchetypeVolume#applyToWorld
1 parent 5e2393c commit 723d5c2

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/main/java/org/spongepowered/api/world/volume/archetype/ArchetypeVolume.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.spongepowered.api.event.EventContextKeys;
3030
import org.spongepowered.api.event.cause.entity.SpawnType;
3131
import org.spongepowered.api.util.transformation.Transformation;
32+
import org.spongepowered.api.world.BlockChangeFlag;
3233
import org.spongepowered.api.world.BlockChangeFlags;
3334
import org.spongepowered.api.world.server.ServerWorld;
3435
import org.spongepowered.api.world.volume.archetype.block.entity.BlockEntityArchetypeVolume;
@@ -76,14 +77,32 @@ default Vector3d logicalCenter() {
7677
* @param spawnContext The context value used for processing spawn entities.
7778
*/
7879
default void applyToWorld(final ServerWorld target, final Vector3i placement, final Supplier<SpawnType> spawnContext) {
80+
this.applyToWorld(target, placement, spawnContext, BlockChangeFlags.DEFAULT_PLACEMENT);
81+
}
82+
83+
/**
84+
* Attempts to apply all of the contents of this
85+
* {@link ArchetypeVolume volume} onto the target {@link ServerWorld world}
86+
* with a relative {@code placement}. This default implementation can be
87+
* used as a guide for utilizing
88+
* {@link org.spongepowered.api.world.volume.stream.VolumeStream VolumeStreams}
89+
* and their companion types.
90+
*
91+
* @param target The target world
92+
* @param placement The target origin, where the diff of relative position
93+
* compared to this volume's min position as the offset
94+
* @param spawnContext The context value used for processing spawn entities.
95+
* @param flag The various change flags controlling some interactions
96+
*/
97+
default void applyToWorld(final ServerWorld target, final Vector3i placement, final Supplier<SpawnType> spawnContext, final BlockChangeFlag flag) {
7998
Objects.requireNonNull(target, "Target world cannot be null");
8099
Objects.requireNonNull(placement, "Target position cannot be null");
81100
try (final CauseStackManager.StackFrame frame = Sponge.server().causeStackManager().pushCauseFrame()) {
82101
this.blockStateStream(this.min(), this.max(), StreamOptions.lazily())
83102
.apply(VolumeCollectors.of(
84103
target,
85104
VolumePositionTranslators.relativeTo(placement),
86-
VolumeApplicators.applyBlocks(BlockChangeFlags.DEFAULT_PLACEMENT)
105+
VolumeApplicators.applyBlocks(flag)
87106
));
88107

89108
this.biomeStream(this.min(), this.max(), StreamOptions.lazily())
@@ -107,5 +126,4 @@ default void applyToWorld(final ServerWorld target, final Vector3i placement, fi
107126
));
108127
}
109128
}
110-
111129
}

0 commit comments

Comments
 (0)