diff --git a/custom/networking/packets/clientbound/play/chunk_data.py b/custom/networking/packets/clientbound/play/chunk_data.py index 6ec6157..6b634d5 100644 --- a/custom/networking/packets/clientbound/play/chunk_data.py +++ b/custom/networking/packets/clientbound/play/chunk_data.py @@ -6,7 +6,7 @@ from minecraft.networking.types import ( multi_attribute_alias, Vector, UnsignedLong ) -from ....types import nbt +from ....types.nbt import Nbt class ChunkDataPacket(Packet): id = 0x20 @@ -14,7 +14,6 @@ class ChunkDataPacket(Packet): fields = 'x', 'bit_mask_y', 'z', 'full_chunk' def read(self, file_object): - print('reading chunk') self.x = Integer.read(file_object) self.z = Integer.read(file_object) self.full_chunk = Boolean.read(file_object) @@ -24,13 +23,13 @@ class ChunkDataPacket(Packet): if self.full_chunk: biomes_length = VarInt.read(file_object) for i in range(biomes_length): - self.biomes.append(Integer.read(file_object)) + self.biomes.append(VarInt.read(file_object)) size = VarInt.read(file_object) self.data = file_object.read(size) size_entities = VarInt.read(file_object) self.entities = [] - for i in range(size_entities): - self.entities.append(Nbt.read(file_object)) + #for i in range(size_entities): + # self.entities.append(Nbt.read(file_object)) self.decode_chunk_data() @@ -101,13 +100,11 @@ class Chunk: self.blocks = [] mask = (1 << self.bpb)-1 + bits_used = int(64 / self.bpb) * self.bpb for i in range(4096): - l1 = int((i*self.bpb)/64) - offset = (i*self.bpb)%64 - l2 = int(((i+1)*self.bpb-1)/64) + l1 = int((i*self.bpb)/bits_used) + offset = (i*self.bpb)%bits_used n = longs[l1] >> offset - if l2>l1: - n |= longs[l2] << (64-offset) n &= mask if self.palette: n = self.palette[n]