-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent the initial pool bounds from being mutated (#23)
- Loading branch information
Showing
2 changed files
with
67 additions
and
50 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/java/fr/catcore/deacoudre/game/map/BlockBoundsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package fr.catcore.deacoudre.game.map; | ||
|
||
import net.minecraft.util.math.BlockPos; | ||
import xyz.nucleoid.map_templates.BlockBounds; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class BlockBoundsBuilder implements Consumer<BlockPos> { | ||
private final Consumer<BlockPos> delegate; | ||
|
||
private BlockBounds bounds = null; | ||
|
||
public BlockBoundsBuilder(Consumer<BlockPos> delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public void accept(BlockPos pos) { | ||
var addedBounds = BlockBounds.ofBlock(pos.toImmutable()); | ||
this.bounds = this.bounds == null ? addedBounds : this.bounds.union(addedBounds); | ||
|
||
this.delegate.accept(pos); | ||
} | ||
|
||
public BlockBounds getBounds() { | ||
return this.bounds; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters