protocol: use WindowID types

This commit is contained in:
extremeheat 2021-03-24 08:32:32 -04:00
commit 3f5b82f0f4
4 changed files with 79 additions and 15 deletions

View file

@ -4531,7 +4531,7 @@
[
{
"name": "window_id",
"type": "u8"
"type": "WindowID"
},
{
"name": "window_type",
@ -4552,7 +4552,7 @@
[
{
"name": "window_id",
"type": "u8"
"type": "WindowID"
},
{
"name": "server",
@ -4595,7 +4595,7 @@
[
{
"name": "window_id",
"type": "varint"
"type": "WindowID"
},
{
"name": "slot",
@ -5481,7 +5481,7 @@
[
{
"name": "window_id",
"type": "u8"
"type": "WindowID"
},
{
"name": "window_type",
@ -5526,7 +5526,7 @@
[
{
"name": "window_id",
"type": "u8"
"type": "WindowID"
},
{
"name": "window_type",

View file

@ -2546,6 +2546,41 @@
}
}
],
"WindowIDVarint": [
"mapper",
{
"type": "varint",
"mappings": {
"0": "inventory",
"1": "first",
"100": "last",
"119": "offhand",
"120": "armor",
"121": "creative",
"122": "hotbar",
"123": "fixed_inventory",
"124": "ui",
"-100": "drop_contents",
"-24": "beacon",
"-23": "trading_output",
"-22": "trading_use_inputs",
"-21": "trading_input_2",
"-20": "trading_input_1",
"-17": "enchant_output",
"-16": "enchant_material",
"-15": "enchant_input",
"-13": "anvil_output",
"-12": "anvil_result",
"-11": "anvil_material",
"-10": "container_input",
"-5": "crafting_use_ingredient",
"-4": "crafting_result",
"-3": "crafting_remove_ingredient",
"-2": "crafting_add_ingredient",
"-1": "none"
}
}
],
"WindowType": [
"mapper",
{
@ -4672,7 +4707,7 @@
[
{
"name": "window_id",
"type": "u8"
"type": "WindowID"
},
{
"name": "window_type",
@ -4693,7 +4728,7 @@
[
{
"name": "window_id",
"type": "u8"
"type": "WindowID"
},
{
"name": "server",
@ -4736,7 +4771,7 @@
[
{
"name": "window_id",
"type": "varint"
"type": "WindowIDVarint"
},
{
"name": "slot",
@ -5653,7 +5688,7 @@
[
{
"name": "window_id",
"type": "u8"
"type": "WindowID"
},
{
"name": "window_type",
@ -5698,7 +5733,7 @@
[
{
"name": "window_id",
"type": "u8"
"type": "WindowID"
},
{
"name": "window_type",

View file

@ -896,7 +896,7 @@ packet_container_open:
!bound: client
# WindowID is the ID representing the window that is being opened. It may be used later to close the
# container using a ContainerClose packet.
window_id: u8
window_id: WindowID
# ContainerType is the type ID of the container that is being opened when opening the container at the
# position of the packet. It depends on the block/entity, and could, for example, be the window type of
# a chest or a hopper, but also a horse inventory.
@ -917,7 +917,7 @@ packet_container_close:
!bound: both
# WindowID is the ID representing the window of the container that should be closed. It must be equal to
# the one sent in the ContainerOpen packet to close the designated window.
window_id: u8
window_id: WindowID
# ServerSide determines whether or not the container was force-closed by the server. If this value is
# not set correctly, the client may ignore the packet and respond with a PacketViolationWarning.
server: bool
@ -954,7 +954,7 @@ packet_inventory_slot:
!bound: both
# WindowID is the ID of the window that the packet modifies. It must point to one of the windows that the
# client currently has opened.
window_id: varint
window_id: WindowIDVarint
# Slot is the index of the slot that the packet modifies. The new item will be set to the slot at this
# index.
slot: varint
@ -1448,7 +1448,7 @@ packet_update_trade:
!id: 0x50
!bound: client
# WindowID is the ID that identifies the trading window that the client currently has opened.
window_id: u8
window_id: WindowID
# WindowType is an identifier specifying the type of the window opened. In vanilla, it appears this is
# always filled out with 15.
window_type: WindowType
@ -1486,7 +1486,7 @@ packet_update_equipment:
!bound: client
# WindowID is the identifier associated with the window that the UpdateEquip packet concerns. It is the
# ID sent for the horse inventory that was opened before this packet was sent.
window_id: u8
window_id: WindowID
# WindowType is the type of the window that was opened. Generally, this is the type of a horse inventory,
# as the packet is specifically made for that.
window_type: WindowType

View file

@ -996,6 +996,35 @@ WindowID: i8 =>
123: fixed_inventory
124: ui
WindowIDVarint: varint =>
-100: drop_contents
-24: beacon
-23: trading_output
-22: trading_use_inputs
-21: trading_input_2
-20: trading_input_1
-17: enchant_output
-16: enchant_material
-15: enchant_input
-13: anvil_output
-12: anvil_result
-11: anvil_material
-10: container_input
-5: crafting_use_ingredient
-4: crafting_result
-3: crafting_remove_ingredient
-2: crafting_add_ingredient
-1: none
0: inventory
1: first
100: last
119: offhand
120: armor
121: creative
122: hotbar
123: fixed_inventory
124: ui
WindowType: u8 =>
0: container
1: workbench