mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-23 15:00:37 +01:00
Fix: Ignored rotation players to session player (self)
This commit is contained in:
parent
5b5ac3024f
commit
9a41f59a33
6 changed files with 33 additions and 16 deletions
|
@ -45,7 +45,6 @@ import org.geysermc.geyser.api.entity.type.GeyserEntity;
|
|||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
|
||||
import org.geysermc.geyser.entity.properties.GeyserEntityPropertyManager;
|
||||
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.scoreboard.Team;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
|
|
@ -25,12 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.entity.type.player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -65,6 +59,13 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.Boolea
|
|||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Getter @Setter
|
||||
public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity {
|
||||
public static final float SNEAKING_POSE_HEIGHT = 1.5f;
|
||||
|
@ -250,10 +251,6 @@ public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateRotation(float yaw, float pitch, float headYaw, boolean isOnGround) {
|
||||
moveRelative(0, 0, 0, yaw, pitch, headYaw, isOnGround);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector3f position) {
|
||||
if (this.bedPosition != null) {
|
||||
|
|
|
@ -144,6 +144,29 @@ public class SessionPlayerEntity extends PlayerEntity {
|
|||
this.position = position.add(0, definition.offset(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Special method used only when updating the session player's rotation.
|
||||
* For some reason, Mode#NORMAL ignored rotation. Yay.
|
||||
* @param yaw the new yaw
|
||||
* @param pitch the new pitch
|
||||
* @param headYaw the head yaw
|
||||
*/
|
||||
public void updateOwnRotation(float yaw, float pitch, float headYaw) {
|
||||
setYaw(yaw);
|
||||
setPitch(pitch);
|
||||
setHeadYaw(headYaw);
|
||||
|
||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
||||
movePlayerPacket.setRuntimeEntityId(geyserId);
|
||||
movePlayerPacket.setPosition(position);
|
||||
movePlayerPacket.setRotation(getBedrockRotation());
|
||||
movePlayerPacket.setOnGround(isOnGround());
|
||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.TELEPORT);
|
||||
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.BEHAVIOR);
|
||||
|
||||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the player's position without applying an offset or moving the bounding box
|
||||
* This is used in BedrockMovePlayerTranslator which receives the player's position
|
||||
|
|
|
@ -49,7 +49,7 @@ public class JavaPlayerLookAtTranslator extends PacketTranslator<ClientboundPlay
|
|||
|
||||
var self = session.getPlayerEntity();
|
||||
// headYaw is also set to yaw in this packet
|
||||
self.updateRotation(yaw, pitch, yaw, self.isOnGround());
|
||||
self.updateOwnRotation(yaw, pitch, yaw);
|
||||
}
|
||||
|
||||
public Vector3f targetPosition(GeyserSession session, ClientboundPlayerLookAtPacket packet) {
|
||||
|
|
|
@ -80,7 +80,7 @@ public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPl
|
|||
// Fixes incorrect rotation upon login
|
||||
// Yes, even that's not respected by Bedrock. Try it out in singleplayer!
|
||||
// Log out and back in - and you're looking elsewhere :)
|
||||
entity.forceRotationUpdate();
|
||||
entity.updateOwnRotation(entity.getYaw(), entity.getPitch(), entity.getHeadYaw());
|
||||
|
||||
session.setSpawned(true);
|
||||
// Make sure the player moves away from (0, 32767, 0) before accepting movement packets
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.translator.protocol.java.entity.player;
|
||||
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
|
@ -36,7 +35,6 @@ public class JavaPlayerRotationTranslator extends PacketTranslator<ClientboundPl
|
|||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ClientboundPlayerRotationPacket packet) {
|
||||
GeyserImpl.getInstance().getLogger().info(packet.toString());
|
||||
// TODO
|
||||
session.getPlayerEntity().updateOwnRotation(packet.getYRot(), packet.getXRot(), packet.getYRot());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue