add Client Status Packet and allow client to respawn when issuing '/respawn'
This commit is contained in:
1 parent
0dc333237b
commit
fecb1d10e9
2 files changed
+23
-1
No files matched your search
@@ -861,6 +861,21 @@ class AnimationPacketServerbound(Packet):
|
|||||||
HAND_MAIN = 0
|
HAND_MAIN = 0
|
||||||
HAND_OFF = 1
|
HAND_OFF = 1
|
||||||
|
|
||||||
|
class ServerClientStatus(Packet):
|
||||||
|
@staticmethod
|
||||||
|
def get_id(context):
|
||||||
|
return 0x04 if context.protocol_version >= 318 else \
|
||||||
|
0x03 if context.protocol_version >= 80 else \
|
||||||
|
0x02 if context.protocol_version >= 67 else \
|
||||||
|
0x17 if context.protocol_version >= 49 else \
|
||||||
|
0x16
|
||||||
|
|
||||||
|
packet_name = "client status"
|
||||||
|
get_definition = staticmethod(lambda context: [
|
||||||
|
{'action_id': VarInt}])
|
||||||
|
|
||||||
|
RESPAWN = 0
|
||||||
|
REQUEST_STATS = 1
|
||||||
|
|
||||||
def state_playing_serverbound(context):
|
def state_playing_serverbound(context):
|
||||||
packets = {
|
packets = {
|
||||||
@@ -868,6 +883,7 @@ def state_playing_serverbound(context):
|
|||||||
ChatPacket,
|
ChatPacket,
|
||||||
PositionAndLookPacket,
|
PositionAndLookPacket,
|
||||||
AnimationPacketServerbound,
|
AnimationPacketServerbound,
|
||||||
|
ServerClientStatus,
|
||||||
}
|
}
|
||||||
if context.protocol_version >= 107:
|
if context.protocol_version >= 107:
|
||||||
packets |= {
|
packets |= {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from optparse import OptionParser
|
|||||||
from minecraft import authentication
|
from minecraft import authentication
|
||||||
from minecraft.exceptions import YggdrasilError
|
from minecraft.exceptions import YggdrasilError
|
||||||
from minecraft.networking.connection import Connection
|
from minecraft.networking.connection import Connection
|
||||||
from minecraft.networking.packets import ChatMessagePacket, ChatPacket
|
from minecraft.networking.packets import ChatMessagePacket, ChatPacket, ServerClientStatus
|
||||||
from minecraft.compat import input
|
from minecraft.compat import input
|
||||||
|
|
||||||
|
|
||||||
@@ -77,6 +77,12 @@ def main():
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
text = input()
|
text = input()
|
||||||
|
if text == "/respawn":
|
||||||
|
print("respawning...")
|
||||||
|
packet = ServerClientStatus()
|
||||||
|
packet.action_id = ServerClientStatus.RESPAWN
|
||||||
|
connection.write_packet(packet)
|
||||||
|
else:
|
||||||
packet = ChatPacket()
|
packet = ChatPacket()
|
||||||
packet.message = text
|
packet.message = text
|
||||||
connection.write_packet(packet)
|
connection.write_packet(packet)
|
||||||
|
|||||||
Reference in new issue
Block a user