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)
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
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
Exemple #4
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)
Exemple #5
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	
Exemple #6
0
def perform(level, box, options):
    method = "Spawner Pointer"
    xend = []
    yend = []
    zend = []
    radi = options["Change Spawn Radius?"]
    print '%s: Started at: %s' % (method, time.ctime())

    for x in xrange(box.minx, box.maxx):
        for y in xrange(box.miny, box.maxy):
            for z in xrange(box.minz, box.maxz):
                block = level.blockAt(x, y, z)
                if block == 19:
                    xend.append(x)
                    yend.append(y)
                    zend.append(z)

    for (chunk, slices, point) in level.getChunkSlices(box):
        for e in chunk.Entities:
            if e["id"].value == "MinecartSpawner":
                x2 = e["Pos"][0].value
                y2 = e["Pos"][1].value
                z2 = e["Pos"][2].value

                if x2 >= box.minx and x2 < box.maxx and y2 >=box.miny and y2 < box.maxy and z2 >= box.minz and z2 < box.maxz:
                    if "SpawnData" in e:
                        pos = e["Spawndata"]
                        pos["Pos"] = TAG_List()
                        pos["Pos"].append(TAG_Double(xend+0.5))
                        pos["Pos"].append(TAG_Double(yend+0.5))
                        pos["Pos"].append(TAG_Double(zend+0.5))
                        del e["SpawnPotentials"]
                        if radi:
                            e["SpawnRange"] = TAG_Short(1)
                        print '%s %s %s' % (xend, yend, zend)
                        print '%s: Ended at: %s' % (method, time.ctime())
                        level.markDirtyBox(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":
                if "SpawnData" in t:
                    pos = t["Spawndata"]
                    pos["Pos"] = TAG_List()
                    pos["Pos"].append(TAG_Double(xend+0.5))
                    pos["Pos"].append(TAG_Double(yend+0.5))
                    pos["Pos"].append(TAG_Double(zend+0.5))
                    del t["Spawnpotentials"]
                    if radi:
                        t["SpawnRange"] = TAG_Short(1)
                    print '%s %s %s' % (xend, yend, zend)
                    print '%s: Ended at: %s' % (method, time.ctime())
                    level.markDirtyBox(box) 
Exemple #7
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)
Exemple #8
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
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 placeBoat(level, x, y, z, blocks):
    boatType = blocks["wood"]["type"].split("_")[0]  # Kinda janky, but works

    boat = TAG_Compound()
    boat["id"] = TAG_String("boat")
    boat["Type"] = TAG_String(boatType)
    boat["Pos"] = TAG_List([TAG_Double(x), TAG_Double(y), TAG_Double(z)])
    boat["Motion"] = TAG_List(
        [TAG_Double(0.0), TAG_Double(0.0),
         TAG_Double(0.0)])
    boat["Rotation"] = TAG_List([TAG_Float(0.0), TAG_Float(0.0)])

    chunk = level.getChunk(x / 16, z / 16)
    chunk.Entities.append(boat)
    chunk.dirty = True
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
Exemple #12
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)
Exemple #13
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
Exemple #14
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
Exemple #15
0
def createChest(lootTable, lootSeed, cx, cy, cz):
    if (lootSeed == 0):
        lootSeed = random.getrandbits(32)
    newte = TileEntity.Create("Chest")
    newte["Items"] = TAG_List()
    newte["LootTable"] = TAG_String(lootTable)
    newte["LootTableSeed"] = TAG_Long(lootSeed)
    newte["x"] = TAG_Int(cx)
    newte["y"] = TAG_Int(cy)
    newte["z"] = TAG_Int(cz)
    return newte
Exemple #16
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
Exemple #17
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
Exemple #18
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
Exemple #19
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 createSandEntity(x, y, z, block, data, life):
    sand = TAG_Compound()
    sand["Motion"] = TAG_List()
    sand["Motion"].append(TAG_Double(0))
    sand["Motion"].append(TAG_Double(0.04))
    sand["Motion"].append(TAG_Double(0))
    sand["OnGround"] = TAG_Byte(1)
    sand["DropItem"] = TAG_Byte(0)
    sand["Dimension"] = TAG_Int(0)
    sand["Air"] = TAG_Short(300)
    sand["Pos"] = TAG_List()
    sand["Pos"].append(TAG_Double(x + 0.5))
    sand["Pos"].append(TAG_Double(y + 0.5))
    sand["Pos"].append(TAG_Double(z + 0.5))
    sand["Data"] = TAG_Byte(data)
    sand["TileID"] = TAG_Int(block)
    sand["Tile"] = TAG_Byte(block)
    sand["Time"] = TAG_Byte(life)
    sand["Fire"] = TAG_Short(-1)
    sand["FallDistance"] = TAG_Float(0)
    sand["Rotation"] = TAG_List()
    sand["Rotation"].append(TAG_Float(0))
    sand["Rotation"].append(TAG_Float(0))
    return sand
Exemple #21
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))
Exemple #22
0
def performed(level, box, options):
    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 box.minx <= x < box.maxx and box.miny <= y < box.maxy and box.minz <= z < box.maxz:
                if "Health" in e:
                    if "ActiveEffects" not in e:
                        e["ActiveEffects"] = TAG_List()

                    resist = TAG_Compound()
                    resist["Amplifier"] = TAG_Byte(4)
                    resist["Id"] = TAG_Byte(11)
                    resist["Duration"] = TAG_Int(2000000000)
                    e["ActiveEffects"].append(resist)
                    chunk.dirty = True
Exemple #23
0
def makeBookNBT(texts):
    book = TAG_Compound()
    book["id"] = TAG_String("minecraft:writable_book")
    book["Count"] = TAG_Byte(1)
    book["Damage"] = TAG_Short(0)

    tag = TAG_Compound()
    pages = TAG_List()
    LIMIT = 150
    discarded = False
    for page in texts:
        if len(pages) < LIMIT:
            pages.append(TAG_String(page))
        else:
            discarded = True
    if discarded == True:
        print "WARNING: Book length exceeded " + str(
            LIMIT) + " pages. Truncated!"
    book["tag"] = tag
    tag["pages"] = pages
    return book
def perform(level, box, options):
    effect = Effects[options["Effect"]]
    lvl = options["Level"]
    duration = options["Duration (seconds)"] * 20

    minx = int(box.minx / 16) * 16
    minz = int(box.minz / 16) * 16

    for x in xrange(minx, box.maxx, 16):
        for z in xrange(minz, box.maxz, 16):
            chunk = level.getChunk(x / 16, z / 16)

            for te in chunk.TileEntities:
                px = te["x"].value
                py = te["y"].value
                pz = te["z"].value

                if px < box.minx or px >= box.maxx:
                    continue
                if py < box.miny or py >= box.maxy:
                    continue
                if pz < box.minz or pz >= box.maxz:
                    continue

                if te["id"].value == "Trap" or te["id"].value == "Chest" or te[
                        "id"].value == "Dropper":
                    for item in te["Items"]:
                        if item["id"].value == 373:
                            if "tag" not in item:
                                item["tag"] = TAG_Compound()
                            if "CustomPotionEffects" not in item["tag"]:
                                item["tag"]["CustomPotionEffects"] = TAG_List()

                            ef = TAG_Compound()
                            ef["Id"] = TAG_Byte(effect)
                            ef["Amplifier"] = TAG_Byte(lvl - 1)
                            ef["Duration"] = TAG_Int(duration)
                            item["tag"]["CustomPotionEffects"].append(ef)

                    chunk.dirty = True
def perform(level, box, options):
    effect = dict([(trn._(a), b) for a, b in list(Effects.items())])[options["Effect"]]
    amp = options["Level"]
    duration = options["Duration (Seconds)"] * 20

    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 box.minx <= x < box.maxx and box.miny <= y < box.maxy and box.minz <= z < box.maxz:
                if trn._("Health") in e:
                    if "ActiveEffects" not in e:
                        e["ActiveEffects"] = TAG_List()

                    ef = TAG_Compound()
                    ef["Amplifier"] = TAG_Byte(amp)
                    ef["Id"] = TAG_Byte(effect)
                    ef["Duration"] = TAG_Int(duration)
                    e["ActiveEffects"].append(ef)
                    chunk.dirty = True
def perform(level, box, options):
    effect = Effects[options["Effect"]]
    amp = options["Level"]
    duration = options["Duration (Seconds)"] * 20

    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 >= box.minx and x < box.maxx and y >= box.miny and y < box.maxy and z >= box.minz and z < box.maxz:
                if "Health" in e:
                    if "ActiveEffects" not in e:
                        e["ActiveEffects"] = TAG_List()

                    ef = TAG_Compound()
                    ef["Amplifier"] = TAG_Byte(amp)
                    ef["Id"] = TAG_Byte(effect)
                    ef["Duration"] = TAG_Int(duration)
                    e["ActiveEffects"].append(ef)
                    chunk.dirty = True
def createChestBlockData2(x, y, z, options, seedtag, ItemsSmokeBox):
    e = TAG_Compound()
    e["x"] = TAG_Int(x)
    e["y"] = TAG_Int(y)
    e["z"] = TAG_Int(z)
    if options["(1.11+)"]:
        e["id"] = TAG_String("chest")
    else:
        e["id"] = TAG_String("Chest")
    e["Items"] = TAG_List()
    e["LootTableSeed"] = TAG_Long(int(seedtag))
    e["CustomName"] = TAG_String("Lucky Crate")
    if options["(Random Loot ID)"]:
        foo = [
            'nether_bridge', 'village_blacksmith', 'stronghold_crossing',
            'spawn_bonus_chest', 'jungle_temple', 'simple_dungeon',
            'igloo_chest', 'end_city_treasure', 'desert_pyramid',
            'abandoned_mineshaft'
        ]
        e["LootTable"] = TAG_String("minecraft:chests/" + random.choice(foo))
    else:
        e["LootTable"] = TAG_String("minecraft:chests/" + str(ItemsSmokeBox))
    return e
Exemple #28
0
def placeChestWithItems(level, things, x, y, z):
    CHUNKSIZE = 16
    CHEST = 54

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

        control = TAG_Compound()
        control["x"] = TAG_Int(x)
        control["y"] = TAG_Int(y)
        control["z"] = TAG_Int(z)
        control["id"] = TAG_String("minecraft:chest")
        control["Lock"] = TAG_String("")
        items = TAG_List()
        control["Items"] = items
        slot = 0
        print things
        for thing in things:
            # if thing["id"].value != "minecraft:Nothing": # Handle empty slots
            if True:
                item = TAG_Compound()
                items.append(item)
                item["Slot"] = TAG_Byte(slot)
                slot += 1
                for key in thing.keys():
                    item[key] = thing[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)
Exemple #29
0
def makeMobSpawnerNBT(type):
    obj = TAG_Compound()
    obj["id"] = TAG_String("minecraft:mob_spawner")
    obj["MaxNearbyEntities"] = TAG_Short(6)
    obj["RequiredPlayerRange"] = TAG_Short(8)
    obj["SpawnCount"] = TAG_Short(1)
    obj["MaxSpawnDelay"] = TAG_Short(800)
    obj["Delay"] = TAG_Short(371)
    obj["SpawnRange"] = TAG_Short(4)
    obj["MinSpawnDelay"] = TAG_Short(200)
    spawnData = TAG_Compound()
    obj["SpawnData"] = spawnData
    spawnData["id"] = TAG_String(type)

    spawnPotentials = TAG_List()
    obj["SpawnPotentials"] = spawnPotentials
    entity = TAG_Compound()
    spawnPotentials.append(entity)

    entity["Entity"] = TAG_Compound()
    entity["Entity"]["id"] = TAG_String(type)
    entity["Weight"] = TAG_Int(1)

    return obj
def fix(angle):
    while angle > pi:
        angle = angle - 2 * pi
    while angle < -pi:
        angle = angle + 2 * pi
    return angle


# createSandSpawner() function by @SethBling (http://youtube.com/SethBling)
# hacks by @abrightmoore
def createSandSpawner(x, y, z, (block, data), frameNum, numFrames, tx, ty, tz,
                      interval, delay, TICKS, life):

    spawner = TAG_Compound()
    spawner["id"] = TAG_String("MobSpawner")
    spawner["Items"] = TAG_List()
    spawner["x"] = TAG_Int(x)
    spawner["y"] = TAG_Int(y)
    spawner["z"] = TAG_Int(z)
    spawner["Delay"] = TAG_Short(TICKS * frameNum + delay)
    spawner["MinSpawnDelay"] = TAG_Short(interval + TICKS * numFrames)
    spawner["MaxSpawnDelay"] = TAG_Short(interval + TICKS * numFrames + 1)
    spawner["SpawnCount"] = TAG_Short(1)
    spawner["SpawnData"] = createSandEntity(tx, ty, tz, block, data, life)
    spawner["MaxNearbyEntities"] = TAG_Short(10000)
    spawner["RequiredPlayerRange"] = TAG_Short(128)
    spawner["EntityId"] = TAG_String("FallingSand")
    return spawner


# createSandEntity() function by @SethBling (http://youtube.com/SethBling)