Merge pull request #2 from TargetedEntropy/Microsoft_Auth

Microsoft Auth
This commit is contained in:
TargetedEntropy 2023-03-20 20:20:37 -04:00 committed by GitHub
commit 6430230b12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 1238 additions and 924 deletions

View File

@ -12,6 +12,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import minecraft
import sys
import os
import shlex
@ -62,7 +63,6 @@ author = u'Ammar Askar'
# |version| and |release|, also used in various other places throughout the
# built documents.
#
import minecraft
# The short X.Y version.
version = minecraft.__version__
# The full version, including alpha/beta/rc tags.
@ -120,12 +120,12 @@ todo_include_todos = True
# Attempt to use RTD theme even when compiling locally.
if os.environ.get("READTHEDOCS", "") != "True":
try:
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
except ImportError:
html_theme = "classic"
try:
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
except ImportError:
html_theme = "classic"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@ -222,25 +222,25 @@ htmlhelp_basename = 'pyCraftdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
# Latex figure (float) alignment
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pyCraft.tex', u'pyCraft Documentation',
u'Ammar Askar', 'manual'),
(master_doc, 'pyCraft.tex', u'pyCraft Documentation',
u'Ammar Askar', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@ -283,9 +283,9 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pyCraft', u'pyCraft Documentation',
author, 'pyCraft', 'One line description of project.',
'Miscellaneous'),
(master_doc, 'pyCraft', u'pyCraft Documentation',
author, 'pyCraft', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.

View File

@ -25,456 +25,456 @@ Version = namedtuple('Version', ('id', 'protocol', 'supported'))
# key in "version.json" in the corresponding ".jar" file distributed by Mojang.
KNOWN_MINECRAFT_VERSION_RECORDS = [
# id protocol supported
Version('13w41a', 0, False),
Version('13w41b', 0, False),
Version('13w42a', 1, False),
Version('13w42b', 1, False),
Version('13w43a', 2, False),
Version('1.7-pre', 3, False),
Version('1.7.1-pre', 3, False),
Version('1.7.2', 4, True),
Version('13w47a', 4, False),
Version('13w47b', 4, False),
Version('13w47c', 4, False),
Version('13w47d', 4, False),
Version('13w47e', 4, False),
Version('13w48a', 4, False),
Version('13w48b', 4, False),
Version('13w49a', 4, False),
Version('1.7.3-pre', 4, False),
Version('1.7.4', 4, True),
Version('1.7.5', 4, True),
Version('1.7.6-pre1', 5, False),
Version('1.7.6-pre2', 5, False),
Version('1.7.6', 5, True),
Version('1.7.7', 5, True),
Version('1.7.8', 5, True),
Version('1.7.9', 5, True),
Version('1.7.10-pre1', 5, False),
Version('1.7.10-pre2', 5, False),
Version('1.7.10-pre3', 5, False),
Version('1.7.10-pre4', 5, False),
Version('1.7.10', 5, True),
Version('14w02a', 5, False),
Version('14w02b', 5, False),
Version('14w02c', 5, False),
Version('14w03a', 6, False),
Version('14w03b', 6, False),
Version('14w04a', 7, False),
Version('14w04b', 8, False),
Version('14w05a', 9, False),
Version('14w05b', 9, False),
Version('14w06a', 10, False),
Version('14w06b', 10, False),
Version('14w07a', 11, False),
Version('14w08a', 12, False),
Version('14w10a', 13, False),
Version('14w10b', 13, False),
Version('14w10c', 13, False),
Version('14w11a', 14, False),
Version('14w11b', 14, False),
Version('14w17a', 15, False),
Version('14w18a', 16, False),
Version('14w18b', 16, False),
Version('14w19a', 17, False),
Version('14w20a', 18, False),
Version('14w20b', 18, False),
Version('14w21a', 19, False),
Version('14w21b', 20, False),
Version('14w25a', 21, False),
Version('14w25b', 22, False),
Version('14w26a', 23, False),
Version('14w26b', 24, False),
Version('14w26c', 25, False),
Version('14w27a', 26, False),
Version('14w27b', 26, False),
Version('14w28a', 27, False),
Version('14w28b', 28, False),
Version('14w29a', 29, False),
Version('14w29a', 29, False),
Version('14w30a', 30, False),
Version('14w30b', 30, False),
Version('14w30c', 31, False),
Version('14w31a', 32, False),
Version('14w32a', 33, False),
Version('14w32b', 34, False),
Version('14w32c', 35, False),
Version('14w32d', 36, False),
Version('14w33a', 37, False),
Version('14w33b', 38, False),
Version('14w33c', 39, False),
Version('14w34a', 40, False),
Version('14w34b', 41, False),
Version('14w34c', 42, False),
Version('14w34d', 43, False),
Version('1.8-pre1', 44, False),
Version('1.8-pre2', 45, False),
Version('1.8-pre3', 46, False),
Version('1.8', 47, True),
Version('1.8.1-pre1', 47, False),
Version('1.8.1-pre2', 47, False),
Version('1.8.1-pre3', 47, False),
Version('1.8.1-pre4', 47, False),
Version('1.8.1-pre5', 47, False),
Version('1.8.1', 47, True),
Version('1.8.2-pre1', 47, False),
Version('1.8.2-pre2', 47, False),
Version('1.8.2-pre3', 47, False),
Version('1.8.2-pre4', 47, False),
Version('1.8.2-pre5', 47, False),
Version('1.8.2-pre6', 47, False),
Version('1.8.2-pre7', 47, False),
Version('1.8.2', 47, True),
Version('1.8.3', 47, True),
Version('1.8.4', 47, True),
Version('1.8.5', 47, True),
Version('1.8.6', 47, True),
Version('1.8.7', 47, True),
Version('1.8.8', 47, True),
Version('1.8.9', 47, True),
Version('15w14a', 48, False),
Version('15w31a', 49, False),
Version('15w31b', 50, False),
Version('15w31c', 51, False),
Version('15w32a', 52, False),
Version('15w32b', 53, False),
Version('15w32c', 54, False),
Version('15w33a', 55, False),
Version('15w33b', 56, False),
Version('15w33c', 57, False),
Version('15w34a', 58, False),
Version('15w34b', 59, False),
Version('15w34c', 60, False),
Version('15w34d', 61, False),
Version('15w35a', 62, False),
Version('15w35b', 63, False),
Version('15w35c', 64, False),
Version('15w35d', 65, False),
Version('15w35e', 66, False),
Version('15w36a', 67, False),
Version('15w36b', 68, False),
Version('15w36c', 69, False),
Version('15w36d', 70, False),
Version('15w37a', 71, False),
Version('15w38a', 72, False),
Version('15w38b', 73, False),
Version('15w39a', 74, False),
Version('15w39b', 74, False),
Version('15w39c', 74, False),
Version('15w40a', 75, False),
Version('15w40b', 76, False),
Version('15w41a', 77, False),
Version('15w41b', 78, False),
Version('15w42a', 79, False),
Version('15w43a', 80, False),
Version('15w43b', 81, False),
Version('15w43c', 82, False),
Version('15w44a', 83, False),
Version('15w44b', 84, False),
Version('15w45a', 85, False),
Version('15w46a', 86, False),
Version('15w47a', 87, False),
Version('15w47b', 88, False),
Version('15w47c', 89, False),
Version('15w49a', 90, False),
Version('15w49b', 91, False),
Version('15w50a', 92, False),
Version('15w51a', 93, False),
Version('15w51b', 94, False),
Version('16w02a', 95, False),
Version('16w03a', 96, False),
Version('16w04a', 97, False),
Version('16w05a', 98, False),
Version('16w05b', 99, False),
Version('16w06a', 100, False),
Version('16w07a', 101, False),
Version('16w07b', 102, False),
Version('1.9-pre1', 103, False),
Version('1.9-pre2', 104, False),
Version('1.9-pre3', 105, False),
Version('1.9-pre4', 106, False),
Version('1.9', 107, True),
Version('1.9.1-pre1', 107, False),
Version('1.9.1-pre2', 108, False),
Version('1.9.1-pre3', 108, False),
Version('1.9.1', 108, True),
Version('1.RV-Pre1', 108, False),
Version('1.9.2', 109, True),
Version('16w14a', 109, False),
Version('16w15a', 109, False),
Version('16w15b', 109, False),
Version('1.9.3-pre1', 109, False),
Version('1.9.3-pre2', 110, False),
Version('1.9.3-pre3', 110, False),
Version('1.9.3', 110, True),
Version('1.9.4', 110, True),
Version('16w20a', 201, False),
Version('16w21a', 202, False),
Version('16w21b', 203, False),
Version('1.10-pre1', 204, False),
Version('1.10-pre2', 205, False),
Version('1.10', 210, True),
Version('1.10.1', 210, True),
Version('1.10.2', 210, True),
Version('16w32a', 301, True),
Version('16w32b', 302, True),
Version('16w33a', 303, True),
Version('16w35a', 304, True),
Version('16w36a', 305, True),
Version('16w38a', 306, True),
Version('16w39a', 307, True),
Version('16w39b', 308, True),
Version('16w39c', 309, True),
Version('16w40a', 310, True),
Version('16w41a', 311, True),
Version('16w42a', 312, True),
Version('16w43a', 313, True),
Version('16w44a', 313, True),
Version('1.11-pre1', 314, True),
Version('1.11', 315, True),
Version('16w50a', 316, True),
Version('1.11.1', 316, True),
Version('1.11.2', 316, True),
Version('17w06a', 317, True),
Version('17w13a', 318, True),
Version('17w13b', 319, True),
Version('17w14a', 320, True),
Version('17w15a', 321, True),
Version('17w16a', 322, True),
Version('17w16b', 323, True),
Version('17w17a', 324, True),
Version('17w17b', 325, True),
Version('17w18a', 326, True),
Version('17w18b', 327, True),
Version('1.12-pre1', 328, True),
Version('1.12-pre2', 329, True),
Version('1.12-pre3', 330, True),
Version('1.12-pre4', 331, True),
Version('1.12-pre5', 332, True),
Version('1.12-pre6', 333, True),
Version('1.12-pre7', 334, True),
Version('1.12', 335, True),
Version('17w31a', 336, True),
Version('1.12.1-pre1', 337, True),
Version('1.12.1', 338, True),
Version('1.12.2-pre1', 339, True),
Version('1.12.2-pre2', 339, True),
Version('1.12.2', 340, True),
Version('17w43a', 341, True),
Version('17w43b', 342, True),
Version('17w45a', 343, True),
Version('17w45b', 344, True),
Version('17w46a', 345, True),
Version('17w47a', 346, True),
Version('17w47b', 347, True),
Version('17w48a', 348, True),
Version('17w49a', 349, True),
Version('17w49b', 350, True),
Version('17w50a', 351, True),
Version('18w01a', 352, True),
Version('18w02a', 353, True),
Version('18w03a', 354, True),
Version('18w03b', 355, True),
Version('18w05a', 356, True),
Version('18w06a', 357, True),
Version('18w07a', 358, True),
Version('18w07b', 359, True),
Version('18w07c', 360, True),
Version('18w08a', 361, True),
Version('18w08b', 362, True),
Version('18w09a', 363, True),
Version('18w10a', 364, True),
Version('18w10b', 365, True),
Version('18w10c', 366, True),
Version('18w10d', 367, True),
Version('18w11a', 368, True),
Version('18w14a', 369, True),
Version('18w14b', 370, True),
Version('18w15a', 371, True),
Version('18w16a', 372, True),
Version('18w19a', 373, True),
Version('18w19b', 374, True),
Version('18w20a', 375, True),
Version('18w20b', 376, True),
Version('18w20c', 377, True),
Version('18w21a', 378, True),
Version('18w21b', 379, True),
Version('18w22a', 380, True),
Version('18w22b', 381, True),
Version('18w22c', 382, True),
Version('1.13-pre1', 383, True),
Version('1.13-pre2', 384, True),
Version('1.13-pre3', 385, True),
Version('1.13-pre4', 386, True),
Version('1.13-pre5', 387, True),
Version('1.13-pre6', 388, True),
Version('1.13-pre7', 389, True),
Version('1.13-pre8', 390, True),
Version('1.13-pre9', 391, True),
Version('1.13-pre10', 392, True),
Version('1.13', 393, True),
Version('18w30a', 394, True),
Version('18w30b', 395, True),
Version('18w31a', 396, True),
Version('18w32a', 397, True),
Version('18w33a', 398, True),
Version('1.13.1-pre1', 399, True),
Version('1.13.1-pre2', 400, True),
Version('1.13.1', 401, True),
Version('1.13.2-pre1', 402, True),
Version('1.13.2-pre2', 403, True),
Version('1.13.2', 404, True),
Version('18w43a', 441, True),
Version('18w43b', 441, True),
Version('18w43c', 442, True),
Version('18w44a', 443, True),
Version('18w45a', 444, True),
Version('18w46a', 445, True),
Version('18w47a', 446, True),
Version('18w47b', 447, True),
Version('18w48a', 448, True),
Version('18w48b', 449, True),
Version('18w49a', 450, True),
Version('18w50a', 451, True),
Version('19w02a', 452, True),
Version('19w03a', 453, True),
Version('19w03b', 454, True),
Version('19w03c', 455, True),
Version('19w04a', 456, True),
Version('19w04b', 457, True),
Version('19w05a', 458, True),
Version('19w06a', 459, True),
Version('19w07a', 460, True),
Version('19w08a', 461, True),
Version('19w08b', 462, True),
Version('19w09a', 463, True),
Version('19w11a', 464, True),
Version('19w11b', 465, True),
Version('19w12a', 466, True),
Version('19w12b', 467, True),
Version('19w13a', 468, True),
Version('19w13b', 469, True),
Version('19w14a', 470, True),
Version('19w14b', 471, True),
Version('1.14 Pre-Release 1', 472, True),
Version('1.14 Pre-Release 2', 473, True),
Version('1.14 Pre-Release 3', 474, True),
Version('1.14 Pre-Release 4', 475, True),
Version('1.14 Pre-Release 5', 476, True),
Version('1.14', 477, True),
Version('1.14.1 Pre-Release 1', 478, True),
Version('1.14.1 Pre-Release 2', 479, True),
Version('1.14.1', 480, True),
Version('1.14.2 Pre-Release 1', 481, True),
Version('1.14.2 Pre-Release 2', 482, True),
Version('1.14.2 Pre-Release 3', 483, True),
Version('1.14.2 Pre-Release 4', 484, True),
Version('1.14.2', 485, True),
Version('1.14.3-pre1', 486, True),
Version('1.14.3-pre2', 487, True),
Version('1.14.3-pre3', 488, True),
Version('1.14.3-pre4', 489, True),
Version('1.14.3', 490, True),
Version('1.14.4-pre1', 491, True),
Version('1.14.4-pre2', 492, True),
Version('1.14.4-pre3', 493, True),
Version('1.14.4-pre4', 494, True),
Version('1.14.4-pre5', 495, True),
Version('1.14.4-pre6', 496, True),
Version('1.14.4-pre7', 497, True),
Version('1.14.4', 498, True),
Version('19w34a', 550, True),
Version('19w35a', 551, True),
Version('19w36a', 552, True),
Version('19w37a', 553, True),
Version('19w38a', 554, True),
Version('19w38b', 555, True),
Version('19w39a', 556, True),
Version('19w40a', 557, True),
Version('19w41a', 558, True),
Version('19w42a', 559, True),
Version('19w44a', 560, True),
Version('19w45a', 561, True),
Version('19w45b', 562, True),
Version('19w46a', 563, True),
Version('19w46b', 564, True),
Version('1.15-pre1', 565, True),
Version('1.15-pre2', 566, True),
Version('1.15-pre3', 567, True),
Version('1.15-pre4', 569, True),
Version('1.15-pre5', 570, True),
Version('1.15-pre6', 571, True),
Version('1.15-pre7', 572, True),
Version('1.15', 573, True),
Version('1.15.1-pre1', 574, True),
Version('1.15.1', 575, True),
Version('1.15.2-pre1', 576, True),
Version('1.15.2-pre2', 577, True),
Version('1.15.2', 578, True),
Version('20w06a', 701, True),
Version('20w07a', 702, True),
Version('20w08a', 703, True),
Version('20w09a', 704, True),
Version('20w10a', 705, True),
Version('20w11a', 706, True),
Version('20w12a', 707, True),
Version('20w13a', 708, True),
Version('20w13b', 709, True),
Version('20w14a', 710, True),
Version('20w15a', 711, True),
Version('20w16a', 712, True),
Version('20w17a', 713, True),
Version('20w18a', 714, True),
Version('20w19a', 715, True),
Version('20w20a', 716, True),
Version('20w20b', 717, True),
Version('20w21a', 718, True),
Version('20w22a', 719, True),
Version('1.16-pre1', 721, True),
Version('1.16-pre2', 722, True),
Version('1.16-pre3', 725, True),
Version('1.16-pre4', 727, True),
Version('1.16-pre5', 729, True),
Version('1.16-pre6', 730, True),
Version('1.16-pre7', 732, True),
Version('1.16-pre8', 733, True),
Version('1.16-rc1', 734, True),
Version('1.16', 735, True),
Version('1.16.1', 736, True),
Version('20w27a', 738, True),
Version('20w28a', 740, True),
Version('20w29a', 741, True),
Version('20w30a', 743, True),
Version('1.16.2-pre1', 744, True),
Version('1.16.2-pre2', 746, True),
Version('1.16.2-pre3', 748, True),
Version('1.16.2-rc1', 749, True),
Version('1.16.2-rc2', 750, True),
Version('1.16.2', 751, True),
Version('1.16.3-rc1', 752, True),
Version('1.16.3', 753, True),
Version('1.16.4-pre1', PRE | 1, True),
Version('1.16.4-pre2', PRE | 2, True),
Version('1.16.4-rc1', PRE | 3, True),
Version('1.16.4', 754, True),
Version('20w45a', PRE | 5, True),
Version('20w46a', PRE | 6, True),
Version('20w48a', PRE | 7, True),
Version('20w49a', PRE | 8, False),
Version('20w51a', PRE | 9, False),
Version('1.16.5', 754, True),
Version('21w03a', PRE | 11, False),
Version('21w05a', PRE | 12, False),
Version('21w05b', PRE | 13, False),
Version('21w06a', PRE | 14, False),
Version('21w07a', PRE | 15, False),
Version('1.17-rc2', PRE | 35, False),
Version('1.17', 755, True),
Version('1.17.1', 756, True),
Version('21w44a', PRE | 48, False),
Version('1.18-rc4', PRE | 60, False),
Version('1.18', 757, True),
Version('1.18.1', 757, True),
Version('13w41a', 0, False),
Version('13w41b', 0, False),
Version('13w42a', 1, False),
Version('13w42b', 1, False),
Version('13w43a', 2, False),
Version('1.7-pre', 3, False),
Version('1.7.1-pre', 3, False),
Version('1.7.2', 4, True),
Version('13w47a', 4, False),
Version('13w47b', 4, False),
Version('13w47c', 4, False),
Version('13w47d', 4, False),
Version('13w47e', 4, False),
Version('13w48a', 4, False),
Version('13w48b', 4, False),
Version('13w49a', 4, False),
Version('1.7.3-pre', 4, False),
Version('1.7.4', 4, True),
Version('1.7.5', 4, True),
Version('1.7.6-pre1', 5, False),
Version('1.7.6-pre2', 5, False),
Version('1.7.6', 5, True),
Version('1.7.7', 5, True),
Version('1.7.8', 5, True),
Version('1.7.9', 5, True),
Version('1.7.10-pre1', 5, False),
Version('1.7.10-pre2', 5, False),
Version('1.7.10-pre3', 5, False),
Version('1.7.10-pre4', 5, False),
Version('1.7.10', 5, True),
Version('14w02a', 5, False),
Version('14w02b', 5, False),
Version('14w02c', 5, False),
Version('14w03a', 6, False),
Version('14w03b', 6, False),
Version('14w04a', 7, False),
Version('14w04b', 8, False),
Version('14w05a', 9, False),
Version('14w05b', 9, False),
Version('14w06a', 10, False),
Version('14w06b', 10, False),
Version('14w07a', 11, False),
Version('14w08a', 12, False),
Version('14w10a', 13, False),
Version('14w10b', 13, False),
Version('14w10c', 13, False),
Version('14w11a', 14, False),
Version('14w11b', 14, False),
Version('14w17a', 15, False),
Version('14w18a', 16, False),
Version('14w18b', 16, False),
Version('14w19a', 17, False),
Version('14w20a', 18, False),
Version('14w20b', 18, False),
Version('14w21a', 19, False),
Version('14w21b', 20, False),
Version('14w25a', 21, False),
Version('14w25b', 22, False),
Version('14w26a', 23, False),
Version('14w26b', 24, False),
Version('14w26c', 25, False),
Version('14w27a', 26, False),
Version('14w27b', 26, False),
Version('14w28a', 27, False),
Version('14w28b', 28, False),
Version('14w29a', 29, False),
Version('14w29a', 29, False),
Version('14w30a', 30, False),
Version('14w30b', 30, False),
Version('14w30c', 31, False),
Version('14w31a', 32, False),
Version('14w32a', 33, False),
Version('14w32b', 34, False),
Version('14w32c', 35, False),
Version('14w32d', 36, False),
Version('14w33a', 37, False),
Version('14w33b', 38, False),
Version('14w33c', 39, False),
Version('14w34a', 40, False),
Version('14w34b', 41, False),
Version('14w34c', 42, False),
Version('14w34d', 43, False),
Version('1.8-pre1', 44, False),
Version('1.8-pre2', 45, False),
Version('1.8-pre3', 46, False),
Version('1.8', 47, True),
Version('1.8.1-pre1', 47, False),
Version('1.8.1-pre2', 47, False),
Version('1.8.1-pre3', 47, False),
Version('1.8.1-pre4', 47, False),
Version('1.8.1-pre5', 47, False),
Version('1.8.1', 47, True),
Version('1.8.2-pre1', 47, False),
Version('1.8.2-pre2', 47, False),
Version('1.8.2-pre3', 47, False),
Version('1.8.2-pre4', 47, False),
Version('1.8.2-pre5', 47, False),
Version('1.8.2-pre6', 47, False),
Version('1.8.2-pre7', 47, False),
Version('1.8.2', 47, True),
Version('1.8.3', 47, True),
Version('1.8.4', 47, True),
Version('1.8.5', 47, True),
Version('1.8.6', 47, True),
Version('1.8.7', 47, True),
Version('1.8.8', 47, True),
Version('1.8.9', 47, True),
Version('15w14a', 48, False),
Version('15w31a', 49, False),
Version('15w31b', 50, False),
Version('15w31c', 51, False),
Version('15w32a', 52, False),
Version('15w32b', 53, False),
Version('15w32c', 54, False),
Version('15w33a', 55, False),
Version('15w33b', 56, False),
Version('15w33c', 57, False),
Version('15w34a', 58, False),
Version('15w34b', 59, False),
Version('15w34c', 60, False),
Version('15w34d', 61, False),
Version('15w35a', 62, False),
Version('15w35b', 63, False),
Version('15w35c', 64, False),
Version('15w35d', 65, False),
Version('15w35e', 66, False),
Version('15w36a', 67, False),
Version('15w36b', 68, False),
Version('15w36c', 69, False),
Version('15w36d', 70, False),
Version('15w37a', 71, False),
Version('15w38a', 72, False),
Version('15w38b', 73, False),
Version('15w39a', 74, False),
Version('15w39b', 74, False),
Version('15w39c', 74, False),
Version('15w40a', 75, False),
Version('15w40b', 76, False),
Version('15w41a', 77, False),
Version('15w41b', 78, False),
Version('15w42a', 79, False),
Version('15w43a', 80, False),
Version('15w43b', 81, False),
Version('15w43c', 82, False),
Version('15w44a', 83, False),
Version('15w44b', 84, False),
Version('15w45a', 85, False),
Version('15w46a', 86, False),
Version('15w47a', 87, False),
Version('15w47b', 88, False),
Version('15w47c', 89, False),
Version('15w49a', 90, False),
Version('15w49b', 91, False),
Version('15w50a', 92, False),
Version('15w51a', 93, False),
Version('15w51b', 94, False),
Version('16w02a', 95, False),
Version('16w03a', 96, False),
Version('16w04a', 97, False),
Version('16w05a', 98, False),
Version('16w05b', 99, False),
Version('16w06a', 100, False),
Version('16w07a', 101, False),
Version('16w07b', 102, False),
Version('1.9-pre1', 103, False),
Version('1.9-pre2', 104, False),
Version('1.9-pre3', 105, False),
Version('1.9-pre4', 106, False),
Version('1.9', 107, True),
Version('1.9.1-pre1', 107, False),
Version('1.9.1-pre2', 108, False),
Version('1.9.1-pre3', 108, False),
Version('1.9.1', 108, True),
Version('1.RV-Pre1', 108, False),
Version('1.9.2', 109, True),
Version('16w14a', 109, False),
Version('16w15a', 109, False),
Version('16w15b', 109, False),
Version('1.9.3-pre1', 109, False),
Version('1.9.3-pre2', 110, False),
Version('1.9.3-pre3', 110, False),
Version('1.9.3', 110, True),
Version('1.9.4', 110, True),
Version('16w20a', 201, False),
Version('16w21a', 202, False),
Version('16w21b', 203, False),
Version('1.10-pre1', 204, False),
Version('1.10-pre2', 205, False),
Version('1.10', 210, True),
Version('1.10.1', 210, True),
Version('1.10.2', 210, True),
Version('16w32a', 301, True),
Version('16w32b', 302, True),
Version('16w33a', 303, True),
Version('16w35a', 304, True),
Version('16w36a', 305, True),
Version('16w38a', 306, True),
Version('16w39a', 307, True),
Version('16w39b', 308, True),
Version('16w39c', 309, True),
Version('16w40a', 310, True),
Version('16w41a', 311, True),
Version('16w42a', 312, True),
Version('16w43a', 313, True),
Version('16w44a', 313, True),
Version('1.11-pre1', 314, True),
Version('1.11', 315, True),
Version('16w50a', 316, True),
Version('1.11.1', 316, True),
Version('1.11.2', 316, True),
Version('17w06a', 317, True),
Version('17w13a', 318, True),
Version('17w13b', 319, True),
Version('17w14a', 320, True),
Version('17w15a', 321, True),
Version('17w16a', 322, True),
Version('17w16b', 323, True),
Version('17w17a', 324, True),
Version('17w17b', 325, True),
Version('17w18a', 326, True),
Version('17w18b', 327, True),
Version('1.12-pre1', 328, True),
Version('1.12-pre2', 329, True),
Version('1.12-pre3', 330, True),
Version('1.12-pre4', 331, True),
Version('1.12-pre5', 332, True),
Version('1.12-pre6', 333, True),
Version('1.12-pre7', 334, True),
Version('1.12', 335, True),
Version('17w31a', 336, True),
Version('1.12.1-pre1', 337, True),
Version('1.12.1', 338, True),
Version('1.12.2-pre1', 339, True),
Version('1.12.2-pre2', 339, True),
Version('1.12.2', 340, True),
Version('17w43a', 341, True),
Version('17w43b', 342, True),
Version('17w45a', 343, True),
Version('17w45b', 344, True),
Version('17w46a', 345, True),
Version('17w47a', 346, True),
Version('17w47b', 347, True),
Version('17w48a', 348, True),
Version('17w49a', 349, True),
Version('17w49b', 350, True),
Version('17w50a', 351, True),
Version('18w01a', 352, True),
Version('18w02a', 353, True),
Version('18w03a', 354, True),
Version('18w03b', 355, True),
Version('18w05a', 356, True),
Version('18w06a', 357, True),
Version('18w07a', 358, True),
Version('18w07b', 359, True),
Version('18w07c', 360, True),
Version('18w08a', 361, True),
Version('18w08b', 362, True),
Version('18w09a', 363, True),
Version('18w10a', 364, True),
Version('18w10b', 365, True),
Version('18w10c', 366, True),
Version('18w10d', 367, True),
Version('18w11a', 368, True),
Version('18w14a', 369, True),
Version('18w14b', 370, True),
Version('18w15a', 371, True),
Version('18w16a', 372, True),
Version('18w19a', 373, True),
Version('18w19b', 374, True),
Version('18w20a', 375, True),
Version('18w20b', 376, True),
Version('18w20c', 377, True),
Version('18w21a', 378, True),
Version('18w21b', 379, True),
Version('18w22a', 380, True),
Version('18w22b', 381, True),
Version('18w22c', 382, True),
Version('1.13-pre1', 383, True),
Version('1.13-pre2', 384, True),
Version('1.13-pre3', 385, True),
Version('1.13-pre4', 386, True),
Version('1.13-pre5', 387, True),
Version('1.13-pre6', 388, True),
Version('1.13-pre7', 389, True),
Version('1.13-pre8', 390, True),
Version('1.13-pre9', 391, True),
Version('1.13-pre10', 392, True),
Version('1.13', 393, True),
Version('18w30a', 394, True),
Version('18w30b', 395, True),
Version('18w31a', 396, True),
Version('18w32a', 397, True),
Version('18w33a', 398, True),
Version('1.13.1-pre1', 399, True),
Version('1.13.1-pre2', 400, True),
Version('1.13.1', 401, True),
Version('1.13.2-pre1', 402, True),
Version('1.13.2-pre2', 403, True),
Version('1.13.2', 404, True),
Version('18w43a', 441, True),
Version('18w43b', 441, True),
Version('18w43c', 442, True),
Version('18w44a', 443, True),
Version('18w45a', 444, True),
Version('18w46a', 445, True),
Version('18w47a', 446, True),
Version('18w47b', 447, True),
Version('18w48a', 448, True),
Version('18w48b', 449, True),
Version('18w49a', 450, True),
Version('18w50a', 451, True),
Version('19w02a', 452, True),
Version('19w03a', 453, True),
Version('19w03b', 454, True),
Version('19w03c', 455, True),
Version('19w04a', 456, True),
Version('19w04b', 457, True),
Version('19w05a', 458, True),
Version('19w06a', 459, True),
Version('19w07a', 460, True),
Version('19w08a', 461, True),
Version('19w08b', 462, True),
Version('19w09a', 463, True),
Version('19w11a', 464, True),
Version('19w11b', 465, True),
Version('19w12a', 466, True),
Version('19w12b', 467, True),
Version('19w13a', 468, True),
Version('19w13b', 469, True),
Version('19w14a', 470, True),
Version('19w14b', 471, True),
Version('1.14 Pre-Release 1', 472, True),
Version('1.14 Pre-Release 2', 473, True),
Version('1.14 Pre-Release 3', 474, True),
Version('1.14 Pre-Release 4', 475, True),
Version('1.14 Pre-Release 5', 476, True),
Version('1.14', 477, True),
Version('1.14.1 Pre-Release 1', 478, True),
Version('1.14.1 Pre-Release 2', 479, True),
Version('1.14.1', 480, True),
Version('1.14.2 Pre-Release 1', 481, True),
Version('1.14.2 Pre-Release 2', 482, True),
Version('1.14.2 Pre-Release 3', 483, True),
Version('1.14.2 Pre-Release 4', 484, True),
Version('1.14.2', 485, True),
Version('1.14.3-pre1', 486, True),
Version('1.14.3-pre2', 487, True),
Version('1.14.3-pre3', 488, True),
Version('1.14.3-pre4', 489, True),
Version('1.14.3', 490, True),
Version('1.14.4-pre1', 491, True),
Version('1.14.4-pre2', 492, True),
Version('1.14.4-pre3', 493, True),
Version('1.14.4-pre4', 494, True),
Version('1.14.4-pre5', 495, True),
Version('1.14.4-pre6', 496, True),
Version('1.14.4-pre7', 497, True),
Version('1.14.4', 498, True),
Version('19w34a', 550, True),
Version('19w35a', 551, True),
Version('19w36a', 552, True),
Version('19w37a', 553, True),
Version('19w38a', 554, True),
Version('19w38b', 555, True),
Version('19w39a', 556, True),
Version('19w40a', 557, True),
Version('19w41a', 558, True),
Version('19w42a', 559, True),
Version('19w44a', 560, True),
Version('19w45a', 561, True),
Version('19w45b', 562, True),
Version('19w46a', 563, True),
Version('19w46b', 564, True),
Version('1.15-pre1', 565, True),
Version('1.15-pre2', 566, True),
Version('1.15-pre3', 567, True),
Version('1.15-pre4', 569, True),
Version('1.15-pre5', 570, True),
Version('1.15-pre6', 571, True),
Version('1.15-pre7', 572, True),
Version('1.15', 573, True),
Version('1.15.1-pre1', 574, True),
Version('1.15.1', 575, True),
Version('1.15.2-pre1', 576, True),
Version('1.15.2-pre2', 577, True),
Version('1.15.2', 578, True),
Version('20w06a', 701, True),
Version('20w07a', 702, True),
Version('20w08a', 703, True),
Version('20w09a', 704, True),
Version('20w10a', 705, True),
Version('20w11a', 706, True),
Version('20w12a', 707, True),
Version('20w13a', 708, True),
Version('20w13b', 709, True),
Version('20w14a', 710, True),
Version('20w15a', 711, True),
Version('20w16a', 712, True),
Version('20w17a', 713, True),
Version('20w18a', 714, True),
Version('20w19a', 715, True),
Version('20w20a', 716, True),
Version('20w20b', 717, True),
Version('20w21a', 718, True),
Version('20w22a', 719, True),
Version('1.16-pre1', 721, True),
Version('1.16-pre2', 722, True),
Version('1.16-pre3', 725, True),
Version('1.16-pre4', 727, True),
Version('1.16-pre5', 729, True),
Version('1.16-pre6', 730, True),
Version('1.16-pre7', 732, True),
Version('1.16-pre8', 733, True),
Version('1.16-rc1', 734, True),
Version('1.16', 735, True),
Version('1.16.1', 736, True),
Version('20w27a', 738, True),
Version('20w28a', 740, True),
Version('20w29a', 741, True),
Version('20w30a', 743, True),
Version('1.16.2-pre1', 744, True),
Version('1.16.2-pre2', 746, True),
Version('1.16.2-pre3', 748, True),
Version('1.16.2-rc1', 749, True),
Version('1.16.2-rc2', 750, True),
Version('1.16.2', 751, True),
Version('1.16.3-rc1', 752, True),
Version('1.16.3', 753, True),
Version('1.16.4-pre1', PRE | 1, True),
Version('1.16.4-pre2', PRE | 2, True),
Version('1.16.4-rc1', PRE | 3, True),
Version('1.16.4', 754, True),
Version('20w45a', PRE | 5, True),
Version('20w46a', PRE | 6, True),
Version('20w48a', PRE | 7, True),
Version('20w49a', PRE | 8, False),
Version('20w51a', PRE | 9, False),
Version('1.16.5', 754, True),
Version('21w03a', PRE | 11, False),
Version('21w05a', PRE | 12, False),
Version('21w05b', PRE | 13, False),
Version('21w06a', PRE | 14, False),
Version('21w07a', PRE | 15, False),
Version('1.17-rc2', PRE | 35, False),
Version('1.17', 755, True),
Version('1.17.1', 756, True),
Version('21w44a', PRE | 48, False),
Version('1.18-rc4', PRE | 60, False),
Version('1.18', 757, True),
Version('1.18.1', 757, True),
]
# An OrderedDict mapping the id string of each known Minecraft version to its

View File

@ -1,6 +1,7 @@
import requests
import json
import uuid
import os
from .exceptions import YggdrasilError
#: The base url for Ygdrassil requests
@ -16,6 +17,7 @@ class Profile(object):
Container class for a MineCraft Selected profile.
See: `<http://wiki.vg/Authentication>`_
"""
def __init__(self, id_=None, name=None):
self.id_ = id_
self.name = name
@ -313,3 +315,295 @@ def _raise_from_response(res):
exception.yggdrasil_cause = json_resp.get("cause")
raise exception
class Microsoft_AuthenticationToken(object):
"""
Represents an authentication token.
See https://wiki.vg/Microsoft_Authentication_Scheme.
This class was shameless copied from github issue,
https://github.com/ammaraskar/pyCraft/issues/234.
The user https://github.com/shikukuya, contributed the comment:
https://github.com/ammaraskar/pyCraft/issues/234#issuecomment-1365140050
I have simply created a fork and submitted the changes as they describe
the usage in their comment. All credit for this goes to shikukua.
"""
UserLoginURL = "https://login.live.com/oauth20_authorize.srf?\
client_id=00000000402b5328&response_type=code\
&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL&redirect_uri=\
https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf"
oauth20_URL = 'https://login.live.com/oauth20_token.srf'
XBL_URL = 'https://user.auth.xboxlive.com/user/authenticate'
XSTS_URL = 'https://xsts.auth.xboxlive.com/xsts/authorize'
LOGIN_WITH_XBOX_URL = "https://api.minecraftservices.com/\
authentication/login_with_xbox"
CheckAccount_URL = 'https://api.minecraftservices.com/entitlements/mcstore'
Profile_URL = 'https://api.minecraftservices.com/minecraft/profile'
jwt_Token = ''
def __init__(self, access_token=None):
self.access_token = access_token
self.profile = Profile()
def GetoAuth20(self, code='') -> object:
if code == '':
print("Please copy this link to your browser to open:"
"\n%s" % self.UserLoginURL)
code = input(
"After logging in,"
"paste the 'code' field in your browser's address bar here:")
oauth20 = requests.post(
self.oauth20_URL,
data={
"client_id": "00000000402b5328",
"code": "{}".format(code),
"grant_type": "authorization_code",
"redirect_uri": "https://login.live.com/oauth20_desktop.srf",
"scope": "service::user.auth.xboxlive.com::MBI_SSL"
},
headers={"content-type": "application/x-www-form-urlencoded"},
timeout=15)
oauth20 = json.loads(oauth20.text)
if 'error' in oauth20:
print("Error: %s" % oauth20["error"])
return 1
else:
self.oauth20_access_token = oauth20['access_token']
self.oauth20_refresh_token = oauth20['refresh_token']
oauth20_access_token = oauth20['access_token']
oauth20_refresh_token = oauth20['refresh_token']
return {
"access_token": oauth20_access_token,
"refresh_token": oauth20_refresh_token
}
def GetXBL(self, access_token: str) -> object:
XBL = requests.post(self.XBL_URL,
json={
"Properties": {
"AuthMethod": "RPS",
"SiteName": "user.auth.xboxlive.com",
"RpsTicket": "{}".format(access_token)
},
"RelyingParty": "http://auth.xboxlive.com",
"TokenType": "JWT"
},
headers=HEADERS,
timeout=15)
return {
"Token": json.loads(XBL.text)['Token'],
"uhs": json.loads(XBL.text)['DisplayClaims']['xui'][0]['uhs']
}
def GetXSTS(self, access_token: str) -> object:
XBL = requests.post(self.XSTS_URL,
json={
"Properties": {
"SandboxId": "RETAIL",
"UserTokens": ["{}".format(access_token)]
},
"RelyingParty":
"rp://api.minecraftservices.com/",
"TokenType": "JWT"
},
headers=HEADERS,
timeout=15)
return {
"Token": json.loads(XBL.text)['Token'],
"uhs": json.loads(XBL.text)['DisplayClaims']['xui'][0]['uhs']
}
def GetXBOX(self, access_token: str, uhs: str) -> str:
mat_jwt = requests.post(
self.LOGIN_WITH_XBOX_URL,
json={"identityToken": "XBL3.0 x={};{}".format(uhs, access_token)},
headers=HEADERS,
timeout=15)
self.access_token = json.loads(mat_jwt.text)['access_token']
return self.access_token
def CheckAccount(self, jwt_Token: str) -> bool:
CheckAccount = requests.get(
self.CheckAccount_URL,
headers={"Authorization": "Bearer {}".format(jwt_Token)},
timeout=15)
CheckAccount = len(json.loads(CheckAccount.text)['items'])
if CheckAccount != 0:
return True
else:
return False
def GetProfile(self, access_token: str) -> object:
if self.CheckAccount(access_token):
Profile = requests.get(
self.Profile_URL,
headers={"Authorization": "Bearer {}".format(access_token)},
timeout=15)
Profile = json.loads(Profile.text)
if 'error' in Profile:
return False
self.profile.id_ = Profile["id"]
self.profile.name = Profile["name"]
self.username = Profile["name"]
return True
else:
return False
@property
def authenticated(self):
"""
Attribute which is ``True`` when the token is authenticated and
``False`` when it isn't.
"""
if not self.username:
return False
if not self.access_token:
return False
if not self.oauth20_refresh_token:
return False
if not self.profile:
return False
return True
def authenticate(self):
"Get verification information for a Microsoft account"
oauth20 = self.GetoAuth20()
if oauth20 == 1:
return False
XBL = self.GetXBL(oauth20['access_token'])
XSTS = self.GetXSTS(XBL['Token'])
XBOX = self.GetXBOX(XSTS['Token'], XSTS['uhs'])
if self.GetProfile(XBOX):
print('GameID: {}'.format(self.profile.id_))
self.PersistenceLogoin_w()
return True
else:
print('Account does not exist')
return False
def refresh(self):
"""
Refreshes the `AuthenticationToken`. Used to keep a user logged in
between sessions and is preferred over storing a user's password in a
file.
Returns:
Returns `True` if `AuthenticationToken` was successfully refreshed.
Otherwise it raises an exception.
Raises:
minecraft.exceptions.YggdrasilError
ValueError - if `AuthenticationToken.access_token` or
`AuthenticationToken.client_token` isn't set.
"""
if self.access_token is None:
raise ValueError("'access_token' not set!'")
if self.oauth20_refresh_token is None:
raise ValueError("'oauth20_refresh_token' is not set!")
oauth20 = requests.post(
self.oauth20_URL,
data={
"client_id": "00000000402b5328",
"refresh_token": "{}".format(self.oauth20_refresh_token),
"grant_type": "refresh_token",
"redirect_uri": "https://login.live.com/oauth20_desktop.srf",
"scope": "service::user.auth.xboxlive.com::MBI_SSL"
},
headers={"content-type": "application/x-www-form-urlencoded"},
timeout=15)
oauth20 = json.loads(oauth20.text)
if 'error' in oauth20:
print("Error: %s" % oauth20["error"])
return False
else:
self.oauth20_access_token = oauth20['access_token']
self.oauth20_refresh_token = oauth20['refresh_token']
XBL = self.GetXBL(self.oauth20_access_token)
XSTS = self.GetXSTS(XBL['Token'])
XBOX = self.GetXBOX(XSTS['Token'], XSTS['uhs'])
if self.GetProfile(XBOX):
self.PersistenceLogoin_w()
print('account: {}'.format(self.profile.id_))
return True
else:
print('Account does not exist')
return False
def join(self, server_id):
"""
Informs the Mojang session-server that we're joining the
MineCraft server with id ``server_id``.
Parameters:
server_id - ``str`` with the server id
Returns:
``True`` if no errors occured
Raises:
:class:`minecraft.exceptions.YggdrasilError`
"""
if not self.authenticated:
err = "AuthenticationToken hasn't been authenticated yet!"
raise YggdrasilError(err)
res = _make_request(
SESSION_SERVER, "join", {
"accessToken": self.access_token,
"selectedProfile": self.profile.to_dict(),
"serverId": server_id
})
if res.status_code != 204:
_raise_from_response(res)
return True
def PersistenceLogoin_w(self):
"Save access token persistent login"
ProjectDir = os.path.dirname(os.path.dirname('{}'.format(__file__)))
PersistenceDir = '{}/Persistence'.format(ProjectDir)
if not self.authenticated:
err = "AuthenticationToken hasn't been authenticated yet!"
raise YggdrasilError(err)
if not os.path.exists(PersistenceDir):
os.mkdir(PersistenceDir)
print(PersistenceDir)
"Save access_token and oauth20_refresh_token"
with open("{}/{}".format(PersistenceDir, self.username),
mode='w',
encoding='utf-8') as file_obj:
file_obj.write('{{"{}": "{}","{}": "{}"}}'.format(
'access_token', self.access_token, 'oauth20_refresh_token',
self.oauth20_refresh_token))
file_obj.close()
return True
def PersistenceLogoin_r(self, GameID: str):
"Load access token persistent login"
ProjectDir = os.path.dirname(os.path.dirname('{}'.format(__file__)))
PersistenceDir = '{}/Persistence'.format(ProjectDir)
if not os.path.exists(PersistenceDir):
return False
"Load access_token and oauth20_refresh_token"
if os.path.isfile("{}/{}".format(PersistenceDir, GameID)):
with open("{}/{}".format(PersistenceDir, GameID),
mode='r',
encoding='utf-8') as file_obj:
Persistence = file_obj.read()
file_obj.close()
Persistence = json.loads(Persistence)
self.access_token = Persistence["access_token"]
self.oauth20_refresh_token = Persistence[
"oauth20_refresh_token"]
self.refresh()
return self.authenticated
else:
return False

View File

@ -30,6 +30,7 @@ class ConnectionContext(object):
shared by the Connection class with other classes, such as Packet.
Importantly, it can be used without knowing the interface of Connection.
"""
def __init__(self, **kwds):
self.protocol_version = kwds.get('protocol_version')
@ -75,6 +76,7 @@ class Connection(object):
server, it handles everything from connecting, sending packets to
handling default network behaviour
"""
def __init__(
self,
address,
@ -442,7 +444,7 @@ class Connection(object):
# then IPv6, then other address families.
def key(ai):
return 0 if ai[0] == socket.AF_INET else \
1 if ai[0] == socket.AF_INET6 else 2
1 if ai[0] == socket.AF_INET6 else 2
ai_faml, ai_type, ai_prot, _ai_cnam, ai_addr = min(info, key=key)
self.socket = socket.socket(ai_faml, ai_type, ai_prot)
@ -678,7 +680,7 @@ class PacketReactor(object):
if decompressed_size > 0:
decompressor = zlib.decompressobj()
decompressed_packet = decompressor.decompress(
packet_data.read())
packet_data.read())
assert len(decompressed_packet) == decompressed_size, \
'decompressed length %d, but expected %d' % \
(len(decompressed_packet), decompressed_size)

View File

@ -24,8 +24,8 @@ class DisconnectPacket(Packet):
@staticmethod
def get_id(context):
return 0x00 if context.protocol_later_eq(391) else \
0x01 if context.protocol_later_eq(385) else \
0x00
0x01 if context.protocol_later_eq(385) else \
0x00
packet_name = "disconnect"
definition = [
@ -36,8 +36,8 @@ class EncryptionRequestPacket(Packet):
@staticmethod
def get_id(context):
return 0x01 if context.protocol_later_eq(391) else \
0x02 if context.protocol_later_eq(385) else \
0x01
0x02 if context.protocol_later_eq(385) else \
0x01
packet_name = "encryption request"
definition = [
@ -50,8 +50,8 @@ class LoginSuccessPacket(Packet):
@staticmethod
def get_id(context):
return 0x02 if context.protocol_later_eq(391) else \
0x03 if context.protocol_later_eq(385) else \
0x02
0x03 if context.protocol_later_eq(385) else \
0x02
packet_name = "login success"
get_definition = staticmethod(lambda context: [
@ -64,8 +64,8 @@ class SetCompressionPacket(Packet):
@staticmethod
def get_id(context):
return 0x03 if context.protocol_later_eq(391) else \
0x04 if context.protocol_later_eq(385) else \
0x03
0x04 if context.protocol_later_eq(385) else \
0x03
packet_name = "set compression"
definition = [
@ -90,7 +90,7 @@ class PluginRequestPacket(Packet):
@staticmethod
def get_id(context):
return 0x04 if context.protocol_later_eq(391) else \
0x00
0x00
packet_name = 'login plugin request'
definition = [

View File

@ -84,28 +84,28 @@ class KeepAlivePacket(AbstractKeepAlivePacket):
@staticmethod
def get_id(context):
return 0x21 if context.protocol_later_eq(755) else \
0x1F if context.protocol_later_eq(741) else \
0x20 if context.protocol_later_eq(721) else \
0x21 if context.protocol_later_eq(550) else \
0x20 if context.protocol_later_eq(471) else \
0x21 if context.protocol_later_eq(389) else \
0x20 if context.protocol_later_eq(345) else \
0x1F if context.protocol_later_eq(332) else \
0x20 if context.protocol_later_eq(318) else \
0x1F if context.protocol_later_eq(107) else \
0x00
0x1F if context.protocol_later_eq(741) else \
0x20 if context.protocol_later_eq(721) else \
0x21 if context.protocol_later_eq(550) else \
0x20 if context.protocol_later_eq(471) else \
0x21 if context.protocol_later_eq(389) else \
0x20 if context.protocol_later_eq(345) else \
0x1F if context.protocol_later_eq(332) else \
0x20 if context.protocol_later_eq(318) else \
0x1F if context.protocol_later_eq(107) else \
0x00
class ServerDifficultyPacket(Packet):
@staticmethod
def get_id(context):
return 0x0E if context.protocol_later_eq(755) else \
0x0D if context.protocol_later_eq(721) else \
0x0E if context.protocol_later_eq(550) else \
0x0D if context.protocol_later_eq(332) else \
0x0E if context.protocol_later_eq(318) else \
0x0D if context.protocol_later_eq(70) else \
0x41
0x0D if context.protocol_later_eq(721) else \
0x0E if context.protocol_later_eq(550) else \
0x0D if context.protocol_later_eq(332) else \
0x0E if context.protocol_later_eq(318) else \
0x0D if context.protocol_later_eq(70) else \
0x41
packet_name = 'server difficulty'
get_definition = staticmethod(lambda context: [
@ -121,13 +121,13 @@ class ChatMessagePacket(Packet):
@staticmethod
def get_id(context):
return 0x0F if context.protocol_later_eq(755) else \
0x0E if context.protocol_later_eq(721) else \
0x0F if context.protocol_later_eq(550) else \
0x0E if context.protocol_later_eq(343) else \
0x0F if context.protocol_later_eq(332) else \
0x10 if context.protocol_later_eq(317) else \
0x0F if context.protocol_later_eq(107) else \
0x02
0x0E if context.protocol_later_eq(721) else \
0x0F if context.protocol_later_eq(550) else \
0x0E if context.protocol_later_eq(343) else \
0x0F if context.protocol_later_eq(332) else \
0x10 if context.protocol_later_eq(317) else \
0x0F if context.protocol_later_eq(107) else \
0x02
packet_name = "chat message"
get_definition = staticmethod(lambda context: [
@ -146,15 +146,15 @@ class DisconnectPacket(Packet):
@staticmethod
def get_id(context):
return 0x1A if context.protocol_later_eq(755) else \
0x19 if context.protocol_later_eq(741) else \
0x1A if context.protocol_later_eq(721) else \
0x1B if context.protocol_later_eq(550) else \
0x1A if context.protocol_later_eq(471) else \
0x1B if context.protocol_later_eq(345) else \
0x1A if context.protocol_later_eq(332) else \
0x1B if context.protocol_later_eq(318) else \
0x1A if context.protocol_later_eq(107) else \
0x40
0x19 if context.protocol_later_eq(741) else \
0x1A if context.protocol_later_eq(721) else \
0x1B if context.protocol_later_eq(550) else \
0x1A if context.protocol_later_eq(471) else \
0x1B if context.protocol_later_eq(345) else \
0x1A if context.protocol_later_eq(332) else \
0x1B if context.protocol_later_eq(318) else \
0x1A if context.protocol_later_eq(107) else \
0x40
packet_name = "disconnect"
@ -167,7 +167,7 @@ class SetCompressionPacket(Packet):
@staticmethod
def get_id(context):
return 0x03 if context.protocol_later_eq(755) else \
0x46
0x46
packet_name = "set compression"
definition = [
@ -178,8 +178,8 @@ class SpawnPlayerPacket(Packet):
@staticmethod
def get_id(context):
return 0x04 if context.protocol_later_eq(721) else \
0x05 if context.protocol_later_eq(67) else \
0x0C
0x05 if context.protocol_later_eq(67) else \
0x0C
packet_name = 'spawn player'
get_definition = staticmethod(lambda context: [
@ -214,21 +214,21 @@ class EntityVelocityPacket(Packet):
@staticmethod
def get_id(context):
return 0x4F if context.protocol_later_eq(755) else \
0x46 if context.protocol_later_eq(721) else \
0x47 if context.protocol_later_eq(707) else \
0x46 if context.protocol_later_eq(550) else \
0x45 if context.protocol_later_eq(471) else \
0x41 if context.protocol_later_eq(461) else \
0x42 if context.protocol_later_eq(451) else \
0x41 if context.protocol_later_eq(389) else \
0x40 if context.protocol_later_eq(352) else \
0x3F if context.protocol_later_eq(345) else \
0x3E if context.protocol_later_eq(336) else \
0x3D if context.protocol_later_eq(332) else \
0x3B if context.protocol_later_eq(86) else \
0x3C if context.protocol_later_eq(77) else \
0x3B if context.protocol_later_eq(67) else \
0x12
0x46 if context.protocol_later_eq(721) else \
0x47 if context.protocol_later_eq(707) else \
0x46 if context.protocol_later_eq(550) else \
0x45 if context.protocol_later_eq(471) else \
0x41 if context.protocol_later_eq(461) else \
0x42 if context.protocol_later_eq(451) else \
0x41 if context.protocol_later_eq(389) else \
0x40 if context.protocol_later_eq(352) else \
0x3F if context.protocol_later_eq(345) else \
0x3E if context.protocol_later_eq(336) else \
0x3D if context.protocol_later_eq(332) else \
0x3B if context.protocol_later_eq(86) else \
0x3C if context.protocol_later_eq(77) else \
0x3B if context.protocol_later_eq(67) else \
0x12
packet_name = 'entity velocity'
get_definition = staticmethod(lambda context: [
@ -243,23 +243,23 @@ class EntityPositionDeltaPacket(Packet):
@staticmethod
def get_id(context):
return 0x29 if context.protocol_later_eq(755) else \
0x27 if context.protocol_later_eq(741) else \
0x28 if context.protocol_later_eq(721) else \
0x29 if context.protocol_later_eq(550) else \
0x28 if context.protocol_later_eq(389) else \
0x27 if context.protocol_later_eq(345) else \
0x26 if context.protocol_later_eq(318) else \
0x25 if context.protocol_later_eq(94) else \
0x26 if context.protocol_later_eq(70) else \
0x15
0x27 if context.protocol_later_eq(741) else \
0x28 if context.protocol_later_eq(721) else \
0x29 if context.protocol_later_eq(550) else \
0x28 if context.protocol_later_eq(389) else \
0x27 if context.protocol_later_eq(345) else \
0x26 if context.protocol_later_eq(318) else \
0x25 if context.protocol_later_eq(94) else \
0x26 if context.protocol_later_eq(70) else \
0x15
packet_name = "entity position delta"
@staticmethod
def get_definition(context):
delta_type = FixedPoint(Short, 12) \
if context.protocol_later_eq(106) else \
FixedPoint(Byte)
if context.protocol_later_eq(106) else \
FixedPoint(Byte)
return [
{'entity_id': VarInt},
{'delta_x_float': delta_type},
@ -272,31 +272,31 @@ class EntityPositionDeltaPacket(Packet):
# they represent the delta values as fixed-point integers with 12 bits
# of fractional part, regardless of the protocol version.
delta_x = attribute_transform(
'delta_x_float', lambda x: int(x * 4096), lambda x: x / 4096)
'delta_x_float', lambda x: int(x * 4096), lambda x: x / 4096)
delta_y = attribute_transform(
'delta_y_float', lambda y: int(y * 4096), lambda y: y / 4096)
'delta_y_float', lambda y: int(y * 4096), lambda y: y / 4096)
delta_z = attribute_transform(
'delta_z_float', lambda z: int(z * 4096), lambda z: z / 4096)
'delta_z_float', lambda z: int(z * 4096), lambda z: z / 4096)
class TimeUpdatePacket(Packet):
@staticmethod
def get_id(context):
return 0x59 if context.protocol_later_eq(PRE | 48) else \
0x58 if context.protocol_later_eq(755) else \
0x4E if context.protocol_later_eq(721) else \
0x4F if context.protocol_later_eq(550) else \
0x4E if context.protocol_later_eq(471) else \
0x4A if context.protocol_later_eq(461) else \
0x4B if context.protocol_later_eq(451) else \
0x4A if context.protocol_later_eq(389) else \
0x49 if context.protocol_later_eq(352) else \
0x48 if context.protocol_later_eq(345) else \
0x47 if context.protocol_later_eq(336) else \
0x46 if context.protocol_later_eq(318) else \
0x44 if context.protocol_later_eq(94) else \
0x43 if context.protocol_later_eq(70) else \
0x03
0x58 if context.protocol_later_eq(755) else \
0x4E if context.protocol_later_eq(721) else \
0x4F if context.protocol_later_eq(550) else \
0x4E if context.protocol_later_eq(471) else \
0x4A if context.protocol_later_eq(461) else \
0x4B if context.protocol_later_eq(451) else \
0x4A if context.protocol_later_eq(389) else \
0x49 if context.protocol_later_eq(352) else \
0x48 if context.protocol_later_eq(345) else \
0x47 if context.protocol_later_eq(336) else \
0x46 if context.protocol_later_eq(318) else \
0x44 if context.protocol_later_eq(94) else \
0x43 if context.protocol_later_eq(70) else \
0x03
packet_name = "time update"
get_definition = staticmethod(lambda context: [
@ -309,21 +309,21 @@ class UpdateHealthPacket(Packet):
@staticmethod
def get_id(context):
return 0x52 if context.protocol_later_eq(755) else \
0x49 if context.protocol_later_eq(721) else \
0x4A if context.protocol_later_eq(707) else \
0x49 if context.protocol_later_eq(550) else \
0x48 if context.protocol_later_eq(471) else \
0x44 if context.protocol_later_eq(461) else \
0x45 if context.protocol_later_eq(451) else \
0x44 if context.protocol_later_eq(389) else \
0x43 if context.protocol_later_eq(352) else \
0x42 if context.protocol_later_eq(345) else \
0x41 if context.protocol_later_eq(336) else \
0x40 if context.protocol_later_eq(318) else \
0x3E if context.protocol_later_eq(86) else \
0x3F if context.protocol_later_eq(77) else \
0x3E if context.protocol_later_eq(67) else \
0x06
0x49 if context.protocol_later_eq(721) else \
0x4A if context.protocol_later_eq(707) else \
0x49 if context.protocol_later_eq(550) else \
0x48 if context.protocol_later_eq(471) else \
0x44 if context.protocol_later_eq(461) else \
0x45 if context.protocol_later_eq(451) else \
0x44 if context.protocol_later_eq(389) else \
0x43 if context.protocol_later_eq(352) else \
0x42 if context.protocol_later_eq(345) else \
0x41 if context.protocol_later_eq(336) else \
0x40 if context.protocol_later_eq(318) else \
0x3E if context.protocol_later_eq(86) else \
0x3F if context.protocol_later_eq(77) else \
0x3E if context.protocol_later_eq(67) else \
0x06
packet_name = 'update health'
get_definition = staticmethod(lambda context: [
@ -337,34 +337,34 @@ class PluginMessagePacket(AbstractPluginMessagePacket):
@staticmethod
def get_id(context):
return 0x18 if context.protocol_later_eq(755) else \
0x17 if context.protocol_later_eq(741) else \
0x18 if context.protocol_later_eq(721) else \
0x19 if context.protocol_later_eq(550) else \
0x18 if context.protocol_later_eq(471) else \
0x19 if context.protocol_later_eq(345) else \
0x18 if context.protocol_later_eq(332) else \
0x19 if context.protocol_later_eq(318) else \
0x18 if context.protocol_later_eq(70) else \
0x3F
0x17 if context.protocol_later_eq(741) else \
0x18 if context.protocol_later_eq(721) else \
0x19 if context.protocol_later_eq(550) else \
0x18 if context.protocol_later_eq(471) else \
0x19 if context.protocol_later_eq(345) else \
0x18 if context.protocol_later_eq(332) else \
0x19 if context.protocol_later_eq(318) else \
0x18 if context.protocol_later_eq(70) else \
0x3F
class PlayerListHeaderAndFooterPacket(Packet):
@staticmethod
def get_id(context):
return 0x5F if context.protocol_later_eq(PRE | 48) else \
0x5E if context.protocol_later_eq(755) else \
0x53 if context.protocol_later_eq(721) else \
0x54 if context.protocol_later_eq(550) else \
0x53 if context.protocol_later_eq(471) else \
0x5F if context.protocol_later_eq(461) else \
0x50 if context.protocol_later_eq(451) else \
0x4F if context.protocol_later_eq(441) else \
0x4E if context.protocol_later_eq(393) else \
0x4A if context.protocol_later_eq(338) else \
0x49 if context.protocol_later_eq(335) else \
0x47 if context.protocol_later_eq(110) else \
0x48 if context.protocol_later_eq(107) else \
0x47
0x5E if context.protocol_later_eq(755) else \
0x53 if context.protocol_later_eq(721) else \
0x54 if context.protocol_later_eq(550) else \
0x53 if context.protocol_later_eq(471) else \
0x5F if context.protocol_later_eq(461) else \
0x50 if context.protocol_later_eq(451) else \
0x4F if context.protocol_later_eq(441) else \
0x4E if context.protocol_later_eq(393) else \
0x4A if context.protocol_later_eq(338) else \
0x49 if context.protocol_later_eq(335) else \
0x47 if context.protocol_later_eq(110) else \
0x48 if context.protocol_later_eq(107) else \
0x47
packet_name = 'player list header and footer'
definition = [
@ -376,15 +376,15 @@ class EntityLookPacket(Packet):
@staticmethod
def get_id(context):
return 0x2B if context.protocol_later_eq(755) else \
0x29 if context.protocol_later_eq(741) else \
0x2A if context.protocol_later_eq(721) else \
0x2B if context.protocol_later_eq(550) else \
0x2A if context.protocol_later_eq(389) else \
0x29 if context.protocol_later_eq(345) else \
0x28 if context.protocol_later_eq(318) else \
0x27 if context.protocol_later_eq(94) else \
0x28 if context.protocol_later_eq(70) else \
0x16
0x29 if context.protocol_later_eq(741) else \
0x2A if context.protocol_later_eq(721) else \
0x2B if context.protocol_later_eq(550) else \
0x2A if context.protocol_later_eq(389) else \
0x29 if context.protocol_later_eq(345) else \
0x28 if context.protocol_later_eq(318) else \
0x27 if context.protocol_later_eq(94) else \
0x28 if context.protocol_later_eq(70) else \
0x16
packet_name = 'entity look'
definition = [
@ -399,21 +399,21 @@ class ResourcePackSendPacket(Packet):
@staticmethod
def get_id(context):
return 0x3C if context.protocol_later_eq(PRE | 15) else \
0x39 if context.protocol_later_eq(PRE | 8) else \
0x38 if context.protocol_later_eq(741) else \
0x39 if context.protocol_later_eq(721) else \
0x3A if context.protocol_later_eq(550) else \
0x39 if context.protocol_later_eq(471) else \
0x37 if context.protocol_later_eq(461) else \
0x38 if context.protocol_later_eq(451) else \
0x37 if context.protocol_later_eq(389) else \
0x36 if context.protocol_later_eq(352) else \
0x35 if context.protocol_later_eq(345) else \
0x34 if context.protocol_later_eq(336) else \
0x33 if context.protocol_later_eq(332) else \
0x34 if context.protocol_later_eq(318) else \
0x32 if context.protocol_later_eq(70) else \
0x48
0x39 if context.protocol_later_eq(PRE | 8) else \
0x38 if context.protocol_later_eq(741) else \
0x39 if context.protocol_later_eq(721) else \
0x3A if context.protocol_later_eq(550) else \
0x39 if context.protocol_later_eq(471) else \
0x37 if context.protocol_later_eq(461) else \
0x38 if context.protocol_later_eq(451) else \
0x37 if context.protocol_later_eq(389) else \
0x36 if context.protocol_later_eq(352) else \
0x35 if context.protocol_later_eq(345) else \
0x34 if context.protocol_later_eq(336) else \
0x33 if context.protocol_later_eq(332) else \
0x34 if context.protocol_later_eq(318) else \
0x32 if context.protocol_later_eq(70) else \
0x48
packet_name = "resource pack send"

View File

@ -10,13 +10,13 @@ class BlockChangePacket(Packet):
@staticmethod
def get_id(context):
return 0x0C if context.protocol_later_eq(755) else \
0x0B if context.protocol_later_eq(721) else \
0x0C if context.protocol_later_eq(550) else \
0x0B if context.protocol_later_eq(332) else \
0x0C if context.protocol_later_eq(318) else \
0x0B if context.protocol_later_eq(67) else \
0x24 if context.protocol_later_eq(62) else \
0x23
0x0B if context.protocol_later_eq(721) else \
0x0C if context.protocol_later_eq(550) else \
0x0B if context.protocol_later_eq(332) else \
0x0C if context.protocol_later_eq(318) else \
0x0B if context.protocol_later_eq(67) else \
0x24 if context.protocol_later_eq(62) else \
0x23
packet_name = 'block change'
definition = [
@ -50,14 +50,14 @@ class MultiBlockChangePacket(Packet):
@staticmethod
def get_id(context):
return 0x3F if context.protocol_later_eq(755) else \
0x3B if context.protocol_later_eq(741) else \
0x0F if context.protocol_later_eq(721) else \
0x10 if context.protocol_later_eq(550) else \
0x0F if context.protocol_later_eq(343) else \
0x10 if context.protocol_later_eq(332) else \
0x11 if context.protocol_later_eq(318) else \
0x10 if context.protocol_later_eq(67) else \
0x22
0x3B if context.protocol_later_eq(741) else \
0x0F if context.protocol_later_eq(721) else \
0x10 if context.protocol_later_eq(550) else \
0x0F if context.protocol_later_eq(343) else \
0x10 if context.protocol_later_eq(332) else \
0x11 if context.protocol_later_eq(318) else \
0x10 if context.protocol_later_eq(67) else \
0x22
packet_name = 'multi block change'
@ -131,9 +131,9 @@ class MultiBlockChangePacket(Packet):
def send_with_context(self, record, socket, context):
if context.protocol_later_eq(741):
value = record.block_state_id << 12 | \
(record.x & 0xF) << 8 | \
(record.z & 0xF) << 4 | \
record.y & 0xF
(record.x & 0xF) << 8 | \
(record.z & 0xF) << 4 | \
record.y & 0xF
VarLong.send(value, socket)
else:
UnsignedByte.send(record.x << 4 | record.z & 0xF, socket)

View File

@ -17,20 +17,20 @@ class CombatEventPacket(Packet):
@classmethod
def get_id(cls, context):
return cls.deprecated() if context.protocol_later_eq(PRE | 15) else \
0x31 if context.protocol_later_eq(741) else \
0x32 if context.protocol_later_eq(721) else \
0x33 if context.protocol_later_eq(550) else \
0x32 if context.protocol_later_eq(471) else \
0x30 if context.protocol_later_eq(451) else \
0x2F if context.protocol_later_eq(389) else \
0x2E if context.protocol_later_eq(345) else \
0x2D if context.protocol_later_eq(336) else \
0x2C if context.protocol_later_eq(332) else \
0x2D if context.protocol_later_eq(318) else \
0x2C if context.protocol_later_eq(86) else \
0x2D if context.protocol_later_eq(80) else \
0x2C if context.protocol_later_eq(67) else \
0x42
0x31 if context.protocol_later_eq(741) else \
0x32 if context.protocol_later_eq(721) else \
0x33 if context.protocol_later_eq(550) else \
0x32 if context.protocol_later_eq(471) else \
0x30 if context.protocol_later_eq(451) else \
0x2F if context.protocol_later_eq(389) else \
0x2E if context.protocol_later_eq(345) else \
0x2D if context.protocol_later_eq(336) else \
0x2C if context.protocol_later_eq(332) else \
0x2D if context.protocol_later_eq(318) else \
0x2C if context.protocol_later_eq(86) else \
0x2D if context.protocol_later_eq(80) else \
0x2C if context.protocol_later_eq(67) else \
0x42
packet_name = 'combat event'

View File

@ -9,17 +9,17 @@ class ExplosionPacket(Packet):
@staticmethod
def get_id(context):
return 0x1C if context.protocol_later_eq(755) else \
0x1B if context.protocol_later_eq(741) else \
0x1C if context.protocol_later_eq(721) else \
0x1D if context.protocol_later_eq(550) else \
0x1C if context.protocol_later_eq(471) else \
0x1E if context.protocol_later_eq(389) else \
0x1D if context.protocol_later_eq(345) else \
0x1C if context.protocol_later_eq(332) else \
0x1D if context.protocol_later_eq(318) else \
0x1C if context.protocol_later_eq(80) else \
0x1B if context.protocol_later_eq(67) else \
0x27
0x1B if context.protocol_later_eq(741) else \
0x1C if context.protocol_later_eq(721) else \
0x1D if context.protocol_later_eq(550) else \
0x1C if context.protocol_later_eq(471) else \
0x1E if context.protocol_later_eq(389) else \
0x1D if context.protocol_later_eq(345) else \
0x1C if context.protocol_later_eq(332) else \
0x1D if context.protocol_later_eq(318) else \
0x1C if context.protocol_later_eq(80) else \
0x1B if context.protocol_later_eq(67) else \
0x27
packet_name = 'explosion'

View File

@ -9,20 +9,20 @@ class FacePlayerPacket(Packet):
@staticmethod
def get_id(context):
return 0x37 if context.protocol_later_eq(755) else \
0x33 if context.protocol_later_eq(741) else \
0x34 if context.protocol_later_eq(721) else \
0x35 if context.protocol_later_eq(550) else \
0x34 if context.protocol_later_eq(471) else \
0x32 if context.protocol_later_eq(451) else \
0x31 if context.protocol_later_eq(389) else \
0x30
0x33 if context.protocol_later_eq(741) else \
0x34 if context.protocol_later_eq(721) else \
0x35 if context.protocol_later_eq(550) else \
0x34 if context.protocol_later_eq(471) else \
0x32 if context.protocol_later_eq(451) else \
0x31 if context.protocol_later_eq(389) else \
0x30
packet_name = 'face player'
@property
def fields(self):
return ('origin', 'x', 'y', 'z', 'entity_id', 'entity_origin') \
if self.context.protocol_later_eq(353) else \
if self.context.protocol_later_eq(353) else \
('entity_id', 'x', 'y', 'z')
# Access the 'x', 'y', 'z' fields as a Vector tuple.

View File

@ -46,6 +46,7 @@ class AbstractDimensionPacket(Packet):
''' The abstract superclass of JoinGamePacket and RespawnPacket, containing
common definitions relating to their 'dimension' field.
'''
def field_string(self, field):
# pylint: disable=no-member
if self.context.protocol_later_eq(748) and field == 'dimension':
@ -59,15 +60,15 @@ class JoinGamePacket(AbstractDimensionPacket):
@staticmethod
def get_id(context):
return 0x26 if context.protocol_later_eq(755) else \
0x24 if context.protocol_later_eq(741) else \
0x25 if context.protocol_later_eq(721) else \
0x26 if context.protocol_later_eq(550) else \
0x25 if context.protocol_later_eq(389) else \
0x24 if context.protocol_later_eq(345) else \
0x23 if context.protocol_later_eq(332) else \
0x24 if context.protocol_later_eq(318) else \
0x23 if context.protocol_later_eq(107) else \
0x01
0x24 if context.protocol_later_eq(741) else \
0x25 if context.protocol_later_eq(721) else \
0x26 if context.protocol_later_eq(550) else \
0x25 if context.protocol_later_eq(389) else \
0x24 if context.protocol_later_eq(345) else \
0x23 if context.protocol_later_eq(332) else \
0x24 if context.protocol_later_eq(318) else \
0x23 if context.protocol_later_eq(107) else \
0x01
packet_name = "join game"
get_definition = staticmethod(lambda context: [
@ -174,20 +175,20 @@ class RespawnPacket(AbstractDimensionPacket):
@staticmethod
def get_id(context):
return 0x3D if context.protocol_later_eq(755) else \
0x39 if context.protocol_later_eq(741) else \
0x3A if context.protocol_later_eq(721) else \
0x3B if context.protocol_later_eq(550) else \
0x3A if context.protocol_later_eq(471) else \
0x38 if context.protocol_later_eq(461) else \
0x39 if context.protocol_later_eq(451) else \
0x38 if context.protocol_later_eq(389) else \
0x37 if context.protocol_later_eq(352) else \
0x36 if context.protocol_later_eq(345) else \
0x35 if context.protocol_later_eq(336) else \
0x34 if context.protocol_later_eq(332) else \
0x35 if context.protocol_later_eq(318) else \
0x33 if context.protocol_later_eq(70) else \
0x07
0x39 if context.protocol_later_eq(741) else \
0x3A if context.protocol_later_eq(721) else \
0x3B if context.protocol_later_eq(550) else \
0x3A if context.protocol_later_eq(471) else \
0x38 if context.protocol_later_eq(461) else \
0x39 if context.protocol_later_eq(451) else \
0x38 if context.protocol_later_eq(389) else \
0x37 if context.protocol_later_eq(352) else \
0x36 if context.protocol_later_eq(345) else \
0x35 if context.protocol_later_eq(336) else \
0x34 if context.protocol_later_eq(332) else \
0x35 if context.protocol_later_eq(318) else \
0x33 if context.protocol_later_eq(70) else \
0x07
packet_name = 'respawn'
get_definition = staticmethod(lambda context: [

View File

@ -10,15 +10,15 @@ class MapPacket(Packet):
@staticmethod
def get_id(context):
return 0x27 if context.protocol_later_eq(755) else \
0x25 if context.protocol_later_eq(741) else \
0x26 if context.protocol_later_eq(721) else \
0x27 if context.protocol_later_eq(550) else \
0x26 if context.protocol_later_eq(389) else \
0x25 if context.protocol_later_eq(345) else \
0x24 if context.protocol_later_eq(334) else \
0x25 if context.protocol_later_eq(318) else \
0x24 if context.protocol_later_eq(107) else \
0x34
0x25 if context.protocol_later_eq(741) else \
0x26 if context.protocol_later_eq(721) else \
0x27 if context.protocol_later_eq(550) else \
0x26 if context.protocol_later_eq(389) else \
0x25 if context.protocol_later_eq(345) else \
0x24 if context.protocol_later_eq(334) else \
0x25 if context.protocol_later_eq(318) else \
0x24 if context.protocol_later_eq(107) else \
0x34
packet_name = 'map'
@ -55,7 +55,7 @@ class MapPacket(Packet):
self.icons = []
self.width = width
self.height = height
self.pixels = bytearray(0 for i in range(width*height))
self.pixels = bytearray(0 for i in range(width * height))
self.is_tracking_position = True
self.is_locked = False

View File

@ -10,18 +10,18 @@ class PlayerListItemPacket(Packet):
@staticmethod
def get_id(context):
return 0x36 if context.protocol_later_eq(755) else \
0x32 if context.protocol_later_eq(741) else \
0x33 if context.protocol_later_eq(721) else \
0x34 if context.protocol_later_eq(550) else \
0x33 if context.protocol_later_eq(471) else \
0x31 if context.protocol_later_eq(451) else \
0x30 if context.protocol_later_eq(389) else \
0x2F if context.protocol_later_eq(345) else \
0x2E if context.protocol_later_eq(336) else \
0x2D if context.protocol_later_eq(332) else \
0x2E if context.protocol_later_eq(318) else \
0x2D if context.protocol_later_eq(107) else \
0x38
0x32 if context.protocol_later_eq(741) else \
0x33 if context.protocol_later_eq(721) else \
0x34 if context.protocol_later_eq(550) else \
0x33 if context.protocol_later_eq(471) else \
0x31 if context.protocol_later_eq(451) else \
0x30 if context.protocol_later_eq(389) else \
0x2F if context.protocol_later_eq(345) else \
0x2E if context.protocol_later_eq(336) else \
0x2D if context.protocol_later_eq(332) else \
0x2E if context.protocol_later_eq(318) else \
0x2D if context.protocol_later_eq(107) else \
0x38
packet_name = "player list item"

View File

@ -11,19 +11,19 @@ class PlayerPositionAndLookPacket(Packet, BitFieldEnum):
@staticmethod
def get_id(context):
return 0x38 if context.protocol_later_eq(755) else \
0x34 if context.protocol_later_eq(741) else \
0x35 if context.protocol_later_eq(721) else \
0x36 if context.protocol_later_eq(550) else \
0x35 if context.protocol_later_eq(471) else \
0x33 if context.protocol_later_eq(451) else \
0x32 if context.protocol_later_eq(389) else \
0x31 if context.protocol_later_eq(352) else \
0x30 if context.protocol_later_eq(345) else \
0x2F if context.protocol_later_eq(336) else \
0x2E if context.protocol_later_eq(332) else \
0x2F if context.protocol_later_eq(318) else \
0x2E if context.protocol_later_eq(70) else \
0x08
0x34 if context.protocol_later_eq(741) else \
0x35 if context.protocol_later_eq(721) else \
0x36 if context.protocol_later_eq(550) else \
0x35 if context.protocol_later_eq(471) else \
0x33 if context.protocol_later_eq(451) else \
0x32 if context.protocol_later_eq(389) else \
0x31 if context.protocol_later_eq(352) else \
0x30 if context.protocol_later_eq(345) else \
0x2F if context.protocol_later_eq(336) else \
0x2E if context.protocol_later_eq(332) else \
0x2F if context.protocol_later_eq(318) else \
0x2E if context.protocol_later_eq(70) else \
0x08
packet_name = "player position and look"
get_definition = staticmethod(lambda context: [

View File

@ -11,20 +11,20 @@ class SoundEffectPacket(Packet):
@staticmethod
def get_id(context):
return 0x5D if context.protocol_later_eq(PRE | 48) else \
0x5C if context.protocol_later_eq(755) else \
0x51 if context.protocol_later_eq(721) else \
0x52 if context.protocol_later_eq(550) else \
0x51 if context.protocol_later_eq(471) else \
0x4D if context.protocol_later_eq(461) else \
0x4E if context.protocol_later_eq(451) else \
0x4D if context.protocol_later_eq(389) else \
0x4C if context.protocol_later_eq(352) else \
0x4B if context.protocol_later_eq(345) else \
0x4A if context.protocol_later_eq(343) else \
0x49 if context.protocol_later_eq(336) else \
0x48 if context.protocol_later_eq(318) else \
0x46 if context.protocol_later_eq(110) else \
0x47
0x5C if context.protocol_later_eq(755) else \
0x51 if context.protocol_later_eq(721) else \
0x52 if context.protocol_later_eq(550) else \
0x51 if context.protocol_later_eq(471) else \
0x4D if context.protocol_later_eq(461) else \
0x4E if context.protocol_later_eq(451) else \
0x4D if context.protocol_later_eq(389) else \
0x4C if context.protocol_later_eq(352) else \
0x4B if context.protocol_later_eq(345) else \
0x4A if context.protocol_later_eq(343) else \
0x49 if context.protocol_later_eq(336) else \
0x48 if context.protocol_later_eq(318) else \
0x46 if context.protocol_later_eq(110) else \
0x47
packet_name = 'sound effect'

View File

@ -11,7 +11,7 @@ class SpawnObjectPacket(Packet):
@staticmethod
def get_id(context):
return 0x00 if context.protocol_later_eq(67) else \
0x0E
0x0E
packet_name = 'spawn object'
@ -51,42 +51,42 @@ class SpawnObjectPacket(Packet):
class EntityType(Enum):
# XXX This has not been updated for >= v1.15
ACTIVATED_TNT = (50, 55)[era] # PrimedTnt
AREA_EFFECT_CLOUD = ( 3, 0)[era]
ARMORSTAND = (78, 1)[era]
ARROW = (60, 2)[era]
BOAT = ( 1, 5)[era]
DRAGON_FIREBALL = (93, 13)[era]
EGG = (62, 74)[era] # ThrownEgg
ENDERCRYSTAL = (51, 16)[era]
ENDERPEARL = (65, 75)[era] # ThrownEnderpearl
EVOCATION_FANGS = (79, 20)[era]
EXP_BOTTLE = (75, 76)[era] # ThrownExpBottle
EYE_OF_ENDER = (72, 23)[era] # EyeOfEnderSignal
FALLING_OBJECT = (70, 24)[era] # FallingSand
FIREBALL = (63, 34)[era] # Fireball (ghast)
FIRECHARGE = (64, 65)[era] # SmallFireball (blaze)
FIREWORK_ROCKET = (76, 25)[era] # FireworksRocketEntity
FISHING_HOOK = (90, 93)[era] # Fishing bobber
ITEM_FRAMES = (71, 33)[era] # ItemFrame
ITEM_STACK = ( 2, 32)[era] # Item
LEASH_KNOT = (77, 35)[era]
LLAMA_SPIT = (68, 37)[era]
MINECART = (10, 39)[era] # MinecartRideable
POTION = (73, 77)[era] # ThrownPotion
SHULKER_BULLET = (67, 60)[era]
SNOWBALL = (61, 67)[era]
SPECTRAL_ARROW = (91, 68)[era]
WITHER_SKULL = (66, 85)[era]
ACTIVATED_TNT = (50, 55)[era] # PrimedTnt
AREA_EFFECT_CLOUD = (3, 0)[era]
ARMORSTAND = (78, 1)[era]
ARROW = (60, 2)[era]
BOAT = (1, 5)[era]
DRAGON_FIREBALL = (93, 13)[era]
EGG = (62, 74)[era] # ThrownEgg
ENDERCRYSTAL = (51, 16)[era]
ENDERPEARL = (65, 75)[era] # ThrownEnderpearl
EVOCATION_FANGS = (79, 20)[era]
EXP_BOTTLE = (75, 76)[era] # ThrownExpBottle
EYE_OF_ENDER = (72, 23)[era] # EyeOfEnderSignal
FALLING_OBJECT = (70, 24)[era] # FallingSand
FIREBALL = (63, 34)[era] # Fireball (ghast)
FIRECHARGE = (64, 65)[era] # SmallFireball (blaze)
FIREWORK_ROCKET = (76, 25)[era] # FireworksRocketEntity
FISHING_HOOK = (90, 93)[era] # Fishing bobber
ITEM_FRAMES = (71, 33)[era] # ItemFrame
ITEM_STACK = (2, 32)[era] # Item
LEASH_KNOT = (77, 35)[era]
LLAMA_SPIT = (68, 37)[era]
MINECART = (10, 39)[era] # MinecartRideable
POTION = (73, 77)[era] # ThrownPotion
SHULKER_BULLET = (67, 60)[era]
SNOWBALL = (61, 67)[era]
SPECTRAL_ARROW = (91, 68)[era]
WITHER_SKULL = (66, 85)[era]
if context.protocol_later_eq(393):
TRIDENT = 94
if context.protocol_later_eq(458):
MINECART_CHEST = 40
MINECART_CHEST = 40
MINECART_COMMAND_BLOCK = 41
MINECART_FURNACE = 42
MINECART_HOPPER = 43
MINECART_SPAWNER = 44
MINECART_TNT = 45
MINECART_FURNACE = 42
MINECART_HOPPER = 43
MINECART_SPAWNER = 44
MINECART_TNT = 45
setattr(cls, name, EntityType)
return EntityType

View File

@ -40,7 +40,7 @@ class Packet(object):
@overridable_property
def definition(self):
return None if self.context is None else \
self.get_definition(self.context)
self.get_definition(self.context)
# In general, a packet instance must have its 'context' attribute set to an
# instance of 'ConnectionContext', for example to decide on version-

View File

@ -22,8 +22,8 @@ class LoginStartPacket(Packet):
@staticmethod
def get_id(context):
return 0x00 if context.protocol_later_eq(391) else \
0x01 if context.protocol_later_eq(385) else \
0x00
0x01 if context.protocol_later_eq(385) else \
0x00
packet_name = "login start"
definition = [
@ -34,8 +34,8 @@ class EncryptionResponsePacket(Packet):
@staticmethod
def get_id(context):
return 0x01 if context.protocol_later_eq(391) else \
0x02 if context.protocol_later_eq(385) else \
0x01
0x02 if context.protocol_later_eq(385) else \
0x01
packet_name = "encryption response"
definition = [
@ -51,7 +51,7 @@ class PluginResponsePacket(Packet):
@staticmethod
def get_id(context):
return 0x02 if context.protocol_later_eq(391) else \
0x00
0x00
packet_name = 'login plugin response'
fields = (

View File

@ -38,35 +38,35 @@ class KeepAlivePacket(AbstractKeepAlivePacket):
@staticmethod
def get_id(context):
return 0x0F if context.protocol_later_eq(755) else \
0x10 if context.protocol_later_eq(712) else \
0x0F if context.protocol_later_eq(471) else \
0x10 if context.protocol_later_eq(464) else \
0x0E if context.protocol_later_eq(389) else \
0x0C if context.protocol_later_eq(386) else \
0x0B if context.protocol_later_eq(345) else \
0x0A if context.protocol_later_eq(343) else \
0x0B if context.protocol_later_eq(336) else \
0x0C if context.protocol_later_eq(318) else \
0x0B if context.protocol_later_eq(107) else \
0x00
0x10 if context.protocol_later_eq(712) else \
0x0F if context.protocol_later_eq(471) else \
0x10 if context.protocol_later_eq(464) else \
0x0E if context.protocol_later_eq(389) else \
0x0C if context.protocol_later_eq(386) else \
0x0B if context.protocol_later_eq(345) else \
0x0A if context.protocol_later_eq(343) else \
0x0B if context.protocol_later_eq(336) else \
0x0C if context.protocol_later_eq(318) else \
0x0B if context.protocol_later_eq(107) else \
0x00
class ChatPacket(Packet):
@staticmethod
def get_id(context):
return 0x03 if context.protocol_later_eq(755) else \
0x03 if context.protocol_later_eq(464) else \
0x02 if context.protocol_later_eq(389) else \
0x01 if context.protocol_later_eq(343) else \
0x02 if context.protocol_later_eq(336) else \
0x03 if context.protocol_later_eq(318) else \
0x02 if context.protocol_later_eq(107) else \
0x01
0x03 if context.protocol_later_eq(464) else \
0x02 if context.protocol_later_eq(389) else \
0x01 if context.protocol_later_eq(343) else \
0x02 if context.protocol_later_eq(336) else \
0x03 if context.protocol_later_eq(318) else \
0x02 if context.protocol_later_eq(107) else \
0x01
@staticmethod
def get_max_length(context):
return 256 if context.protocol_later_eq(306) else \
100
100
@property
def max_length(self):
@ -82,18 +82,18 @@ class PositionAndLookPacket(Packet):
@staticmethod
def get_id(context):
return 0x12 if context.protocol_later_eq(755) else \
0x13 if context.protocol_later_eq(712) else \
0x12 if context.protocol_later_eq(471) else \
0x13 if context.protocol_later_eq(464) else \
0x11 if context.protocol_later_eq(389) else \
0x0F if context.protocol_later_eq(386) else \
0x0E if context.protocol_later_eq(345) else \
0x0D if context.protocol_later_eq(343) else \
0x0E if context.protocol_later_eq(336) else \
0x0F if context.protocol_later_eq(332) else \
0x0E if context.protocol_later_eq(318) else \
0x0D if context.protocol_later_eq(107) else \
0x06
0x13 if context.protocol_later_eq(712) else \
0x12 if context.protocol_later_eq(471) else \
0x13 if context.protocol_later_eq(464) else \
0x11 if context.protocol_later_eq(389) else \
0x0F if context.protocol_later_eq(386) else \
0x0E if context.protocol_later_eq(345) else \
0x0D if context.protocol_later_eq(343) else \
0x0E if context.protocol_later_eq(336) else \
0x0F if context.protocol_later_eq(332) else \
0x0E if context.protocol_later_eq(318) else \
0x0D if context.protocol_later_eq(107) else \
0x06
packet_name = "position and look"
definition = [
@ -130,18 +130,18 @@ class AnimationPacket(Packet):
@staticmethod
def get_id(context):
return 0x2C if context.protocol_later_eq(755) else \
0x2C if context.protocol_later_eq(738) else \
0x2B if context.protocol_later_eq(712) else \
0x2A if context.protocol_later_eq(468) else \
0x29 if context.protocol_later_eq(464) else \
0x27 if context.protocol_later_eq(389) else \
0x25 if context.protocol_later_eq(386) else \
0x1D if context.protocol_later_eq(345) else \
0x1C if context.protocol_later_eq(343) else \
0x1D if context.protocol_later_eq(332) else \
0x1C if context.protocol_later_eq(318) else \
0x1A if context.protocol_later_eq(107) else \
0x0A
0x2C if context.protocol_later_eq(738) else \
0x2B if context.protocol_later_eq(712) else \
0x2A if context.protocol_later_eq(468) else \
0x29 if context.protocol_later_eq(464) else \
0x27 if context.protocol_later_eq(389) else \
0x25 if context.protocol_later_eq(386) else \
0x1D if context.protocol_later_eq(345) else \
0x1C if context.protocol_later_eq(343) else \
0x1D if context.protocol_later_eq(332) else \
0x1C if context.protocol_later_eq(318) else \
0x1A if context.protocol_later_eq(107) else \
0x0A
packet_name = "animation"
get_definition = staticmethod(lambda context: [
@ -155,15 +155,15 @@ class ClientStatusPacket(Packet, Enum):
@staticmethod
def get_id(context):
return 0x04 if context.protocol_later_eq(755) else \
0x04 if context.protocol_later_eq(464) else \
0x03 if context.protocol_later_eq(389) else \
0x02 if context.protocol_later_eq(343) else \
0x03 if context.protocol_later_eq(336) else \
0x04 if context.protocol_later_eq(318) else \
0x03 if context.protocol_later_eq(80) else \
0x02 if context.protocol_later_eq(67) else \
0x17 if context.protocol_later_eq(49) else \
0x16
0x04 if context.protocol_later_eq(464) else \
0x03 if context.protocol_later_eq(389) else \
0x02 if context.protocol_later_eq(343) else \
0x03 if context.protocol_later_eq(336) else \
0x04 if context.protocol_later_eq(318) else \
0x03 if context.protocol_later_eq(80) else \
0x02 if context.protocol_later_eq(67) else \
0x17 if context.protocol_later_eq(49) else \
0x16
packet_name = "client status"
get_definition = staticmethod(lambda context: [
@ -181,14 +181,14 @@ class PluginMessagePacket(AbstractPluginMessagePacket):
@staticmethod
def get_id(context):
return 0x0A if context.protocol_later_eq(755) else \
0x0B if context.protocol_later_eq(464) else \
0x0A if context.protocol_later_eq(389) else \
0x09 if context.protocol_later_eq(345) else \
0x08 if context.protocol_later_eq(343) else \
0x09 if context.protocol_later_eq(336) else \
0x0A if context.protocol_later_eq(317) else \
0x09 if context.protocol_later_eq(94) else \
0x17
0x0B if context.protocol_later_eq(464) else \
0x0A if context.protocol_later_eq(389) else \
0x09 if context.protocol_later_eq(345) else \
0x08 if context.protocol_later_eq(343) else \
0x09 if context.protocol_later_eq(336) else \
0x0A if context.protocol_later_eq(317) else \
0x09 if context.protocol_later_eq(94) else \
0x17
class PlayerBlockPlacementPacket(Packet):
@ -208,18 +208,18 @@ class PlayerBlockPlacementPacket(Packet):
@staticmethod
def get_id(context):
return 0x2E if context.protocol_later_eq(755) else \
0x2E if context.protocol_later_eq(738) else \
0x2D if context.protocol_later_eq(712) else \
0x2C if context.protocol_later_eq(468) else \
0x2B if context.protocol_later_eq(464) else \
0x29 if context.protocol_later_eq(389) else \
0x27 if context.protocol_later_eq(386) else \
0x1F if context.protocol_later_eq(345) else \
0x1E if context.protocol_later_eq(343) else \
0x1F if context.protocol_later_eq(332) else \
0x1E if context.protocol_later_eq(318) else \
0x1C if context.protocol_later_eq(94) else \
0x08
0x2E if context.protocol_later_eq(738) else \
0x2D if context.protocol_later_eq(712) else \
0x2C if context.protocol_later_eq(468) else \
0x2B if context.protocol_later_eq(464) else \
0x29 if context.protocol_later_eq(389) else \
0x27 if context.protocol_later_eq(386) else \
0x1F if context.protocol_later_eq(345) else \
0x1E if context.protocol_later_eq(343) else \
0x1F if context.protocol_later_eq(332) else \
0x1E if context.protocol_later_eq(318) else \
0x1C if context.protocol_later_eq(94) else \
0x08
packet_name = 'player block placement'
@ -248,19 +248,19 @@ class UseItemPacket(Packet):
@staticmethod
def get_id(context):
return 0x2F if context.protocol_later_eq(755) else \
0x2F if context.protocol_later_eq(738) else \
0x2E if context.protocol_later_eq(712) else \
0x2D if context.protocol_later_eq(468) else \
0x2C if context.protocol_later_eq(464) else \
0x2A if context.protocol_later_eq(389) else \
0x28 if context.protocol_later_eq(386) else \
0x20 if context.protocol_later_eq(345) else \
0x1F if context.protocol_later_eq(343) else \
0x20 if context.protocol_later_eq(332) else \
0x1F if context.protocol_later_eq(318) else \
0x1D if context.protocol_later_eq(94) else \
0x1A if context.protocol_later_eq(70) else \
0x08
0x2F if context.protocol_later_eq(738) else \
0x2E if context.protocol_later_eq(712) else \
0x2D if context.protocol_later_eq(468) else \
0x2C if context.protocol_later_eq(464) else \
0x2A if context.protocol_later_eq(389) else \
0x28 if context.protocol_later_eq(386) else \
0x20 if context.protocol_later_eq(345) else \
0x1F if context.protocol_later_eq(343) else \
0x20 if context.protocol_later_eq(332) else \
0x1F if context.protocol_later_eq(318) else \
0x1D if context.protocol_later_eq(94) else \
0x1A if context.protocol_later_eq(70) else \
0x08
packet_name = "use item"
get_definition = staticmethod(lambda context: [

View File

@ -12,12 +12,12 @@ class ClientSettingsPacket(Packet):
@staticmethod
def get_id(context):
return 0x05 if context.protocol_later_eq(464) else \
0x04 if context.protocol_later_eq(389) else \
0x03 if context.protocol_later_eq(343) else \
0x04 if context.protocol_later_eq(336) else \
0x05 if context.protocol_later_eq(318) else \
0x04 if context.protocol_later_eq(94) else \
0x15
0x04 if context.protocol_later_eq(389) else \
0x03 if context.protocol_later_eq(343) else \
0x04 if context.protocol_later_eq(336) else \
0x05 if context.protocol_later_eq(318) else \
0x04 if context.protocol_later_eq(94) else \
0x15
packet_name = 'client settings'

View File

@ -22,26 +22,26 @@ class Vector(namedtuple('BaseVector', ('x', 'y', 'z'))):
def __add__(self, other):
return NotImplemented if not isinstance(other, Vector) else \
type(self)(self.x + other.x, self.y + other.y, self.z + other.z)
type(self)(self.x + other.x, self.y + other.y, self.z + other.z)
def __sub__(self, other):
return NotImplemented if not isinstance(other, Vector) else \
type(self)(self.x - other.x, self.y - other.y, self.z - other.z)
type(self)(self.x - other.x, self.y - other.y, self.z - other.z)
def __neg__(self):
return type(self)(-self.x, -self.y, -self.z)
def __mul__(self, other):
return type(self)(self.x*other, self.y*other, self.z*other)
return type(self)(self.x * other, self.y * other, self.z * other)
def __rmul__(self, other):
return type(self)(other*self.x, other*self.y, other*self.z)
return type(self)(other * self.x, other * self.y, other * self.z)
def __truediv__(self, other):
return type(self)(self.x/other, self.y/other, self.z/other)
return type(self)(self.x / other, self.y / other, self.z / other)
def __floordiv__(self, other):
return type(self)(self.x//other, self.y//other, self.z//other)
return type(self)(self.x // other, self.y // other, self.z // other)
__div__ = __floordiv__
@ -66,7 +66,7 @@ class MutableRecord(object):
if hasattr(self, a)))
def __eq__(self, other):
return type(self) is type(other) and all(
return isinstance(self, type(other)) and all(
getattr(self, a) == getattr(other, a) for a in self._all_slots())
def __ne__(self, other):

View File

@ -122,6 +122,7 @@ class overridable_property(overridable_descriptor):
descriptor, overridable by attributes of instances of the class
in which the property occurs. See also 'overridable_descriptor' above.
"""
def __get__(self, instance, _owner):
return self._fget(instance)

View File

@ -36,15 +36,23 @@ def get_options():
action="store_true",
help="include unknown packets in --dump-packets output")
parser.add_option(
"-m",
"--microsoft",
dest="microsoft",
action="store_true",
help="Enable Microsoft Auth")
(options, args) = parser.parse_args()
if not options.username:
options.username = input("Enter your username: ")
if not options.microsoft:
if not options.username:
options.username = input("Enter your username: ")
if not options.password and not options.offline:
options.password = getpass.getpass("Enter your password (leave "
"blank for offline mode): ")
options.offline = options.offline or (options.password == "")
if not options.password and not options.offline:
options.password = getpass.getpass("Enter your password (leave "
"blank for offline mode): ")
options.offline = options.offline or (options.password == "")
if not options.server:
options.server = input("Enter server host or host:port "
@ -68,15 +76,20 @@ def main():
connection = Connection(
options.address, options.port, username=options.username)
else:
auth_token = authentication.AuthenticationToken()
try:
auth_token.authenticate(options.username, options.password)
auth_token = authentication.Microsoft_AuthenticationToken()
auth_token.authenticate()
except YggdrasilError as e:
print(e)
sys.exit()
print("Logged in as %s..." % auth_token.username)
connection = Connection(
options.address, options.port, auth_token=auth_token)
options.address,
options.port,
auth_token,
None,
"1.8")
if options.dump_packets:
def print_incoming(packet):

View File

@ -38,6 +38,7 @@ class FakeServerDisconnect(Exception):
the client's connection. 'message' is provided as an argument to
'handle_play_server_disconnect' or 'handle_login_server_disconnect'.
"""
def __init__(self, message=None):
self.message = message
@ -166,14 +167,14 @@ class FakeClientHandler(object):
packet = clientbound.status.ResponsePacket()
packet.json_response = json.dumps({
'version': {
'name': self.server.minecraft_version,
'name': self.server.minecraft_version,
'protocol': self.server.context.protocol_version},
'players': {
'max': 1,
'online': 0,
'sample': []},
'max': 1,
'online': 0,
'sample': []},
'description': {
'text': 'FakeServer'}})
'text': 'FakeServer'}})
self.write_packet(packet)
def handle_ping(self, ping_packet):
@ -227,7 +228,7 @@ class FakeClientHandler(object):
self.handle_connection()
packet = self.read_packet()
assert isinstance(packet, serverbound.handshake.HandShakePacket), \
type(packet)
type(packet)
self.handle_handshake(packet)
if packet.next_state == 1:
self._run_status()

View File

@ -209,7 +209,7 @@ class MakeRequest(unittest.TestCase):
"George": 1,
"Nestly": {
"Nestling": "Nestling's tail"
},
},
"Listly": ["listling1", 2, "listling 3"]
}

View File

@ -130,13 +130,13 @@ class AllowedVersionsTest(fake_server._FakeServerTest):
for index in self.test_indices:
self._test_connect(
server_version=self.versions[index][0],
client_versions={v[0] for v in self.versions[:index+1]})
client_versions={v[0] for v in self.versions[:index + 1]})
def test_with_protocol_numbers(self):
for index in self.test_indices:
self._test_connect(
server_version=self.versions[index][0],
client_versions={v[1] for v in self.versions[:index+1]})
client_versions={v[1] for v in self.versions[:index + 1]})
class LoginDisconnectTest(fake_server._FakeServerTest):
@ -220,11 +220,12 @@ class EarlyPacketListenerTest(ConnectTest):
""" Early packet listeners should be called before ordinary ones, even when
the early packet listener is registered afterwards.
"""
def _start_client(self, client):
@client.listener(clientbound.play.JoinGamePacket)
def handle_join(packet):
assert early_handle_join.called, \
'Ordinary listener called before early listener.'
'Ordinary listener called before early listener.'
handle_join.called = True
handle_join.called = False
@ -337,8 +338,8 @@ class IgnorePacketTest(ConnectTest):
def handle_play_client_disconnect(self):
assert self._keep_alive_ids_returned == [3], \
'Returned keep-alive IDs %r != %r' % \
(self._keep_alive_ids_returned, [3])
'Returned keep-alive IDs %r != %r' % \
(self._keep_alive_ids_returned, [3])
raise fake_server.FakeServerTestSuccess
@ -427,7 +428,7 @@ class VersionNegotiationEdgeCases(fake_server._FakeServerTest):
def test_server_protocol_disallowed(self, client_versions=None):
if client_versions is None:
client_versions = set(SUPPORTED_PROTOCOL_VERSIONS) \
- {self.latest_version}
- {self.latest_version}
with self.assertRaisesRegexp(VersionMismatch, 'not allowed'):
self._test_connect(client_versions={self.earliest_version},
server_version=self.latest_version)
@ -465,7 +466,7 @@ class VersionNegotiationEdgeCases(fake_server._FakeServerTest):
class ClientHandler(fake_server.FakeClientHandler):
def handle_status(self, request_packet):
raise fake_server.FakeServerDisconnect(
'Refusing to handle status request, for test purposes.')
'Refusing to handle status request, for test purposes.')
def handle_play_start(self):
super(ClientHandler, self).handle_play_start()

View File

@ -66,7 +66,7 @@ class Encryption(unittest.TestCase):
def test_generate_hash(self):
verification_hash = generate_verification_hash(
u"", "secret".encode('utf-8'), public_key)
u"", "secret".encode('utf-8'), public_key)
self.assertEquals("1f142e737a84a974a5f2a22f6174a78d80fd97f5",
verification_hash)

View File

@ -163,10 +163,10 @@ class TestReadWritePackets(unittest.TestCase):
context = ConnectionContext(protocol_version=TEST_VERSIONS[-1])
Record = clientbound.play.ExplosionPacket.Record
packet = clientbound.play.ExplosionPacket(
position=Vector(787, -37, 0), radius=15,
records=[Record(-14, -116, -5), Record(-77, 34, -36),
Record(-35, -127, 95), Record(11, 113, -8)],
player_motion=Vector(4, 5, 0), context=context)
position=Vector(787, -37, 0), radius=15,
records=[Record(-14, -116, -5), Record(-77, 34, -36),
Record(-35, -127, 95), Record(11, 113, -8)],
player_motion=Vector(4, 5, 0), context=context)
self.assertEqual(
str(packet),
@ -268,7 +268,7 @@ class TestReadWritePackets(unittest.TestCase):
context = ConnectionContext(protocol_version=protocol_version)
EntityType = clientbound.play.SpawnObjectPacket.field_enum(
'type_id', context)
'type_id', context)
pos_look = PositionAndLook(
position=(Vector(68.0, 38.0, 76.0)
@ -279,12 +279,12 @@ class TestReadWritePackets(unittest.TestCase):
entity_id, type_name, type_id = 49846, 'EGG', EntityType.EGG
packet = clientbound.play.SpawnObjectPacket(
context=context,
x=pos_look.x, y=pos_look.y, z=pos_look.z,
yaw=pos_look.yaw, pitch=pos_look.pitch,
velocity_x=velocity.x, velocity_y=velocity.y,
velocity_z=velocity.z,
entity_id=entity_id, type_id=type_id, data=1)
context=context,
x=pos_look.x, y=pos_look.y, z=pos_look.z,
yaw=pos_look.yaw, pitch=pos_look.pitch,
velocity_x=velocity.x, velocity_y=velocity.y,
velocity_z=velocity.z,
entity_id=entity_id, type_id=type_id, data=1)
if context.protocol_later_eq(49):
object_uuid = 'd9568851-85bc-4a10-8d6a-261d130626fa'
packet.object_uuid = object_uuid
@ -312,9 +312,9 @@ class TestReadWritePackets(unittest.TestCase):
)
packet2 = clientbound.play.SpawnObjectPacket(
context=context, position_and_look=pos_look,
velocity=velocity, type=type_name,
entity_id=entity_id, data=1)
context=context, position_and_look=pos_look,
velocity=velocity, type=type_name,
entity_id=entity_id, data=1)
if context.protocol_later_eq(49):
packet2.object_uuid = object_uuid
self.assertEqual(packet.__dict__, packet2.__dict__)
@ -326,9 +326,9 @@ class TestReadWritePackets(unittest.TestCase):
if context.protocol_earlier(49):
del packet2.velocity
self._test_read_write_packet(packet, context,
yaw=360/256, pitch=360/256)
yaw=360 / 256, pitch=360 / 256)
self._test_read_write_packet(packet2, context,
yaw=360/256, pitch=360/256)
yaw=360 / 256, pitch=360 / 256)
def test_sound_effect_packet(self):
for protocol_version in TEST_VERSIONS:

View File

@ -67,11 +67,11 @@ class SerializationTest(unittest.TestCase):
packet_buffer, context)
if data_type is FixedPointInteger:
self.assertAlmostEqual(
test_data, deserialized, delta=1.0/32.0)
test_data, deserialized, delta=1.0 / 32.0)
elif data_type is Angle:
self.assertAlmostEqual(test_data % 360,
deserialized,
delta=360/256)
delta=360 / 256)
elif data_type is Float or data_type is Double:
self.assertAlmostEqual(test_data, deserialized, 3)
else:

View File

@ -49,7 +49,7 @@ class VectorTest(unittest.TestCase):
self.assertEqual(-Vector(1, -2, 0), Vector(-1, 2, 0))
self.assertEqual(Vector(1, -2, 0) * 2, Vector(2, -4, 0))
self.assertEqual(2 * Vector(1, -2, 0), Vector(2, -4, 0))
self.assertEqual(Vector(1, -2, 0) / 2, Vector(1/2, -2/2, 0/2))
self.assertEqual(Vector(1, -2, 0) / 2, Vector(1 / 2, -2 / 2, 0 / 2))
self.assertEqual(Vector(1, -2, 0) // 2, Vector(0, -1, 0))
def test_repr(self):
@ -59,6 +59,7 @@ class VectorTest(unittest.TestCase):
class PositionAndLookTest(unittest.TestCase):
""" This also tests the MutableRecord base type. """
def test_properties(self):
pos_look_1 = PositionAndLook(position=(1, 2, 3), look=(4, 5))
pos_look_2 = PositionAndLook(x=1, y=2, z=3, yaw=4, pitch=5)

View File

@ -10,4 +10,4 @@ class VersionTest(unittest.TestCase):
def test_protocol_version_is_an_int(self):
for version in minecraft.SUPPORTED_PROTOCOL_VERSIONS:
self.assertTrue(type(version) is int)
self.assertTrue(isinstance(version, int))