mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-31 04:36:33 +00:00
Fix: swimming near water surface. (#5992)
* Fix: swimming near water surface. * Only update if pose change.
This commit is contained in:
@@ -41,6 +41,7 @@ import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.AddPlayerPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.entity.type.LivingEntity;
|
||||
import org.geysermc.geyser.level.block.Blocks;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
@@ -317,8 +318,7 @@ public class AvatarEntity extends LivingEntity {
|
||||
|
||||
if (pose == Pose.SWIMMING) {
|
||||
// This is just for, so we know if player is swimming or crawling.
|
||||
// TODO test, changed from position (field) to position() (method), which adds offset
|
||||
if (session.getGeyser().getWorldManager().blockAt(session, position.toInt()).is(Blocks.WATER)) {
|
||||
if (session.getGeyser().getWorldManager().blockAt(session, position.down(EntityDefinitions.PLAYER.offset()).toInt()).is(Blocks.WATER)) {
|
||||
setFlag(EntityFlag.SWIMMING, true);
|
||||
} else {
|
||||
setFlag(EntityFlag.CRAWLING, true);
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.util.CooldownUtils;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerState;
|
||||
@@ -185,7 +186,14 @@ public final class BedrockPlayerAuthInputTranslator extends PacketTranslator<Pla
|
||||
|
||||
// The player will calculate the "desired" pose at the end of every tick, if this pose still invalid then
|
||||
// it will consider the smaller pose, but we don't need to calculate that, we can go off what the client sent us.
|
||||
entity.setPose(entity.getDesiredPose());
|
||||
// Also set the session pose directly and set the metadata directly since we don't want setPose method inside entity to change
|
||||
// the current entity flag again.
|
||||
final Pose pose = entity.getDesiredPose();
|
||||
if (pose != session.getPose()) {
|
||||
session.setPose(pose);
|
||||
entity.setDimensionsFromPose(session.getPose());
|
||||
entity.updateBedrockMetadata();
|
||||
}
|
||||
|
||||
// Vehicle input is send before player movement
|
||||
processVehicleInput(session, packet, wasJumping);
|
||||
|
||||
Reference in New Issue
Block a user