Exemplo n.º 1
0
def createEndGateway(level, options, block_ids, block_datas):

    for key in bk:
        chunk = level.getChunk(bk[key]["x"] / 16, bk[key]["z"] / 16)

        e = TAG_Compound()

        e["ExactTeleport"] = TAG_Byte(options["ExactTeleport: "])

        e["x"] = TAG_Int(bk[key]["x"])
        e["y"] = TAG_Int(bk[key]["y"])
        e["z"] = TAG_Int(bk[key]["z"])

        ep = TAG_Compound()
        ep["X"] = TAG_Int(tp.get("x"))
        ep["Y"] = TAG_Int(tp.get("y"))
        ep["Z"] = TAG_Int(tp.get("z"))
        e["ExitPortal"] = ep

        if options["1.11+: "]:
            e["id"] = TAG_String("minecraft:end_gateway")

        else:
            e["id"] = TAG_String("EndGateway")

        e["Age"] = TAG_Long(9223372036854775807)

        if options["Invisible Teleporter: "]:
            setBlock(level, (36, 0), bk[key]["x"], bk[key]["y"], bk[key]["z"])

        else:
            setBlock(level, (block_ids, block_datas), bk[key]["x"],
                     bk[key]["y"], bk[key]["z"])

        chunk.TileEntities.append(e)
Exemplo n.º 2
0
def createChestBlockData(x, y, z, blockID, maxData):
	e = TAG_Compound()
	e["x"] = TAG_Int(x)
	e["y"] = TAG_Int(y)
	e["z"] = TAG_Int(z)
	e["TileX"] = TAG_Int(x)
	e["TileY"] = TAG_Int(y)
	e["TileZ"] = TAG_Int(z)
	e["id"] = TAG_String("Chest")
	e["Lock"] = TAG_String("")
	e["Items"] = TAG_List()
	# TileEntity.setpos(e, (x, y, z))
	# Item access below modified from @Texelelf's MapIt filter
	item = TAG_Compound()
	item["id"] = TAG_String(names[blockID])
	item["Count"] = TAG_Byte(64)
	item["Damage"] = TAG_Short(0)
	item["Slot"] = TAG_Byte(0)
	if blockID in names:
		for blockData in xrange(0,maxData):
			newitem = deepcopy(item)
			newitem["Slot"] = TAG_Byte(blockData)
			newitem["Damage"] = TAG_Short(blockData)
			e["Items"].append(newitem)
	return e
Exemplo n.º 3
0
def testSign():
    usign = USIGN(["Line 1", "Line 2", "Line 3", "Line 4"],
                  (1, 2, 3))  # Canonical
    javasign = usign.toNative("UNKNOWN", "1_12")
    bedrocksign = usign.toNative("PE", "1_2")

    # Java format example
    control = TAG_Compound()
    control["id"] = TAG_String("minecraft:sign")
    control["Text1"] = TAG_String("Text1")
    control["Text2"] = TAG_String("Text2")
    control["Text3"] = TAG_String("Text3")
    control["Text4"] = TAG_String("Text4")
    control["x"] = TAG_Int(111)
    control["y"] = TAG_Int(2222)
    control["z"] = TAG_Int(33333)
    usignFromJava = usign.toCanonical(control, "UNKNOWN", "1_12")
    usignFromJava2 = usign.toCanonical(javasign, "UNKNOWN", "1_12")

    # Bedrock format example
    control = TAG_Compound()
    control["id"] = TAG_String("Sign")
    control["Text"] = TAG_String("Text1\nText2\nText3\nText4")
    control["isMovable"] = TAG_Int(1)
    control["x"] = TAG_Int(111111)
    control["y"] = TAG_Int(22222)
    control["z"] = TAG_Int(3333)
    usignFromBedrock = usign.toCanonical(control, "PE", "1_2")

    #	bedrocksign = usign.toCanonical("BEDROCK","1_2")

    print usign, "\n", javasign, "\n", bedrocksign, "\n", usignFromJava, "\n", usignFromJava2, "\n", usignFromBedrock
Exemplo n.º 4
0
def item_stack(item):
    item_tag = TAG_Compound()
    item_tag.name = 'tag'
    item_tag['id'] = TAG_Short(item['id'])
    item_tag['Damage'] = TAG_Short(item['damage'])
    item_tag['Count'] = TAG_Byte(item['count'])
    item_tag['Slot'] = TAG_Byte(item['slot'])
    return item_tag
Exemplo n.º 5
0
def item_stack(item):
    item_tag = TAG_Compound()
    item_tag.name = 'tag'
    item_tag['id'] = TAG_Short(item['id'])
    item_tag['Damage'] = TAG_Short(item['damage'])
    item_tag['Count'] = TAG_Byte(item['count'])
    item_tag['Slot'] = TAG_Byte(item['slot'])
    return item_tag
