3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Don't send more than one ServerboundSwingPacket per tick

Should address #2875
Dieser Commit ist enthalten in:
Camotoy 2023-01-03 15:51:58 -05:00
Ursprung c483204446
Commit 00df4c26ba
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 18 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -457,7 +457,6 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
* Counts how many ticks have occurred since an arm animation started. * Counts how many ticks have occurred since an arm animation started.
* -1 means there is no active arm swing. * -1 means there is no active arm swing.
*/ */
@Getter(AccessLevel.NONE)
private int armAnimationTicks = -1; private int armAnimationTicks = -1;
/** /**

Datei anzeigen

@ -49,11 +49,26 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
case SWING_ARM -> case SWING_ARM ->
// Delay so entity damage can be processed first // Delay so entity damage can be processed first
session.scheduleInEventLoop(() -> { session.scheduleInEventLoop(() -> {
if (session.getArmAnimationTicks() != 0) {
// So, generally, a Java player can only do one *thing* at a time.
// If a player right-clicks, for example, then there's probably only one action associated with
// that right-click that will send a swing.
// The only exception I can think of to this, *maybe*, is a player dropping items
// Bedrock is a little funkier than this - it can send several arm animation packets in the
// same tick, notably with high levels of haste applied.
// Packet limiters do not like this and can crash the player.
// If arm animation ticks is 0, then we just sent an arm swing packet this tick.
// See https://github.com/GeyserMC/Geyser/issues/2875
// This behavior was last touched on with ViaVersion 4.5.1 (with its packet limiter), Java 1.16.5,
// and Bedrock 1.19.51.
// Note for the future: we should probably largely ignore this packet and instead replicate
// all actions on our end, and send swings where needed.
session.sendDownstreamPacket(new ServerboundSwingPacket(Hand.MAIN_HAND)); session.sendDownstreamPacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
session.activateArmAnimationTicking(); session.activateArmAnimationTicking();
}, }
25, },
TimeUnit.MILLISECONDS 25,
TimeUnit.MILLISECONDS
); );
// These two might need to be flipped, but my recommendation is getting moving working first // These two might need to be flipped, but my recommendation is getting moving working first
case ROW_LEFT -> { case ROW_LEFT -> {