From 723d5c2f6bf5eeb834980da725d43610790b33d5 Mon Sep 17 00:00:00 2001 From: aromaa Date: Thu, 10 Oct 2024 21:41:12 +0300 Subject: [PATCH] Add overload with BlockChangeFlag to ArchetypeVolume#applyToWorld --- .../volume/archetype/ArchetypeVolume.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spongepowered/api/world/volume/archetype/ArchetypeVolume.java b/src/main/java/org/spongepowered/api/world/volume/archetype/ArchetypeVolume.java index 18b5002490..5ed26a6494 100644 --- a/src/main/java/org/spongepowered/api/world/volume/archetype/ArchetypeVolume.java +++ b/src/main/java/org/spongepowered/api/world/volume/archetype/ArchetypeVolume.java @@ -29,6 +29,7 @@ import org.spongepowered.api.event.EventContextKeys; import org.spongepowered.api.event.cause.entity.SpawnType; import org.spongepowered.api.util.transformation.Transformation; +import org.spongepowered.api.world.BlockChangeFlag; import org.spongepowered.api.world.BlockChangeFlags; import org.spongepowered.api.world.server.ServerWorld; import org.spongepowered.api.world.volume.archetype.block.entity.BlockEntityArchetypeVolume; @@ -76,6 +77,24 @@ default Vector3d logicalCenter() { * @param spawnContext The context value used for processing spawn entities. */ default void applyToWorld(final ServerWorld target, final Vector3i placement, final Supplier spawnContext) { + this.applyToWorld(target, placement, spawnContext, BlockChangeFlags.DEFAULT_PLACEMENT); + } + + /** + * Attempts to apply all of the contents of this + * {@link ArchetypeVolume volume} onto the target {@link ServerWorld world} + * with a relative {@code placement}. This default implementation can be + * used as a guide for utilizing + * {@link org.spongepowered.api.world.volume.stream.VolumeStream VolumeStreams} + * and their companion types. + * + * @param target The target world + * @param placement The target origin, where the diff of relative position + * compared to this volume's min position as the offset + * @param spawnContext The context value used for processing spawn entities. + * @param flag The various change flags controlling some interactions + */ + default void applyToWorld(final ServerWorld target, final Vector3i placement, final Supplier spawnContext, final BlockChangeFlag flag) { Objects.requireNonNull(target, "Target world cannot be null"); Objects.requireNonNull(placement, "Target position cannot be null"); try (final CauseStackManager.StackFrame frame = Sponge.server().causeStackManager().pushCauseFrame()) { @@ -83,7 +102,7 @@ default void applyToWorld(final ServerWorld target, final Vector3i placement, fi .apply(VolumeCollectors.of( target, VolumePositionTranslators.relativeTo(placement), - VolumeApplicators.applyBlocks(BlockChangeFlags.DEFAULT_PLACEMENT) + VolumeApplicators.applyBlocks(flag) )); this.biomeStream(this.min(), this.max(), StreamOptions.lazily()) @@ -107,5 +126,4 @@ default void applyToWorld(final ServerWorld target, final Vector3i placement, fi )); } } - }