Class PacketBlock

java.lang.Object
net.bitbylogic.packetblocks.block.PacketBlock
All Implemented Interfaces:
PacketBlockHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>, DataHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>, MetadataHolder, ViewerHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>

public class PacketBlock extends Object implements PacketBlockHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>
  • Constructor Details

    • PacketBlock

      protected PacketBlock(@NonNull @NonNull org.bukkit.Location location, @NonNull @NonNull org.bukkit.block.data.BlockData blockData)
      Constructs a new PacketBlock instance associated with a specific location and block data. The PacketBlock represents a virtual block that interacts with players based on certain conditions, metadata, and viewer states.
      Parameters:
      location - The location of the block in the world. Must not be null.
      blockData - The visual and physical characteristics of the block. Must not be null.
    • PacketBlock

      protected PacketBlock(@NonNull @NonNull org.bukkit.Location location, @NonNull @NonNull org.bukkit.block.data.BlockData blockData, int breakSpeed)
      Constructs a new PacketBlock instance associated with a specific location and block data. The PacketBlock represents a virtual block that interacts with players based on certain conditions, metadata, and viewer states.
      Parameters:
      location - The location of the block in the world. Must not be null.
      blockData - The visual and physical characteristics of the block. Must not be null.
      breakSpeed - The speed at which the block breaks, in ticks.
  • Method Details

    • getBlockState

      public org.bukkit.block.BlockState getBlockState(@NonNull @NonNull org.bukkit.entity.Player player)
      Retrieves the BlockState associated with a specific player. This method takes into account the player's data and determines the appropriate BlockState, using either their pre-existing block data or a supplier to generate new data. If no player-specific data is available, a default BlockState is created based on the block data and location.
      Parameters:
      player - the player for whom the BlockState is being retrieved
      Returns:
      the BlockState associated with the given player
    • sendUpdate

      public void sendUpdate(@NonNull @NonNull org.bukkit.entity.Player player)
      Sends a block update to the specified player at the current location.
      Specified by:
      sendUpdate in interface PacketBlockHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>
      Parameters:
      player - the player to whom the block update will be sent
    • simulateBreak

      public void simulateBreak(@NonNull @NonNull org.bukkit.entity.Player player)
      Simulates the breaking action for the specified player. This method triggers a simulation of a break event for the provided player.
      Parameters:
      player - The player for whom the breaking action is being simulated. Must not be null.
    • simulateBreak

      public void simulateBreak(@NonNull @NonNull org.bukkit.entity.Player player, @Nullable @Nullable org.bukkit.inventory.ItemStack tool)
      Simulates the block-breaking process, triggering a custom event and handling item drops based on the event state.
      Parameters:
      player - The player performing the block-breaking action. Must not be null.
      tool - The tool used by the player to break the block. Can be null if no tool is used.
    • existsIn

      public boolean existsIn(@NonNull @NonNull org.bukkit.World world)
      Specified by:
      existsIn in interface PacketBlockHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>
    • existsAt

      public boolean existsAt(@NonNull @NonNull org.bukkit.Location location)
      Specified by:
      existsAt in interface PacketBlockHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>