Class PylonBlock
-
- All Implemented Interfaces:
public class PylonBlock
All custom Pylon blocks extend this class. Every instance of this class is wrapping a real block in the world, and is stored in BlockStorage. All new block types must be registered using register.
An implementation of PylonBlock must have two constructors: one that takes a Block and a BlockCreateContext, and one that takes a Block and a PersistentDataContainer. The first constructor is known as the "create constructor", and is used when the block is created in the world. The second constructor is known as the "load constructor", and is used to reconstruct the block when the chunk containing the block is loaded.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
PylonBlock.Companion
-
Field Summary
Fields Modifier and Type Field Description private final PylonBlockSchema
schema
private final NamespacedKey
key
private final TranslatableComponent
defaultTranslationKey
private final Block
block
public final static PylonBlock.Companion
Companion
-
Constructor Summary
Constructors Constructor Description PylonBlock(Block block, BlockCreateContext context)
This constructor is called when a new block is created in the world ex: A player places a block
BlockStorage.placeBlock
called
PylonBlock(Block block, PersistentDataContainer pdc)
This constructor is called while the chunk is being loaded
-
Method Summary
Modifier and Type Method Description final PylonBlockSchema
getSchema()
The schema of a block is all the data needed to create or load the block. final NamespacedKey
getKey()
final TranslatableComponent
getDefaultTranslationKey()
final Block
getBlock()
WailaConfig
getWaila(Player player)
This will only be called for the player if the player has WAILA enabled ItemStack
getItem(BlockItemContext context)
Called when the corresponding item of the block is requested. Unit
write(PersistentDataContainer pdc)
Called when the block is saved final Config
getSettings()
final static Unit
register(NamespacedKey key, Material material, Class<out PylonBlock> blockClass)
-
-
Constructor Detail
-
PylonBlock
PylonBlock(Block block, BlockCreateContext context)
This constructor is called when a new block is created in the world ex:A player places a block
BlockStorage.placeBlock
called
-
PylonBlock
PylonBlock(Block block, PersistentDataContainer pdc)
This constructor is called while the chunk is being loaded
-
-
Method Detail
-
getSchema
final PylonBlockSchema getSchema()
The schema of a block is all the data needed to create or load the block.
-
getKey
final NamespacedKey getKey()
-
getDefaultTranslationKey
final TranslatableComponent getDefaultTranslationKey()
-
getWaila
WailaConfig getWaila(Player player)
This will only be called for the player if the player has WAILA enabled
- Returns:
the WAILA configuration, or null if WAILA should not be shown for this block
-
getItem
ItemStack getItem(BlockItemContext context)
Called when the corresponding item of the block is requested. By default, returns the item with the same key as the block. If the block is being broken, the item will only be returned if BlockBreakContext.normallyDrops is true, otherwise it will return null.
- Returns:
the item, or null if none
-
write
Unit write(PersistentDataContainer pdc)
Called when the block is saved
-
getSettings
final Config getSettings()
-
register
final static Unit register(NamespacedKey key, Material material, Class<out PylonBlock> blockClass)
-
-
-
-