コード例 #1
0
def perform(level, box, options):
    includePos = options["Include position data"]
    entitiesToRemove = []

    for (chunk, slices, point) in level.getChunkSlices(box):

        for _entity in chunk.Entities:
            entity = deepcopy(_entity)
            x = int(entity["Pos"][0].value)
            y = int(entity["Pos"][1].value)
            z = int(entity["Pos"][2].value)

            if box.minx <= x < box.maxx and box.miny <= y < box.maxy and box.minz <= z < box.maxz:
                entitiesToRemove.append((chunk, _entity))

                level.setBlockAt(x, y, z, 52)
                level.setBlockDataAt(x, y, z, 0)

                spawner = TileEntity.Create("MobSpawner", entity=entity)
                TileEntity.setpos(spawner, (x, y, z))
                spawner["Delay"] = TAG_Short(120)
                if not includePos:
                    del spawner["SpawnData"]["Pos"]
                spawner["EntityId"] = entity["id"]

                chunk.TileEntities.append(spawner)

    for (chunk, entity) in entitiesToRemove:
        chunk.Entities.remove(entity)
コード例 #2
0
def spawn(level, box, options):
    entitiesToRemove = []

    for (chunk, slices, point) in level.getChunkSlices(box):

        for entity in chunk.Entities:
            x2 = int(entity["Pos"][0].value - 0.5)
            y2 = int(entity["Pos"][1].value)
            z2 = int(entity["Pos"][2].value - 0.5)

            if x2 >= box.minx and x2 < box.maxx and y2 >= box.miny and y2 < box.maxy and z2 >= box.minz and z2 < box.maxz and entity[
                    "id"].value == "MinecartSpawner":
                entitiesToRemove.append((chunk, entity))

                level.setBlockAt(x2, y2, z2, 52)
                # Sets the block at the coordinates to 52, the spawner block
                spawner = TileEntity.Create("MobSpawner")
                TileEntity.setpos(spawner, (x2, y2, z2))
                # Makes the block at the coordinates a Tile Entity with the value of Spawner
                spawner["Delay"] = TAG_Short(120)
                spawner["SpawnData"] = entity
                spawner["EntityId"] = entity["id"]

                chunk.TileEntities.append(spawner)

    for (chunk, entity) in entitiesToRemove:
        chunk.Entities.remove(entity)
コード例 #3
0
def performed(level, box, options):
    includePos = options["Include position data"]
    entitiesToRemove = []

    for (chunk, slices, point) in level.getChunkSlices(box):

        for _entity in chunk.Entities:
            entity = deepcopy(_entity)
            x = int(entity["Pos"][0].value)
            y = int(entity["Pos"][1].value)
            z = int(entity["Pos"][2].value)

            if box.minx <= x < box.maxx and box.miny <= y < box.maxy and box.minz <= z < box.maxz:
                entitiesToRemove.append((chunk, _entity))

                level.setBlockAt(x, y, z, 52)
                level.setBlockDataAt(x, y, z, 0)

                spawner = TileEntity.Create("MobSpawner", entity=entity)
                TileEntity.setpos(spawner, (x, y, z))
                spawner["Delay"] = TAG_Short(120)
                if not includePos:
                    del spawner["SpawnData"]["Pos"]
                spawner["EntityId"] = entity["id"]

                chunk.TileEntities.append(spawner)

    for (chunk, entity) in entitiesToRemove:
        chunk.Entities.remove(entity)
コード例 #4
0
def perform(level, box, options):
	includePos = options["Include position data"]
	entitiesToRemove = []

	for (chunk, slices, point) in level.getChunkSlices(box):
	
		for entity in chunk.Entities:
			x = int(entity["Pos"][0].value)
			y = int(entity["Pos"][1].value)
			z = int(entity["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:
				entitiesToRemove.append((chunk, entity))

				level.setBlockAt(x, y, z, 52)

				spawner = TileEntity.Create("MobSpawner")
				TileEntity.setpos(spawner, (x, y, z))
				spawner["Delay"] = TAG_Short(120)
				spawner["SpawnData"] = entity
				if not includePos:
					spawner["SpawnData"].value.remove(entity["Pos"])
				spawner["EntityId"] = entity["id"]
				
				chunk.TileEntities.append(spawner)
		
	for (chunk, entity) in entitiesToRemove:
		chunk.Entities.remove(entity)
コード例 #5
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())
コード例 #6
0
def spawn(level, box, options):
    entitiesToRemove = []

    for (chunk, slices, point) in level.getChunkSlices(box):

        for entity in chunk.Entities:
            x2 = int(entity["Pos"][0].value-0.5)
            y2 = int(entity["Pos"][1].value)
            z2 = int(entity["Pos"][2].value-0.5)

            if x2 >= box.minx and x2 < box.maxx and y2 >= box.miny and y2 < box.maxy and z2 >= box.minz and z2 < box.maxz and entity["id"].value == "MinecartSpawner":
                entitiesToRemove.append((chunk, entity))

                level.setBlockAt(x2, y2, z2, 52)
                # Sets the block at the coordinates to 52, the spawner block
                spawner = TileEntity.Create("MobSpawner")
                TileEntity.setpos(spawner, (x2, y2, z2))
                # Makes the block at the coordinates a Tile Entity with the value of Spawner
                spawner["Delay"] = TAG_Short(120)
                spawner["SpawnData"] = entity
                spawner["EntityId"] = entity["id"]

                chunk.TileEntities.append(spawner)

    for (chunk, entity) in entitiesToRemove:
        chunk.Entities.remove(entity)
コード例 #7
0
ファイル: build.py プロジェクト: intchanter/Skyblock-CE
 def add_entity(self, entity, position):
     east, south, up = position
     chunk_east = east // 16
     chunk_south = south // 16
     if not (chunk_east, chunk_south) in self.chunks:
         raise KeyError('position not in world slice: {}'.format(position))
     chunk = self.chunks[chunk_east, chunk_south]
     TileEntity.setpos(entity, (east, up, south))
     chunk.TileEntities.append(entity)
コード例 #8
0
ファイル: build.py プロジェクト: intchanter/Skyblock-CE
 def add_entity(self, entity, position):
     east, south, up = position
     chunk_east = east // 16
     chunk_south = south // 16
     if not (chunk_east, chunk_south) in self.chunks:
         raise KeyError('position not in world slice: {}'.format(position))
     chunk = self.chunks[chunk_east, chunk_south]
     TileEntity.setpos(entity, (east, up, south))
     chunk.TileEntities.append(entity)
コード例 #9
0
def fillChestAt(level, x, y, z):
	chunk = level.getChunk(x / 16, z / 16)

	chest = TileEntity.Create("Chest")
	TileEntity.setpos(chest, (x, y, z))

	if(random.random() < 0.8):
		chest["Items"].append(createItemInRange(256, 294)) #various weapons/random

	if(random.random() < 0.8):
		chest["Items"].append(createItemInRange(298, 317)) #various armor

	if(random.random() < 0.9):
		chest["Items"].append(createItemInRange(318, 350)) #various food/tools

	if(random.random() < 0.9):
		chest["Items"].append(createItemInRange(351, 351)) #various food/tools
	
	if(random.random() < 0.3):
		chest["Items"].append(createItemWithRandomDamage(383, 50, 52)) # various spawn eggs

	if(random.random() < 0.9):
		chest["Items"].append(createItemWithRandomDamage(383, 54, 62)) #various spawn eggs
		
	if(random.random() < 0.2):
		chest["Items"].append(createItemWithRandomDamage(383, 65, 68)) #various spawn eggs

	if(random.random() < 0.4):
		chest["Items"].append(createItemWithRandomDamage(383, 90, 96)) #various spawn eggs

	if(random.random() < 0.2):
		chest["Items"].append(createItemWithRandomDamage(383, 98, 98)) #ocelot spawn egg

	if(random.random() < 0.1):
		chest["Items"].append(createItemWithRandomDamage(383, 120, 120)) #villager spawn egg
		
	if(random.random() < 0.4):
		chest["Items"].append(createItemWithRandomDamage(383, 101, 101)) #rabbit spawn egg
	
	if(random.random() < 0.1):
		chest["Items"].append(createItemWithRandomDamage(383, 100, 100)) #horse spawn egg
	
	if random.random() < 0.1:
		chest["Items"].append(createItemWithRandomDamage(397, 0, 4)) # masks

	if(random.random() < 0.9):
		itemid = randint(1, 5)
		count = randint(10, 64)
		slot = randint(0, 26)
		blocks = createItem(itemid, count, 0, slot)
		chest["Items"].append(blocks)

	sapling = createItemWithRandomDamage(6, 0, 5)
	sapling["Slot"] = TAG_Byte(randint(0, 26))
	chest["Items"].append(sapling)

	chunk.TileEntities.append(chest)
コード例 #10
0
    def setEntity(self, y, x, z, value, entityID):
        self.matrix[y][x][z] = value
        self.changed[y][x][z] = False

        x = self.getWorldX(x)
        z = self.getWorldZ(z)
        y = self.getWorldY(y)

        self.level.setBlockAt((int)(x), (int)(y), (int)(z), value[0])
        self.level.setBlockDataAt((int)(x), (int)(y), (int)(z), value[1])

        chunk = self.level.getChunk(x / 16, z / 16)
        entity = TileEntity.Create(entityID)
        TileEntity.setpos(entity, (x, y, z))
        chunk.TileEntities.append(entity)
コード例 #11
0
ファイル: skygrid.py プロジェクト: YeetoCheeto72/SkyGrid
def fillChestAt(level, x, y, z):
    chunk = level.getChunk(x / 16, z / 16)

    chest = TileEntity.Create("Chest")
    TileEntity.setpos(chest, (x, y, z))

    if (random.random() < 0.7):
        chest["Items"].append(createItemInRange(256,
                                                294))  #various weapons/random

    if (random.random() < 0.7):
        chest["Items"].append(createItemInRange(298, 317))  #various armor

    if (random.random() < 0.7):
        chest["Items"].append(createItemInRange(318, 350))  #various food/tools

    if (random.random() < 0.3):
        chest["Items"].append(createItemWithRandomDamage(
            383, 50, 52))  # various spawn eggs

    if (random.random() < 0.9):
        chest["Items"].append(createItemWithRandomDamage(
            383, 54, 62))  #various spawn eggs

    if (random.random() < 0.4):
        chest["Items"].append(createItemWithRandomDamage(
            383, 90, 96))  #various spawn eggs

    if (random.random() < 0.1):
        chest["Items"].append(createItemWithRandomDamage(
            383, 98, 98))  #ocelot spawn egg

    if (random.random() < 0.1):
        chest["Items"].append(createItemWithRandomDamage(
            383, 120, 120))  #villager spawn egg

    if (random.random() < 0.7):
        itemid = randomInRange(1, 5)
        count = randomInRange(10, 64)
        slot = randomInRange(0, 26)
        blocks = createItem(itemid, count, 0, slot)
        chest["Items"].append(blocks)

    sapling = createItemWithRandomDamage(6, 0, 3)
    sapling["Slot"] = TAG_Byte(randomInRange(0, 26))
    chest["Items"].append(sapling)

    chunk.TileEntities.append(chest)
コード例 #12
0
ファイル: skygrid.py プロジェクト: YeetoCheeto72/SkyGrid
def setSpawnerAt(level, worldtype, x, y, z):
    chunk = level.getChunk(x / 16, z / 16)

    if worldtype == "Overworld":
        spawns = overworldSpawns()
    elif worldtype == "Nether":
        spawns = netherSpawns()

    spawnindex = randomInRange(0, len(spawns) - 1)

    spawner = TileEntity.Create("MobSpawner")
    TileEntity.setpos(spawner, (x, y, z))
    spawner["Delay"] = TAG_Short(120)
    spawner["EntityId"] = spawns[spawnindex]

    chunk.TileEntities.append(spawner)
コード例 #13
0
def setSpawnerAt(level, worldtype, x, y, z):
	chunk = level.getChunk(x / 16, z / 16)

	if worldtype=="Overworld":
		spawns = overworldSpawns()
	elif worldtype=="Nether":
		spawns = netherSpawns()
		
	spawnindex = randint(0, len(spawns) - 1)

	spawner = TileEntity.Create("MobSpawner")
	TileEntity.setpos(spawner, (x, y, z))
	spawner["Delay"] = TAG_Short(120)
	spawner["EntityId"] = TAG_String(spawns[spawnindex])

	chunk.TileEntities.append(spawner)
コード例 #14
0
ファイル: build.py プロジェクト: intchanter/Skyblock-CE
def make_chest(level, chunk, pos, contents):
    x, z, y = pos
    chest_id = level.materials.Chest.ID
    chunk.Blocks[x % 16, z % 16, y] = chest_id
    chest_facing_west = 4
    chunk.Data[x % 16, z % 16, y] = chest_facing_west
    chest = TileEntity.Create('Chest')
    TileEntity.setpos(chest, (x, y, z))
    slot = 0
    for item in contents:
        try:
            item.name  # Already a TAG_Compound?
            item['Slot'] = TAG_Byte(slot)
            chest['Items'].append(item)
        except AttributeError:
            item['slot'] = slot
            chest['Items'].append(item_stack(item))
        slot += 1
    chunk.TileEntities.append(chest)
コード例 #15
0
ファイル: build.py プロジェクト: intchanter/Skyblock-CE
def make_chest(level, chunk, pos, contents):
    x, z, y = pos
    chest_id = level.materials.Chest.ID
    chunk.Blocks[x % 16, z % 16, y] = chest_id
    chest_facing_west = 4
    chunk.Data[x % 16, z % 16, y] = chest_facing_west
    chest = TileEntity.Create('Chest')
    TileEntity.setpos(chest, (x, y, z))
    slot = 0
    for item in contents:
        try:
            item.name  # Already a TAG_Compound?
            item['Slot'] = TAG_Byte(slot)
            chest['Items'].append(item)
        except AttributeError:
            item['slot'] = slot
            chest['Items'].append(item_stack(item))
        slot += 1
    chunk.TileEntities.append(chest)
コード例 #16
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
コード例 #17
0
ファイル: assembler.py プロジェクト: bowiz2/cbac
def tagged_cb(command_block, location, blockspace):
    """
    Translate a command block into a tile mcentity.
    :param command_block: The command block you want to translate.
    :param location: the location of the block in the blockspace.
    :param blockspace: the blockspace at which the command block is located.
    :return: nbt tag
    """
    command = command_block.command
    if isinstance(command, str):
        command = command_factory(command)
    if hasattr(command, "context"):
        context = command.context
        context.executor = command_block
        context.blockspace = blockspace
    adjust(command_block, command)
    command = command.compile()

    root_tag = nbt.TAG_Compound()

    root_tag["id"] = nbt.TAG_String("Control")

    if command_block.custom_name is not None:
        root_tag["CustomName"] = nbt.TAG_String(command_block.custom_name)
    if command_block.always_active:
        root_tag['auto'] = nbt.TAG_Byte(1)

    root_tag["facing"] = nbt.TAG_String(command_block.facing)
    # Set the location of the command block.
    TileEntity.setpos(root_tag, location)
    # Parse the command of the command block.

    root_tag["Command"] = nbt.TAG_String(command)
    root_tag["conditional"] = nbt.TAG_Byte(
        1 if command_block.conditional else 0)

    # Return the tag which represents the mcentity of the command block.
    return root_tag
コード例 #18
0
ファイル: assembler.py プロジェクト: bowiz2/cbac
def tagged_cb(command_block, location, blockspace):
    """
    Translate a command block into a tile mcentity.
    :param command_block: The command block you want to translate.
    :param location: the location of the block in the blockspace.
    :param blockspace: the blockspace at which the command block is located.
    :return: nbt tag
    """
    command = command_block.command
    if isinstance(command, str):
        command = command_factory(command)
    if hasattr(command, "context"):
        context = command.context
        context.executor = command_block
        context.blockspace = blockspace
    adjust(command_block, command)
    command = command.compile()

    root_tag = nbt.TAG_Compound()

    root_tag["id"] = nbt.TAG_String("Control")

    if command_block.custom_name is not None:
        root_tag["CustomName"] = nbt.TAG_String(command_block.custom_name)
    if command_block.always_active:
        root_tag['auto'] = nbt.TAG_Byte(1)

    root_tag["facing"] = nbt.TAG_String(command_block.facing)
    # Set the location of the command block.
    TileEntity.setpos(root_tag, location)
    # Parse the command of the command block.

    root_tag["Command"] = nbt.TAG_String(command)
    root_tag["conditional"] = nbt.TAG_Byte(1 if command_block.conditional else 0)

    # Return the tag which represents the mcentity of the command block.
    return root_tag
コード例 #19
0
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
	
	
コード例 #20
0
def SkeleTest(level, box, options):
    # CONSTANTS AND GLOBAL VARIABLES
    method = "SKELETEST"
    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
        y = box.miny
        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 = "/summon Skeleton ~ ~2 ~ {Equipment:[{},{},{},{},{id:" + str(
                    x
                ) + "}],ActiveEffects:[{Id:14,Amplifier:2,Duration:10000000}]}"

                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())
コード例 #21
0
    def addTileEntity(self, tileEntityTag):
        """
        Adds an entity to the level.
        :param tileEntityTag: nbt.TAG_Compound containing the Tile entity's data.
        :return:
        """
        assert isinstance(tileEntityTag, nbt.TAG_Compound)
        if 'x' not in tileEntityTag:
            return
        x, y, z = TileEntity.pos(tileEntityTag)

        try:
            chunk = self.getChunk(x >> 4, z >> 4)
        except (ChunkNotPresent, ChunkMalformed):
            return
        chunk.addTileEntity(tileEntityTag)
        chunk.dirty = True
コード例 #22
0
    def addTileEntity(self, tileEntityTag):
        """
        Adds an entity to the level.
        :param tileEntityTag: nbt.TAG_Compound containing the Tile entity's data.
        :return:
        """
        assert isinstance(tileEntityTag, nbt.TAG_Compound)
        if 'x' not in tileEntityTag:
            return
        x, y, z = TileEntity.pos(tileEntityTag)

        try:
            chunk = self.getChunk(x >> 4, z >> 4)
        except (ChunkNotPresent, ChunkMalformed):
            return
        chunk.addTileEntity(tileEntityTag)
        chunk.dirty = True
コード例 #23
0
def perform(level, box, options):
	start = time.time()
	print(start)
	file_name = options["Export File Name:"]

	if file_name == "":
		file_name = "translate-java-2-bedrock.txt"

	if file_name.find(".txt") < 0:
		file_name += ".txt"

	output_text = ''
	contents = ''
	
					
	if options["Prepare for Bedrock:"]:
		tileEntitiesToReplace = []
		tileEntitiesToRemove = []
		entitiesToRemove = []
		entitiesToUpdate = []
		tileEntityContainer = []
		entityContainer = []
		for (chunk, slices, point) in level.getChunkSlices(box):
			# get list of all entities in selection
			for t in chunk.TileEntities:				
				x = t["x"].value
				y = t["y"].value
				z = t["z"].value
				coords = str(x) +","+ str(y) +","+str(z)
				id = fixID(t["id"].value)
				if (coords) not in tileEntityContainer:
					tileEntityContainer.append(coords)
					if (x,y,z) in box:
						if id in removeTileEntities:
							# tile entities that need to be removed
							tileEntitiesToRemove.append((chunk, t))		
						else:
							# tile entities that need to be translated
							tileEntitiesToReplace.append((chunk, t))
			# get all entities in selection
			for e in chunk.Entities:
				x = e["Pos"][0].value
				y = e["Pos"][1].value
				z = e["Pos"][2].value
				id = fixID(e["id"].value)
				coords = str(x) +","+ str(y) +","+str(z)	
				if (coords) not in entityContainer:	
					entityContainer.append(coords)					
					if (x,y,z) in box:
						# delete tile entity
						entitiesToRemove.append((chunk, e))
						# removed replacement code until entities can be translated
						#if (id in removeEntities):
							#entitiesToRemove.append((chunk, e))	
						#else:
							#entitiesToUpdate.append((chunk, e))
		
		if tileEntitiesToReplace:
			for (chunk, t) in tileEntitiesToReplace:
				iIgnore = 0
				x = t["x"].value
				y = t["y"].value
				z = t["z"].value
				id = fixID(t["id"].value)	
				# check to see if the ID needs to be translated
				if id in tileEntityNameReplacements:
					id = tileEntityNameReplacements[id]
				blockid = level.blockAt(x,y,z)
				contents += "----"+id+" "+str(x)+","+str(y)+","+str(z)+"\n"
				contents += str(chunk)+"\n"+ str(t) + "\n\n"
				chunk.TileEntities.remove(t)
				newte = TileEntity.Create(id)
				TileEntity.setpos(newte, (x, y, z))
				# rewrite spawner data - no features carried over as bedrock doesn't support
				# SpawnData or SpawnPotentials
				# adding MinSpawnDelay, MaxSpawnDelay, MaxNearbyEntities, etc is a good idea
				if ("Banner" in id):
					newte = t
					del newte["Patterns"]
				if ("Skull" in id):
					newte = t
					newte["MouthMoving"] = TAG_Byte(0)
					newte["MouthTickCount"] = TAG_Int(0)
					
				if ("MobSpawner" in id):
					try:
						entityName = t["SpawnData"]["id"].value.replace("minecraft:","")
					except KeyError:
						entityName = t["EntityId"].value
					if not str(entityName).isdigit():
						entityName = fixID(entityName)
						print(entityName)
					if (entityName in idMappings["entities"]):
						newte = t
						if "SpawnData" in newte:
							del newte["SpawnData"]
						if "SpawnPotentials" in newte:
							del newte["SpawnPotentials"]
						if entityName.isdigit():
							entityId = entityName
						else:
							entityId = idMappings["entities"][entityName]
						newte["EntityId"] = TAG_Int(int(entityId))
					else:
						print("ENTITY NOT FOUND REPLACED WITH ZOMBIE: "+str(entityName)+" "+str(x)+","+str(y)+","+str(z))
						contents += "ENTITY NOT FOUND REPLACED WITH ZOMBIE: "+str(entityName)+" "+str(x)+","+str(y)+","+str(z)+"\n"
						newte = t
						if "SpawnData" in newte:						
							del newte["SpawnData"]
						if "SpawnPotentials" in newte:							
							del newte["SpawnPotentials"]
						newte["EntityId"] = TAG_Int(32)
				# MCEdit doesn't add all the needed tags when creating a new tile entity
				if ("Items" in t) and (not "Items" in newte):
					newte["Items"]=TAG_List()
				# if the tile entity has an inventory, convert the inventory
				if ("Items" in t) and ("Items" in newte):
					for i in t["Items"]:
						if not str(i["id"].value).isdigit():
							itemNew = stripID(i["id"].value)
							if itemNew in idMappings["items"]:
								idItems = idMappings["items"][itemNew]	
							elif itemNew in idMappings:
								idItems = idMappings[itemNew]["id"]
							else:
								idItems = 248
								print("ITEM NOT FOUND: "+str(i["id"].value)+" "+str(x)+","+str(y)+","+str(z))
								contents += "ITEM NOT FOUND: "+str(i["id"].value)+" "+str(x)+","+str(y)+","+str(z)+"\n"
						else:
							idItems = i["id"].value
						idItems = int(idItems)					
						item = TAG_Compound()
						item["id"] = TAG_Short(idItems)
						if stripID(i["id"].value) == "lava_bucket":
							item["Damage"] = TAG_Short(10)
						elif stripID(i["id"].value) == "water_bucket":
							item["Damage"] = TAG_Short(8)
						elif stripID(i["id"].value) == "milk_bucket":	
							item["Damage"] = TAG_Short(1)
						else:
							item["Damage"] = TAG_Short(i["Damage"].value)
						item["Count"] = TAG_Byte(i["Count"].value)
						item["Slot"] = TAG_Byte(i["Slot"].value)
						if "tag" in i:
							pset=0
							item["tag"] = TAG_Compound(i["tag"].value)
							if ("Potion" in item["tag"]) and (not itemNew in idMappings):
								potion = stripID(item["tag"]["Potion"].value)
								if potion in idMappings["potions"]:
									item["Damage"] = TAG_Short(int(idMappings["potions"][potion]))
							elif ("Potion" in item["tag"]) and (itemNew in idMappings):
								potion = stripID(item["tag"]["Potion"].value)
								item["Damage"] = TAG_Short(int(idMappings[itemNew][potion]))
								del item["tag"]["Potion"]
							if ("ench" in i["tag"]):
								enchHolder = TAG_List()
								for e in i["tag"]["ench"]:
									ench = TAG_Compound()
									enchId = e["id"].value
									enchLvl = e["lvl"].value
									if str(enchId) in idMappings["enchantments"]:
										enchId = int(idMappings["enchantments"][str(enchId)])
										ench["lvl"] = TAG_Short(enchLvl)
										ench["id"] = TAG_Short(enchId)	
										enchHolder.append(ench)
								item["tag"]["ench"] = enchHolder
							if "StoredEnchantments" in i["tag"]:
								enchHolder = TAG_List()
								for e in i["tag"]["StoredEnchantments"]:
									ench = TAG_Compound()
									enchId = e["id"].value
									enchLvl = e["lvl"].value
									if str(enchId) in idMappings["enchantments"]:
										enchId = int(idMappings["enchantments"][str(enchId)])
										ench["lvl"] = TAG_Short(enchLvl)
										ench["id"] = TAG_Short(enchId)	
										enchHolder.append(ench)
								item["tag"]["ench"] = enchHolder
								del item["tag"]["StoredEnchantments"]
							if "CanPlaceOn" in i["tag"]:
								canPlaceOn = TAG_List()
								for p in i["tag"]["CanPlaceOn"]:
									canPlaceOn.append(TAG_String(p.value.replace("minecraft:","")))
								del item["tag"]["CanPlaceOn"]
								item["CanPlaceOn"] = canPlaceOn
							if "CanDestroy" in i["tag"]:
								canDestroy = TAG_List()
								for p in i["tag"]["CanDestroy"]:
									canDestroy.append(TAG_String(p.value.replace("minecraft:","")))
								del item["tag"]["CanDestroy"]
								item["CanDestroy"] = canDestroy
						newte["Items"].append(item)
				# convert command block data after fixing the ID earlier
				if id == "CommandBlock":
					newte = t
					if "UpdateLastExecution" in newte:
						del newte["UpdateLastExecution"]
					if "auto" not in newte:
						newte["auto"] = TAG_Byte(0)
					if "powered" not in newte:
						newte["powered"] = TAG_Byte(0)				
					if "SuccessCount" not in newte:
						newte["SuccessCount"] = TAG_Int(0)
					if "conditionMet" not in newte:
						newte["conditionMet"] = TAG_Byte(0)		
					if "TrackOutput" not in newte:
						newte["TrackOutput"] = TAG_Byte(0)		
					if ("CustomName" not in newte) or newte["CustomName"] == TAG_String(u'@'):
						newte["CustomName"] = TAG_String('')
				# my attempt at converting signs with or without json data
				# still probably breaks some (most?) signs that are json formatted
				if id == "Sign":
					if "Text1" in t:
						if t["Text1"].value.find('"text":') > 0:
							text1 = t["Text1"].value
							text1 = json.loads(text1)
							text1 = text1["text"]
							newte["Text1"] = TAG_String(text1)
						else:
							text1 = t["Text1"].value
							if not text1 == "":
								if (text1[0] == '"' and text1[:1] == '"'):
									text1 = text1[:-1]
									text1 = text1[1:]
							newte["Text1"] = TAG_String(text1)
					if "Text2" in t:
						if t["Text2"].value.find('"text":') > 0:
							text2 = t["Text2"].value
							text2 = json.loads(text2)
							text2 = text2["text"]
							newte["Text2"] = TAG_String(text2)
						else:
							text2 = t["Text2"].value
							if not text2 == "":
								if (text2[0] == '"' and text2[:1] == '"'):
									text2 = text2[:-1]
									text2 = text2[1:]
							newte["Text2"] = TAG_String(text2)
					if "Text3" in t:
						if t["Text3"].value.find('"text":') > 0:
							text3 = t["Text3"].value
							text3 = json.loads(text3)
							text3 = text3["text"]
							newte["Text3"] = TAG_String(text3)
						else:
							text3 = t["Text3"].value
							if not text3 == "":
								if (text3[0] == '"' and text3[:1] == '"'):
									text3 = text3[:-1]
									text3 = text3[1:]
							newte["Text3"] = TAG_String(text3)
					if "Text4" in t:
						if t["Text4"].value.find('"text":') > 0:
							text4 = t["Text4"].value
							text4 = json.loads(text4)
							text4 = text4["text"]
							newte["Text4"] = TAG_String(text4)
						else:
							text4 = t["Text4"].value
							if not text4 == "":
								if (text4[0] == '"' and text4[:1] == '"'):
									text4 = text4[:-1]
									text4 = text4[1:]
							newte["Text4"] = TAG_String(text4)
				# convert new style brewing stands (with blaze powder) to old style
				# will need to be reverted for 1.2 (which uses blaze powder)
				# also translates some tags
				if id == "BrewingStand":
					itemHolder = TAG_List()
					if "BrewTime" in t:
						newte["CookTime"] = t["BrewTime"]
					else:
						newte["CookTime"] = t["CookTime"]
					for i in t["Items"]:
						item = TAG_Compound()
						if i["Slot"].value == 3:
							slotID = stripID(i["id"].value)
							slotID = idMappings['items'][slotID]
							item["Slot"] = TAG_Byte(0)
							item["id"] = TAG_Short(int(slotID))
							item["Damage"] = i["Damage"]
							item["Count"] = i["Count"]
						elif i["Slot"].value == 0:
							slotID = stripID(i["id"].value)
							slotID = idMappings['items'][slotID]
							item["Slot"] = TAG_Byte(1)
							item["Count"] = i["Count"]
							item["id"] = TAG_Short(int(slotID))
							if "tag" in i:
								potionType = stripID(i["tag"]["Potion"].value)
								item["Damage"] = TAG_Short(int(idMappings['potions'][potionType]))
							else:
								potionType = i["Damage"].value
								item["Damage"] = TAG_Short(int(idMappings['potions'][potionType]))
						elif i["Slot"].value == 1:
							slotID = stripID(i["id"].value)
							slotID = idMappings['items'][slotID]
							item["Slot"] = TAG_Byte(2)	
							item["Count"] = i["Count"]
							item["id"] = TAG_Short(int(slotID))
							if "tag" in i:
								potionType = stripID(i["tag"]["Potion"].value)
								item["Damage"] = TAG_Short(int(idMappings['potions'][potionType]))
							else:
								potionType = i["Damage"].value
								item["Damage"] = TAG_Short(int(idMappings['potions'][potionType]))
						elif i["Slot"].value == 2:
							slotID = stripID(i["id"].value)
							slotID = idMappings['items'][slotID]
							item["Slot"] = TAG_Byte(3)
							item["Count"] = i["Count"]
							item["id"] = TAG_Short(int(slotID))
							if "tag" in i:
								potionType = stripID(i["tag"]["Potion"].value)
								item["Damage"] = TAG_Short(int(idMappings['potions'][potionType]))
							else:
								potionType = i["Damage"].value
								item["Damage"] = TAG_Short(int(idMappings['potions'][potionType]))
						itemHolder.append(item)
					newte["Items"] = itemHolder
				newte["id"] = TAG_String(str(id))
				chunk.TileEntities.append(newte)
				# playing around with java mode. If enabled it removes the block be keeps
				# the tile entity data. usecase would be to copy the tile entity data over
				# a world converted with a different tool
				if options["Java Mode:"]:
					level.setBlockAt(x, y, z, 0)
				else: 
					level.setBlockAt(x, y, z, blockid)
								
		if tileEntitiesToRemove:
			for (chunk, t) in tileEntitiesToRemove:
				x = t["x"].value
				y = t["y"].value
				z = t["z"].value
				id = fixID(t["id"].value)	
				contents += "----"+id+" "+str(x)+","+str(y)+","+str(z)+"\n"
				contents += str(chunk)+"\n"+ str(t) + "\n\n"
				chunk.TileEntities.remove(t)
				level.setBlockAt(x, y, z, 0)
		
		if 	entitiesToRemove:
			for (chunk, e) in entitiesToRemove:
				x = e["Pos"][0].value
				y = e["Pos"][1].value
				z = e["Pos"][2].value
				id = fixID(e["id"].value)
				contents += "----"+id+" "+str(x)+","+str(y)+","+str(z)+"\n"
				contents += str(chunk)+"\n"+ str(e) + "\n\n"
				chunk.Entities.remove(e)

		# beginning of translate entity data
		# not currently used
		if 	entitiesToUpdate:
			for (chunk, e) in entitiesToUpdate:
				x = e["Pos"][0].value
				y = e["Pos"][1].value
				z = e["Pos"][2].value
				id = fixID(e["id"].value)
				newEntity = e
				newEntity["id"] = TAG_String(id)
				contents += "----"+id+" "+str(x)+","+str(y)+","+str(z)+"\n"
				contents += str(chunk)+"\n"+ str(e) + "\n\n"
				chunk.Entities.remove(e)
				chunk.Entities.append(newEntity)
		
		output_text += contents
		chunk.dirty = True
	output_text = output_text.encode('utf-8')
	with open(file_name, "w") as text_file:
		text_file.write(output_text)	
	end = time.time()
	finalTime = end - start
	print(end)
	print("It took " + str(finalTime) + " seconds to complete the requested operation")	
