mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-25 03:35:29 +01:00
Fix: MultiBlockChangePacket.ChunkSectionPos reads/writes incorrectly
This commit is contained in:
parent
cf93923acc
commit
f37feeca18
@ -1,7 +1,7 @@
|
|||||||
from minecraft.networking.packets import Packet
|
from minecraft.networking.packets import Packet
|
||||||
from minecraft.networking.types import (
|
from minecraft.networking.types import (
|
||||||
Type, VarInt, VarLong, Long, Integer, UnsignedByte, Position, Vector,
|
Type, VarInt, VarLong, UnsignedLong, Integer, UnsignedByte, Position,
|
||||||
MutableRecord, PrefixedArray, Boolean, attribute_alias,
|
Vector, MutableRecord, PrefixedArray, Boolean, attribute_alias,
|
||||||
multi_attribute_alias,
|
multi_attribute_alias,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -63,17 +63,19 @@ class MultiBlockChangePacket(Packet):
|
|||||||
class ChunkSectionPos(Vector, Type):
|
class ChunkSectionPos(Vector, Type):
|
||||||
@classmethod
|
@classmethod
|
||||||
def read(cls, file_object):
|
def read(cls, file_object):
|
||||||
value = Long.read(file_object)
|
value = UnsignedLong.read(file_object)
|
||||||
x = value >> 42
|
y = value | ~0xFFFFF if value & 0x80000 else value & 0xFFFFF
|
||||||
z = (value >> 20) & 0x3FFFFF
|
value >>= 20
|
||||||
y = value & 0xFFFFF
|
z = value | ~0x3FFFFF if value & 0x200000 else value & 0x3FFFFF
|
||||||
|
value >>= 22
|
||||||
|
x = value | ~0x3FFFFF if value & 0x200000 else value
|
||||||
return cls(x, y, z)
|
return cls(x, y, z)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def send(cls, pos, socket):
|
def send(cls, pos, socket):
|
||||||
x, y, z = pos
|
x, y, z = pos
|
||||||
value = (x & 0x3FFFFF) << 42 | (z & 0x3FFFFF) << 20 | y & 0xFFFFF
|
value = (x & 0x3FFFFF) << 42 | (z & 0x3FFFFF) << 20 | y & 0xFFFFF
|
||||||
Long.send(value, socket)
|
UnsignedLong.send(value, socket)
|
||||||
|
|
||||||
class Record(MutableRecord, Type):
|
class Record(MutableRecord, Type):
|
||||||
__slots__ = 'x', 'y', 'z', 'block_state_id'
|
__slots__ = 'x', 'y', 'z', 'block_state_id'
|
||||||
|
@ -7,6 +7,9 @@ from minecraft.networking.types import (
|
|||||||
ShortPrefixedByteArray, VarIntPrefixedByteArray, UUID,
|
ShortPrefixedByteArray, VarIntPrefixedByteArray, UUID,
|
||||||
String as StringType, Position, TrailingByteArray, UnsignedLong,
|
String as StringType, Position, TrailingByteArray, UnsignedLong,
|
||||||
)
|
)
|
||||||
|
from minecraft.networking.packets.clientbound.play import (
|
||||||
|
MultiBlockChangePacket
|
||||||
|
)
|
||||||
from minecraft.networking.packets import PacketBuffer
|
from minecraft.networking.packets import PacketBuffer
|
||||||
from minecraft.networking.connection import ConnectionContext
|
from minecraft.networking.connection import ConnectionContext
|
||||||
from minecraft import SUPPORTED_PROTOCOL_VERSIONS, RELEASE_PROTOCOL_VERSIONS
|
from minecraft import SUPPORTED_PROTOCOL_VERSIONS, RELEASE_PROTOCOL_VERSIONS
|
||||||
@ -36,6 +39,12 @@ TEST_DATA = {
|
|||||||
UUID: ["12345678-1234-5678-1234-567812345678"],
|
UUID: ["12345678-1234-5678-1234-567812345678"],
|
||||||
StringType: ["hello world"],
|
StringType: ["hello world"],
|
||||||
Position: [(758, 0, 691), (-500, -12, -684)],
|
Position: [(758, 0, 691), (-500, -12, -684)],
|
||||||
|
MultiBlockChangePacket.ChunkSectionPos: [
|
||||||
|
(x, y, z)
|
||||||
|
for x in [-0x200000, -123, -1, 0, 123, 0x1FFFFF]
|
||||||
|
for z in [-0x200000, -456, -1, 0, 456, 0x1FFFFF]
|
||||||
|
for y in [-0x80000, -789, -1, 0, 789, 0x7FFFF]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user