fix: guess properly bitfield size

This commit is contained in:
əlemi 2023-03-13 22:57:54 +01:00
parent 49e85d47d1
commit 152dda2f2c
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 15 additions and 9 deletions

View file

@ -112,12 +112,12 @@ class PacketMultiBlockChange(Packet):
734 : [ ( 'chunkX', Int ), ( 'chunkZ', Int ), ( 'records', ArrayType(StructType(( 'horizontalPos', Byte ), ( 'y', Byte ), ( 'blockId', VarInt ), ), VarInt, ) ) ],
735 : [ ( 'chunkX', Int ), ( 'chunkZ', Int ), ( 'records', ArrayType(StructType(( 'horizontalPos', Byte ), ( 'y', Byte ), ( 'blockId', VarInt ), ), VarInt, ) ) ],
736 : [ ( 'chunkX', Int ), ( 'chunkZ', Int ), ( 'records', ArrayType(StructType(( 'horizontalPos', Byte ), ( 'y', Byte ), ( 'blockId', VarInt ), ), VarInt, ) ) ],
751 : [ ( 'chunkCoordinates', Int ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
755 : [ ( 'chunkCoordinates', Int ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
756 : [ ( 'chunkCoordinates', Int ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
757 : [ ( 'chunkCoordinates', Int ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
758 : [ ( 'chunkCoordinates', Int ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
759 : [ ( 'chunkCoordinates', Int ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(VarInt, VarInt, ) ) ],
760 : [ ( 'chunkCoordinates', Int ), ( 'suppressLightUpdates', Boolean ), ( 'records', ArrayType(VarInt, VarInt, ) ) ],
761 : [ ( 'chunkCoordinates', Int ), ( 'suppressLightUpdates', Boolean ), ( 'records', ArrayType(VarInt, VarInt, ) ) ]
751 : [ ( 'chunkCoordinates', Long ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
755 : [ ( 'chunkCoordinates', Long ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
756 : [ ( 'chunkCoordinates', Long ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
757 : [ ( 'chunkCoordinates', Long ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
758 : [ ( 'chunkCoordinates', Long ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(TrailingData, VarInt, ) ) ],
759 : [ ( 'chunkCoordinates', Long ), ( 'notTrustEdges', Boolean ), ( 'records', ArrayType(VarInt, VarInt, ) ) ],
760 : [ ( 'chunkCoordinates', Long ), ( 'suppressLightUpdates', Boolean ), ( 'records', ArrayType(VarInt, VarInt, ) ) ],
761 : [ ( 'chunkCoordinates', Long ), ( 'suppressLightUpdates', Boolean ), ( 'records', ArrayType(VarInt, VarInt, ) ) ]
}

View file

@ -162,7 +162,13 @@ def mctype(slot_type:Any) -> Ref:
mctype(v["default"]) if "default" in v and v['default'] != 'void' else None,
)
elif t == "bitfield":
return Ref('Int') # TODO
# TODO can be made better...
size = 0
for field in v:
size += field["size"]
if size <= 32:
return Ref('Int')
return Ref('Long')
# elif t == "mapper": # ????
# return TrailingData
else: