From 3e00bb77b818b318f7de9b70724a1771f4d4344d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 7 Mar 2023 01:24:42 +0100 Subject: [PATCH] Fix some incompatibilities --- lihzahrd/enums/itemtype.py | 3 +++ lihzahrd/enums/walltype.py | 1 - lihzahrd/world.py | 42 +++++++++++++++++++++++--------------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lihzahrd/enums/itemtype.py b/lihzahrd/enums/itemtype.py index 3d522e4..2e47bd0 100644 --- a/lihzahrd/enums/itemtype.py +++ b/lihzahrd/enums/itemtype.py @@ -5508,6 +5508,9 @@ class ItemType(enum.IntEnum): RAINBOW_MOSS_BLOCK_WALL = 5450 JIMS_DRONE = 5451 JIMS_DRONE_VISOR = 5452 + DONT_HURT_CRITTERS_BOOK_INACTIVE = 5453 + DONT_HURT_NATURE_BOOK_INACTIVE = 5454 + DONT_HURT_COMBO_BOOK_INACTIVE = 5455 def __repr__(self): return f"{self.__class__.__name__}.{self.name}" diff --git a/lihzahrd/enums/walltype.py b/lihzahrd/enums/walltype.py index abfdbd0..59ccad9 100644 --- a/lihzahrd/enums/walltype.py +++ b/lihzahrd/enums/walltype.py @@ -353,6 +353,5 @@ class WallType(enum.IntEnum): VIOLET_MOSS_BLOCK_WALL = 345 RAINBOW_MOSS_BLOCK_WALL = 346 - def __repr__(self): return f"{self.__class__.__name__}.{self.name}" diff --git a/lihzahrd/world.py b/lihzahrd/world.py index 28adfbc..516be57 100644 --- a/lihzahrd/world.py +++ b/lihzahrd/world.py @@ -279,17 +279,16 @@ class World: flags4 = fr.bits() if has_flags4 else INT_TO_BITS_CACHE[0] has_block = flags1[1] - has_wall = flags1[2] - has_extended_block_id = flags1[5] - has_extended_wall_id = flags3[6] - - is_block_active = not flags3[2] is_block_painted = flags3[3] - is_wall_painted = flags3[4] + is_block_active = not flags3[2] is_block_echo = flags4[1] - is_wall_echo = flags4[2] is_block_illuminant = flags4[3] + + has_wall = flags1[2] + has_extended_wall_id = flags3[6] + is_wall_painted = flags3[4] + is_wall_echo = flags4[2] is_wall_illuminant = flags4[4] liquid_type = LiquidType.from_flags(flags1, flags3) @@ -325,14 +324,29 @@ class World: # Parse wall if has_wall: - if has_extended_wall_id: - wall_type = WallType(fr.uint2()) - else: - wall_type = WallType(fr.uint1()) + wall_type_l = fr.uint1() if is_wall_painted: wall_paint = fr.uint1() else: wall_paint = None + else: + wall_type_l = 0 + wall_paint = None + + # Parse liquid + if liquid_type != LiquidType.NO_LIQUID: + liquid = Liquid(type_=liquid_type, volume=fr.uint1()) + else: + liquid = None + + # Parse wall, again + if has_extended_wall_id: + wall_type_g = fr.uint1() + else: + wall_type_g = 0 + + if has_wall: + wall_type = WallType(wall_type_g * 256 + wall_type_l) wall = Wall( type_=wall_type, paint=wall_paint, @@ -342,12 +356,6 @@ class World: else: wall = None - # Parse liquid - if liquid_type != LiquidType.NO_LIQUID: - liquid = Liquid(type_=liquid_type, volume=fr.uint1()) - else: - liquid = None - # Find RLE Compression multiplier if rle_compression == RLEEncoding.DOUBLE_BYTE: multiply_by = fr.uint2() + 1