Skip to content

Commit 967d871

Browse files
committed
Add chess pattern
1 parent 8dc1319 commit 967d871

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

fastasyncworldedit/API/fill-region-by-pattern.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,47 @@
33
## Foreword
44
First of all, patterns usually come from the core part of WorldEdit or FAWE. You can find all existing patterns [here](https://intellectualsites.github.io/fastasyncworldedit-javadocs/worldedit-core/com/sk89q/worldedit/function/pattern/Pattern.html)
55

6+
## Chess Pattern example
7+
Given are 3 things:
8+
- Position1: X=300, y=-64, z=300
9+
- Position2: X=600, y=128, z=600
10+
11+
{% hint style="danger" %}
12+
**This code is Fawe specific and can not used in WorldEdit in this way**
13+
{% endhint %}
14+
```java
15+
public void setChessArea(World world, BlockVector3 position1, BlockVector3 position 2) {
16+
// Here we must first adapt the world as in the WorldEdit example or translate it into the WorldEdit specialized object.
17+
World faweWorld = BukkitAdapter.adapt(world);
18+
19+
//Now we define a square region using our 2 positions
20+
CuboidRegion cuboidRegion = new CuboidRegion(position1, position2);
21+
22+
// Now we open an EditSession, which contains the complete process or information during an edit process in the world.
23+
// Through the try-and-catch-with-resources we let Java automatically close the resource EditSession after use
24+
try (EditSession editSession = WorldEdit.getInstance().newEditSession(faweWorld)) {
25+
// Here we create our biome pattern
26+
var pattern = new Linear3DBlockPattern(new Pattern[]{ BlockTypes.WHITE_WOOL, BlockTypes.BLACK_WOOL }, 2, 2, 2);
27+
28+
//This sets the pattern to the region
29+
editSession.setBlocks((Region) cuboidRegion, pattern);
30+
}
31+
}
32+
// This code would be called by the plugin in the main thread
33+
public void call() {
34+
// Here we set our position 1 and 2
35+
BlockVector3 position1 = BlockVector3.at(300, -64, 300);
36+
BlockVector3 position2 = BlockVector3.at(600, 128, 600);
37+
World bukkitWorld = Bukkit.getWorld("world");
38+
setChessArea(bukkitWorld, position1, position2);
39+
}
40+
```
41+
42+
### Result:
43+
44+
![api_chess_pattern.png](/fastasyncworldedit/images/api_chess_pattern.png)
45+
46+
647
## Biome Cuboid Example
748
Given are 3 things:
849
- Position1: X=300, y=-64, z=300
1.38 MB
Loading

0 commit comments

Comments
 (0)