Exemplo n.º 6
0
def toNative(
        canonical):  # Version specific mapping to NBT from universal class
    # Data transformation, and any validation
    associations = updateAssociations()
    position = canonical.position
    customname = canonical.customname
    lock = canonical.lock
    items = canonical.items  # list of items, which includes lists of lore and enchants
    loottable = canonical.loottable
    loottableseed = canonical.loottableseed
    id = getNativeID()
    (x, y, z) = canonical.position

    # Create native-compatible NBT and return it
    control = TAG_Compound()
    control["id"] = TAG_String(id)
    control["CustomName"] = TAG_String(customname)
    if lock != "": control["Lock"] = TAG_String(lock)
    if loottable != "":
        control["LootTable"] = TAG_String(loottable)
        control["LootTableSeed"] = TAG_Long(loottableseed)
    control["x"] = TAG_Int(x)
    control["y"] = TAG_Int(y)
    control["z"] = TAG_Int(z)
    control["Items"] = TAG_List()
    itemsTag = control["Items"]
    for (item_id, item_damage, item_slot, item_count, item_display_name,
         item_display_lore_l, item_tag_ench_l, item_potion) in items:
        item = TAG_Compound()
        item["id"] = TAG_Short(int(itemNameToNumber(item_id, associations)))
        item["Damage"] = TAG_Short(item_damage)
        item["Count"] = TAG_Byte(item_count)
        item["Slot"] = TAG_Byte(item_slot)
        if len(item_tag_ench_l) > 0 or item_display_name != "" or len(
                item_display_lore_l) > 0 or item_potion != "":
            item["tag"] = TAG_Compound()
            tag = item["tag"]
            if len(item_tag_ench_l) > 0:
                tag["ench"] = TAG_List()
                ench = tag["ench"]
                for (ench_id, ench_lvl) in item_tag_ench_l:
                    theEnch = TAG_Compound()
                    theEnch["id"] = TAG_Short(ench_id)
                    theEnch["lvl"] = TAG_Short(ench_lvl)
                    ench.append(theEnch)
            if len(item_display_name) != "":
                tag["display"] = TAG_Compound()
                display = tag["display"]
                display["Name"] = TAG_String(item_display_name)
            if len(item_display_lore_l) > 0:
                display["Lore"] = TAG_List()
                for lore in item_display_lore_l:
                    display["Lore"].append(TAG_String(lore))
            if item_potion != "":
                tag["Potion"] = TAG_String(item_potion)
        itemsTag.append(item)
    control["isMovable"] = TAG_Byte(1)
    return control
Exemplo n.º 7
0
def CreateItemFrame(x, y, z, dir, blockID, invuln):
	TileY = y
	posy = float(y) + 0.5
	if dir == 1:
		direction = dir
		rotation = 90.0
		TileX = x + 1
		TileZ = z
		posx = float(x) + 0.9375
		posz = float(z) + 0.5
	elif dir == 3:
		rotation = 270.0
		direction = dir
		TileX = x - 1
		TileZ = z
		posx = float(x) + 0.0625
		posz = float(z) + 0.5
	elif dir == 0:
		rotation = 0.0
		direction = 2
		TileZ = z + 1
		TileX = x
		posz = float(z) + 0.9375
		posx = float(x) + 0.5
	elif dir == 2:
		rotation = 180.0
		direction = 0
		TileZ = z - 1
		TileX = x
		posz = float(z) + 0.0625
		posx = float(x) + 0.5
	iframe = TAG_Compound()
	iframe["id"] = TAG_String("ItemFrame")
	iframe["Pos"] = TAG_List()
	iframe["Pos"].append(TAG_Double(posx))
	iframe["Pos"].append(TAG_Double(posy))
	iframe["Pos"].append(TAG_Double(posz))
	iframe["Facing"] = TAG_Byte(dir)
	iframe["Dir"] = TAG_Byte(dir)
	iframe["Direction"] = TAG_Byte(direction)
	iframe["Facing"] = TAG_Byte(direction)  #new tag here
	iframe["Invulnerable"] = TAG_Byte(invuln)
	iframe["Motion"] = TAG_List()
	iframe["Motion"].append(TAG_Double(0.0))
	iframe["Motion"].append(TAG_Double(0.0))
	iframe["Motion"].append(TAG_Double(0.0))
	iframe["TileX"] = TAG_Int(TileX)
	iframe["TileY"] = TAG_Int(TileY)
	iframe["TileZ"] = TAG_Int(TileZ)
	iframe["Rotation"] = TAG_List()
	iframe["Rotation"].append(TAG_Float(rotation))
	iframe["Rotation"].append(TAG_Float(0.0))
	iframe["Item"] = TAG_Compound()
	iframe["Item"]["id"] = TAG_String(names[blockID])
	iframe["Item"]["Damage"] = TAG_Short(0)
	iframe["Item"]["Count"] = TAG_Byte(1)
	return iframe	
Exemplo n.º 8
0
 def __repeater_tile_tick(level, x, y, z, powered):
     string_id = '{}powered_repeater'.format('' if powered else 'un')
     tile_tick = TAG_Compound()
     tile_tick.add(TAG_Int(-1, 'p'))
     tile_tick.add(TAG_Int(10, 't'))
     tile_tick.add(TAG_Int(x, 'x'))
     tile_tick.add(TAG_Int(y, 'y'))
     tile_tick.add(TAG_Int(z, 'z'))
     tile_tick.add(TAG_String(string_id, 'i'))
     level.addTileTick(tile_tick)
Exemplo n.º 9
0
def CreateItemFrameJava(x, y, z, dir, mapid, invuln):
    TileY = y
    posy = float(y) + 0.5
    if dir == 1:  #westward
        direction = dir
        rotation = 90.0
        TileX = x
        TileZ = z
        posx = float(x) + 0.96875
        posz = float(z) + 0.5
    elif dir == 3:  #eastward
        rotation = 270.0
        direction = dir
        TileX = x
        TileZ = z
        posx = float(x) + 0.03125
        posz = float(z) + 0.5
    elif dir == 0:  #northward
        rotation = 180.0
        direction = 2
        TileZ = z
        TileX = x
        posz = float(z) + 0.96875
        posx = float(x) + 0.5
    elif dir == 2:  #southward
        rotation = 0.0
        direction = 0
        TileZ = z
        TileX = x
        posz = float(z) + 0.03125
        posx = float(x) + 0.5
    iframe = TAG_Compound()
    iframe["id"] = TAG_String("item_frame")
    iframe["Pos"] = TAG_List()
    iframe["Pos"].append(TAG_Double(posx))
    iframe["Pos"].append(TAG_Double(posy))
    iframe["Pos"].append(TAG_Double(posz))
    iframe["Facing"] = TAG_Byte(direction)
    iframe["Invulnerable"] = TAG_Byte(invuln)
    iframe["Motion"] = TAG_List()
    iframe["Motion"].append(TAG_Double(0.0))
    iframe["Motion"].append(TAG_Double(0.0))
    iframe["Motion"].append(TAG_Double(0.0))
    iframe["TileX"] = TAG_Int(TileX)
    iframe["TileY"] = TAG_Int(TileY)
    iframe["TileZ"] = TAG_Int(TileZ)
    iframe["Rotation"] = TAG_List()
    iframe["Rotation"].append(TAG_Float(rotation))
    iframe["Rotation"].append(TAG_Float(0.0))
    iframe["Item"] = TAG_Compound()
    iframe["Item"]["id"] = TAG_String("minecraft:filled_map")
    iframe["Item"]["Damage"] = TAG_Short(mapid)
    iframe["Item"]["Count"] = TAG_Byte(1)
    return iframe
Exemplo n.º 10
0
def perform(level, box, options):
    print "Follow Me On Twitter At @RedstonerLabs"
    ShowBottoms = options["ShowBottom"]
    Invun = options["Invulnerable"]
    target1 = options["Y"]
    target2 = options["X"]
    target3 = options["Z"]
    for x in xrange(box.minx, box.maxx):
        for y in xrange(box.miny, box.maxy):
            for z in xrange(box.minz, box.maxz):
                chunk = level.getChunk(x / 16, z / 16)
                enderCrystal = TAG_Compound()
                pos = TAG_List()
                pos.append(TAG_Double(x + 0.5))
                pos.append(TAG_Double(y))
                pos.append(TAG_Double(z + 0.5))
                enderCrystal["Pos"] = pos
                if options["1.11-1.12+Worlds"]:
                    enderCrystal["id"] = TAG_String(u'ender_crystal')
                else:
                    enderCrystal["id"] = TAG_String(u'EnderCrystal')

                if options["Offset X,Y,Z Coordinates"]:
                    beamTarget = TAG_Compound()
                    beamTarget["X"] = TAG_Int(x + target2)
                    beamTarget["Y"] = TAG_Int(y + target1)
                    beamTarget["Z"] = TAG_Int(z + target3)
                    enderCrystal["BeamTarget"] = beamTarget
                else:
                    beamTarget = TAG_Compound()
                    beamTarget["X"] = TAG_Int(target2)
                    beamTarget["Y"] = TAG_Int(target1)
                    beamTarget["Z"] = TAG_Int(target3)
                    enderCrystal["BeamTarget"] = beamTarget

                enderCrystal["OnGround"] = TAG_Byte(0)
                motion = TAG_List()
                motion.append(TAG_Double(0.0))
                motion.append(TAG_Double(0.0))
                motion.append(TAG_Double(0.0))
                enderCrystal["Motion"] = motion
                enderCrystal["Dimension"] = TAG_Int(0)
                enderCrystal["Air"] = TAG_Short(300)
                rotation = TAG_List()
                rotation.append(TAG_Float(0.0))
                rotation.append(TAG_Float(0.0))
                enderCrystal["Rotation"] = rotation
                enderCrystal["FallDistance"] = TAG_Float(0.0)
                enderCrystal["Fire"] = TAG_Short(0)
                enderCrystal["Invulnerable"] = TAG_Byte(Invun)
                enderCrystal["PortalCooldown"] = TAG_Int(0)
                enderCrystal["Glowing"] = TAG_Byte(0)
                enderCrystal["ShowBottom"] = TAG_Byte(ShowBottoms)
                chunk.Entities.append(enderCrystal)
Exemplo n.º 11
0
def CreateNewMapFileJava(path, number, colors):
    map = TAG_Compound()
    map["data"] = TAG_Compound()
    map["data"]["scale"] = TAG_Byte(4)
    map["data"]["dimension"] = TAG_Byte(0)
    map["data"]["height"] = TAG_Short(128)
    map["data"]["width"] = TAG_Short(128)
    map["data"]["xCenter"] = TAG_Int(2147483647)
    map["data"]["yCenter"] = TAG_Int(2147483647)
    map["data"]["colors"] = TAG_Byte_Array(colors)
    map.save(os.path.join(path, "map_" + str(number) + ".dat"))
Exemplo n.º 12
0
def CreateItemFramePE(x, y, z, mapid):
    iframe = TAG_Compound()
    iframe["id"] = TAG_String("ItemFrame")
    iframe["x"] = TAG_Int(x)
    iframe["y"] = TAG_Int(y)
    iframe["z"] = TAG_Int(z)
    iframe["Item"] = TAG_Compound()
    iframe["Item"]["id"] = TAG_Short(358)
    iframe["Item"]["Damage"] = TAG_Short(0)
    iframe["Item"]["Count"] = TAG_Byte(1)
    iframe["Item"]["tag"] = TAG_Compound()
    iframe["Item"]["tag"]["map_uuid"] = TAG_Long(mapid)
    return iframe
Exemplo n.º 13
0
def signed_book(title='', pages=[''], author='Skyblock CE'):
    book_tag = TAG_Compound()
    book_tag.name = 'tag'
    book_tag['title'] = title
    book_tag['author'] = author
    book_tag['pages'] = TAG_List(name='pages', list_type=TAG_String)
    for page in pages:
        book_tag['pages'].append(TAG_String(page))
    item_tag = TAG_Compound()
    item_tag['id'] = TAG_Short(items.names['Written Book'])
    item_tag['Damage'] = TAG_Byte(0)
    item_tag['Count'] = TAG_Byte(1)
    item_tag['tag'] = book_tag
    return item_tag
Exemplo n.º 14
0
def signed_book(title='', pages=[''], author='Skyblock CE'):
    book_tag = TAG_Compound()
    book_tag.name = 'tag'
    book_tag['title'] = title
    book_tag['author'] = author
    book_tag['pages'] = TAG_List(name='pages', list_type=TAG_String)
    for page in pages:
        book_tag['pages'].append(TAG_String(page))
    item_tag = TAG_Compound()
    item_tag['id'] = TAG_Short(items.names['Written Book'])
    item_tag['Damage'] = TAG_Byte(0)
    item_tag['Count'] = TAG_Byte(1)
    item_tag['tag'] = book_tag
    return item_tag
def createChest(blockData,count,canPlaceOn,chest,level):
	newte = TileEntity.Create("Chest")
	slot = 0
	for i in blockData:		
		if count[i] > 64:
			icount = 1
			iterCount = math.ceil(count[i]/64.0)
			rcount = count[i] % 64				
			while icount <= iterCount:
				if icount == iterCount:
					item= TAG_Compound()
					item["CanPlaceOn"] = TAG_List()
					item["id"] = TAG_Short(i[0])
					item["Damage"] = TAG_Short(i[1])
					item["Count"] = TAG_Byte(rcount)					
					item["Slot"] = TAG_Byte(int(slot))
					item["CanPlaceOn"] = [TAG_String(canPlaceOn)]
					newte["Items"].append(item)
					slot += 1
				else:
					item= TAG_Compound()
					item["CanPlaceOn"] = TAG_List()
					item["id"] = TAG_Short(i[0])
					item["Damage"] = TAG_Short(i[1])
					item["Damage"] = TAG_Short(i[1])
					item["Count"] = TAG_Byte(64)					
					item["Slot"] = TAG_Byte(int(slot))
					item["CanPlaceOn"] = [TAG_String(canPlaceOn)]
					newte["Items"].append(item)
					slot += 1
				icount += 1
		else:
			item= TAG_Compound()
			item["CanPlaceOn"] = TAG_List()
			item["id"] = TAG_Short(i[0])
			item["Damage"] = TAG_Short(i[1])
			item["Count"] = TAG_Byte(count[i])
			item["Slot"] = TAG_Byte(int(slot))
			item["CanPlaceOn"] = [TAG_String(canPlaceOn)]
			newte["Items"].append(item)
			slot += 1		
		
	print(chest)
	newte['x'] = TAG_Int(chest[0])
	newte['y'] = TAG_Int(chest[1])
	newte['z'] = TAG_Int(chest[2])
	return newte
	
	
def createArmorStand(level, x, y, z, customName, Invisible, CustomNameVisible,
                     Invulnerable, Marker, NoGravity, MotionX, MotionY,
                     MotionZ, RotationX, RotationY):  # After @Sethbling
    print("New ArmorStand named " + customName)

    mob = TAG_Compound()
    mob["CustomName"] = TAG_String(customName)
    mob["Invisible"] = TAG_Byte(Invisible)
    mob["CustomNameVisible"] = TAG_Byte(CustomNameVisible)
    mob["Invulnerable"] = TAG_Byte(Invulnerable)
    mob["Marker"] = TAG_Byte(Marker)
    mob["NoGravity"] = TAG_Byte(NoGravity)
    mob["OnGround"] = TAG_Byte(1)
    mob["Air"] = TAG_Short(300)
    mob["DeathTime"] = TAG_Short(0)
    mob["Fire"] = TAG_Short(-1)
    mob["Health"] = TAG_Short(20)
    mob["HurtTime"] = TAG_Short(0)
    mob["Age"] = TAG_Int(0)
    mob["FallDistance"] = TAG_Float(0)
    mob["Motion"] = TAG_List()
    mob["Motion"].append(TAG_Double(MotionX))
    mob["Motion"].append(TAG_Double(MotionY))
    mob["Motion"].append(TAG_Double(MotionZ))
    mob["Pos"] = TAG_List()
    mob["Pos"].append(TAG_Double(x + 0.5))
    mob["Pos"].append(TAG_Double(y))
    mob["Pos"].append(TAG_Double(z + 0.5))
    mob["Rotation"] = TAG_List()
    mob["Rotation"].append(TAG_Float(RotationX))
    mob["Rotation"].append(TAG_Float(RotationY))
    mob["id"] = TAG_String("ArmorStand")
    chunk = level.getChunk(x / CHUNKSIZE, z / CHUNKSIZE)
    chunk.Entities.append(mob)
    chunk.dirty = True
Exemplo n.º 17
0
def perform(level, box, options):

    # Pre-condition: fill a selection box in MCEdit with south facing Chests (block 54). This filter does not verify the block type and assumes it is a container

    # Add items to the chests
    for (chunk, _, _) in level.getChunkSlices(box):
        for e in chunk.TileEntities:  # Loop through all the block entities in this chunk
            x = e["x"].value
            y = e["y"].value
            z = e["z"].value
            if (
                    x, y, z
            ) in box:  # Only process the entities within the selection, ignore malformed entries
                # print e["id"],level.blockAt(x,y,z)
                # print fromNative(e)
                e["Items"] = TAG_List()
                itemsTag = e["Items"]
                item = TAG_Compound()
                item["id"] = TAG_String(str(randint(0, 255)))
                item["Damage"] = TAG_Short(randint(0, 127))
                item["Count"] = TAG_Byte(randint(1, 64))
                item["Slot"] = TAG_Byte(randint(0, 27))
                itemsTag.append(item)
            if options["Cause the problem?"] == True:
                chunk.TileEntities.remove(e)
                chunk.TileEntities.append(e)

    # At this point each chest should have an item. Check the console for results
    printEmptyChests(level, box, options)
def dat(level, box, options):
    tileEntitiesToRemove = []

    for (chunk, slices, point) in level.getChunkSlices(box):
        for t in chunk.TileEntities:
            x1 = t["x"].value
            y1 = t["y"].value
            z1 = t["z"].value

            if x1 >= box.minx and x1 < box.maxx and y1 >= box.miny and y1 < box.maxy and z1 >= box.minz and z1 < box.maxz and t["id"].value == "MobSpawner":
                tileEntitiesToRemove.append((chunk, t))

                level.setBlockAt(x1, y1, z1, 0)

                cart = TAG_Compound()
                cart["id"] = TAG_String("MinecartSpawner")
                cart["Pos"] = TAG_List([TAG_Double(x1+0.5), TAG_Double(y1+0.35), TAG_Double(z1+0.5)])
                cart["PortalCooldown"] = TAG_Int(0)
                cart["Motion"] = TAG_List([TAG_Double(0), TAG_Double(0), TAG_Double(0)])
                cart["OnGround"] = TAG_Byte(0)
                cart["Type"] = TAG_Int(0)
                cart["Fire"] = TAG_Short(-1)
                cart["Dimension"] = TAG_Int(0)
                cart["FallDistance"] = TAG_Float(0)
                cart["Air"] = TAG_Short(300)
                cart["Rotation"] = TAG_List([TAG_Float(0), TAG_Float(0)])
                cart["Invunerable"] = TAG_Byte(0)
                for tag in t:
                        if tag not in ["id", "x", "y", "z"]:
                            cart[tag] = t[tag]

                chunk.Entities.append(cart)

    for (chunk, t) in tileEntitiesToRemove:
        chunk.TileEntities.remove(t)
Exemplo n.º 19
0
def placeMobSpawner(level, type, x, y, z):
    CHUNKSIZE = 16
    SPAWNER = 52

    if level.blockAt(
            x, y, z
    ) != SPAWNER:  # Don't try to create a duplicate set of NBT - it confuses the game.
        level.setBlockAt(x, y, z, SPAWNER)
        level.setBlockDataAt(x, y, z, 0)

        control = TAG_Compound()
        control["x"] = TAG_Int(x)
        control["y"] = TAG_Int(y)
        control["z"] = TAG_Int(z)
        # control["id"] = TAG_String("minecraft:mob_spawner")

        nbt = makeMobSpawnerNBT(type)
        for key in nbt.keys():
            control[key] = nbt[key]

        try:
            chunka = level.getChunk((int)(x / CHUNKSIZE), (int)(z / CHUNKSIZE))
            chunka.TileEntities.append(control)
            chunka.dirty = True
        except ChunkNotPresent:
            print "ChunkNotPresent", (int)(x / CHUNKSIZE), (int)(z / CHUNKSIZE)
Exemplo n.º 20
0
def perform(level, box, options):
    name1 = options["Entity #1 Name:"]
    name2 = options["Entity #2 Name:"]
    remove = options["Remove Entity's Names"]

    for (chunk, slices, point) in level.getChunkSlices(box):
        for e in chunk.Entities:
            x = e["Pos"][0].value
            y = e["Pos"][1].value
            z = e["Pos"][2].value

            if (x, y, z) in box:
                if e["CustomName"].value != '':
                    if e["CustomName"].value == name1:
                        e["Leashed"] = TAG_Byte(1)
                        e["Leash"] = TAG_Compound()
                        e["Leash"]["UUIDMost"] = TAG_Long(UM)
                        e["Leash"]["UUIDLeast"] = TAG_Long(UL)
                        if remove:
                            e["CustomName"] = TAG_String()

                    elif e["CustomName"].value == name2:
                        UL = e["UUIDLeast"].value
                        UM = e["UUIDMost"].value
                        if remove:
                            e["CustomName"] = TAG_String()

        chunk.dirty = True
Exemplo n.º 21
0
def createSign(
    level, x, y, z, texts
):  #abrightmoore - convenience method. Due to Jigarbov - this is not a Sign.
    # This is Java only. Bedrock has one line of text with line breaks.
    CHUNKSIZE = 16
    STANDING_SIGN = 63

    if level.blockAt(
            x, y, z
    ) != STANDING_SIGN:  # Don't try to create a duplicate set of NBT - it confuses the game.
        level.setBlockAt(x, y, z, STANDING_SIGN)
        level.setBlockDataAt(x, y, z, randint(0, 15))
        #setBlock(level, (STANDING_SIGN,randint(0,15)), x, y, z)
        level.setBlockAt(x, y - 1, z, 1)
        level.setBlockDataAt(x, y - 1, z, 0)
        #setBlock(level, (1,0), x, y-1, z)
        control = TAG_Compound()
        # control["TileEntity"] = TAG_String("minecraft:sign")
        control["x"] = TAG_Int(x)
        control["Text4"] = TAG_String("{\"text\":\"" + texts[3] + "\"}")
        control["y"] = TAG_Int(y)
        control["Text3"] = TAG_String("{\"text\":\"" + texts[2] + "\"}")
        control["z"] = TAG_Int(z)
        control["Text2"] = TAG_String("{\"text\":\"" + texts[1] + "\"}")
        control["id"] = TAG_String("minecraft:sign")
        control["Text1"] = TAG_String("{\"text\":\"" + texts[0] + "\"}")

        try:
            chunka = level.getChunk((int)(x / CHUNKSIZE), (int)(z / CHUNKSIZE))
            chunka.TileEntities.append(control)
            chunka.dirty = True
        except ChunkNotPresent:
            print "ChunkNotPresent", (int)(x / CHUNKSIZE), (int)(z / CHUNKSIZE)
def toNative(
        canonical):  # Version specific mapping to NBT from universal class
    # Data transformation, and any validation
    position = canonical.position
    customname = canonical.customname
    commandstats = canonical.commandstats  # Dictionary {}. This is a runtime artifact. Should it be translated? TODO: Find out.
    command = canonical.command
    successcount = canonical.successcount
    lastoutput = canonical.lastoutput
    trackoutput = canonical.trackoutput
    powered = canonical.powered
    auto = canonical.auto
    conditionmet = canonical.conditionmet
    updatelastexecution = canonical.updatelastexecution
    lastexecution = canonical.lastexecution
    id = getNativeID()
    (x, y, z) = canonical.position

    # Create native-compatible NBT and return it
    control = TAG_Compound()
    control["id"] = TAG_String(id)
    control["auto"] = TAG_Byte(auto)
    control["powered"] = TAG_Byte(powered)
    control["LastExecution"] = TAG_Long(lastexecution)
    control["SuccessCount"] = TAG_Int(successcount)
    control["UpdateLastExecution"] = TAG_Byte(updatelastexecution)
    control["conditionMet"] = TAG_Byte(conditionmet)
    control["CustomName"] = TAG_String(customname)
    control["Command"] = TAG_String(command)
    control["LastOutput"] = TAG_String(lastoutput)
    control["TrackOutput"] = TAG_Byte(trackoutput)
    control["x"] = TAG_Int(x)
    control["y"] = TAG_Int(y)
    control["z"] = TAG_Int(z)
    return control
Exemplo n.º 23
0
def CreateNewMapFilePE(level, number, colors):
    map = TAG_Compound()
    map["mapId"] = TAG_Long(number)
    map["parentMapId"] = TAG_Long(-1)
    map["decorations"] = TAG_List()
    map["dimension"] = TAG_Byte(0)
    map["fullyExplored"] = TAG_Byte(1)
    map["scale"] = TAG_Byte(4)
    map["height"] = TAG_Short(128)
    map["width"] = TAG_Short(128)
    map["xCenter"] = TAG_Int(2147483647)
    map["zCenter"] = TAG_Int(2147483647)
    map["colors"] = TAG_Byte_Array(colors)
    with level.worldFile.world_db() as db:
        wop = level.worldFile.writeOptions
        with nbt.littleEndianNBT():
            db.Put(wop, 'map_' + str(number), map.save(compressed=False))
Exemplo n.º 24
0
def perform(level, box, options):
    inv = options["Invulnerable:"]
    fixLag = options["Fix lag by changing only outer blocks to sheep:"]

    temp = []

    for y in xrange(box.miny, box.maxy):
        for x in xrange(box.minx, box.maxx):
            for z in xrange(box.minz, box.maxz):
                if (level.blockAt(x, y, z) == 35):
                    if not fixLag or level.blockAt(
                            x + 1, y, z) == 0 or level.blockAt(
                                x, y + 1, z) == 0 or level.blockAt(
                                    x, y, z + 1) == 0 or level.blockAt(
                                        x - 1, y, z) == 0 or level.blockAt(
                                            x, y - 1, z) == 0 or level.blockAt(
                                                x, y, z - 1) == 0:
                        color = level.blockDataAt(x, y, z)

                        temp.append(Vector(x, y, z))

                        sheep = TAG_Compound()
                        sheep["Color"] = TAG_Byte(color)
                        sheep["PersistenceRequired"] = TAG_Byte(1)
                        sheep["OnGround"] = TAG_Byte(0)
                        sheep["Air"] = TAG_Short(300)
                        sheep["DeathTime"] = TAG_Short(0)
                        sheep["Fire"] = TAG_Short(-1)
                        sheep["Health"] = TAG_Float(8)
                        sheep["HurtTime"] = TAG_Short(0)
                        sheep["Age"] = TAG_Int(0)
                        sheep["FallDistance"] = TAG_Float(0)
                        sheep["Invulnerable"] = TAG_Byte(inv)
                        sheep["NoAI"] = TAG_Byte(1)
                        sheep["NoGravity"] = TAG_Byte(1)
                        sheep["Silent"] = TAG_Byte(options["Silent Sheep:"])
                        sheep["id"] = TAG_String("Sheep")
                        sheep["Motion"] = TAG_List([
                            TAG_Double(0.0),
                            TAG_Double(0.0),
                            TAG_Double(0.0)
                        ])
                        sheep["Pos"] = TAG_List([
                            TAG_Double(x + 0.5),
                            TAG_Double(y),
                            TAG_Double(z + 0.5)
                        ])
                        sheep["Rotation"] = TAG_List(
                            [TAG_Float(0), TAG_Float(0)])

                        chunk = level.getChunk(x / 16, z / 16)
                        chunk.Entities.append(sheep)
                        chunk.dirty = True

    while temp:
        cell = temp.pop()
        level.setBlockAt(cell.x, cell.y, cell.z, 0)
        level.setBlockDataAt(cell.x, cell.y, cell.z, 0)
Exemplo n.º 25
0
def createItem(itemid, count=1, damage=0, slot=0):
    item = TAG_Compound()

    item["id"] = TAG_Short(itemid)
    item["Damage"] = TAG_Short(damage)
    item["Count"] = TAG_Byte(count)
    item["Slot"] = TAG_Byte(slot)

    return item
Exemplo n.º 26
0
def toNative(
        canonical):  # Version specific mapping to NBT from universal class
    # Data transformation, and any validation
    position = canonical.position
    customname = canonical.customname
    # Not used in Bedrock
    # commandstats = canonical.commandstats # Dictionary {}. This is a runtime artifact. Should it be translated? TODO: Find out.
    command = parseCommandToBedrock(canonical.command)
    successcount = canonical.successcount
    lastoutput = canonical.lastoutput
    trackoutput = canonical.trackoutput
    powered = canonical.powered
    auto = canonical.auto
    conditionmet = canonical.conditionmet
    # Not used in Bedrock
    # updatelastexecution = canonical.updatelastexecution
    # lastexecution = self.lastexecution
    id = getNativeID()
    (x, y, z) = canonical.position

    # Create native-compatible NBT and return it
    control = TAG_Compound()
    control["id"] = TAG_String(id)
    control["Command"] = TAG_String(command)
    control["CustomName"] = TAG_String(customname)

    #	control["LPCommandMode"] = TAG_Int(lpcommandmode) # <---- not in model
    #	control["LPCondionalMode"] = TAG_Int(lpconditionalmode) # <---- not in model
    #	control["LPRedstoneMode"] = TAG_Int(lpredstonemode) # <---- not in model

    #	control["LastOutput"] = TAG_String(lastoutput)

    #	lastoutputparamsctl = TAG_List()
    #	control["LastOutputParams"] = lastoutputparamsctl # <---- not in model
    # TODO: parse the params and append to the list

    #	control["SuccessCount"] = TAG_Int(successcount)
    control["TrackOutput"] = TAG_Byte(trackoutput)

    #	control["Version"] = TAG_Int(version) # <---- not in model

    control["auto"] = TAG_Byte(auto)
    control["conditionMet"] = TAG_Byte(conditionmet)
    #	control["isMovable"] = TAG_Byte(1) #TODO: Should this be editable?

    #	control["powered"] = TAG_Byte(powered)

    # Not used in bedrock
    #	control["LastExecution"] = TAG_Long(lastexecution)
    #	control["UpdateLastExecution"] = TAG_Byte(updatelastexecution)

    control["x"] = TAG_Int(x)
    control["y"] = TAG_Int(y)
    control["z"] = TAG_Int(z)
    return control
Exemplo n.º 27
0
def placePig(level, x, y, z):
    pig = TAG_Compound()
    pig["id"] = TAG_String("pig")
    pig["Pos"] = TAG_List(
        [TAG_Double(x + 0.5),
         TAG_Double(y),
         TAG_Double(z + 0.5)])

    chunk = level.getChunk(x / 16, z / 16)
    chunk.Entities.append(pig)
    chunk.dirty = True
Exemplo n.º 28
0
def	CreateWallSign(x, y, z, text):
	e = TAG_Compound()
	e["x"] = TAG_Int(x)
	e["y"] = TAG_Int(y)
	e["z"] = TAG_Int(z)
	e["id"] = TAG_String("Sign")
	e["Text1"] = TAG_String("")
	e["Text2"] = TAG_String(text)
	e["Text3"] = TAG_String("")
	e["Text4"] = TAG_String("")
	return e
Exemplo n.º 29
0
def placeHorse(level, x, y, z):
    horse = TAG_Compound()
    horse["id"] = TAG_String("horse")
    horse["Pos"] = TAG_List(
        [TAG_Double(x + 0.5),
         TAG_Double(y),
         TAG_Double(z + 0.5)])

    chunk = level.getChunk(x / 16, z / 16)
    chunk.Entities.append(horse)
    chunk.dirty = True
Exemplo n.º 30
0
def placeChicken(level, x, y, z):
    chicken = TAG_Compound()
    chicken["id"] = TAG_String("chicken")
    chicken["Pos"] = TAG_List(
        [TAG_Double(x + 0.5),
         TAG_Double(y),
         TAG_Double(z + 0.5)])

    chunk = level.getChunk(x / 16, z / 16)
    chunk.Entities.append(chicken)
    chunk.dirty = True
Exemplo n.º 31
0
def placeCow(level, x, y, z):
    cow = TAG_Compound()
    cow["id"] = TAG_String("cow")
    cow["Pos"] = TAG_List(
        [TAG_Double(x + 0.5),
         TAG_Double(y),
         TAG_Double(z + 0.5)])

    chunk = level.getChunk(x / 16, z / 16)
    chunk.Entities.append(cow)
    chunk.dirty = True
Exemplo n.º 32
0
def placeSheep(level, x, y, z):
    sheep = TAG_Compound()
    sheep["id"] = TAG_String("sheep")
    sheep["Pos"] = TAG_List(
        [TAG_Double(x + 0.5),
         TAG_Double(y),
         TAG_Double(z + 0.5)])

    chunk = level.getChunk(x / 16, z / 16)
    chunk.Entities.append(sheep)
    chunk.dirty = True
Exemplo n.º 33
0
def genWallMap(level, box, options):
    mapScale = options["Scale"]
    wallMapCentreX = options["x"]
    wallMapCentreZ = options["z"]
    gridAlign = options["Align with Grid"]
    renderMaps = options["Render Maps"]
    
    if dimNo != 0:
        dataFolder = level.parentWorld.worldFolder.getFolderPath("data")
    else:
        dataFolder = level.worldFolder.getFolderPath("data")
    
    if os.path.exists(os.path.join(dataFolder, "idcounts.dat")):
        idcountsTag = nbt.load(os.path.join(dataFolder, "idcounts.dat"))
        # Value of last existing map, new map should be map_(mapCount+1)
        mapCount = idcountsTag["map"].value
    else:
        mapCount = -1
        
    if gridAlign:
        wallMapCentreX = int(round(wallMapCentreX/8.0))*8
        wallMapCentreZ = int(round(wallMapCentreZ/8.0))*8
    
    # if the box is not 1 thick
    if box.width != 1 and box.length != 1:
        raise Exception("The selection box needs to be 1 block thick")
    
    for chunk, slices, point in level.getChunkSlices(box):
        if chunk.Blocks[slices].any():
            raise Exception("The selection box should be clear of blocks")
    
    # facing
    # 0 : south, +x map left to right
    # 1 : west, +z
    # 2 : north, -x
    # 3 : east, -z
    
    positive = 0
    negative = 0
    if box.width == 1:
        # wall map along y-z plane
        for chunk, slices, point in level.getChunkSlices(pymclevel.box.BoundingBox(box.origin + (1, 0, 0), box.size)):
            positive += chunk.Blocks[slices][chunk.Blocks[slices] != 0].size
        for chunk, slices, point in level.getChunkSlices(pymclevel.box.BoundingBox(box.origin + (-1, 0, 0), box.size)):
            negative += chunk.Blocks[slices][chunk.Blocks[slices] != 0].size
        if positive > negative:
            facing = 1
        else:
            facing = 3
        wallMapWidth = box.length
    else:
        # wall map along x-y plane
        for chunk, slices, point in level.getChunkSlices(pymclevel.box.BoundingBox(box.origin + (0, 0, 1), box.size)):
            positive += chunk.Blocks[slices][chunk.Blocks[slices] != 0].size
        for chunk, slices, point in level.getChunkSlices(pymclevel.box.BoundingBox(box.origin + (0, 0, -1), box.size)):
            negative += chunk.Blocks[slices][chunk.Blocks[slices] != 0].size
        if positive > negative:
            facing = 2
        else:
            facing = 0
        wallMapWidth = box.width
    wallMapHeight = box.height
    
    for chunk, slices, point in level.getChunkSlices(pymclevel.box.BoundingBox(box.origin + (1*[0, 1, 0, -1][facing], 0, 1*[-1, 0, 1, 0][facing], box.size))):
        if not chunk.Blocks[slices].all():
            raise Exception("The selection box should be against a wall")
    
    def itemFramePosIter(box, facing):
        if facing == 0:
            return ((x, y, box.minz) for y in xrange(box.maxy-1, box.miny-1, -1) for x in xrange(box.minx, box.maxx))
        elif facing == 1:
            return ((box.minx, y, z) for y in xrange(box.maxy-1, box.miny-1, -1) for z in xrange(box.minz, box.maxz))
        elif facing == 2:
            return ((x, y, box.minz) for y in xrange(box.maxy-1, box.miny-1, -1) for x in xrange(box.maxx-1, box.minx-1, -1))
        elif facing == 3:
            return ((box.minx, y, z) for y in xrange(box.maxy-1, box.miny-1, -1) for z in xrange(box.maxz-1, box.minz-1, -1))
    
    
    def mapCentreIter(wallMapCentreX, wallMapCentreZ, wallMapWidth, wallMapHeight, mapScale, upDir):
        mapWidthInBlocks = 128 * 2**mapScale
        
        if upDir == 2:
            topLeftMapCentreX = wallMapCentreX - wallMapWidth*mapWidthInBlocks/2 + mapWidthInBlocks/2
            topLeftMapCentreZ = wallMapCentreZ - wallMapHeight*mapWidthInBlocks/2 + mapWidthInBlocks/2
            
            for h in xrange(wallMapHeight):
                for w in xrange(wallMapWidth):
                    yield (topLeftMapCentreX + w * mapWidthInBlocks, topLeftMapCentreZ + h * mapWidthInBlocks)
            
        elif upDir == 3:
            topLeftMapCentreX = wallMapCentreX + wallMapHeight*mapWidthInBlocks/2 - mapWidthInBlocks/2
            topLeftMapCentreZ = wallMapCentreZ - wallMapWidth*mapWidthInBlocks/2 + mapWidthInBlocks/2
            
            for h in xrange(wallMapHeight):
                for w in xrange(wallMapWidth):
                    yield (topLeftMapCentreX - h * mapWidthInBlocks, topLeftMapCentreZ + w * mapWidthInBlocks)
            
        elif upDir == 0:
            topLeftMapCentreX = wallMapCentreX + wallMapWidth*mapWidthInBlocks/2 - mapWidthInBlocks/2
            topLeftMapCentreZ = wallMapCentreZ + wallMapHeight*mapWidthInBlocks/2 - mapWidthInBlocks/2
            
            for h in xrange(wallMapHeight):
                for w in xrange(wallMapWidth):
                    yield (topLeftMapCentreX - w * mapWidthInBlocks, topLeftMapCentreZ - h * mapWidthInBlocks)
            
        elif upDir == 1:
            topLeftMapCentreX = wallMapCentreX - wallMapHeight*mapWidthInBlocks/2 + mapWidthInBlocks/2
            topLeftMapCentreZ = wallMapCentreZ + wallMapWidth*mapWidthInBlocks/2 - mapWidthInBlocks/2
            
            for h in xrange(wallMapHeight):
                for w in xrange(wallMapWidth):
                    yield (topLeftMapCentreX + h * mapWidthInBlocks, topLeftMapCentreZ - w * mapWidthInBlocks)
    
    
    upDir = {"North":2, "East":3, "South":0, "West":1}[options["Up is"]]
    
    itemRotation = [2, 1, 0, 3][upDir]
    progressBarMapCount = 0
    numMaps = wallMapWidth * wallMapHeight
    numCols = numMaps * 128
    for itemFramePos, mapCentre in itertools.izip(itemFramePosIter(box, facing), mapCentreIter(wallMapCentreX, wallMapCentreZ, wallMapWidth, wallMapHeight, mapScale, upDir)):
        mapCount += 1
        mapTag = makeMapTag(*mapCentre, scale=mapScale)
        if renderMaps:
            for column in renderMap(level, mapTag):
                yield progressBarMapCount * 128 + column, numCols, "Map: "+str(progressBarMapCount)+"/"+str(numMaps)
        saveMapTag(level, mapTag, mapCount)
        
        mapItem = makeMapItemTag(mapCount)
        
        itemFrame = makeItemFrameEntity(*itemFramePos, facing=facing, itemtag=mapItem, itemRotation=itemRotation)
        level.addEntity(itemFrame)
        progressBarMapCount += 1
    
    if mapCount >= 0:
        idcountsTag = TAG_Compound()
        idcountsTag["map"] = TAG_Short(mapCount)
        idcountsTag.save(os.path.join(dataFolder, "idcounts.dat"))