Port over custom packets and update to 1.16.2
This commit is contained in:
+87
-9
@@ -1,18 +1,14 @@
|
||||
from math import floor
|
||||
|
||||
from minecraft.networking.packets import Packet, PacketBuffer
|
||||
from minecraft.networking.types import (
|
||||
VarInt, Integer, Boolean, UnsignedByte, Long, Short,
|
||||
multi_attribute_alias, Vector, UnsignedLong
|
||||
)
|
||||
|
||||
from protocol.types import Nbt
|
||||
from minecraft.networking.packets import Packet
|
||||
from minecraft.networking.types import (
|
||||
VarInt, Integer, UnsignedByte, Position, Vector, MutableRecord,
|
||||
attribute_alias, multi_attribute_alias, Long, Boolean, VarLong,
|
||||
Short, UnsignedLong, Byte, BlockFace,
|
||||
)
|
||||
|
||||
from protocol.types import Nbt, Slot
|
||||
|
||||
|
||||
class BlockChangePacket(Packet):
|
||||
id = 0x0B
|
||||
@@ -176,9 +172,7 @@ class ChunkDataPacket(Packet):
|
||||
y = e['y']
|
||||
self.chunks[floor(y/16)].entities.append(e)
|
||||
|
||||
|
||||
class Chunk:
|
||||
|
||||
position = multi_attribute_alias(Vector, 'x', 'y', 'z')
|
||||
|
||||
def __init__(self, x, y, z, empty=True):
|
||||
@@ -246,3 +240,87 @@ class Chunk:
|
||||
def origin(self):
|
||||
return self.position*16
|
||||
|
||||
|
||||
class AcknowledgePlayerDiggingPacket(Packet):
|
||||
id = 0x07
|
||||
packet_name = 'acknowledge player digging'
|
||||
definition = [
|
||||
{'location': Position},
|
||||
{'block': VarInt},
|
||||
{'status': VarInt},
|
||||
{'successful': Boolean},
|
||||
]
|
||||
|
||||
|
||||
class BlockBreakAnimationPacket(Packet):
|
||||
id = 0x08
|
||||
packet_name = 'block break animation'
|
||||
definition = [
|
||||
{'entity_id': VarInt},
|
||||
{'location': Position},
|
||||
{'destroy_stage': Byte},
|
||||
]
|
||||
|
||||
|
||||
class SetSlotPacket(Packet):
|
||||
id = 0x15
|
||||
packet_name = 'set slot'
|
||||
definition = [
|
||||
{'window_id': Byte},
|
||||
{'slot': Short},
|
||||
{'slot_data': Slot},
|
||||
]
|
||||
|
||||
|
||||
class TimeUpdatePacket(Packet):
|
||||
id = 0x4E
|
||||
packet_name = 'time update'
|
||||
definition = [
|
||||
{'world_age': Long},
|
||||
{'time_of_day': Long},
|
||||
]
|
||||
|
||||
|
||||
class PlayerDiggingPacket(Packet):
|
||||
# used when player mines / breaks blocks
|
||||
# https://wiki.vg/Protocol#Player_Digging
|
||||
|
||||
id = 0x1B
|
||||
packet_name = 'player digging'
|
||||
|
||||
definition = [
|
||||
{'status': VarInt},
|
||||
{'location': Position},
|
||||
{'face': VarInt},
|
||||
]
|
||||
|
||||
STARTED = 0
|
||||
CANCELLED = 1
|
||||
FINISHED = 2
|
||||
|
||||
# PlayerBlockPlacementPacket.Face is an alias for BlockFace.
|
||||
Face = BlockFace
|
||||
|
||||
|
||||
class PickItemPacket(Packet):
|
||||
# used when player picks item (middle click)
|
||||
# https://wiki.vg/Protocol#Pick_Item
|
||||
|
||||
id = 0x18
|
||||
packet_name = 'pick item'
|
||||
|
||||
definition = [
|
||||
{'slot_to_use': VarInt},
|
||||
]
|
||||
|
||||
|
||||
class HeldItemChangePacket(Packet):
|
||||
# Sent when the player changes the slot selection
|
||||
# https://wiki.vg/Protocol#Held_Item_Change_.28serverbound.29
|
||||
|
||||
id = 0x25
|
||||
packet_name = 'held item change'
|
||||
|
||||
definition = [
|
||||
{'slot': Short},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user