diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketUpdateViewDistance.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketUpdateViewDistance.java new file mode 100644 index 000000000..86926764b --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketUpdateViewDistance.java @@ -0,0 +1,44 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.protocol.packets.clientbound.play; + +import de.bixilon.minosoft.logging.Log; +import de.bixilon.minosoft.protocol.packets.ClientboundPacket; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.PacketHandler; + +public class PacketUpdateViewDistance implements ClientboundPacket { + int viewDistance; + + @Override + public boolean read(InByteBuffer buffer) { + switch (buffer.getVersion()) { + case VERSION_1_14_4: + viewDistance = buffer.readVarInt(); + return true; + } + + return false; + } + + @Override + public void log() { + Log.protocol(String.format("Received view distance update (viewDistance=%s)", viewDistance)); + } + + @Override + public void handle(PacketHandler h) { + h.handle(this); + } +} diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketUpdateViewPosition.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketUpdateViewPosition.java new file mode 100644 index 000000000..39b9560d5 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketUpdateViewPosition.java @@ -0,0 +1,45 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.protocol.packets.clientbound.play; + +import de.bixilon.minosoft.game.datatypes.world.ChunkLocation; +import de.bixilon.minosoft.logging.Log; +import de.bixilon.minosoft.protocol.packets.ClientboundPacket; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.PacketHandler; + +public class PacketUpdateViewPosition implements ClientboundPacket { + ChunkLocation location; + + @Override + public boolean read(InByteBuffer buffer) { + switch (buffer.getVersion()) { + case VERSION_1_14_4: + location = new ChunkLocation(buffer.readVarInt(), buffer.readVarInt()); + return true; + } + + return false; + } + + @Override + public void log() { + Log.protocol(String.format("Received view position update (location=%s)", location)); + } + + @Override + public void handle(PacketHandler h) { + h.handle(this); + } +} diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java index a02259caf..7461b35b8 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java @@ -605,4 +605,10 @@ public class PacketHandler { public void handle(PacketUpdateLight pkg) { } + + public void handle(PacketUpdateViewPosition pkg) { + } + + public void handle(PacketUpdateViewDistance pkg) { + } } diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java index a2fa1c45f..e9f6d0311 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java @@ -159,6 +159,8 @@ public abstract class Protocol implements ProtocolInterface { packetClassMapping.put(Packets.Clientbound.PLAY_DECLARE_RECIPES, PacketDeclareRecipes.class); packetClassMapping.put(Packets.Clientbound.PLAY_STOP_SOUND, PacketStopSound.class); packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_LIGHT, PacketUpdateLight.class); + packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_VIEW_DISTANCE, PacketUpdateViewDistance.class); + packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_VIEW_POSITION, PacketUpdateViewPosition.class); } public static ProtocolVersion getLowestVersionSupported() {