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

public class BlockType extends ItemType
Base class for specific types of blocks.
  • Field Details

    • SIDES

      protected static final org.bukkit.block.BlockFace[] SIDES
    • ADJACENT

      protected static final org.bukkit.block.BlockFace[] ADJACENT
    • drops

      protected List<org.bukkit.inventory.ItemStack> drops
    • placeSound

      protected SoundInfo placeSound
      Gets the sound that will be played when a player places the block.
    • soundGroup

      protected GlowBlockSoundGroup 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 of
      inverted - 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 or null 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

      @NotNull public @NotNull Collection<org.bukkit.inventory.ItemStack> getMinedDrops(GlowBlock block)
      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

      public BlockEntity createBlockEntity(GlowChunk chunk, int cx, int cy, int cz)
      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 block
      state - the BlockState to edit
      holding - the ItemStack that was being held
      face - the face off which the block is being placed
      clickedLoc - 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 block
      block - the block that was placed
      holding - the the ItemStack that was being held
      oldState - 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 interacting
      block - the block interacted with
      face - the clicked face
      clickedLoc - where in the block the click occurred
      Returns:
      Whether the interaction occurred.
    • blockDestroy

      public void blockDestroy(GlowPlayer player, GlowBlock block, org.bukkit.block.BlockFace face)
      Called when a player attempts to destroy a block.
      Parameters:
      player - The player interacting
      block - The block the player destroyed
      face - 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 interacting
      block - The block the player destroyed
      face - The block face
      oldState - The block state of the block the player destroyed.
    • receivePulse

      public void receivePulse(GlowBlock block)
      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-clicked
      face - The face on which the click occurred
      holding - 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 placement
      face - The face on which the click occurred
      holding - 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 for
      face - The BlockFace to the changed block, or null if unavailable
      changedBlock - The neighboring block that has changed
      oldType - The old type of the changed block
      oldData - The old data of the changed block
      newType - The new type of the changed block
      newData - 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) or GlowBlock.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 changed
      oldType - The old Material
      oldData - The old data
      newType - The new Material
      data - The new data
    • updatePhysics

      public final void updatePhysics(GlowBlock block)

      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

      public void updatePhysicsAfterEvent(GlowBlock block)
    • 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 class ItemType
      Parameters:
      player - The player
      against - The block the player right-clicked
      face - The face on which the click occurred
      holding - The ItemStack the player was holding
      clickedLoc - The coordinates at which the click occurred
      hand - 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

      public void updateBlock(GlowBlock block)
      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 block
      block - the block that was clicked
      holding - the ItemStack that was being held
    • warnMaterialData

      @Deprecated protected void warnMaterialData(Class<?> clazz, org.bukkit.material.MaterialData data)
      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

      public void onRedstoneUpdate(GlowBlock block)
    • onEntityStep

      public void onEntityStep(GlowBlock block, org.bukkit.entity.LivingEntity entity)
      Called when an entity gets updated on top of the block.
      Parameters:
      block - the block that was stepped on
      entity - the entity
    • getPlaceAs

      public BlockType getPlaceAs()
      Description copied from class: ItemType
      The type of block to place when the item is used.
      Overrides:
      getPlaceAs in class ItemType
      Returns:
      the type of block to place
    • requestPulse

      public void requestPulse(GlowBlockState state)
    • getPulseTickSpeed

      public int getPulseTickSpeed(GlowBlock block)
      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

      public boolean isPulseOnce(GlowBlock block)
      Whether the block should only be pulsed once.
      Parameters:
      block - the block
      Returns:
      true if the block should be pulsed once, false otherwise.
    • getPlaceSound

      public SoundInfo getPlaceSound()
      Gets the sound that will be played when a player places the block.
      Returns:
      The sound to be played
    • getSoundGroup

      public GlowBlockSoundGroup getSoundGroup()