mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-15 11:51:53 +01:00
Small utility methods for EntityRotationPacket
This commit is contained in:
parent
5eb5f32095
commit
7de0067a13
@ -75,7 +75,7 @@ public interface Viewable {
|
||||
/**
|
||||
* Sends a packet to all viewers and the viewable element if it is a player.
|
||||
* <p>
|
||||
* If 'this' isn't a player, then {only @link #sendPacketToViewers(ServerPacket)} is called.
|
||||
* If 'this' isn't a player, then only {@link #sendPacketToViewers(ServerPacket)} is called.
|
||||
*
|
||||
* @param packet the packet to send
|
||||
*/
|
||||
|
@ -463,13 +463,8 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
position, new Position(lastPlayerSyncX, lastPlayerSyncY, lastPlayerSyncZ), onGround);
|
||||
} else {
|
||||
// View changed
|
||||
EntityRotationPacket entityRotationPacket = new EntityRotationPacket();
|
||||
entityRotationPacket.entityId = getEntityId();
|
||||
entityRotationPacket.yaw = position.getYaw();
|
||||
entityRotationPacket.pitch = position.getPitch();
|
||||
entityRotationPacket.onGround = onGround;
|
||||
|
||||
updatePacket = entityRotationPacket;
|
||||
updatePacket = EntityRotationPacket.getPacket(getEntityId(),
|
||||
position.getYaw(), position.getPitch(), onGround);
|
||||
}
|
||||
|
||||
if (viewChanged) {
|
||||
@ -552,7 +547,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
|
||||
/**
|
||||
* Respawns the player by sending a {@link RespawnPacket} to the player and teleporting him
|
||||
* to {@link #getRespawnPoint()}. It also resets fire and his health
|
||||
* to {@link #getRespawnPoint()}. It also resets fire and health.
|
||||
*/
|
||||
public void respawn() {
|
||||
if (!isDead())
|
||||
|
@ -26,6 +26,7 @@ public class EntityPositionPacket implements ServerPacket {
|
||||
return ServerPacketIdentifier.ENTITY_POSITION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static EntityPositionPacket getPacket(int entityId,
|
||||
@NotNull Position newPosition, @NotNull Position oldPosition,
|
||||
boolean onGround) {
|
||||
|
@ -23,4 +23,17 @@ public class EntityRotationPacket implements ServerPacket {
|
||||
public int getId() {
|
||||
return ServerPacketIdentifier.ENTITY_ROTATION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static EntityRotationPacket getPacket(int entityId,
|
||||
float yaw, float pitch,
|
||||
boolean onGround) {
|
||||
EntityRotationPacket entityRotationPacket = new EntityRotationPacket();
|
||||
entityRotationPacket.entityId = entityId;
|
||||
entityRotationPacket.yaw = yaw;
|
||||
entityRotationPacket.pitch = pitch;
|
||||
entityRotationPacket.onGround = onGround;
|
||||
|
||||
return entityRotationPacket;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user