return None return self[slot] class DrawerInventoryAttr(nbtattr.NBTCompoundListAttr): def __init__(self, name="Slots"): super(DrawerInventoryAttr, self).__init__(name, DrawerItemStackRef) self.listProxyClass = DrawerSlotsListProxy class StorageDrawerRef(PCTileEntityRefBase): Slots = DrawerInventoryAttr() def __init__(self, rootTag, chunk=None): super(StorageDrawerRef, self).__init__(rootTag, chunk) DRAWERS4_SLOT_LAYOUT = [(s % 2, s // 2, s) for s in range(4)] DRAWERS2_SLOT_LAYOUT = [(s, 0, s) for s in range(2)] DRAWERS1_SLOT_LAYOUT = [(1, 0, 0)] class StorageDrawers4EditorWidget(GenericContainerEditorWidget): tileEntityID = "StorageDrawers:halfDrawers4" def __init__(self, editorSession, tileEntityRef): super(StorageDrawers4EditorWidget, self).__init__("StorageDrawers:halfDrawers4", DRAWERS4_SLOT_LAYOUT, editorSession, tileEntityRef) def getItemsRef(self): return self.tileEntityRef.Slots registerTileEntityRefClass("StorageDrawers:halfDrawers4", StorageDrawerRef) registerBlockInspectorWidget(StorageDrawers4EditorWidget)
def getItemInSlot(self, slot): if slot >= len(self): return None return self[slot] class DrawerInventoryAttr(nbtattr.NBTCompoundListAttr): def __init__(self, name="Slots"): super(DrawerInventoryAttr, self).__init__(name, DrawerItemStackRef) self.listProxyClass = DrawerSlotsListProxy class StorageDrawerRef(PCTileEntityRefBase): Slots = DrawerInventoryAttr() def __init__(self, rootTag, chunk=None): super(StorageDrawerRef, self).__init__(rootTag, chunk) DRAWERS4_SLOT_LAYOUT = [(s % 2, s // 2, s) for s in range(4)] DRAWERS2_SLOT_LAYOUT = [(s, 0, s) for s in range(2)] DRAWERS1_SLOT_LAYOUT = [(1, 0, 0)] class StorageDrawers4EditorWidget(GenericContainerEditorWidget): def __init__(self, editorSession, tileEntityRef): super(StorageDrawers4EditorWidget, self).__init__("StorageDrawers:halfDrawers4", DRAWERS4_SLOT_LAYOUT, editorSession, tileEntityRef) def getItemsRef(self): return self.tileEntityRef.Slots registerTileEntityRefClass("StorageDrawers:halfDrawers4", StorageDrawerRef) registerBlockInspectorWidget("StorageDrawers:halfDrawers4", StorageDrawers4EditorWidget)