コード例 #24
0
def createCommandBlockData(x, y, z, theCommand):
    e = TileEntity.Create("Control")
    e["Command"] = TAG_String(theCommand)
    TileEntity.setpos(e, (x, y, z))
    return e
コード例 #25
0
def createCommandBlockData(x, y, z, theCommand):
    e = TileEntity.Create("minecraft:command_block")
    e["Command"] = TAG_String(theCommand)
    TileEntity.setpos(e, (x, y, z))
    return e
コード例 #26
0
def MobRidingTest(level, box, options):
	# CONSTANTS AND GLOBAL VARIABLES
	method = "MOB RIDING TEST"
	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
	MOBS = [ "Chicken",
			"Cow",
			"Ozelot",
			"Pig",
			"Sheep",
			"EntityHorse",
			"Squid",
			"Bat",
			"Villager",
			"MushroomCow",
			"CaveSpider",
			"Enderman",
			"Spider",
			"Wolf",
			"PigZombie",
			"Blaze",
			"Creeper",
			"Ghast",
			"LavaSlime",
			"Silverfish",
			"Skeleton",
			"Slime",
			"Witch",
#			"WitherSkeleton",
			"Zombie",
#			"ZombieVillager",
#			"ChickenJockey",
			"SnowMan",
			"VillagerGolem",
			"Giant",
			]
			#			"EnderDragon",

