Skip to content

Commit

Permalink
Allows passing a consumer for blocks inside simultaneousPlace in Stru…
Browse files Browse the repository at this point in the history
…ctrador
  • Loading branch information
anjoismysign committed Nov 14, 2023
1 parent 161e112 commit ed28020
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ci-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.24</version>
<version>1.697.25</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion local-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.24</version>
<version>1.697.25</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.24</version>
<version>1.697.25</version>
<packaging>pom</packaging>

<properties>
Expand Down Expand Up @@ -62,7 +62,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.1</version>
<version>2.12.7.1</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
Expand All @@ -84,7 +84,7 @@
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
<scope>compile</scope>
<version>2.5</version>
<version>2.7</version>
</dependency>
<dependency>
<groupId>com.github.decentsoftware-eu</groupId>
Expand Down
32 changes: 31 additions & 1 deletion src/main/java/us/mytheria/bloblib/utilities/Structrador.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.structure.Mirror;
Expand Down Expand Up @@ -159,7 +160,36 @@ public Blob toBlob() {
public void simultaneousPlace(Location location, boolean includeEntities,
StructureRotation structureRotation, Mirror mirror, int palette,
float integrity, Random random) {
structure.place(location, includeEntities, structureRotation, mirror, palette, integrity, random);
structure.place(location, includeEntities,
structureRotation, mirror, palette, integrity, random);
}

/**
* Will place the structure at the given location in the same tick.
* A consumer will be called for each block placed.
* NOTE: AIR blocks are not ignored!
*
* @param location - The location to place the structure at.
* @param includeEntities - If the entities present in the structure should be spawned.
* @param structureRotation - The rotation of the structure.
* @param mirror - The mirror settings of the structure.
* @param palette - The palette index of the structure to use, starting at 0, or -1 to pick a random palette.
* @param integrity - Determines how damaged the building should look by randomly skipping blocks to place. This value can range from 0 to 1. With 0 removing all blocks and 1 spawning the structure in pristine condition.
* @param random - The randomizer used for setting the structure's LootTables and integrity.
* @param consumer - The consumer that will be called when a block is placed.
*/
public void simultaneousPlace(Location location, boolean includeEntities,
StructureRotation structureRotation, Mirror mirror, int palette,
float integrity, Random random,
Consumer<Block> consumer) {
simultaneousPlace(location, includeEntities, structureRotation, mirror, palette, integrity, random);
structure.getPalettes().stream().map(Palette::getBlocks).flatMap(List::stream).forEach(state -> {
int x = state.getX();
int y = state.getY();
int z = state.getZ();
Block block = location.clone().add(x, y, z).getBlock();
consumer.accept(block);
});
}

/**
Expand Down

0 comments on commit ed28020

Please sign in to comment.