Package net.glowstone.block.blocktype
Class BlockBed
java.lang.Object
net.glowstone.block.itemtype.ItemType
net.glowstone.block.blocktype.BlockType
net.glowstone.block.blocktype.BlockBed
-
Nested Class Summary
Nested classes/interfaces inherited from class net.glowstone.block.itemtype.ItemType
ItemType.Context
-
Field Summary
Fields inherited from class net.glowstone.block.blocktype.BlockType
ADJACENT, drops, placeSound, SIDES, soundGroup
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterPlace
(GlowPlayer player, GlowBlock block, org.bukkit.inventory.ItemStack holding, GlowBlockState oldState) Called after a block has been placed by a player.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
canPlaceAt
(GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace against) Check whether the block can be placed at the given location.createBlockEntity
(GlowChunk chunk, int cx, int cy, int cz) Create a new block entity at the given location.@NotNull Collection<org.bukkit.inventory.ItemStack>
Get the items that will be dropped by digging the block.static org.bukkit.block.Block
getExitLocation
(GlowBlock head, GlowBlock foot) Returns an 'empty' block next to the bed used to put the player at when they exit a bed or respawn.static GlowBlock
Returns the foot of a bed given one of its blocks.static GlowBlock
Returns the head of a bed given one of its blocks.static boolean
isOccupied
(GlowBlock block) Return whether the specified bed block is occupied.static boolean
isValidSpawn
(org.bukkit.Material material) Returns whether a player can spawn within a block of specified material.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
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.static void
setOccupied
(GlowBlock head, GlowBlock foot, boolean occupied) Helper method for set whether the specified bed blocks are occupied.Methods inherited from class net.glowstone.block.blocktype.BlockType
afterDestroy, blockDestroy, canAbsorb, canOverride, canTickRandomly, getCastedBlockData, getMinedDrops, getOppositeBlockFace, getPlaceAs, getPlaceSound, getPulseTickSpeed, getSoundGroup, isPulseOnce, leftClickBlock, onBlockChanged, onEntityStep, onRedstoneUpdate, receivePulse, requestPulse, rightClickBlock, setDrops, setPlaceSound, updateBlock, updatePhysics, updatePhysicsAfterEvent, warnMaterialData
Methods inherited from class net.glowstone.block.itemtype.ItemType
getContext, getMaterial, getMaterials, getMaxStackSize, rightClickAir, setMaterial, setMaxStackSize, setPlaceAs, setPlaceAs, toString
-
Constructor Details
-
BlockBed
public BlockBed()
-
-
Method Details
-
setOccupied
Helper method for set whether the specified bed blocks are occupied.- Parameters:
head
- head of the bedfoot
- foot of the bedoccupied
- if the bed is occupied by a player
-
isOccupied
Return whether the specified bed block is occupied.- Parameters:
block
- part of the bed- Returns:
- true if this bed is occupied, false if it is not
-
getHead
Returns the head of a bed given one of its blocks.- Parameters:
block
- part of the bed- Returns:
- The head of the bed
-
getFoot
Returns the foot of a bed given one of its blocks.- Parameters:
block
- part of the bed- Returns:
- The foot of the bed
-
isValidSpawn
public static boolean isValidSpawn(org.bukkit.Material material) Returns whether a player can spawn within a block of specified material.- Parameters:
material
- the material- Returns:
- Whether spawning is possible
-
getExitLocation
Returns an 'empty' block next to the bed used to put the player at when they exit a bed or respawn.- Parameters:
head
- head of the bedfoot
- foot of the bed- Returns:
- Exit block or
null
if all spots are blocked
-
getDrops
@NotNull public @NotNull Collection<org.bukkit.inventory.ItemStack> getDrops(GlowBlock block, org.bukkit.inventory.ItemStack tool) Description copied from class:BlockType
Get the items that will be dropped by digging the block. -
canPlaceAt
Description copied from class:BlockType
Check whether the block can be placed at the given location.- Overrides:
canPlaceAt
in classBlockType
- 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.
-
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) Description copied from class:BlockType
Called when a neighboring block (within a 3x3x3 cube) has changed its type or data and physics checks should occur.- Overrides:
onNearBlockChanged
in classBlockType
- 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
-
placeBlock
public void placeBlock(GlowPlayer player, GlowBlockState state, org.bukkit.block.BlockFace face, org.bukkit.inventory.ItemStack holding, org.bukkit.util.Vector clickedLoc) Description copied from class:BlockType
Called when a block is placed to calculate what the block will become.- Overrides:
placeBlock
in classBlockType
- Parameters:
player
- the player who placed the blockstate
- the BlockState to editface
- the face off which the block is being placedholding
- the ItemStack that was being heldclickedLoc
- where in the block the click occurred
-
createBlockEntity
Description copied from class:BlockType
Create a new block entity at the given location.- Overrides:
createBlockEntity
in classBlockType
- 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.
-
afterPlace
public void afterPlace(GlowPlayer player, GlowBlock block, org.bukkit.inventory.ItemStack holding, GlowBlockState oldState) Description copied from class:BlockType
Called after a block has been placed by a player.- Overrides:
afterPlace
in classBlockType
- 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) Description copied from class:BlockType
Called when a player attempts to interact with (right-click) a block of this type already in the world.- Overrides:
blockInteract
in classBlockType
- Parameters:
player
- the player interactingblock
- the block interacted withface
- the clicked faceclickedLoc
- where in the block the click occurred- Returns:
- Whether the interaction occurred.
-