mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 02:57:37 +01:00
Added UpdateViewPositionPacket
This commit is contained in:
parent
d1967186e5
commit
25621dede6
@ -2,6 +2,7 @@ package fr.themode.minestom.entity;
|
||||
|
||||
import fr.themode.minestom.Main;
|
||||
import fr.themode.minestom.net.packet.server.play.EntityTeleportPacket;
|
||||
import fr.themode.minestom.net.packet.server.play.UpdateViewPositionPacket;
|
||||
import fr.themode.minestom.net.player.PlayerConnection;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -38,6 +39,7 @@ public class Player extends LivingEntity {
|
||||
if (!onlinePlayer.equals(this))
|
||||
onlinePlayer.getPlayerConnection().sendPacket(entityTeleportPacket);
|
||||
}
|
||||
playerConnection.sendPacket(new UpdateViewPositionPacket(Math.floorDiv((int) x, 16), Math.floorDiv((int) z, 16)));
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
|
@ -17,8 +17,8 @@ public class EntityTeleportPacket implements ServerPacket {
|
||||
buffer.putDouble(x);
|
||||
buffer.putDouble(y);
|
||||
buffer.putDouble(y);
|
||||
buffer.getData().writeByte((int) (this.yaw * 256 / 360));
|
||||
buffer.getData().writeByte((int) (this.pitch * 256 / 360));
|
||||
buffer.putByte((byte) (this.yaw * 256 / 360));
|
||||
buffer.putByte((byte) (this.pitch * 256 / 360));
|
||||
buffer.putBoolean(onGround);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package fr.themode.minestom.net.packet.server.play;
|
||||
|
||||
import fr.adamaq01.ozao.net.Buffer;
|
||||
import fr.themode.minestom.net.packet.server.ServerPacket;
|
||||
import fr.themode.minestom.utils.Utils;
|
||||
|
||||
public class UpdateViewPositionPacket implements ServerPacket {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
|
||||
public UpdateViewPositionPacket(int chunkX, int chunkZ) {
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Buffer buffer) {
|
||||
Utils.writeVarInt(buffer, chunkX);
|
||||
Utils.writeVarInt(buffer, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return 0x40;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user