2929import org .spongepowered .api .event .EventContextKeys ;
3030import org .spongepowered .api .event .cause .entity .SpawnType ;
3131import org .spongepowered .api .util .transformation .Transformation ;
32+ import org .spongepowered .api .world .BlockChangeFlag ;
3233import org .spongepowered .api .world .BlockChangeFlags ;
3334import org .spongepowered .api .world .server .ServerWorld ;
3435import 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