-
Notifications
You must be signed in to change notification settings - Fork 3
Phobos 2.0.0
sagan edited this page Aug 19, 2021
·
1 revision
To build a schematic:
SchemBuilder.from(
myPluginInstance,
Path.of("C:\\path\\to\\schematic\\house.schem").toFile()
).ifPresentOrElse(schemBuilder -> {
schemBuilder.buildAt(someLocation);
}, () -> {
System.out.println("Oh no! Path invalid or loading error :(");
});
Easy right? However, this doesn't do anything cool that phobos was made for. Maybe something like this:
SchemBuilder.from(
myPluginInstance,
Path.of("C:\\path\\to\\schematic\\house.schem").toFile()
).ifPresentOrElse(schemBuilder -> {
schemBuilder
.buildPattern(new RandomBuildPattern())
.placeEffect(new GreenSparkleEffect())
.ticksBetweenIterations(5)
.blocksPerIteration(2)
.ignoreAir(true)
.buildAt(someLocation);
}, () -> {
System.out.println("Oh no! Path invalid or loading error :(");
});
This will build the same schematic but with the following characteristics accordingly:
- Will place blocks randomly (the build pattern)
- Green sparkles will be played at a location around the block (the place effect)
- Will wait 5 ticks before placing a set of blocks (ticks between iterations)
- Will place 2 blocks at a time (blocks per iteration)
- Will ignore air blocks in the clipboard and not place them (ignore air)
The power is yours now. You can make custom block place effect and build pattern classes implementing
PlaceEffect
and BuildPattern
respectively. Look at existing examples in phobos for an idea of what these do
[NOTE]: You also get access to the Clipboard
loaded into the schematic builder via
SchemBuilder#.getClipboard()
. With this you can apply rotations and transformations to the
clipboard before it is built.
These are functional interfaces so you can also inline them:
SchemBuilder.from(
myPluginInstance,
Path.of("C:\\path\\to\\schematic\\house.schem").toFile()
).ifPresentOrElse(schemBuilder -> {
schemBuilder
.buildPattern((location, clipboard) -> {/* whatever I want */})
.placeEffect((location, clipboard) -> {/* whatever I want */})
.buildAt(someLocation);
}, () -> {
System.out.println("Oh no! Path invalid or loading error :(");
});
(All sorting/arranging done in these build patterns is done async)