PacketSpectate (1.8, 1.9)

This commit is contained in:
Bixilon 2020-07-01 22:18:25 +02:00
parent 32942a0a91
commit e476c57b98
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -0,0 +1,49 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.protocol.packets.serverbound.play;
import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
import de.bixilon.minosoft.protocol.protocol.Packets;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.UUID;
public class PacketSpectate implements ServerboundPacket {
final UUID entityUUID;
public PacketSpectate(UUID entityUUID) {
this.entityUUID = entityUUID;
log();
}
@Override
public OutPacketBuffer write(ProtocolVersion version) {
OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_SPECTATE));
switch (version) {
case VERSION_1_8:
case VERSION_1_9_4:
buffer.writeUUID(entityUUID);
break;
}
return buffer;
}
@Override
public void log() {
Log.protocol(String.format("Spectating entity (entityUUID=%s)", entityUUID));
}
}