Add methods to ProtoWorld
for working with BlockState
s (#5929)
This commit is contained in:
parent
0b90741c3f
commit
6a93c5c949
2 changed files with 324 additions and 6 deletions
|
@ -13,6 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+package io.papermc.paper.world.generation;
|
||||
+
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.block.data.BlockData;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
|
@ -58,6 +59,48 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param x X coordinate.
|
||||
+ * @param y Y coordinate.
|
||||
+ * @param z Z coordinate.
|
||||
+ * @param state The block state.
|
||||
+ */
|
||||
+ void setBlockState(int x, int y, int z, @NotNull BlockState state);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param location Location to set block state.
|
||||
+ * @param state The block state.
|
||||
+ */
|
||||
+ default void setBlockState(@NotNull Vector location, @NotNull BlockState state) {
|
||||
+ setBlockState(location.getBlockX(), location.getBlockY(), location.getBlockZ(), state);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param x X coordinate.
|
||||
+ * @param y Y coordinate.
|
||||
+ * @param z Z coordinate.
|
||||
+ * @return The block state.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ BlockState getBlockState(int x, int y, int z);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link BlockState} at a location.
|
||||
+ *
|
||||
+ * @param location Location to get block state from.
|
||||
+ * @return The block state.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ default BlockState getBlockState(@NotNull Vector location) {
|
||||
+ return getBlockState(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Schedule a block update at (x, y, z).
|
||||
+ *
|
||||
+ * @param x X coordinate in this ProtoWorld
|
||||
|
@ -134,7 +177,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ int getCenterChunkX();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the X-coordinate of the block in the center of this ProtoWorld
|
||||
+ * Get the X-coordinate of the block in the center of this {@link ProtoWorld}
|
||||
+ *
|
||||
+ * @return The center chunk's X coordinate.
|
||||
+ */
|
||||
|
@ -143,14 +186,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the Z-coordinate of the chunk in the center of this ProtoWorld
|
||||
+ * Get the Z-coordinate of the chunk in the center of this {@link ProtoWorld}
|
||||
+ *
|
||||
+ * @return The center chunk's Z coordinate.
|
||||
+ */
|
||||
+ int getCenterChunkZ();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the Z-coordinate of the block in the center of this ProtoWorld
|
||||
+ * Get the Z-coordinate of the block in the center of this {@link ProtoWorld}
|
||||
+ *
|
||||
+ * @return The center chunk's Z coordinate.
|
||||
+ */
|
||||
|
@ -159,7 +202,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a entity at the location represented by the given {@link Vector}
|
||||
+ * Creates an entity at the location represented by the given {@link Vector}
|
||||
+ *
|
||||
+ * @param loc The {@link Vector} representing the location to spawn the entity
|
||||
+ * @param type The entity to spawn
|
||||
|
@ -245,7 +288,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a entity at the location represented by the given {@link Vector}
|
||||
+ * Creates an entity at the location represented by the given {@link Vector}
|
||||
+ *
|
||||
+ * @param loc The {@link Vector} representing the location to spawn the entity
|
||||
+ * @param type The entity to spawn
|
||||
|
@ -259,7 +302,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a entity at the location represented by the given {@link Vector}, with
|
||||
+ * Creates an entity at the location represented by the given {@link Vector}, with
|
||||
+ * the supplied function run before the entity is added to the world.
|
||||
+ * <br>
|
||||
+ * Note that when the function is run, the entity will not be actually in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue