Example #1
0
def registerTileEntityRefClass(ID, cls):
    """
    Register a TileEntityRef class with the world loader to create when loading a TileEntity
    with the given ID.

    xxx specify world format here, too.

    >>> from mceditlib.anvil.entities import PCTileEntityRefBase
    >>> class MyBarrelRef(PCTileEntityRefBase):
    >>>     pass
    >>> registerTileEntityRefClass("MyBarrel", MyBarrelRef)

    :param cls:
    :type cls:
    :return:
    :rtype:
    """
    # xxx this is anvil.entities - delegate to correct world format
    return entities.registerTileEntityRefClass(ID, cls)
Example #2
0
def registerTileEntityRefClass(ID, cls):
    """
    Register a TileEntityRef class with the world loader to create when loading a TileEntity
    with the given ID.

    xxx specify world format here, too.

    >>> from mceditlib.anvil.entities import PCTileEntityRefBase
    >>> class MyBarrelRef(PCTileEntityRefBase):
    >>>     pass
    >>> registerTileEntityRefClass("MyBarrel", MyBarrelRef)

    :param cls:
    :type cls:
    :return:
    :rtype:
    """
    # xxx this is anvil.entities - delegate to correct world format
    _registerClass(cls)
    return entities.registerTileEntityRefClass(ID, cls)
Example #3
0
            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)