1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Improve motion translation from explosions (#5659)

This commit is contained in:
oryxel
2025-07-11 06:59:09 +07:00
committed by GitHub
parent fc34aa464a
commit 8c8782c65b
2 changed files with 7 additions and 2 deletions

View File

@@ -108,6 +108,7 @@ final class BedrockMovePlayer {
}
entity.setLastTickEndVelocity(packet.getDelta());
entity.setMotion(packet.getDelta());
// This takes into account no movement sent from the client, but the player is trying to move anyway.
// (Press into a wall in a corner - you're trying to move but nothing actually happens)

View File

@@ -31,6 +31,7 @@ import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
import org.cloudburstmc.protocol.bedrock.packet.LevelEventGenericPacket;
import org.cloudburstmc.protocol.bedrock.packet.SetEntityMotionPacket;
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@@ -68,9 +69,12 @@ public class JavaExplodeTranslator extends PacketTranslator<ClientboundExplodePa
SoundUtils.playSound(session, packet.getExplosionSound(), vector, 4.0f, pitch);
if (packet.getPlayerKnockback() != null) {
SessionPlayerEntity entity = session.getPlayerEntity();
entity.setMotion(entity.getMotion().add(packet.getPlayerKnockback().toFloat()));
SetEntityMotionPacket motionPacket = new SetEntityMotionPacket();
motionPacket.setRuntimeEntityId(session.getPlayerEntity().getGeyserId());
motionPacket.setMotion(packet.getPlayerKnockback().toFloat());
motionPacket.setRuntimeEntityId(entity.getGeyserId());
motionPacket.setMotion(entity.getMotion());
session.sendUpstreamPacket(motionPacket);
}
}