mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
PacketFacePlayer
This commit is contained in:
parent
dbabc8177a
commit
be2d3443b9
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* 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.clientbound.play;
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.game.datatypes.entities.Location;
|
||||||
|
import de.bixilon.minosoft.logging.Log;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||||
|
|
||||||
|
public class PacketFacePlayer implements ClientboundPacket {
|
||||||
|
PlayerFaces face;
|
||||||
|
Location location;
|
||||||
|
int entityId = -1;
|
||||||
|
PlayerFaces entityFace;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean read(InPacketBuffer buffer) {
|
||||||
|
switch (buffer.getVersion()) {
|
||||||
|
case VERSION_1_13_2:
|
||||||
|
face = PlayerFaces.byId(buffer.readVarInt());
|
||||||
|
location = buffer.readLocation();
|
||||||
|
if (buffer.readBoolean()) {
|
||||||
|
// entity present
|
||||||
|
entityId = buffer.readVarInt();
|
||||||
|
entityFace = PlayerFaces.byId(buffer.readVarInt());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
Log.protocol(String.format("Received face player packet (face=%s, location=%s, entityId=%d, entityFace=%s)", face.name(), location.toString(), entityId, ((entityFace != null) ? entityFace.name() : null)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(PacketHandler h) {
|
||||||
|
h.handle(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerFaces getFace() {
|
||||||
|
return face;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEntityId() {
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerFaces getEntityFace() {
|
||||||
|
return entityFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PlayerFaces {
|
||||||
|
FEET(0),
|
||||||
|
EYES(1);
|
||||||
|
|
||||||
|
final int id;
|
||||||
|
|
||||||
|
PlayerFaces(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerFaces byId(int id) {
|
||||||
|
for (PlayerFaces face : values()) {
|
||||||
|
if (face.getId() == id) {
|
||||||
|
return face;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -577,4 +577,7 @@ public class PacketHandler {
|
|||||||
|
|
||||||
public void handle(PacketNBTQueryResponse pkg) {
|
public void handle(PacketNBTQueryResponse pkg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handle(PacketFacePlayer pkg) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,7 @@ public abstract class Protocol implements ProtocolInterface {
|
|||||||
packetClassMapping.put(Packets.Clientbound.PLAY_SELECT_ADVANCEMENT_TAB, PacketSelectAdvancementTab.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_SELECT_ADVANCEMENT_TAB, PacketSelectAdvancementTab.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_ADVANCEMENTS, PacketAdvancements.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_ADVANCEMENTS, PacketAdvancements.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_NBT_QUERY_RESPONSE, PacketNBTQueryResponse.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_NBT_QUERY_RESPONSE, PacketNBTQueryResponse.class);
|
||||||
|
packetClassMapping.put(Packets.Clientbound.PLAY_FACE_PLAYER, PacketFacePlayer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolVersion getLowestVersionSupported() {
|
public static ProtocolVersion getLowestVersionSupported() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user