Package net.glowstone.block.blocktype
Class BlockType
java.lang.Object
net.glowstone.block.itemtype.ItemType
net.glowstone.block.blocktype.BlockType
- Direct Known Subclasses:
BlockBanner
,BlockBed
,BlockCactus
,BlockChorusFlower
,BlockChorusPlant
,BlockClimbable
,BlockContainer
,BlockDaylightDetector
,BlockDirectional
,BlockDirt
,BlockDoor
,BlockDoubleSlab
,BlockDropless
,BlockFalling
,BlockFarmland
,BlockFlowerPot
,BlockGrass
,BlockHay
,BlockHugeMushroom
,BlockIce
,BlockJukebox
,BlockLamp
,BlockLeaves
,BlockLiquid
,BlockLog
,BlockMelon
,BlockMonsterEgg
,BlockMycel
,BlockNeedsAttached
,BlockNeedsTool
,BlockNote
,BlockOpenable
,BlockSkull
,BlockSlab
,BlockSnowBlock
,BlockSponge
,BlockStairs
,BlockTnt
,BlockWeb
,BlockWorkbench
Base class for specific types of blocks.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.glowstone.block.itemtype.ItemType
ItemType.Context
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final org.bukkit.block.BlockFace[]
protected List<org.bukkit.inventory.ItemStack>
protected SoundInfo
Gets the sound that will be played when a player places the block.protected static final org.bukkit.block.BlockFace[]
protected GlowBlockSoundGroup
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterDestroy
(GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace face, GlowBlockState oldState) Called after a player successfully destroys a block.void
afterPlace
(GlowPlayer player, GlowBlock block, org.bukkit.inventory.ItemStack holding, GlowBlockState oldState) Called after a block has been placed by a player.void
blockDestroy
(GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace face) Called when a player attempts to destroy a block.boolean
blockInteract
(GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace face, org.bukkit.util.Vector clickedLoc) Called when a player attempts to interact with (right-click) a block of this type already in the world.boolean
Called when a player attempts to place a block on an existing block of this type.boolean
canOverride
(GlowBlock block, org.bukkit.block.BlockFace face, org.bukkit.inventory.ItemStack holding) Called to check if this block can be overridden by a block place which would occur inside it.boolean
canPlaceAt
(GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace against) Check whether the block can be placed at the given location.boolean
Called to check if this block can perform random tick updates.createBlockEntity
(GlowChunk chunk, int cx, int cy, int cz) Create a new block entity at the given location.protected <T extends org.bukkit.block.data.BlockData>
TgetCastedBlockData
(Class<T> clazz, org.bukkit.block.data.BlockData data) Assert that block data matches the expected BlockData class@NotNull Collection<org.bukkit.inventory.ItemStack>
Get the items that will be dropped by digging the block.@NotNull Collection<org.bukkit.inventory.ItemStack>
getMinedDrops
(GlowBlock block) Get the items that would be dropped if the block was successfully mined.protected static org.bukkit.block.BlockFace
getOppositeBlockFace
(org.bukkit.Location location, boolean inverted) Gets the BlockFace opposite of the direction the location is facing.The type of block to place when the item is used.Gets the sound that will be played when a player places the block.int
getPulseTickSpeed
(GlowBlock block) The rate at which the block should be pulsed.boolean
isPulseOnce
(GlowBlock block) Whether the block should only be pulsed once.void
leftClickBlock
(GlowPlayer player, GlowBlock block, org.bukkit.inventory.ItemStack holding) Called when a player left clicks a block.void
onBlockChanged
(GlowBlock block, org.bukkit.Material oldType, byte oldData, org.bukkit.Material newType, byte data) Called when this block has just changed to some other type.void
onEntityStep
(GlowBlock block, org.bukkit.entity.LivingEntity entity) Called when an entity gets updated on top of the block.void
onNearBlockChanged
(GlowBlock block, org.bukkit.block.BlockFace face, GlowBlock changedBlock, org.bukkit.Material oldType, byte oldData, org.bukkit.Material newType, byte newData) Called when a neighboring block (within a 3x3x3 cube) has changed its type or data and physics checks should occur.void
onRedstoneUpdate
(GlowBlock block) void
placeBlock
(GlowPlayer player, GlowBlockState state, org.bukkit.block.BlockFace face, org.bukkit.inventory.ItemStack holding, org.bukkit.util.Vector clickedLoc) Called when a block is placed to calculate what the block will become.void
receivePulse
(GlowBlock block) Called when the BlockType gets pulsed as requested.void
requestPulse
(GlowBlockState state) final void
rightClickBlock
(GlowPlayer player, GlowBlock against, org.bukkit.block.BlockFace face, org.bukkit.inventory.ItemStack holding, org.bukkit.util.Vector clickedLoc, org.bukkit.inventory.EquipmentSlot hand) Called when a player right-clicks on a block while holding this item.protected final void
setDrops
(org.bukkit.inventory.ItemStack... drops) void
setPlaceSound
(org.bukkit.Sound sound) Sets the sound that will be played when a player places the block.void
updateBlock
(GlowBlock block) Called when this block needs to be updated.final void
updatePhysics
(GlowBlock block) Called when the BlockType should calculate the current physics.void
updatePhysicsAfterEvent
(GlowBlock block) protected void
warnMaterialData
(Class<?> clazz, org.bukkit.material.MaterialData data) Deprecated.MaterialData is no longer used (1.13).Methods inherited from class net.glowstone.block.itemtype.ItemType
getContext, getMaterial, getMaterials, getMaxStackSize, rightClickAir, setMaterial, setMaxStackSize, setPlaceAs, setPlaceAs, toString
-
Field Details
-
SIDES
protected static final org.bukkit.block.BlockFace[] SIDES -
ADJACENT
protected static final org.bukkit.block.BlockFace[] ADJACENT -
drops
-
placeSound
Gets the sound that will be played when a player places the block. -
soundGroup
-
-
Constructor Details
-
BlockType
public BlockType()
-
-
Method Details
-
getOppositeBlockFace
protected static org.bukkit.block.BlockFace getOppositeBlockFace(org.bukkit.Location location, boolean inverted) Gets the BlockFace opposite of the direction the location is facing. Usually used to set the way container blocks face when being placed.- Parameters:
location
- Location to get opposite ofinverted
- If up/down should be used- Returns:
- Opposite BlockFace or EAST if yaw is invalid
-
setDrops
protected final void setDrops(org.bukkit.inventory.ItemStack... drops) -
getDrops
@NotNull public @NotNull Collection<org.bukkit.inventory.ItemStack> getDrops(GlowBlock block, org.bukkit.inventory.ItemStack tool) Get the items that will be dropped by digging the block.- Parameters:
block
- The block being dug.tool
- The tool used ornull
if fists or no tool was used.- Returns:
- The drops that should be returned.
-
setPlaceSound
public void setPlaceSound(org.bukkit.Sound sound) Sets the sound that will be played when a player places the block.- Parameters:
sound
- The sound.
-
getMinedDrops
Get the items that would be dropped if the block was successfully mined. This is used f.e. to calculate TNT drops.- Parameters:
block
- The block.- Returns:
- The drops from that block.
-
createBlockEntity
Create a new block entity at the given location.- Parameters:
chunk
- The chunk to create the block entity at.cx
- The x coordinate in the chunk.cy
- The y coordinate in the chunk.cz
- The z coordinate in the chunk.- Returns:
- The new BlockEntity, or null if no block entity is used.
-
canPlaceAt
public boolean canPlaceAt(@Nullable GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace against) Check whether the block can be placed at the given location.- Parameters:
player
- The player who placed the block.block
- The location the block is being placed at.against
- The face the block is being placed against.- Returns:
- Whether the placement is valid.
-
placeBlock
public void placeBlock(GlowPlayer player, GlowBlockState state, org.bukkit.block.BlockFace face, org.bukkit.inventory.ItemStack holding, org.bukkit.util.Vector clickedLoc) Called when a block is placed to calculate what the block will become.- Parameters:
player
- the player who placed the blockstate
- the BlockState to editholding
- the ItemStack that was being heldface
- the face off which the block is being placedclickedLoc
- where in the block the click occurred
-
afterPlace
public void afterPlace(GlowPlayer player, GlowBlock block, org.bukkit.inventory.ItemStack holding, GlowBlockState oldState) Called after a block has been placed by a player.- Parameters:
player
- the player who placed the blockblock
- the block that was placedholding
- the the ItemStack that was being heldoldState
- The old block state before the block was placed.
-
blockInteract
public boolean blockInteract(GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace face, org.bukkit.util.Vector clickedLoc) Called when a player attempts to interact with (right-click) a block of this type already in the world.- Parameters:
player
- the player interactingblock
- the block interacted withface
- the clicked faceclickedLoc
- where in the block the click occurred- Returns:
- Whether the interaction occurred.
-
blockDestroy
Called when a player attempts to destroy a block.- Parameters:
player
- The player interactingblock
- The block the player destroyedface
- The block face
-
afterDestroy
public void afterDestroy(GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace face, GlowBlockState oldState) Called after a player successfully destroys a block.- Parameters:
player
- The player interactingblock
- The block the player destroyedface
- The block faceoldState
- The block state of the block the player destroyed.
-
receivePulse
Called when the BlockType gets pulsed as requested.- Parameters:
block
- The block that was pulsed
-
canAbsorb
public boolean canAbsorb(GlowBlock block, org.bukkit.block.BlockFace face, org.bukkit.inventory.ItemStack holding) Called when a player attempts to place a block on an existing block of this type. Used to determine if the placement should occur into the air adjacent to the block (normal behavior), or absorbed into the block clicked on.- Parameters:
block
- The block the player right-clickedface
- The face on which the click occurredholding
- The ItemStack the player was holding- Returns:
- Whether the place should occur into the block given.
-
canOverride
public boolean canOverride(GlowBlock block, org.bukkit.block.BlockFace face, org.bukkit.inventory.ItemStack holding) Called to check if this block can be overridden by a block place which would occur inside it.- Parameters:
block
- The block being targeted by the placementface
- The face on which the click occurredholding
- The ItemStack the player was holding- Returns:
- Whether this block can be overridden.
-
onNearBlockChanged
public void onNearBlockChanged(GlowBlock block, org.bukkit.block.BlockFace face, GlowBlock changedBlock, org.bukkit.Material oldType, byte oldData, org.bukkit.Material newType, byte newData) Called when a neighboring block (within a 3x3x3 cube) has changed its type or data and physics checks should occur.- Parameters:
block
- The block to perform physics checks forface
- The BlockFace to the changed block, or null if unavailablechangedBlock
- The neighboring block that has changedoldType
- The old type of the changed blockoldData
- The old data of the changed blocknewType
- The new type of the changed blocknewData
- The new data of the changed block
-
onBlockChanged
public void onBlockChanged(GlowBlock block, org.bukkit.Material oldType, byte oldData, org.bukkit.Material newType, byte data) Called when this block has just changed to some other type.This is called whenever
GlowBlock.setTypeIdAndData(int, byte, boolean)
,GlowBlock.setType(org.bukkit.Material)
orGlowBlock.setData(byte)
is called with physics enabled, and might be called from plugins or other means of changing the block.- Parameters:
block
- The block that was changedoldType
- The old MaterialoldData
- The old datanewType
- The new Materialdata
- The new data
-
updatePhysics
Called when the BlockType should calculate the current physics.
Subclasses should override
updatePhysicsAfterEvent(GlowBlock)
if they need a custom handling of the physics calculation- Parameters:
block
- The block
-
updatePhysicsAfterEvent
-
rightClickBlock
public final void rightClickBlock(GlowPlayer player, GlowBlock against, org.bukkit.block.BlockFace face, org.bukkit.inventory.ItemStack holding, org.bukkit.util.Vector clickedLoc, org.bukkit.inventory.EquipmentSlot hand) Description copied from class:ItemType
Called when a player right-clicks on a block while holding this item.- Overrides:
rightClickBlock
in classItemType
- Parameters:
player
- The playeragainst
- The block the player right-clickedface
- The face on which the click occurredholding
- The ItemStack the player was holdingclickedLoc
- The coordinates at which the click occurredhand
- The hand slot of this item
-
canTickRandomly
public boolean canTickRandomly()Called to check if this block can perform random tick updates.- Returns:
- Whether this block updates on tick.
-
updateBlock
Called when this block needs to be updated.- Parameters:
block
- The block that needs an update
-
leftClickBlock
public void leftClickBlock(GlowPlayer player, GlowBlock block, org.bukkit.inventory.ItemStack holding) Called when a player left clicks a block.- Parameters:
player
- the player who clicked the blockblock
- the block that was clickedholding
- the ItemStack that was being held
-
warnMaterialData
Deprecated.MaterialData is no longer used (1.13). Use getCastedBlockData.Display the warning for finding the wrong MaterialData subclass.- Parameters:
clazz
- The expected subclass of MaterialData.data
- The actual MaterialData found.
-
getCastedBlockData
protected <T extends org.bukkit.block.data.BlockData> T getCastedBlockData(Class<T> clazz, org.bukkit.block.data.BlockData data) Assert that block data matches the expected BlockData class- Parameters:
clazz
- The expected subclass of BlockData.data
- The actual MaterialData found.- Returns:
- The casted block data.
-
onRedstoneUpdate
-
onEntityStep
Called when an entity gets updated on top of the block.- Parameters:
block
- the block that was stepped onentity
- the entity
-
getPlaceAs
Description copied from class:ItemType
The type of block to place when the item is used.- Overrides:
getPlaceAs
in classItemType
- Returns:
- the type of block to place
-
requestPulse
-
getPulseTickSpeed
The rate at which the block should be pulsed.- Parameters:
block
- the block- Returns:
- 0 if the block should not pulse, or a number of ticks between pulses.
-
isPulseOnce
Whether the block should only be pulsed once.- Parameters:
block
- the block- Returns:
- true if the block should be pulsed once, false otherwise.
-
getPlaceSound
Gets the sound that will be played when a player places the block.- Returns:
- The sound to be played
-
getSoundGroup
-