1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2026-01-04 15:31:36 +00:00

Re-introduce old sneaking behavior

This commit is contained in:
onebeastchris
2025-06-19 15:05:54 +02:00
parent 0fcdd8a438
commit f5ea3ccaee
3 changed files with 23 additions and 9 deletions

View File

@@ -223,10 +223,10 @@ public class SessionPlayerEntity extends PlayerEntity {
@Override
protected void setSneaking(boolean value) {
if (value) {
session.startSneaking();
session.startSneaking(false);
} else {
session.setShouldSendSneak(false);
session.stopSneaking();
session.stopSneaking(false);
}
}

View File

@@ -1283,20 +1283,20 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
worldTicks++;
}
public void startSneaking() {
public void startSneaking(boolean updateMetaData) {
// Toggle the shield, if there is no ongoing arm animation
// This matches Bedrock Edition behavior as of 1.18.12
if (armAnimationTicks < 0) {
attemptToBlock();
}
setSneaking(true);
setSneaking(true, updateMetaData);
}
public void stopSneaking() {
public void stopSneaking(boolean updateMetaData) {
disableBlocking();
setSneaking(false);
setSneaking(false, updateMetaData);
}
public void setSpinAttack(boolean spinAttack) {
@@ -1307,7 +1307,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
switchPose(gliding, EntityFlag.GLIDING, Pose.FALL_FLYING);
}
private void setSneaking(boolean sneaking) {
private void setSneaking(boolean sneaking, boolean update) {
this.sneaking = sneaking;
// Update pose and bounding box on our end
@@ -1317,7 +1317,9 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
}
collisionManager.updateScaffoldingFlags(false);
playerEntity.updateBedrockMetadata();
if (update) {
playerEntity.updateBedrockMetadata();
}
if (mouseoverEntity != null) {
// Horses, etc can change their property depending on if you're sneaking

View File

@@ -76,6 +76,8 @@ public final class InputCache {
right = analogMovement.getX() < 0;
}
boolean sneaking = isSneaking(bedrockInput);
// TODO when is UP_LEFT, etc. used?
this.inputPacket = this.inputPacket
.withForward(up)
@@ -86,9 +88,19 @@ public final class InputCache {
// using the "raw" values allows us sending key presses even with locked input
// There appear to be cases where the raw value is not sent - e.g. sneaking with a shield on mobile (1.21.80)
.withJump(bedrockInput.contains(PlayerAuthInputData.JUMP_CURRENT_RAW) || bedrockInput.contains(PlayerAuthInputData.JUMP_DOWN))
.withShift(session.isShouldSendSneak() || isSneaking(bedrockInput))
.withShift(session.isShouldSendSneak() || sneaking)
.withSprint(bedrockInput.contains(PlayerAuthInputData.SPRINT_DOWN));
// TODO - test whether we can rely on the Java server setting sneaking for us.
// 1.21.6+ only sends the shifting state in the input packet, and removed the START/STOP sneak command packet sending
if (session.isSneaking() != sneaking) {
if (sneaking) {
session.startSneaking(true);
} else {
session.stopSneaking(true);
}
}
if (oldInputPacket != this.inputPacket) { // Simple equality check is fine since we're checking for an instance change.
session.sendDownstreamGamePacket(this.inputPacket);
}