mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-11-29 03:32:46 +01:00
Fix double sending ServerboundPlayerActionPacket in creative (both of which Spigot interprets as a BlockBreakEvent) (Fixes #4021) (#3996)
This commit is contained in:
parent
d147ee37dc
commit
7725651726
1 changed files with 14 additions and 13 deletions
|
@ -144,9 +144,13 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
ServerboundPlayerCommandPacket stopSleepingPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.LEAVE_BED);
|
||||
session.sendDownstreamPacket(stopSleepingPacket);
|
||||
break;
|
||||
case START_BREAK:
|
||||
case START_BREAK: {
|
||||
// Start the block breaking animation
|
||||
if (session.getGameMode() != GameMode.CREATIVE) {
|
||||
// Ignore START_BREAK when the player is CREATIVE to avoid Spigot receiving 2 packets it interpets as block breaking. https://github.com/GeyserMC/Geyser/issues/4021
|
||||
if (session.getGameMode() == GameMode.CREATIVE) {
|
||||
break;
|
||||
}
|
||||
|
||||
int blockState = session.getGeyser().getWorldManager().getBlockAt(session, vector);
|
||||
LevelEventPacket startBreak = new LevelEventPacket();
|
||||
startBreak.setType(LevelEvent.BLOCK_START_BREAK);
|
||||
|
@ -155,7 +159,6 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
startBreak.setData((int) (65535 / breakTime));
|
||||
session.setBreakingBlock(blockState);
|
||||
session.sendUpstreamPacket(startBreak);
|
||||
}
|
||||
|
||||
// Account for fire - the client likes to hit the block behind.
|
||||
Vector3i fireBlockPos = BlockUtils.getBlockPosition(vector, packet.getFace());
|
||||
|
@ -165,15 +168,13 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, fireBlockPos,
|
||||
Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(startBreakingPacket);
|
||||
if (session.getGameMode() == GameMode.CREATIVE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING,
|
||||
vector, Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(startBreakingPacket);
|
||||
break;
|
||||
}
|
||||
case CONTINUE_BREAK:
|
||||
if (session.getGameMode() == GameMode.CREATIVE) {
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue