Port over custom packets and update to 1.16.2
This commit is contained in:
+38
-3
@@ -1,11 +1,12 @@
|
||||
from __future__ import division
|
||||
|
||||
from minecraft.networking.types.basic import Type, Byte, Short, Integer, Long, Float, Double, ShortPrefixedByteArray
|
||||
|
||||
import struct
|
||||
|
||||
from minecraft.networking.types.basic import (
|
||||
Type, Byte, Short, Integer, Long, Float, Double,
|
||||
ShortPrefixedByteArray, Boolean, VarInt, TrailingByteArray
|
||||
)
|
||||
from minecraft.networking.types.utility import Vector
|
||||
from minecraft.networking.types.basic import Type, Byte, Short, Integer, Long, Float, Double, ShortPrefixedByteArray
|
||||
|
||||
|
||||
class IntegerPrefixedByteArray(Type):
|
||||
@@ -19,6 +20,7 @@ class IntegerPrefixedByteArray(Type):
|
||||
Integer.send(len(value), socket)
|
||||
socket.send(value)
|
||||
|
||||
|
||||
TAG_End = 0
|
||||
TAG_Byte = 1
|
||||
TAG_Short = 2
|
||||
@@ -96,3 +98,36 @@ class Nbt(Type):
|
||||
def send(value, socket):
|
||||
# TODO
|
||||
pass
|
||||
|
||||
|
||||
class Slot(Type):
|
||||
def __init__(self, present, item_id, item_count, nbt):
|
||||
self.present = present
|
||||
self.item_id = item_id
|
||||
self.item_count = item_count
|
||||
self.nbt = nbt
|
||||
|
||||
def __str__(self):
|
||||
return str(self.__dict__)
|
||||
def __repr__(self):
|
||||
return 'Slot(present={}, item_id={}, item_count={}, nbt={}'.format(
|
||||
self.present, self.item_id, self.item_count, self.nbt)
|
||||
|
||||
@staticmethod
|
||||
def read(file_object):
|
||||
present = Boolean.read(file_object)
|
||||
item_id = VarInt.read(file_object) if present else None
|
||||
item_count = Byte.read(file_object) if present else None
|
||||
nbt = TrailingByteArray.read(file_object) if present else None
|
||||
return Slot(present, item_id, item_count, nbt)
|
||||
#a = {}
|
||||
#a['present'] = Boolean.read(file_object)
|
||||
#a['item_id'] = VarInt.read(file_object) if a['present'] else None
|
||||
#a['item_count'] = Byte.read(file_object) if a['present'] else None
|
||||
#a['nbt'] = TrailingByteArray.read(file_object) if a['present'] else None
|
||||
#return a
|
||||
|
||||
@staticmethod
|
||||
def send(value, socket):
|
||||
# TODO
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user