#			"Wither"
			
		
	mobCounterX = 0
	mobCounterY = 0
	# 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
		y = box.miny
		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):
				Rider = MOBS[mobCounterX]
				Mount = MOBS[mobCounterY]
				mobCounterY = mobCounterY + 1
				if mobCounterY >= len(MOBS):
					mobCounterY = 0
					mobCounterX = mobCounterX + 1
					if mobCounterX >= len(MOBS):
						mobCounterX = 0
						mobCounterY = 0
				
				theCommand = "/summon "+Rider+" ~ ~ ~8 {Riding:{id:"+Mount+"}}"
				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())
コード例 #27
0
def perform(level, box, options):
	global materials
	materials = []

	for g in xrange(len(palettes)):
		if options[materialGroups[g]]:
			materials += palettes[g]

	if options["Use Local Skin"]:
		reader = png.Reader(os.path.join(cwd, options["Character Name"] + ".png"))
		(width, height, pixels, metadata) = reader.asRGBA8()
		pixels = list(pixels)
	else:
		skinData = downloadSkin(options["Character Name"])
		if skinData == None:
			return
		(width, height, pixels, metadata) = skinData

	oneEight = pixels and height == 64

	if options["Half Size"]:
		regions[:] = regionsOldHalf
	else:
		regions[:] = regionsNew if oneEight else regionsOld
		if oneEight:
			for i, part in enumerate(layerParts):
				if options[part]:
					regions.extend(layerRegions[i])

	if not options["Half Size"]:
		if options["Character Name"] == "deadmau5" or options["Force Mouse Ears"]:
			regions.append((25, 31, 1, 7, XDIM, YDIM, -1, 31, 4))  # Right Ear
			regions.append((25, 31, 1, 7, -XDIM, YDIM, 11, 31, 4)) # Left Ear
	elif options["Half Size"]:
		simple = []
		final = []
		pack = []

		for i, package in enumerate(pixels):
			simple.extend(pixels[i])
		pixels = simple	

		for x, item in enumerate(pixels):
			if x % 4 == 0:
				y = x / 4
				if y % 2 == 0:
					final.extend(pixels[x : x + 4])
		pixels = final

		for i, group in enumerate(pixels):
			if i % 256 == 0:
				pack.append(pixels[i : i + 256])
		pixels = pack
		if options["Character Name"] == "deadmau5" or options["Force Mouse Ears"]:
			regions.append((15, 19, 0, 4, XDIM, YDIM, -1, 15, 2)) # Right Ear
			regions.append((15, 19, 0, 4, -XDIM, YDIM, 5, 15, 2)) # Left Ear

	for (xl, xh, yl, yh, dim1, dim2, sx, sy, sz) in regions:
		lx = sx
		ly = sy
		lz = sz
		if dim1 == -ZDIM:
			lz = sz + xh-xl - 1
		if dim2 == -ZDIM:
			lz = sz + yh-yl - 1
		if dim1 == -XDIM:
			lx = sx + xh-xl - 1

		for px in range(xl, xh):
			for py in reversed(range(yl, yh)):
				color = getPixel(pixels, px, py)
				if not transparent(color):
					(mat, dat) = closestMaterial(color)

					if options["Half Size"]:
						level.setBlockAt(box.minx + 8-lx, box.miny + ly, box.minz + lz, mat)
						level.setBlockDataAt(box.minx + 8-lx, box.miny + ly, box.minz + lz, dat)
					else:
						level.setBlockAt(box.minx + 15-lx, box.miny + ly, box.minz + lz, mat)
						level.setBlockDataAt(box.minx + 15-lx, box.miny + ly, box.minz + lz, dat)

				if dim2 == YDIM:
					ly = ly + 1
				if dim2 == ZDIM:
					lz = lz + 1
				if dim2 == -ZDIM:
					lz = lz - 1

			if dim2 == YDIM:
				ly = sy
			if dim2 == ZDIM:
				lz = sz
			if dim2 == -ZDIM:
				lz = sz + yh-yl - 1

			if dim1 == XDIM:
				lx = lx + 1
			if dim1 == -XDIM:
				lx = lx - 1
			if dim1 == ZDIM:
				lz = lz + 1
			if dim1 == -ZDIM:
				lz = lz - 1

	fill = options["Head filled with:"]

	if not options["Half Size"]:
		for x in range(5,11):
			for y in range(25,31):
				for z in range(2,8):
					level.setBlockAt(box.minx + x, box.miny + y, box.minz + z, fill.ID)
					level.setBlockDataAt(box.minx + x, box.miny + y, box.minz + z, fill.blockData)

	if not options["Half Size"] and options["Sign Label"]:
		level.setBlockAt(box.minx + 8, box.miny + 1, box.minz + 2, 68)
		level.setBlockDataAt(box.minx + 8, box.miny + 1, box.minz + 2, 2)
		level.setBlockAt(box.minx + 7, box.miny + 1, box.minz + 2, 68)
		level.setBlockDataAt(box.minx + 7, box.miny + 1, box.minz + 2, 2)

		sign = TileEntity.Create("Sign")
		TileEntity.setpos(sign, (box.minx + 8, box.miny + 1, box.minz + 2))
		sign["Text1"] = TAG_String("Character:")
		sign["Text2"] = TAG_String("Made with:")
		sign["Text3"] = TAG_String("Created by:")
		sign["Text4"] = TAG_String("Extended by:")
		level.getChunk((box.minx + 8) >> 4, (box.minz + 2) >> 4).TileEntities.append(sign)
		sign = TileEntity.Create("Sign")
		TileEntity.setpos(sign, (box.minx + 7, box.miny + 1, box.minz + 2))
		sign["Text1"] = TAG_String(options["Character Name"])
		sign["Text2"] = TAG_String("Player Statue")
		sign["Text3"] = TAG_String("SethBling")
		sign["Text4"] = TAG_String("pau101")
		level.getChunk((box.minx + 7) >> 4, (box.minz + 2) >> 4).TileEntities.append(sign)

	if options["Half Size"]:
		for x in range(4,6):
			for y in range(13,15):
				for z in range(2,4):
					level.setBlockAt(box.minx + x, box.miny + y, box.minz + z, fill.ID)
					level.setBlockDataAt(box.minx + x, box.miny + y, box.minz + z, fill.blockData)

	if options["Half Size"] and options["Sign Label"]:
		level.setBlockAt(box.minx + 5, box.miny + 1, box.minz + 1, 68)
		level.setBlockDataAt(box.minx + 5, box.miny + 1, box.minz + 1, 2)
		level.setBlockAt(box.minx + 4, box.miny + 1, box.minz + 1, 68)
		level.setBlockDataAt(box.minx + 4, box.miny + 1, box.minz + 1, 2)

		sign = TileEntity.Create("Sign")
		TileEntity.setpos(sign, (box.minx + 5, box.miny + 1, box.minz + 1))
		sign["Text1"] = TAG_String("Character:")
		sign["Text2"] = TAG_String("Made with:")
		sign["Text3"] = TAG_String("Created by:")
		sign["Text4"] = TAG_String("Extended by:")
		level.getChunk((box.minx + 5) >> 4, (box.minz + 1) >> 4).TileEntities.append(sign)
		sign = TileEntity.Create("Sign")
		TileEntity.setpos(sign, (box.minx + 4, box.miny + 1, box.minz + 1))
		sign["Text1"] = TAG_String(options["Character Name"])
		sign["Text2"] = TAG_String("Player Statue")
		sign["Text3"] = TAG_String("SethBling")
		sign["Text4"] = TAG_String("pau101")
		level.getChunk((box.minx + 4) >> 4, (box.minz + 1) >> 4).TileEntities.append(sign)

	if options["Cape                "]:
		if options["Use Local Skin"]:
			file = os.path.join(cwd, options["Character Name"] + "_cape.png")
			if os.path.isfile(file):
				reader = png.Reader(file)
				(width, height, pixels, metadata) = reader.asRGBA8()
				pixels = list(pixels)
			else:
				return
		else:
			capeData = downloadSkin(options["Character Name"], None, True)
			if capeData == None:
				return
			(width, height, pixels, metadata) = capeData

		if options["Half Size"]:
			simple = []
			final = []
			pack = []

			for i, package in enumerate(pixels):
				simple.extend(pixels[i])
			pixels = simple

			for x, item in enumerate(pixels):
				if x % 4 == 0:
					y = x / 4
					if y % 2 == 0:
						final.extend(pixels[x:x+4])
			pixels = final

			for i, group in enumerate(pixels):
				if i % 256 == 0:
					pack.append(pixels[i:i+256])
			pixels = pack

			capeRegions = [
				(0, 6, 2, 9, -XDIM, YDIM, 1, 5, 4),	# Cape
				(0, 1, 2, 9, XDIM, YDIM, 1, 5, 4), # Cape Fix
			]
		else:
			capeRegions = [
				(1, 11, 1, 17, -XDIM, YDIM, 3, 8, 7),	# Cape
			]

		for (xl, xh, yl, yh, dim1, dim2, sx, sy, sz) in capeRegions:
			lx = sx
			ly = sy
			lz = sz
			if dim1 == -ZDIM:
				lz = sz + xh-xl - 1
			if dim2 == -ZDIM:
				lz = sz + yh-yl - 1
			if dim1 == -XDIM:
				lx = sx + xh-xl - 1

			for px in range(xl, xh):
				for py in reversed(range(yl, yh)):
					color = getPixel(pixels, px, py)
					if not transparent(color):
						(mat, dat) = closestMaterial(color)

						if options["Half Size"]:
							level.setBlockAt(box.minx + 8-lx, box.miny + ly, box.minz + lz, mat)
							level.setBlockDataAt(box.minx + 8-lx, box.miny + ly, box.minz + lz, dat)
						else:
							level.setBlockAt(box.minx + 15-lx, box.miny + ly, box.minz + lz, mat)
							level.setBlockDataAt(box.minx + 15-lx, box.miny + ly, box.minz + lz, dat)

					if dim2 == YDIM:
						ly = ly + 1
					if dim2 == ZDIM:
							lz = lz + 1
					if dim2 == -ZDIM:
						lz = lz - 1

				if dim2 == YDIM:
					ly = sy
				if dim2 == ZDIM:
					lz = sz
				if dim2 == -ZDIM:
					lz = sz + yh-yl - 1

				if dim1 == XDIM:
					lx = lx + 1
				if dim1 == -XDIM:
					lx = lx - 1
				if dim1 == ZDIM:
					lz = lz + 1
				if dim1 == -ZDIM:
					lz = lz - 1
コード例 #28
0
ファイル: build.py プロジェクト: intchanter/Skyblock-CE
def spawn_island(level, east, south, target=(6, 6, 64)):
    # TODO: Fill the coordinates based on the actual position of the dirt
    # and spawn islands
    block_radius = 13
    pad_min_east = east - 10
    pad_min_south = south - 10
    pad_max_east = east + 10
    pad_max_south = south + 10
    pad_up = 0  # Bottom of the world so we can't ever spawn below it
    wire_up = pad_up + 1
    redstone_up = wire_up + 1
    cap_up = redstone_up + 1
    slab_id = 126
    slab_data = 0  # oak, lower half
    tripwire_id = 132
    tripwire_data = 4 + 2  # attached and suspended
    tripwire_hook_id = 131
    tripwire_hook_n_data = 4 + 0  # connected, pointing south
    tripwire_hook_s_data = 4 + 2  # connected, pointing north
    redstone_wire_id = 55
    command_block_id = 137
    bedrock_id = 7

    command = u''.join([
        u'/tp',
        u' @p[{s_east},{s_up},{s_south},{radius},c=100]',
        u' {t_east}',
        u' {t_up}',
        u' {t_south}',
    ]).format(
        t_east=target[0],
        t_south=target[1],
        t_up=target[2],
        s_east=east,
        s_south=south,
        s_up=wire_up,
        radius=block_radius,
    )

    # Place the player
    level.setPlayerPosition((east, wire_up + 2, south))
    level.setPlayerSpawnPosition((east, wire_up, south))

    # Get a world slice object
    world_slice = LevelSlice(
        level,
        east=east,
        south=south,
        up=pad_up,
        radius=block_radius,
    )

    world_slice.empty()

    # Slab level
    world_slice.set_blocks(
        block_id=slab_id,
        block_data=slab_data,
        minimum=(pad_min_east, pad_min_south, pad_up),
        maximum=(pad_max_east, pad_max_south, pad_up),
    )

    # Wire level with fully connected tripwire lined N and S with tripwire
    # hooks attached to bedrock
    world_slice.set_blocks(
        block_id=bedrock_id,
        minimum=(pad_min_east, pad_min_south - 2, wire_up),
        maximum=(pad_max_east, pad_max_south + 2, wire_up),
    )
    world_slice.set_blocks(
        block_id=tripwire_hook_id,
        block_data=tripwire_hook_n_data,
        minimum=(pad_min_east, pad_min_south - 1, wire_up),
        maximum=(pad_max_east, pad_min_south - 1, wire_up),
    )
    world_slice.set_blocks(
        block_id=tripwire_hook_id,
        block_data=tripwire_hook_s_data,
        minimum=(pad_min_east, pad_max_south + 1, wire_up),
        maximum=(pad_max_east, pad_max_south + 1, wire_up),
    )
    world_slice.set_blocks(
        block_id=tripwire_id,
        block_data=tripwire_data,
        minimum=(pad_min_east, pad_min_south, wire_up),
        maximum=(pad_max_east, pad_max_south, wire_up),
    )

    # Just above the wire, cap the bedrock on the S and add the redstone
    # wire and command block on the N
    world_slice.set_blocks(
        block_id=slab_id,
        minimum=(pad_min_east, pad_max_south + 2, redstone_up),
        maximum=(pad_max_east, pad_max_south + 2, redstone_up),
    )
    world_slice.set_blocks(
        block_id=redstone_wire_id,
        minimum=(pad_min_east, pad_min_south - 2, redstone_up),
        maximum=(pad_max_east, pad_min_south - 2, cap_up),
    )
    world_slice.set_blocks(
        block_id=command_block_id,
        minimum=(east, pad_min_south - 2, redstone_up),
        maximum=(east, pad_min_south - 2, redstone_up),
    )
    entity = TileEntity.Create('Control')
    entity['Command'] = TAG_String(command)
    entity['LastOutput'] = TAG_String(u'')
    world_slice.add_entity(entity, (east, pad_min_south - 2, redstone_up))

    # Cap redstone wire and command block with slabs
    world_slice.set_blocks(
        block_id=slab_id,
        minimum=(pad_min_east, pad_min_south - 2, cap_up),
        maximum=(pad_max_east, pad_min_south - 2, cap_up),
    )

    world_slice.save()