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 Summary
ConstructorsModifierConstructorDescriptionprotectedPacketBlock(@NonNull org.bukkit.Location location, @NonNull org.bukkit.block.data.BlockData blockData) Constructs a new PacketBlock instance associated with a specific location and block data.protectedPacketBlock(@NonNull org.bukkit.Location location, @NonNull org.bukkit.block.data.BlockData blockData, int breakSpeed) Constructs a new PacketBlock instance associated with a specific location and block data. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexistsAt(@NonNull org.bukkit.Location location) booleanexistsIn(@NonNull org.bukkit.World world) org.bukkit.block.BlockStategetBlockState(@NonNull org.bukkit.entity.Player player) Retrieves the BlockState associated with a specific player.voidsendUpdate(@NonNull org.bukkit.entity.Player player) Sends a block update to the specified player at the current location.voidsimulateBreak(@NonNull org.bukkit.entity.Player player) Simulates the breaking action for the specified player.voidsimulateBreak(@NonNull org.bukkit.entity.Player player, @Nullable org.bukkit.inventory.ItemStack tool) Simulates the block-breaking process, triggering a custom event and handling item drops based on the event state.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.bitbylogic.packetblocks.data.DataHolder
getBoundingBoxes, getBreakSpeed, getBreakSpeed, getData, getData, getDataHandler, isAddViewerOnJoin, isGlobalBreakAnimation, sendUpdates, setAddViewerOnJoin, setBlockDataAndUpdate, setBreakSpeed, setData, setData, setDataForAll, setDataSupplier, setDataSupplierForAll, setGlobalBreakAnimationMethods inherited from interface net.bitbylogic.packetblocks.metadata.MetadataHolder
addMetadata, getMetadata, getMetadata, getMetadataAs, getMetadataHandler, hasMetadata, removeMetadataMethods inherited from interface net.bitbylogic.packetblocks.viewer.ViewerHolder
addAndUpdateViewer, addMetadata, addViewCondition, addViewer, attemptAddViewer, canView, getMetadata, getMetadataAs, getViewer, getViewerHandler, getViewers, hasMetadata, isViewer, removeMetadata, removeViewer
-
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:
sendUpdatein interfacePacketBlockHolder<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:
existsInin interfacePacketBlockHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>
-
existsAt
public boolean existsAt(@NonNull @NonNull org.bukkit.Location location) - Specified by:
existsAtin interfacePacketBlockHolder<org.bukkit.block.data.BlockData,SinglePacketBlockViewer>
-