diff --git a/lihzahrd/chests/__init__.py b/lihzahrd/chests/__init__.py index cd02a02..9f5531d 100644 --- a/lihzahrd/chests/__init__.py +++ b/lihzahrd/chests/__init__.py @@ -1,5 +1,6 @@ from .itemtype import ItemType from .itemstack import ItemStack from .chest import Chest +from .mannequin import Mannequin -__all__ = ["ItemType", "ItemStack", "Chest"] +__all__ = ["ItemType", "ItemStack", "Chest", "Mannequin"] diff --git a/lihzahrd/chests/mannequin.py b/lihzahrd/chests/mannequin.py new file mode 100755 index 0000000..59fdf67 --- /dev/null +++ b/lihzahrd/chests/mannequin.py @@ -0,0 +1,26 @@ +import typing +from .itemstack import ItemStack + +class Mannequin: + """Data pertaining to a Logic Sensor (https://terraria.gamepedia.com/Mannequin).""" + + __slots__ = "item_flags", "dye_flags", "wearing_items", "wearing_dyes" + + def __init__(self, + item_flags: typing.List[bool], + dye_flags: typing.List[bool], + wearing_items: typing.List[ItemStack], + wearing_dyes: typing.List[ItemStack],): + + self.item_flags: typing.List[bool] = item_flags + """Which slots have items in them.""" + self.dye_flags: typing.List[bool] = dye_flags + """Which slots have dyes in them.""" + self.wearing_items: typing.List[ItemStack] = wearing_items + """What items is the mannequin wearing.""" + self.wearing_dyes: typing.List[ItemStack] = wearing_dyes + """What dyes is the mannequin wearing.""" + + + def __repr__(self): + return f"Mannequin()" diff --git a/lihzahrd/world.py b/lihzahrd/world.py index b8577ae..dac14b4 100644 --- a/lihzahrd/world.py +++ b/lihzahrd/world.py @@ -728,16 +728,40 @@ class World: te_type = f.uint1() te_id = f.int4() te_position = Coordinates(f.int2(), f.int2()) + # Target Dummy if te_type == 0: te_extra = TargetDummy(npc=f.int2()) + # Item Frame elif te_type == 1: te_extra = ItemFrame(item=ItemStack(type_=ItemType(f.int2()), modifier=f.uint1(), quantity=f.int2())) + # Logic Sensor elif te_type == 2: te_extra = LogicSensor(logic_check=f.uint1(), enabled=f.bool()) + # Mannequin + elif te_type == 3: + item_flags = f.bits() + dye_flags = f.bits() + mannequin_items = [None for _ in range(len(item_flags))] + mannequin_dyes = [None for _ in range(len(dye_flags))] + for slot in range(len(item_flags)): + if item_flags[slot]: + slot_item_id = ItemType(f.int2()) + slot_item_modifier = f.int1() + slot_item_stack = f.int2() + mannequin_items[slot] = ItemStack(slot_item_id, slot_item_modifier, slot_item_stack) + for slot in range(len(mannequin_dyes)): + if dye_flags[slot]: + slot_item_id = ItemType(f.int2()) + slot_item_modifier = f.int1() + slot_item_stack = f.int2() + mannequin_dyes[slot] = ItemStack(slot_item_id, slot_item_modifier, slot_item_stack) + te_extra = Mannequin(item_flags, dye_flags, mannequin_items, mannequin_dyes) else: - te_extra = ... + print(f"te_type:", te_type) + te_extra = None + tile_entity = TileEntity(id_=te_id, position=te_position, extra=te_extra) tile_entities.append(tile_entity) tm[tile_entity.position].extra = tile_entity