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 DirectionThe last known face of the block the client was breaking.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 GeyserItemStackThe last item used to break blocks.protected floatThe current block breaking progressprotected @Nullable org.cloudburstmc.math.vector.Vector3iUsed to ignore subsequent block interactions after an item frame interactionprotected org.cloudburstmc.math.vector.Vector3iThe last block position that was broken.protected Set<org.cloudburstmc.math.vector.Vector3i>Caches all blocks we had to restore e.g.protected booleanWhether we must break the block ourselves.protected final GeyserSessionprotected @Nullable IntegerIndicates that we should re-check the current block state for changes -
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, org.cloudburstmc.protocol.bedrock.data.PlayerActionType action) 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) @Nullable org.cloudburstmc.math.vector.Vector3iThe position of the current block being broken.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 voidhandleBlockBreakActions(org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket packet) protected voidhandleContinueDestroy(@NonNull org.cloudburstmc.math.vector.Vector3i position, @NonNull BlockState state, @NonNull Direction blockFace, boolean bedrockDestroyed, boolean sendParticles, 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) protected booleanmayBreak(float progress, boolean bedrockDestroyed) voidreset()Resets the handler, including variables that persist across single packetsvoidsetUpdatedServerBlockStateId(@Nullable Integer updatedServerBlockStateId) Indicates that we should re-check the current block state for changesprotected 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 booleantestForLastBreakPosOrReset(org.cloudburstmc.math.vector.Vector3i position) Helper method to ignore all insta-break actions that were already sent to the Java server.protected voidtick(long tick)
-
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. -
updatedServerBlockStateId
Indicates that we should re-check the current block state for changes -
serverSideBlockBreaking
protected boolean serverSideBlockBreakingWhether we must break the block ourselves. Only set when keeping track of custom blocks / custom items breaking blocks. -
currentProgress
protected float currentProgressThe current block breaking progress -
currentBlockFace
The last known face of the block the client was breaking. Only set when keeping track of custom blocks / custom items breaking blocks. -
currentItemStack
The last item used to break blocks. Used to track whether block breaking should be re-started as the item changed -
lastMinedPosition
protected org.cloudburstmc.math.vector.Vector3i lastMinedPositionThe last block position that was 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(long 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(@NonNull org.cloudburstmc.math.vector.Vector3i position, @NonNull BlockState state, @NonNull Direction blockFace, boolean bedrockDestroyed, boolean sendParticles, long tick) -
handlePredictDestroy
protected void handlePredictDestroy(org.cloudburstmc.math.vector.Vector3i position, BlockState state, Direction blockFace, long tick) -
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
protected boolean canBreak(org.cloudburstmc.math.vector.Vector3i vector, BlockState state, org.cloudburstmc.protocol.bedrock.data.PlayerActionType action) 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
-
mayBreak
protected boolean mayBreak(float progress, boolean bedrockDestroyed) -
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) -
testForLastBreakPosOrReset
protected boolean testForLastBreakPosOrReset(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 -
getCurrentBlockPos
public @Nullable org.cloudburstmc.math.vector.Vector3i getCurrentBlockPos()The position of the current block being broken. Null indicates no block breaking in progress. -
setUpdatedServerBlockStateId
Indicates that we should re-check the current block state for changes -
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
-