Interface ProtoWorld
public interface ProtoWorld
Represents a small grid of chunks in a
World
with rudimentary block and entity access, for use during world generation.
A ProtoWorld is guaranteed read/write access to a 3x3 grid of chunks, but may have access to a grid as large as 17x17. It is safest to assume that there is only read/write access to 3x3 chunks. Some chunks outside of the 3x3 area may be readable but not writable.
ProtoWorlds should not be stored! After they are used during chunk generation they should be disposed of.
-
Method Summary
Modifier and TypeMethodDescriptiongetBlockData(int x, int y, int z)Get theBlockDataof the block at the provided coordinates.getBlockData(@NotNull Vector vector)Get theBlockDataof the block at the provided coordinates.default intGet the X-coordinate of the block in the center of this ProtoWorlddefault intGet the Z-coordinate of the block in the center of this ProtoWorldintGet the X-coordinate of the chunk in the center of this ProtoWorldintGet the Z-coordinate of the chunk in the center of this ProtoWorldgetWorld()Get theWorldobject this ProtoWorld represents.voidscheduleBlockUpdate(int x, int y, int z)Schedule a block update at (x, y, z).default voidscheduleBlockUpdate(@NotNull Vector location)Schedule a block update at a vector locationvoidscheduleFluidUpdate(int x, int y, int z)Schedule a fluid update at (x, y, z).default voidscheduleFluidUpdate(@NotNull Vector location)Schedule a fluid update at a vector locationvoidsetBlockData(int x, int y, int z, @NotNull BlockData data)Sets the block at (x, y, z) to the providedBlockData.default voidsetBlockData(@NotNull Vector vector, @NotNull BlockData data)Sets the block at a vector location to the providedBlockData.default <T extends Entity>
TSpawn an entity of a specific class at location represented by the givenVectordefault <T extends Entity>
TSpawn an entity of a specific class at the location represented by the givenVector, with the supplied function run before the entity is added to the world.<T extends Entity>
Tspawn(@NotNull Vector location, @NotNull Class<T> clazz, @Nullable Consumer<T> function, CreatureSpawnEvent.SpawnReason reason)default <T extends Entity>
TSpawn an entity of a specific class at location represented by the givenVectordefault <T extends Entity>
Tspawn(@NotNull Vector location, @NotNull Class<T> clazz, CreatureSpawnEvent.SpawnReason reason, @Nullable Consumer<T> function)Spawn an entity of a specific class at the location represented by the givenVector, with the supplied function run before the entity is added to the world.spawnEntity(@NotNull Vector loc, @NotNull EntityType type)Creates a entity at the location represented by the givenVectorspawnEntity(@NotNull Vector loc, @NotNull EntityType type, CreatureSpawnEvent.SpawnReason reason)Creates a entity at the location represented by the givenVectorspawnEntity(@NotNull Vector loc, @NotNull EntityType type, CreatureSpawnEvent.SpawnReason reason, @Nullable Consumer<Entity> function)Creates a entity at the location represented by the givenVector, with the supplied function run before the entity is added to the world.
-
Method Details
-
setBlockData
Sets the block at (x, y, z) to the providedBlockData.- Parameters:
x- X coordinate in this ProtoWorldy- Y coordinate in this ProtoWorldz- Z coordinate in this ProtoWorlddata-BlockDatato set the block at the provided coordinates to.
-
setBlockData
Sets the block at a vector location to the providedBlockData. -
scheduleBlockUpdate
void scheduleBlockUpdate(int x, int y, int z)Schedule a block update at (x, y, z).- Parameters:
x- X coordinate in this ProtoWorldy- Y coordinate in this ProtoWorldz- Z coordinate in this ProtoWorld
-
scheduleBlockUpdate
Schedule a block update at a vector location- Parameters:
location-Vectorrepresenting the position of the block to update.
-
scheduleFluidUpdate
void scheduleFluidUpdate(int x, int y, int z)Schedule a fluid update at (x, y, z).- Parameters:
x- X coordinate in this ProtoWorldy- Y coordinate in this ProtoWorldz- Z coordinate in this ProtoWorld
-
scheduleFluidUpdate
Schedule a fluid update at a vector location- Parameters:
location-Vectorrepresenting the position of the block to update.
-
getWorld
Get theWorldobject this ProtoWorld represents.Do not attempt to read from/write to this world! Doing so during generation will cause a deadlock!
- Returns:
- The
Worldobject that this ProtoWorld represents.
-
getBlockData
Get theBlockDataof the block at the provided coordinates.- Parameters:
x- X coordinate in this ProtoWorldy- Y coordinate in this ProtoWorldz- Z coordinate in this ProtoWorld- Returns:
BlockDataat the coordinates
-
getBlockData
Get theBlockDataof the block at the provided coordinates. -
getCenterChunkX
int getCenterChunkX()Get the X-coordinate of the chunk in the center of this ProtoWorld- Returns:
- The center chunk's X coordinate.
-
getCenterBlockX
default int getCenterBlockX()Get the X-coordinate of the block in the center of this ProtoWorld- Returns:
- The center chunk's X coordinate.
-
getCenterChunkZ
int getCenterChunkZ()Get the Z-coordinate of the chunk in the center of this ProtoWorld- Returns:
- The center chunk's Z coordinate.
-
getCenterBlockZ
default int getCenterBlockZ()Get the Z-coordinate of the block in the center of this ProtoWorld- Returns:
- The center chunk's Z coordinate.
-
spawnEntity
@NotNull default @NotNull Entity spawnEntity(@NotNull @NotNull Vector loc, @NotNull @NotNull EntityType type)Creates a entity at the location represented by the givenVector- Parameters:
loc- TheVectorrepresenting the location to spawn the entitytype- The entity to spawn- Returns:
- Resulting Entity of this method
-
spawn
@NotNull default <T extends Entity> T spawn(@NotNull @NotNull Vector location, @NotNull @NotNull Class<T> clazz) throws IllegalArgumentExceptionSpawn an entity of a specific class at location represented by the givenVector- Type Parameters:
T- The class of theEntityto spawn- Parameters:
location- TheVectorrepresenting the location to spawn the entity atclazz- The class of theEntityto spawn- Returns:
- An instance of the spawned
Entity - Throws:
IllegalArgumentException- if either parameter is null or theEntityrequested cannot be spawned
-
spawn
@NotNull default <T extends Entity> T spawn(@NotNull @NotNull Vector location, @NotNull @NotNull Class<T> clazz, @NotNull CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentExceptionSpawn an entity of a specific class at location represented by the givenVector- Type Parameters:
T- The class of theEntityto spawn- Parameters:
location- TheVectorrepresenting the location to spawn the entity atclazz- The class of theEntityto spawnreason- The reason for the entity's spawn.- Returns:
- An instance of the spawned
Entity - Throws:
IllegalArgumentException- if either parameter is null or theEntityrequested cannot be spawned
-
spawn
@NotNull default <T extends Entity> T spawn(@NotNull @NotNull Vector location, @NotNull @NotNull Class<T> clazz, @Nullable @Nullable Consumer<T> function) throws IllegalArgumentExceptionSpawn an entity of a specific class at the location represented by the givenVector, with the supplied function run before the entity is added to the world.
Note that when the function is run, the entity will not be actually in the world. Any operation involving such as teleporting the entity is undefined until after this function returns.- Type Parameters:
T- The class of theEntityto spawn- Parameters:
location- TheVectorrepresenting the location to spawn the entity atclazz- The class of theEntityto spawnfunction- The function to be run before the entity is spawned.- Returns:
- An instance of the spawned
Entity - Throws:
IllegalArgumentException- if either parameter is null or theEntityrequested cannot be spawned
-
spawn
@NotNull default <T extends Entity> T spawn(@NotNull @NotNull Vector location, @NotNull @NotNull Class<T> clazz, @NotNull CreatureSpawnEvent.SpawnReason reason, @Nullable @Nullable Consumer<T> function) throws IllegalArgumentExceptionSpawn an entity of a specific class at the location represented by the givenVector, with the supplied function run before the entity is added to the world.
Note that when the function is run, the entity will not be actually in the world. Any operation involving such as teleporting the entity is undefined until after this function returns.- Type Parameters:
T- The class of theEntityto spawn- Parameters:
location- TheVectorrepresenting the location to spawn the entity atclazz- The class of theEntityto spawnreason- The reason for the entity's spawn.function- The function to be run before the entity is spawned.- Returns:
- An instance of the spawned
Entity - Throws:
IllegalArgumentException- if either parameter is null or theEntityrequested cannot be spawned
-
spawnEntity
@NotNull default @NotNull Entity spawnEntity(@NotNull @NotNull Vector loc, @NotNull @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason)Creates a entity at the location represented by the givenVector- Parameters:
loc- TheVectorrepresenting the location to spawn the entitytype- The entity to spawnreason- The reason for the entity's spawn.- Returns:
- Resulting Entity of this method
-
spawnEntity
@NotNull default @NotNull Entity spawnEntity(@NotNull @NotNull Vector loc, @NotNull @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason, @Nullable @Nullable Consumer<Entity> function)Creates a entity at the location represented by the givenVector, with the supplied function run before the entity is added to the world.
Note that when the function is run, the entity will not be actually in the world. Any operation involving such as teleporting the entity is undefined until after this function returns.- Parameters:
loc- TheVectorrepresenting the location to spawn the entitytype- The entity to spawnreason- The reason for the entity's spawn.function- The function to be run before the entity is spawned.- Returns:
- Resulting Entity of this method
-
spawn
@NotNull <T extends Entity> T spawn(@NotNull @NotNull Vector location, @NotNull @NotNull Class<T> clazz, @Nullable @Nullable Consumer<T> function, @NotNull CreatureSpawnEvent.SpawnReason reason) throws IllegalArgumentException- Throws:
IllegalArgumentException
-