-
-
Notifications
You must be signed in to change notification settings - Fork 828
Survival fly block breaking #6227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,13 +40,15 @@ | |||||||||||||||||||||
| import org.cloudburstmc.protocol.bedrock.data.PlayerBlockActionData; | ||||||||||||||||||||||
| import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition; | ||||||||||||||||||||||
| import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket; | ||||||||||||||||||||||
| import org.cloudburstmc.protocol.bedrock.packet.MobEffectPacket; | ||||||||||||||||||||||
| import org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket; | ||||||||||||||||||||||
| import org.geysermc.geyser.GeyserImpl; | ||||||||||||||||||||||
| import org.geysermc.geyser.api.block.custom.CustomBlockState; | ||||||||||||||||||||||
| import org.geysermc.geyser.entity.EntityDefinitions; | ||||||||||||||||||||||
| import org.geysermc.geyser.entity.type.Entity; | ||||||||||||||||||||||
| import org.geysermc.geyser.entity.type.ItemFrameEntity; | ||||||||||||||||||||||
| import org.geysermc.geyser.inventory.GeyserItemStack; | ||||||||||||||||||||||
| import org.geysermc.geyser.level.EffectType; | ||||||||||||||||||||||
| import org.geysermc.geyser.level.block.Blocks; | ||||||||||||||||||||||
| import org.geysermc.geyser.level.block.type.Block; | ||||||||||||||||||||||
| import org.geysermc.geyser.level.block.type.BlockState; | ||||||||||||||||||||||
|
|
@@ -60,6 +62,7 @@ | |||||||||||||||||||||
| import org.geysermc.geyser.translator.protocol.java.level.JavaBlockDestructionTranslator; | ||||||||||||||||||||||
| import org.geysermc.geyser.util.BlockUtils; | ||||||||||||||||||||||
| import org.geysermc.mcprotocollib.protocol.data.game.entity.player.BlockBreakStage; | ||||||||||||||||||||||
| import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode; | ||||||||||||||||||||||
| import org.geysermc.mcprotocollib.protocol.data.game.entity.player.InteractAction; | ||||||||||||||||||||||
| import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerAction; | ||||||||||||||||||||||
| import org.geysermc.mcprotocollib.protocol.data.game.item.component.AdventureModePredicate; | ||||||||||||||||||||||
|
|
@@ -327,6 +330,17 @@ protected void handleStartBreak(@NonNull Vector3i position, @NonNull BlockState | |||||||||||||||||||||
| this.serverSideBlockBreaking = true; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Survival fly in Bedrock doesn't come with a mining speed penalty, but we can use effects to lower the mining speed to match Java's one | ||||||||||||||||||||||
| if (session.getGameMode() == GameMode.SURVIVAL && session.isFlying() && breakProgress > 0) { | ||||||||||||||||||||||
| MobEffectPacket mobEffectPacket = new MobEffectPacket(); | ||||||||||||||||||||||
| mobEffectPacket.setAmplifier(0); | ||||||||||||||||||||||
| mobEffectPacket.setDuration((int) BlockUtils.reciprocal(breakProgress)); | ||||||||||||||||||||||
| mobEffectPacket.setEvent(MobEffectPacket.Event.ADD); | ||||||||||||||||||||||
| mobEffectPacket.setRuntimeEntityId(session.getPlayerEntity().geyserId()); | ||||||||||||||||||||||
| mobEffectPacket.setEffectId(EffectType.MINING_FATIGUE.getBedrockId()); | ||||||||||||||||||||||
| session.sendUpstreamPacket(mobEffectPacket); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
+333
to
+343
|
||||||||||||||||||||||
| // Survival fly in Bedrock doesn't come with a mining speed penalty, but we can use effects to lower the mining speed to match Java's one | |
| if (session.getGameMode() == GameMode.SURVIVAL && session.isFlying() && breakProgress > 0) { | |
| MobEffectPacket mobEffectPacket = new MobEffectPacket(); | |
| mobEffectPacket.setAmplifier(0); | |
| mobEffectPacket.setDuration((int) BlockUtils.reciprocal(breakProgress)); | |
| mobEffectPacket.setEvent(MobEffectPacket.Event.ADD); | |
| mobEffectPacket.setRuntimeEntityId(session.getPlayerEntity().geyserId()); | |
| mobEffectPacket.setEffectId(EffectType.MINING_FATIGUE.getBedrockId()); | |
| session.sendUpstreamPacket(mobEffectPacket); | |
| } |
Copilot
AI
Mar 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The effect removal is conditional on session.isFlying(). If the player starts breaking while flying (effect applied) but lands before ABORT_BREAK (or a forced abort), this condition will skip removal and leave mining fatigue applied. Track whether the temporary effect was applied and remove it based on that flag (or remove unconditionally when aborting/clearing), rather than checking the current flying state.
Uh oh!
There was an error while loading. Please reload this page.