Add support for Minecraft 1.18 and 1.18.1.
This commit is contained in:
1 parent
1ae9a2b48a
commit
bf49006553
17 files changed
+322
-75
No files matched your search
@@ -1,8 +1,11 @@
|
||||
import operator
|
||||
|
||||
from minecraft.networking.packets import Packet
|
||||
from minecraft.networking.types import (
|
||||
String, Byte, VarInt, Boolean, UnsignedByte, Enum, BitFieldEnum,
|
||||
AbsoluteHand
|
||||
)
|
||||
from minecraft.utility import attribute_transform
|
||||
|
||||
|
||||
class ClientSettingsPacket(Packet):
|
||||
@@ -18,13 +21,40 @@ class ClientSettingsPacket(Packet):
|
||||
|
||||
packet_name = 'client settings'
|
||||
|
||||
get_definition = staticmethod(lambda context: [
|
||||
{'locale': String},
|
||||
{'view_distance': Byte},
|
||||
{'chat_mode': VarInt if context.protocol_later(47) else Byte},
|
||||
{'chat_colors': Boolean},
|
||||
{'displayed_skin_parts': UnsignedByte},
|
||||
{'main_hand': VarInt} if context.protocol_later(49) else {}])
|
||||
@staticmethod
|
||||
def get_definition(context):
|
||||
return [
|
||||
{'locale': String},
|
||||
{'view_distance': Byte},
|
||||
{'chat_mode': VarInt if context.protocol_later(47) else Byte},
|
||||
{'chat_colors': Boolean},
|
||||
{'displayed_skin_parts': UnsignedByte},
|
||||
{'main_hand': VarInt} if context.protocol_later(49) else {},
|
||||
|
||||
{'enable_text_filtering': Boolean}
|
||||
if context.protocol_later_eq(757) else
|
||||
{'disable_text_filtering': Boolean}
|
||||
if context.protocol_later_eq(755) else {},
|
||||
|
||||
{'allow_server_listings': Boolean}
|
||||
if context.protocol_later_eq(755) else {},
|
||||
]
|
||||
|
||||
# Set a default value for 'enable_text_filtering', because most clients
|
||||
# will probably want this value, and to avoid breaking old code.
|
||||
enable_text_filtering = False
|
||||
|
||||
# To support the possibility of both 'enable_text_filtering' and
|
||||
# 'disable_text_filtering' fields existing, make 'disable_text_filtering'
|
||||
# (which is the less likely to be used of the two) into a property that
|
||||
# stores the negation of its value in the ordinary attribute
|
||||
# 'enable_text_filtering'.
|
||||
disable_text_filtering = attribute_transform(
|
||||
'enable_text_filtering', operator.not_, operator.not_)
|
||||
|
||||
# Set a default value for 'allow_server_listings', because most clients
|
||||
# will probably want this value, and to avoid breaking old code.
|
||||
allow_server_listings = False
|
||||
|
||||
field_enum = classmethod(
|
||||
lambda cls, field, context: {
|
||||
|
||||
Reference in new issue
Block a user