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.º 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
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.º 4
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)
Exemplo n.º 5
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.º 6
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.º 7
0
def perform(level, box, options):
    datapack = options["Datapack name (Alphanumeric) "]

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

            if (x, y, z) in box:
                if e["id"].value in [
                        "minecraft:command_block",
                        "minecraft:chain_command_block",
                        "minecraft:repeating_command_block"
                ]:

                    e["Command"] = TAG_String(convert(e["Command"].value))
                    chunk.dirty = True

                elif e["id"].value == "minecraft:structure_block":
                    e["name"] = TAG_String(
                        re.sub(r'([A-Za-z_/]+)',
                               r'{}:structures/\1'.format(datapack),
                               e["name"].value))
                    chunk.dirty = True
Exemplo n.º 8
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.º 9
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.º 10
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.º 11
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.º 12
0
def setCmd(x, y, z, cmd, level):
    control = TAG_Compound()
    control["id"] = TAG_String(u'Control')
    control["CustomName"] = TAG_String(u"builder")
    control["z"] = TAG_Int(z)
    control["y"] = TAG_Int(y)
    control["x"] = TAG_Int(x)
    control["Command"] = TAG_String(cmd)
    chunk = level.getChunk((int(x / 16)), (int(z / 16)))
    chunk.TileEntities.append(control)
    chunk.dirty = True
Exemplo n.º 13
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.º 14
0
def add_objective(name, criteria, display=None):
    """
    add_objective(name, criteria[, display])
    Add the objective with the given properties.
    """
    global scoreboard_dat
    obj = TAG_Compound()
    obj['CriteriaName'] = TAG_String(criteria)
    obj['DisplayName'] = TAG_String(display or name)
    obj['Name'] = TAG_String(name)
    obj['RenderType'] = TAG_String("integer")
    scoreboard_dat["data"]["Objectives"].append(obj)
def perform(level, box, options):
	nBlocks = []
	removeTiles = []
	#Materials (If you are wondering I did not do these by hand)
	#There may be a few new blocks that aren't included in this list, but it shouldn't really matter anyway
	rock = [1, 4, 7, 14, 15, 16, 21, 22, 23, 24, 43, 44, 45, 48, 49, 52, 56, 61, 62, 67, 70, 73, 74, 87, 98, 108, 109, 112, 113, 114, 116, 120, 121, 128, 129, 130, 139]
	wood = [5, 17, 25, 47, 53, 54, 58, 63, 64, 68, 72, 84, 85, 95, 96, 99, 100, 107, 125, 126, 134, 135, 136]
	glass = [20, 89, 102, 138]
	sand = [12, 13, 88]
	
	for (chunk, slices, point) in level.getChunkSlices(box):
		for t in chunk.TileEntities:
			x = t["x"].value
			y = t["y"].value
			z = t["z"].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 and t["id"].value == "Music":
				nBlocks.append(t)
			for n in nBlocks:
				if "note" in n:
					note = n["note"].value
					#pitch = round(0.5*(1.0594632**note),8)
					#pitchString = str(pitch)
					pitchString = options["Pitch"] 
					
					type = "harp"
					below = level.blockAt(x, y - 1, z)
					if below in rock:
						
						type = "bd"
					elif below in wood:
						type = "bass"
					elif below in glass:
						type = "hat"
					elif below in sand:
						type = "snare"
					elif below == 42:
						type = "pling"
					
					theSoundCommand = resolveSound(type, note)
					
					command = "/playsound " + theSoundCommand + " @a ~0 ~0 ~0 1 " + str(pitchString)
					level.setBlockAt(x,y,z,137)
					n["Command"] = TAG_String(command)
					n["id"] = TAG_String("Control")
					if "note" in n:
						del n["note"]
				
	#for (chunk, tileEntity) in removeTiles:
		#chunk.TileEntities.remove(tileEntity)
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
	
	
Exemplo n.º 17
0
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 createCmdBlock(level, x, y, z, command): #abrightmoore - convenience method.
	COMMANDBLOCK = 137
	CHUNKSIZE = 16

	level.setBlockAt(x, y, z, COMMANDBLOCK)
	control = TAG_Compound()
	control["id"] = TAG_String("Control")
	control["Command"] = TAG_String(command)
	control["SuccessCount"] = TAG_Int(0)
	control["x"] = TAG_Int(x)
	control["y"] = TAG_Int(y)
	control["z"] = TAG_Int(z)
	chunka = level.getChunk((int)(x/CHUNKSIZE), (int)(z/CHUNKSIZE))
	chunka.TileEntities.append(control)
	chunka.dirty = True
Exemplo n.º 19
0
def placeSign(level, surface, x, y, z, rotation, text1, text2, text3, text4):
    level.setBlockAt(x, y, z, 63)

    sign = TAG_Compound()
    sign["id"] = TAG_String('minecraft:sign')
    sign["x"] = TAG_Int(x)
    sign["y"] = TAG_Int(y)
    sign["z"] = TAG_Int(z)
    sign["Text1"] = TAG_String("{'text':''}")
    sign["Text2"] = TAG_String("{'text':''}")
    sign["Text3"] = TAG_String("{'text':''}")
    sign["Text4"] = TAG_String("{'text':''}")

    chunk = level.getChunk(x / 16, z / 16)
    chunk.Entities.append(sign)
    chunk.dirty = True
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.º 21
0
def compileCommandBlocks(blocks,command):
	index=0
	while len(blocks)>0:
		block=heappop(blocks)[1]
		block.tile["Command"] = TAG_String(command.format(i=index,X=block.x,Y=block.y,Z=block.z))
		index+=1
		block.chunk.dirty = True
Exemplo n.º 22
0
def perform(level, box, options):
    loadVars(tape.vars)
    for i, row in enumerate(tape):
        if isinstance(row, int):
            byte = '{0:08b}'.format(row)
            loc = None
            for bnum, bit in enumerate(byte):
                z = int(i % 16)
                y = int(i / 16)
                loc = tape.corner + Point(7 - bnum, y, z)

                if (bit == '0'):
                    level.setBlockAt(loc.x, loc.y, loc.z, 80)
                else:
                    level.setBlockAt(loc.x, loc.y, loc.z, 152)
                level.getChunk(loc.x / 16, loc.z / 16).dirty = True
        elif isinstance(row, list):
            if len(row) != 8:
                raise Exception(
                    "[Image File Error] opcode byte size is not 8 bits long")
            for bnum, bit in enumerate(row):
                tape[i][bnum] = parseCommand(bit)
    for (chunk, slices, point) in level.getChunkSlices(box):
        for t in chunk.TileEntities:
            _x = t["x"].value
            _y = t["y"].value
            _z = t["z"].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 and t[
                    "id"].value == "Control":
                command = t["Command"].value
                t["Command"] = TAG_String(parseCommand(command))
                chunk.dirty = True
Exemplo n.º 23
0
def NBTCustomNameSwap(level, box, options):
    method = "NBTCustomNameSwap"
    print '%s: Started at %s' % (method, time.ctime())
    (width, height, depth) = getBoxSize(box)
    centreWidth = width / 2
    centreHeight = height / 2
    centreDepth = depth / 2
    AIR = (0, 0)
    COMMANDBLOCK = (137, 0)
    CHUNKSIZE = 16

    BLOCKTYPE = options["Block Type"]
    PREFIX = options["Prefix"]
    NBTTAGROOT = str(options["NBT Tag"])
    SUFFIX = options["Suffix"]

    for (chunk, slices, point) in level.getChunkSlices(box):
        print 'a'
        for te in chunk.TileEntities:
            theCommand = PREFIX

            x = te["x"].value
            y = te["y"].value
            z = te["z"].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:
                print '1 - %s' % (te)
                if te["id"].value == BLOCKTYPE:
                    theCommand = theCommand + " " + str(
                        te["x"].value) + " " + str(te["y"].value) + " " + str(
                            te["z"].value) + " " + SUFFIX
                    te[NBTTAGROOT] = TAG_String(theCommand)  # Swap strings
                    chunk.dirty = True
Exemplo n.º 24
0
def ChatBlocks(level, box, options):
    # CONSTANTS AND GLOBAL VARIABLES
    method = "CHATBLOCKS"
    print '%s: Started at %s' % (method, time.ctime())
    (width, height, depth) = getBoxSize(box)
    centreWidth = width / 2
    centreHeight = height / 2
    centreDepth = depth / 2
    MATERIAL = (35, 0)
    scratchpad = level.extractSchematic(box)
    # END CONSTANTS

    # The following structure is from @Texelelf - http://www.elemanser.com/filters.html
    for (chunk, slices, point) in level.getChunkSlices(box):
        (cx, cz) = chunk.chunkPosition
        cposx = cx * 16
        cposz = cz * 16
        for y in range(box.miny, box.maxy, 1):
            for x in range((cposx if (cposx > box.minx) else box.minx),
                           (cposx + 16 if
                            ((cposx + 16) < box.maxx) else box.maxx), 1):
                for z in range((cposz if (cposz > box.minz) else box.minz),
                               (cposz + 16 if
                                ((cposz + 16) < box.maxz) else box.maxz), 1):
                    theCommand = "/say CHATBLOCK " + str(x) + " " + str(
                        y) + " " + str(z)

                    level.setBlockAt(x, y, z, 137)
                    e = TileEntity.Create("Control")
                    e["Command"] = TAG_String(theCommand)
                    TileEntity.setpos(e, (x, y, z))
                    chunk.TileEntities.append(e)
        chunk.dirty = True

    print '%s: Ended at %s' % (method, time.ctime())
Exemplo n.º 25
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)
Exemplo n.º 26
0
def cmdblock(
    level,
    box,
    options,
    x,
    y,
    z,
    colour,
):
    explosiontype = options["Explosion Type"]
    level.setBlockAt(x, y, z, 137)
    level.setBlockDataAt(x, y, z, 0)
    cmd = TAG_Compound()
    cmd["x"] = TAG_Int(x)
    cmd["y"] = TAG_Int(y)
    cmd["z"] = TAG_Int(z)
    if options["Game Version"] == "1.11":
        cmd["id"] = TAG_String("command_block")
        entityname = "fireworks_rocket"
    else:
        cmd["id"] = TAG_String("Control")
        entityname = "FireworksRocketEntity"
    if options["Mode"] == "Absolute":
        cmd["Command"] = TAG_String(
            "summon " + entityname + " " + str(x) + " " + str(y) + " " +
            str(z) +
            " {LifeTime:0,FireworksItem:{id:fireworks,Count:1,tag:{Fireworks:{Explosions:[{Type:"
            + {
                True: "0",
                False: "1"
            }[explosiontype == "Small"] + ",Flicker:0,Trail:0,Colors:[" +
            str(colour) + "],FadeColors:[" + str(colour) + "]}]}}}}")
    elif options["Mode"] == "Relative":
        cmd["Command"] = TAG_String(
            options["Optional Relative Prefix"] + "summon " + entityname +
            " ~" + str(x - box.minx) + " ~" + str(y - box.miny) + " ~" +
            str(z - box.minz) +
            " {LifeTime:0,FireworksItem:{id:fireworks,Count:1,tag:{Fireworks:{Explosions:[{Type:"
            + {
                True: "0",
                False: "1"
            }[explosiontype == "Small"] + ",Flicker:0,Trail:0,Colors:[" +
            str(colour) + "],FadeColors:[" + str(colour) + "]}]}}}}")
    chunk = level.getChunk(x / 16, z / 16)
    chunk.TileEntities.append(cmd)
    chunk.dirty = True
    chunk.dirty = True
def handleCommand(e, namespace, lines):
    namespace_obj = "command"
    sep = "_"

    posx = e["x"].value
    posy = e["y"].value
    posz = e["z"].value
    text = e["Command"].value
    if "\"translate\"" not in text:  # If this is already calling out to a translatable component, ignore it
        key = namespace + "." + namespace_obj + sep + str(posx) + sep + str(
            posy) + sep + str(posz)
        found = False
        for l in lines:
            if key in l:
                found = True
        if found == False:
            posn = text.find("say")
            if posn >= 0:
                customname = e["CustomName"].value
                v = text[(posn + 4):]  # Tail past the say part
                if customname != "":
                    v = "[" + customname + "] " + v
                newText = "tellraw @a {\"rawtext\": [ {\"translate\":\"" + key + "\"}]}"  # This is the text to replace on the command. We build it now
                lines.append(
                    key + "=" +
                    v)  # Add this new key to the language file copy in memory
                print newText
                e["Command"] = TAG_String(newText)
            else:
                posn = text.find(" title")  # Looking for the SECOND title
                if posn >= 0:
                    v = text[(posn + 7):]  # Tail past the title part
                    spaceposn = text.find(" ")
                    newText = "titleraw" + text[spaceposn:(
                        posn + 7
                    )] + "{\"rawtext\": [ {\"translate\":\"" + key + "\"}]}"  # This is the text to replace on the command. We build it now
                    lines.append(
                        key + "=" + v
                    )  # Add this new key to the language file copy in memory
                    print newText
                    e["Command"] = TAG_String(newText)

        else:
            print "Ignored the " + namespace_obj + " because it is already referring to a translation in the language file: " + key
    else:
        print "Ignored the " + namespace_obj + " because it is already referring to a translation: " + text
        print "Note that the word TRANSLATE can confuse me if it is not a translation"
Exemplo n.º 28
0
def createSign(level, x, y, z, text):  #abrightmoore - convenience method.
    COMMANDBLOCK = 137
    CHUNKSIZE = 16

    setBlock(level, (63, 8), x, y, z)
    control = TAG_Compound()
    control["id"] = TAG_String("Sign")
    control["Text1"] = TAG_String(text[0])
    control["Text2"] = TAG_String(text[1])
    control["Text3"] = TAG_String(text[2])
    control["Text4"] = TAG_String(text[3])
    control["x"] = TAG_Int(x)
    control["y"] = TAG_Int(y)
    control["z"] = TAG_Int(z)
    chunka = level.getChunk((int)(x / CHUNKSIZE), (int)(z / CHUNKSIZE))
    chunka.TileEntities.append(control)
    chunka.dirty = True
Exemplo n.º 29
0
def addCommandBlock(level, x, y, z, command):
    chunk = level.getChunk(x / 16, z / 16)
    te = level.tileEntityAt(x, y, z)
    if te != None:
        chunk.TileEntities.remove(te)
    control = TAG_Compound()
    control["Command"] = TAG_String(command)
    control["id"] = TAG_String(u'Control')
    control["CustomName"] = TAG_String(u'@')
    control["x"] = TAG_Int(x)
    control["y"] = TAG_Int(y)
    control["z"] = TAG_Int(z)
    chunk.TileEntities.append(control)
    chunk.dirty = True
    level.setBlockAt(x, y, z, 137)
    level.setBlockDataAt(x, y, z, 0)
    chunk.dirty = True
Exemplo n.º 30
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)