Add state machine for caching items into chests

This commit is contained in:
2020-09-20 19:08:23 -06:00
parent b8cbd9a5f0
commit f8d44e7e38
12 changed files with 326 additions and 59 deletions
+43 -1
View File
@@ -4,7 +4,7 @@ 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,
Short, UnsignedLong, Byte, BlockFace, String
)
from protocol.types import Nbt, Slot
@@ -217,3 +217,45 @@ class HeldItemChangePacket(Packet):
definition = [
{'slot': Short},
]
class OpenWindowPacket(Packet):
# Sent to the client when it should open an inventory, such as a chest, workbench, or furnace
# https://wiki.vg/Protocol#Open_Window
id = 0x2D
packet_name = 'open window'
definition = [
{'window_id': VarInt},
{'window_type': VarInt},
{'window_title': String},
]
class CloseWindowPacket(Packet):
# Sent by the client when closing a window
# https://wiki.vg/Protocol#Close_Window_.28serverbound.29
id = 0x0A
packet_name = 'close window'
definition = [
{'window_id': UnsignedByte},
]
class ClickWindowPacket(Packet):
# Sent by the player when it clicks on a slot in a window
# https://wiki.vg/Protocol#Click_Window
id = 0x09
packet_name = 'click window'
definition = [
{'window_id': UnsignedByte},
{'slot': Short},
{'button': Byte},
{'action_number': Short},
{'mode': VarInt},
{'clicked_item': Slot},
]