mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-20 15:29:27 +00:00
Improve motion translation from explosions (#5659)
This commit is contained in:
@@ -108,6 +108,7 @@ final class BedrockMovePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.setLastTickEndVelocity(packet.getDelta());
|
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.
|
// 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)
|
// (Press into a wall in a corner - you're trying to move but nothing actually happens)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import org.cloudburstmc.nbt.NbtMapBuilder;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.LevelEventGenericPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelEventGenericPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityMotionPacket;
|
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.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
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);
|
SoundUtils.playSound(session, packet.getExplosionSound(), vector, 4.0f, pitch);
|
||||||
|
|
||||||
if (packet.getPlayerKnockback() != null) {
|
if (packet.getPlayerKnockback() != null) {
|
||||||
|
SessionPlayerEntity entity = session.getPlayerEntity();
|
||||||
|
entity.setMotion(entity.getMotion().add(packet.getPlayerKnockback().toFloat()));
|
||||||
|
|
||||||
SetEntityMotionPacket motionPacket = new SetEntityMotionPacket();
|
SetEntityMotionPacket motionPacket = new SetEntityMotionPacket();
|
||||||
motionPacket.setRuntimeEntityId(session.getPlayerEntity().getGeyserId());
|
motionPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
motionPacket.setMotion(packet.getPlayerKnockback().toFloat());
|
motionPacket.setMotion(entity.getMotion());
|
||||||
session.sendUpstreamPacket(motionPacket);
|
session.sendUpstreamPacket(motionPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user