How to use the mcpi.nbt function in mcpi

To help you get started, we’ve selected a few mcpi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arpruss / raspberryjam-pe / p2 / scripts / import.py View on Github external
def importSchematic(mc,path,x0,y0,z0,centerX=False,centerY=False,centerZ=False,clear=False,movePlayer=True):
    mc.postToChat("Reading "+path);
    schematic = nbt.NBTFile(path, "rb")
    sizeX = schematic["Width"].value
    sizeY = schematic["Height"].value
    sizeZ = schematic["Length"].value

    def offset(x,y,z):
        return x + (y*sizeZ + z)*sizeX

    px,pz = x0,z0

    if centerX:
        x0 -= sizeX // 2
    if centerY:
        y0 -= sizeY // 2
    if centerZ:
        z0 -= sizeZ // 2
github arpruss / raspberryjam-pe / p3 / scripts / import.py View on Github external
def importSchematic(mc,path,x0,y0,z0,centerX=False,centerY=False,centerZ=False,clear=False,movePlayer=True):
    mc.postToChat("Reading "+path);
    schematic = nbt.NBTFile(path, "rb")
    sizeX = schematic["Width"].value
    sizeY = schematic["Height"].value
    sizeZ = schematic["Length"].value

    def offset(x,y,z):
        return x + (y*sizeZ + z)*sizeX

    px,pz = x0,z0

    if centerX:
        x0 -= sizeX // 2
    if centerY:
        y0 -= sizeY // 2
    if centerZ:
        z0 -= sizeZ // 2
github arpruss / raspberryjam-pe / p3 / scripts / import.py View on Github external
def getValue(v):
    if isinstance(v,nbt.TAG_Compound):
       return getCompound(v)
    elif isinstance(v,nbt.TAG_List):
       out = []
       for a in v:
           out.append(getValue(a))
       return out
    else:
       return v.value
github arpruss / raspberryjam-pe / p2 / scripts / import.py View on Github external
def getValue(v):
    if isinstance(v,nbt.TAG_Compound):
       return getCompound(v)
    elif isinstance(v,nbt.TAG_List):
       out = []
       for a in v:
           out.append(getValue(a))
       return out
    else:
       return v.value
github arpruss / raspberryjam-pe / p3 / scripts / import.py View on Github external
def getValue(v):
    if isinstance(v,nbt.TAG_Compound):
       return getCompound(v)
    elif isinstance(v,nbt.TAG_List):
       out = []
       for a in v:
           out.append(getValue(a))
       return out
    else:
       return v.value