def perform(level, box, options): # Pre-condition: fill a selection box in MCEdit with south facing Chests (block 54). This filter does not verify the block type and assumes it is a container # Add items to the chests for (chunk, _, _) in level.getChunkSlices(box): for e in chunk.TileEntities: # Loop through all the block entities in this chunk x = e["x"].value y = e["y"].value z = e["z"].value if ( x, y, z ) in box: # Only process the entities within the selection, ignore malformed entries # print e["id"],level.blockAt(x,y,z) # print fromNative(e) e["Items"] = TAG_List() itemsTag = e["Items"] item = TAG_Compound() item["id"] = TAG_String(str(randint(0, 255))) item["Damage"] = TAG_Short(randint(0, 127)) item["Count"] = TAG_Byte(randint(1, 64)) item["Slot"] = TAG_Byte(randint(0, 27)) itemsTag.append(item) if options["Cause the problem?"] == True: chunk.TileEntities.remove(e) chunk.TileEntities.append(e) # At this point each chest should have an item. Check the console for results printEmptyChests(level, box, options)
def 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 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
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 item_stack(item): item_tag = TAG_Compound() item_tag.name = 'tag' item_tag['id'] = TAG_Short(item['id']) item_tag['Damage'] = TAG_Short(item['damage']) item_tag['Count'] = TAG_Byte(item['count']) item_tag['Slot'] = TAG_Byte(item['slot']) return item_tag
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
def createItem(itemid, count=1, damage=0, slot=0): item = TAG_Compound() item["id"] = TAG_Short(itemid) item["Damage"] = TAG_Short(damage) item["Count"] = TAG_Byte(count) item["Slot"] = TAG_Byte(slot) return item
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
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 CreateNewMapFileJava(path, number, colors): map = TAG_Compound() map["data"] = TAG_Compound() map["data"]["scale"] = TAG_Byte(4) map["data"]["dimension"] = TAG_Byte(0) map["data"]["height"] = TAG_Short(128) map["data"]["width"] = TAG_Short(128) map["data"]["xCenter"] = TAG_Int(2147483647) map["data"]["yCenter"] = TAG_Int(2147483647) map["data"]["colors"] = TAG_Byte_Array(colors) map.save(os.path.join(path, "map_" + str(number) + ".dat"))
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)
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 perform(level, box, options): method = "Witherer" print '%s: Started at %s' % (method, time.ctime()) # Logs in the MCEdit console when filter was started for (chunk, slices, point) in level.getChunkSlices(box): #Splits the box into Minecrafts Chunk data that is found in <World Folder>/region for e in chunk.Entities: #Looks for anything in the chunk that is a mob/entity if e["id"].value == "Skeleton": # Check to see if the mob/entity's Id tag matches "Skeleton" x = e["Pos"][0].value y = e["Pos"][1].value z = e["Pos"][2].value # If it does, its position is turned into variables if (x, y, z) in box: # Checks to see if the Mob's position is in the box, so if it is not, the filter will not edit that entity if "id" in e: e["SkeletonType"] = TAG_Byte(1) # Changes the Skeleton Type byte to 1 (Which is the Wither Seletons Byte value print '%s: Ended at %s' % (method, time.ctime()) # Logs in the MCEdit console when the filter finishes chunk.dirty = True
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
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)
def perform(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 # Gets the position of the mob 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: # Checks to see if the Entity has the Health tag if "PersistenceRequired" not in e: e["PersistenceRequired"] = TAG_Byte() e["PersistenceRequired"] = TAG_Byte(1) # Changes the byte to 1 chunk.dirty = True
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))
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
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)
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 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 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 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 CreateItemFramePE(x, y, z, mapid): iframe = TAG_Compound() iframe["id"] = TAG_String("ItemFrame") iframe["x"] = TAG_Int(x) iframe["y"] = TAG_Int(y) iframe["z"] = TAG_Int(z) iframe["Item"] = TAG_Compound() iframe["Item"]["id"] = TAG_Short(358) iframe["Item"]["Damage"] = TAG_Short(0) iframe["Item"]["Count"] = TAG_Byte(1) iframe["Item"]["tag"] = TAG_Compound() iframe["Item"]["tag"]["map_uuid"] = TAG_Long(mapid) return iframe
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
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
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)
def perform(level, box, options): for (chunk, slices, point) in level.getChunkSlices(box): for t in chunk.TileEntities: if t["id"].value == "Trap" or t["id"].value == "Dropper": x = t["x"].value y = t["y"].value z = t["z"].value if (x, y, z) in box: for item in t["Items"]: count = item["Count"].value new_count = count * -1 item["Count"] = TAG_Byte(new_count) chunk.dirty = True
def perform(level, box, options): method = "Witherer" print '%s: Started at %s' % (method, time.ctime()) for (chunk, slices, point) in level.getChunkSlices(box): for e in chunk.Entities: if e["id"].value == "Skeleton": x = e["x"].value y = e["y"].value z = e["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: if "id" in e: e["SkeletonType"] = TAG_Byte(1) print '%s: Started at %s' % (method, time.ctime()) chunk.dirty = True
def makeItemNBT(id, count, damage): ''' Prepare an item of the form: TAG_Compound({ "Slot": TAG_Byte(21), "id": TAG_String(u'minecraft:iron_boots'), "Count": TAG_Byte(1), "Damage": TAG_Short(0), }), ''' item = TAG_Compound() item["id"] = TAG_String("minecraft:" + id) item["Count"] = TAG_Byte(int(count)) item["Damage"] = TAG_Short(int(damage)) return item