Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 thread
valaphee marked this conversation as resolved.

Comment on lines +333 to +343
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The injected MINING_FATIGUE effect is added when starting to break a block while flying, but it is never removed when the block is successfully broken (destroyBlock path). This can leave the Bedrock client with mining fatigue after the break completes (until the duration expires), affecting subsequent gameplay. Consider explicitly removing the effect when breaking finishes (and when state is cleared) instead of relying on duration.

Suggested change
// 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 uses AI. Check for mistakes.
LevelEventPacket startBreak = new LevelEventPacket();
startBreak.setType(LevelEvent.BLOCK_START_BREAK);
startBreak.setPosition(position.toFloat());
Expand Down Expand Up @@ -419,6 +433,15 @@ private void handleAbortBreaking(Vector3i position) {
session.sendDownstreamGamePacket(abortBreakingPacket);
}

// Remove effect again which is applied to simulate survival fly block breaking
if (session.getGameMode() == GameMode.SURVIVAL && session.isFlying()) {
MobEffectPacket mobEffectPacket = new MobEffectPacket();
mobEffectPacket.setEvent(MobEffectPacket.Event.REMOVE);
mobEffectPacket.setRuntimeEntityId(session.getPlayerEntity().geyserId());
mobEffectPacket.setEffectId(EffectType.MINING_FATIGUE.getBedrockId());
session.sendUpstreamPacket(mobEffectPacket);
}
Comment on lines +436 to +443
Copy link

Copilot AI Mar 9, 2026

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.

Copilot uses AI. Check for mistakes.

BlockUtils.sendBedrockStopBlockBreak(session, position.toFloat());
this.clearCurrentVariables();
}
Expand Down
Loading