BlockManager
The BlockManager allows you to interact with Nova's blocks. You can place/destroy/get drops/etc.
You can get the BlockManager
using the previously retrieved Nova instance.
Getting a BlockState
The BlockManager also allows you to get a BlockState at a specific location.
You can also check if a block at a specific location is a Nova block via BlockManager.hasBlock(Location)
Block Type
NovaBlock
is a block type, similar to Material
in Bukkit, except that it is only for blocks.
To retrieve the block type of block at a specific location, you can do the following:
Tile Entity
TileEntities use the NovaTileEntityState
class via which you can get the TileEntity
instance of the block.
Placing a block
You can also place a nova block at a specific location by using a NovaBlock
.
val block = blockRegistry.get("machines:pulverizer")
blockManager.placeBlock(
location, // (1)!
block, // (2)!
player, // (3)!
true // (4)!
)
- The location at which to place the block.
- The block type to place.
- The source of the block placement. This doesn't have to be a player, it can also be a tile-entity or similar.
- Whether to play a sound when the block is placed.
NovaBlock block = blockRegistry.get("machines:pulverizer");
blockManager.placeBlock(
location, // (1)!
block, // (2)!
player, // (3)!
true // (4)!
);
- The location at which to place the block.
- The block type to place.
- The source of the block placement. This doesn't have to be a player, it can also be a tile-entity or similar.
- Whether to play a sound when the block is placed.
Note
The BlockManager.placeBlock
function has a few overrides requiring less arguments.
Getting the drops of a block
If you want to get the drops of a block, you can use the BlockManager.getDrops
function. Again, there are a few
overrides requiring less arguments.
Warning
This function will return null
if there is no nova block at the provided location.
- The location of the block.
- The source, again, this doesn't have to be a player, it can also be a tile-entity or similar.
- The tool used to break the block.
Removing a block
You can remove a block at a specific location by using the BlockManager.removeBlock
function. The function will return
a boolean
whether there was a block at the provided location and whether it was removed successfully.
- The location of the block.
- The source, again, this doesn't have to be a player, it can also be a tile-entity or similar.
- Whether to play a sound when the block is removed.
- Whether break particles should be displayed.
- The location of the block.
- The source, again, this doesn't have to be a player, it can also be a tile-entity or similar.
- Whether to play a sound when the block is removed.
- Whether break particles should be displayed.