Add UpdateViewPositionPacket

This commit is contained in:
Paul Heidenreich 2019-04-28 12:06:59 +02:00
parent 2f88909d48
commit 48a1e1fbda
2 changed files with 44 additions and 2 deletions

View file

@ -135,6 +135,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerSpawnP
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUnloadChunkPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateViewPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerWorldBorderPacket;
import com.github.steveice10.mc.protocol.packet.login.client.EncryptionResponsePacket;
import com.github.steveice10.mc.protocol.packet.login.client.LoginPluginResponsePacket;
@ -425,7 +426,7 @@ public class MinecraftProtocol extends PacketProtocol {
this.registerIncoming(0x3D, ServerWorldBorderPacket.class);
this.registerIncoming(0x3E, ServerSwitchCameraPacket.class);
this.registerIncoming(0x3F, ServerPlayerChangeHeldItemPacket.class);
// 0x40 Update View Position
this.registerIncoming(0x40, ServerUpdateViewPositionPacket.class);
// 0x41 Update View Distance
this.registerIncoming(0x42, ServerDisplayScoreboardPacket.class);
this.registerIncoming(0x43, ServerEntityMetadataPacket.class);
@ -615,7 +616,7 @@ public class MinecraftProtocol extends PacketProtocol {
this.registerOutgoing(0x3D, ServerWorldBorderPacket.class);
this.registerOutgoing(0x3E, ServerSwitchCameraPacket.class);
this.registerOutgoing(0x3F, ServerPlayerChangeHeldItemPacket.class);
// 0x40 Update View Position
this.registerOutgoing(0x40, ServerUpdateViewPositionPacket.class);
// 0x41 Update View Distance
this.registerOutgoing(0x42, ServerDisplayScoreboardPacket.class);
this.registerOutgoing(0x43, ServerEntityMetadataPacket.class);

View file

@ -0,0 +1,41 @@
package com.github.steveice10.mc.protocol.packet.ingame.server.world;
import java.io.IOException;
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
import com.github.steveice10.packetlib.io.NetInput;
import com.github.steveice10.packetlib.io.NetOutput;
public class ServerUpdateViewPositionPacket extends MinecraftPacket {
private int chunkX;
private int chunkZ;
public ServerUpdateViewPositionPacket() {
}
public ServerUpdateViewPositionPacket(int chunkX, int chunkZ) {
this.chunkX = chunkX;
this.chunkZ = chunkZ;
}
public int getChunkX() {
return chunkX;
}
public int getChunkZ() {
return chunkZ;
}
@Override
public void read(NetInput in) throws IOException {
this.chunkX = in.readVarInt();
this.chunkZ = in.readVarInt();
}
@Override
public void write(NetOutput out) throws IOException {
out.writeVarInt(this.chunkX);
out.writeVarInt(this.chunkZ);
}
}