Handle entity metadata
This commit is contained in:
+23
-2
@@ -4,10 +4,11 @@ from minecraft.networking.packets import Packet, PacketBuffer
|
||||
from minecraft.networking.types import (
|
||||
VarInt, Integer, UnsignedByte, Position, Vector, MutableRecord,
|
||||
attribute_alias, multi_attribute_alias, Long, Boolean, VarLong,
|
||||
Short, UnsignedLong, Byte, BlockFace, String
|
||||
Short, UnsignedLong, Byte, BlockFace, String, UUID, Angle, Double,
|
||||
Float,
|
||||
)
|
||||
|
||||
from protocol.types import Nbt, Slot
|
||||
from protocol.types import Nbt, Slot, Entry
|
||||
|
||||
|
||||
class ChunkDataPacket(Packet):
|
||||
@@ -286,3 +287,23 @@ class ServerWindowConfirmationPacket(Packet):
|
||||
{'action_number': Short},
|
||||
{'accepted': Boolean},
|
||||
]
|
||||
|
||||
|
||||
class EntityMetadataPacket(Packet):
|
||||
# Updates one or more metadata properties for an existing entity
|
||||
# https://wiki.vg/Protocol#Entity_Metadata
|
||||
|
||||
id = 0x44
|
||||
packet_name = 'entity metadata'
|
||||
fields = 'entity_id', 'metadata'
|
||||
|
||||
class Entry:
|
||||
__slots__ = 'index', 'type', 'value'
|
||||
|
||||
def read(self, file_object):
|
||||
self.entity_id = VarInt.read(file_object)
|
||||
self.metadata = []
|
||||
for _ in range(99):
|
||||
entry = Entry.read(file_object)
|
||||
if not entry: break
|
||||
self.metadata.append(entry)
|
||||
|
||||
Reference in New Issue
Block a user