Class BlockBreakHandler
java.lang.Object
org.geysermc.geyser.session.cache.BlockBreakHandler
Class responsible for block breaking handling. This is designed to be extensible
by extensions (not officially supported!).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longThe Bedrock client tick in which block breaking of the current block began.protected @Nullable org.cloudburstmc.math.vector.Vector3iThe position of the current block being broken.protected @Nullable BlockStateThe current block state that is being broken.protected @Nullable org.cloudburstmc.math.vector.Vector3iUsed to ignore subsequent block interactions after an item frame interactionprotected DirectionThe last known face of the block the client was breaking.protected org.cloudburstmc.math.vector.Vector3iThe last block position that was instantly broken.protected Set<org.cloudburstmc.math.vector.Vector3i>Caches all blocks we had to restore e.g.protected final GeyserSession -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected floatcalculateBreakProgress(BlockState state, org.cloudburstmc.math.vector.Vector3i vector, GeyserItemStack stack) protected booleancanBreak(org.cloudburstmc.math.vector.Vector3i vector, BlockState state) Checks whether a block interaction may proceed, or whether it must be interrupted.protected booleancanDestroyBlock(BlockState state) protected voidResets variables after a block was broken.protected voiddestroyBlock(BlockState state, org.cloudburstmc.math.vector.Vector3i vector, Direction direction, boolean instamine) com.google.common.cache.Cache<org.cloudburstmc.math.vector.Vector3i,it.unimi.dsi.fastutil.Pair<Long, org.geysermc.mcprotocollib.protocol.data.game.entity.player.BlockBreakStage>> SeeJavaBlockDestructionTranslatorfor usage and explanationprotected voidhandleAbortBreaking(org.cloudburstmc.math.vector.Vector3i position) protected voidhandleBlockBreakActions(org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket packet) protected voidhandleContinueDestroy(org.cloudburstmc.math.vector.Vector3i position, BlockState state, Direction blockFace, long tick) voidhandlePlayerAuthInputPacket(org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket packet) Main entrypoint that handles block breaking actions, if present.protected voidhandlePredictDestroy(org.cloudburstmc.math.vector.Vector3i position, BlockState state, Direction blockFace, long tick) protected voidhandleStartBreak(@NonNull org.cloudburstmc.math.vector.Vector3i position, @NonNull BlockState state, Direction blockFace, long tick) voidreset()Resets the handler, including variables that persist across single packetsprotected booleantestForItemFrameEntity(org.cloudburstmc.math.vector.Vector3i position) Tests for a previous item frame block interaction, or the presence of an item frame at the position.protected booleantestForLastInstaBreakPosOrReset(org.cloudburstmc.math.vector.Vector3i position) Helper method to ignore all insta-break actions that were already sent to the Java server.protected voidtick()
-
Field Details
-
session
-
currentBlockPos
protected @Nullable org.cloudburstmc.math.vector.Vector3i currentBlockPosThe position of the current block being broken. Null indicates no block breaking in progress. -
currentBlockState
The current block state that is being broken. Null indicates no block breaking in progress. -
blockStartBreakTime
protected long blockStartBreakTimeThe Bedrock client tick in which block breaking of the current block began. Only set when keeping track of custom blocks / custom items breaking blocks. -
lastBlockBreakFace
The last known face of the block the client was breaking. Only set when keeping track of custom blocks / custom items breaking blocks. -
lastInstaMinedPosition
protected org.cloudburstmc.math.vector.Vector3i lastInstaMinedPositionThe last block position that was instantly broken. Used to ignore subsequent block actions from the Bedrock client. -
restoredBlocks
Caches all blocks we had to restore e.g. due to out-of-range or being unable to mine in order to avoid duplicate corrections. -
itemFramePos
protected @Nullable org.cloudburstmc.math.vector.Vector3i itemFramePosUsed to ignore subsequent block interactions after an item frame interaction
-
-
Constructor Details
-
BlockBreakHandler
-
-
Method Details
-
handlePlayerAuthInputPacket
public void handlePlayerAuthInputPacket(org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket packet) Main entrypoint that handles block breaking actions, if present. Ticks the handler if no breaking actions were performed.- Parameters:
packet- the player auth input packet
-
tick
protected void tick() -
handleBlockBreakActions
protected void handleBlockBreakActions(org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket packet) -
handleStartBreak
protected void handleStartBreak(@NonNull org.cloudburstmc.math.vector.Vector3i position, @NonNull BlockState state, Direction blockFace, long tick) -
handleContinueDestroy
protected void handleContinueDestroy(org.cloudburstmc.math.vector.Vector3i position, BlockState state, Direction blockFace, long tick) -
handlePredictDestroy
protected void handlePredictDestroy(org.cloudburstmc.math.vector.Vector3i position, BlockState state, Direction blockFace, long tick) -
handleAbortBreaking
protected void handleAbortBreaking(org.cloudburstmc.math.vector.Vector3i position) -
testForItemFrameEntity
protected boolean testForItemFrameEntity(org.cloudburstmc.math.vector.Vector3i position) Tests for a previous item frame block interaction, or the presence of an item frame at the position.- Returns:
- whether block breaking must stop due to an item frame interaction
-
canBreak
Checks whether a block interaction may proceed, or whether it must be interrupted. This includes world border, "hands busy" (boat steering), and GameMode checks. -
canDestroyBlock
-
destroyBlock
protected void destroyBlock(BlockState state, org.cloudburstmc.math.vector.Vector3i vector, Direction direction, boolean instamine) -
calculateBreakProgress
protected float calculateBreakProgress(BlockState state, org.cloudburstmc.math.vector.Vector3i vector, GeyserItemStack stack) -
testForLastInstaBreakPosOrReset
protected boolean testForLastInstaBreakPosOrReset(org.cloudburstmc.math.vector.Vector3i position) Helper method to ignore all insta-break actions that were already sent to the Java server. This ensures that Geyser does not send a FINISH_DIGGING player action for instantly mined blocks, or those mined while in creative mode. -
clearCurrentVariables
protected void clearCurrentVariables()Resets variables after a block was broken. -
reset
public void reset()Resets the handler, including variables that persist across single packets -
getDestructionStageCache
public com.google.common.cache.Cache<org.cloudburstmc.math.vector.Vector3i,it.unimi.dsi.fastutil.Pair<Long, getDestructionStageCache()org.geysermc.mcprotocollib.protocol.data.game.entity.player.BlockBreakStage>> SeeJavaBlockDestructionTranslatorfor usage and explanation
-