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 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 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 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 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 perform(level, box, options): method = "Spawner Pointer" xend = [] yend = [] zend = [] radi = options["Change Spawn Radius?"] print '%s: Started at: %s' % (method, time.ctime()) for x in xrange(box.minx, box.maxx): for y in xrange(box.miny, box.maxy): for z in xrange(box.minz, box.maxz): block = level.blockAt(x, y, z) if block == 19: xend.append(x) yend.append(y) zend.append(z) for (chunk, slices, point) in level.getChunkSlices(box): for e in chunk.Entities: if e["id"].value == "MinecartSpawner": x2 = e["Pos"][0].value y2 = e["Pos"][1].value z2 = e["Pos"][2].value if x2 >= box.minx and x2 < box.maxx and y2 >=box.miny and y2 < box.maxy and z2 >= box.minz and z2 < box.maxz: if "SpawnData" in e: pos = e["Spawndata"] pos["Pos"] = TAG_List() pos["Pos"].append(TAG_Double(xend+0.5)) pos["Pos"].append(TAG_Double(yend+0.5)) pos["Pos"].append(TAG_Double(zend+0.5)) del e["SpawnPotentials"] if radi: e["SpawnRange"] = TAG_Short(1) print '%s %s %s' % (xend, yend, zend) print '%s: Ended at: %s' % (method, time.ctime()) level.markDirtyBox(box) for t in chunk.TileEntities: x1 = t["x"].value y1 = t["y"].value z1 = t["z"].value if x1 >= box.minx and x1 < box.maxx and y1 >= box.miny and y1 < box.maxy and z1 >= box.minz and z1 < box.maxz and t["id"].value == "MobSpawner": if "SpawnData" in t: pos = t["Spawndata"] pos["Pos"] = TAG_List() pos["Pos"].append(TAG_Double(xend+0.5)) pos["Pos"].append(TAG_Double(yend+0.5)) pos["Pos"].append(TAG_Double(zend+0.5)) del t["Spawnpotentials"] if radi: t["SpawnRange"] = TAG_Short(1) print '%s %s %s' % (xend, yend, zend) print '%s: Ended at: %s' % (method, time.ctime()) level.markDirtyBox(box)
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 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 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 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)
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)
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)
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 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 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 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 signed_book(title='', pages=[''], author='Skyblock CE'): book_tag = TAG_Compound() book_tag.name = 'tag' book_tag['title'] = title book_tag['author'] = author book_tag['pages'] = TAG_List(name='pages', list_type=TAG_String) for page in pages: book_tag['pages'].append(TAG_String(page)) item_tag = TAG_Compound() item_tag['id'] = TAG_Short(items.names['Written Book']) item_tag['Damage'] = TAG_Byte(0) item_tag['Count'] = TAG_Byte(1) item_tag['tag'] = book_tag return item_tag
def createSandEntity(x, y, z, block, data, life): sand = TAG_Compound() sand["Motion"] = TAG_List() sand["Motion"].append(TAG_Double(0)) sand["Motion"].append(TAG_Double(0.04)) sand["Motion"].append(TAG_Double(0)) sand["OnGround"] = TAG_Byte(1) sand["DropItem"] = TAG_Byte(0) sand["Dimension"] = TAG_Int(0) sand["Air"] = TAG_Short(300) sand["Pos"] = TAG_List() sand["Pos"].append(TAG_Double(x + 0.5)) sand["Pos"].append(TAG_Double(y + 0.5)) sand["Pos"].append(TAG_Double(z + 0.5)) sand["Data"] = TAG_Byte(data) sand["TileID"] = TAG_Int(block) sand["Tile"] = TAG_Byte(block) sand["Time"] = TAG_Byte(life) sand["Fire"] = TAG_Short(-1) sand["FallDistance"] = TAG_Float(0) sand["Rotation"] = TAG_List() sand["Rotation"].append(TAG_Float(0)) sand["Rotation"].append(TAG_Float(0)) return sand
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)
def createChest(blockData,count,canPlaceOn,chest,level): newte = TileEntity.Create("Chest") slot = 0 for i in blockData: if count[i] > 64: icount = 1 iterCount = math.ceil(count[i]/64.0) rcount = count[i] % 64 while icount <= iterCount: if icount == iterCount: item= TAG_Compound() item["CanPlaceOn"] = TAG_List() item["id"] = TAG_Short(i[0]) item["Damage"] = TAG_Short(i[1]) item["Count"] = TAG_Byte(rcount) item["Slot"] = TAG_Byte(int(slot)) item["CanPlaceOn"] = [TAG_String(canPlaceOn)] newte["Items"].append(item) slot += 1 else: item= TAG_Compound() item["CanPlaceOn"] = TAG_List() item["id"] = TAG_Short(i[0]) item["Damage"] = TAG_Short(i[1]) item["Damage"] = TAG_Short(i[1]) item["Count"] = TAG_Byte(64) item["Slot"] = TAG_Byte(int(slot)) item["CanPlaceOn"] = [TAG_String(canPlaceOn)] newte["Items"].append(item) slot += 1 icount += 1 else: item= TAG_Compound() item["CanPlaceOn"] = TAG_List() item["id"] = TAG_Short(i[0]) item["Damage"] = TAG_Short(i[1]) item["Count"] = TAG_Byte(count[i]) item["Slot"] = TAG_Byte(int(slot)) item["CanPlaceOn"] = [TAG_String(canPlaceOn)] newte["Items"].append(item) slot += 1 print(chest) newte['x'] = TAG_Int(chest[0]) newte['y'] = TAG_Int(chest[1]) newte['z'] = TAG_Int(chest[2]) return newte
def 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
def makeBookNBT(texts): book = TAG_Compound() book["id"] = TAG_String("minecraft:writable_book") book["Count"] = TAG_Byte(1) book["Damage"] = TAG_Short(0) tag = TAG_Compound() pages = TAG_List() LIMIT = 150 discarded = False for page in texts: if len(pages) < LIMIT: pages.append(TAG_String(page)) else: discarded = True if discarded == True: print "WARNING: Book length exceeded " + str( LIMIT) + " pages. Truncated!" book["tag"] = tag tag["pages"] = pages return book
def perform(level, box, options): # Read in the supplied text from the nominated file filename = options["File path"] text = loadTextFromFile(filename) tagName = options["Tag to replace"] tagType = options["Tag type"] for (chunk, _, _) in level.getChunkSlices(box): print "TileEntities:" for e in chunk.TileEntities: print e #if e["id"].value == "ChalkboardBlock": if tagName in e: if tagType == "TAG_String" and type(e[tagName]) is TAG_String: e[tagName] = TAG_String(text) chunk.dirty = True elif tagType == "TAG_Byte" and type(e[tagName]) is TAG_Byte: e[tagName] = TAG_Byte(int(text)) chunk.dirty = True elif tagType == "TAG_Int" and type(e[tagName]) is TAG_Int: e[tagName] = TAG_Int(int(text)) chunk.dirty = True elif tagType == "TAG_Short" and type(e[tagName]) is TAG_Short: e[tagName] = TAG_Short(int(text)) chunk.dirty = True elif tagType == "TAG_Long" and type(e[tagName]) is TAG_Long: e[tagName] = TAG_Long(int(text)) chunk.dirty = True elif tagType == "TAG_Float" and type(e[tagName]) is TAG_Float: e[tagName] = TAG_Float(float(text)) chunk.dirty = True elif tagType == "TAG_Double" and type( e[tagName]) is TAG_Double: e[tagName] = TAG_Double(float(text)) chunk.dirty = True else: print "Tag", tagName, "of type", tagType, "is a", type( e[tagName])
def makeMobSpawnerNBT(type): obj = TAG_Compound() obj["id"] = TAG_String("minecraft:mob_spawner") obj["MaxNearbyEntities"] = TAG_Short(6) obj["RequiredPlayerRange"] = TAG_Short(8) obj["SpawnCount"] = TAG_Short(1) obj["MaxSpawnDelay"] = TAG_Short(800) obj["Delay"] = TAG_Short(371) obj["SpawnRange"] = TAG_Short(4) obj["MinSpawnDelay"] = TAG_Short(200) spawnData = TAG_Compound() obj["SpawnData"] = spawnData spawnData["id"] = TAG_String(type) spawnPotentials = TAG_List() obj["SpawnPotentials"] = spawnPotentials entity = TAG_Compound() spawnPotentials.append(entity) entity["Entity"] = TAG_Compound() entity["Entity"]["id"] = TAG_String(type) entity["Weight"] = TAG_Int(1) return obj
angle = angle + 2 * pi return angle # createSandSpawner() function by @SethBling (http://youtube.com/SethBling) # hacks by @abrightmoore def createSandSpawner(x, y, z, (block, data), frameNum, numFrames, tx, ty, tz, interval, delay, TICKS, life): spawner = TAG_Compound() spawner["id"] = TAG_String("MobSpawner") spawner["Items"] = TAG_List() spawner["x"] = TAG_Int(x) spawner["y"] = TAG_Int(y) spawner["z"] = TAG_Int(z) spawner["Delay"] = TAG_Short(TICKS * frameNum + delay) spawner["MinSpawnDelay"] = TAG_Short(interval + TICKS * numFrames) spawner["MaxSpawnDelay"] = TAG_Short(interval + TICKS * numFrames + 1) spawner["SpawnCount"] = TAG_Short(1) spawner["SpawnData"] = createSandEntity(tx, ty, tz, block, data, life) spawner["MaxNearbyEntities"] = TAG_Short(10000) spawner["RequiredPlayerRange"] = TAG_Short(128) spawner["EntityId"] = TAG_String("FallingSand") return spawner # createSandEntity() function by @SethBling (http://youtube.com/SethBling) # hacks by @abrightmoore def createSandEntity(x, y, z, block, data, life): sand = TAG_Compound() sand["Motion"] = TAG_List()
def createShop(level, x, y, z, emptyTrade, invincible, profession, unlimited, xp, nomove, silent, name, yaxis, xaxis, IsCustomHead, SkullType, PlayerName): chest = level.tileEntityAt(x, y, z) if chest is None: return priceList = {} priceListB = {} saleList = {} for item in chest["Items"]: slot = item["Slot"].value if 0 <= slot <= 8: priceList[slot] = item elif 9 <= slot <= 17: priceListB[slot - 9] = item elif 18 <= slot <= 26: saleList[slot - 18] = item villager = TAG_Compound() villager["PersistenceRequired"] = TAG_Byte(1) villager["OnGround"] = TAG_Byte(1) villager["Air"] = TAG_Short(300) villager["AttackTime"] = TAG_Short(0) villager["DeathTime"] = TAG_Short(0) villager["Fire"] = TAG_Short(-1) villager["Health"] = TAG_Short(20) villager["HurtTime"] = TAG_Short(0) villager["Age"] = TAG_Int(0) villager["Profession"] = TAG_Int(profession) villager["Career"] = TAG_Int(1) villager["CareerLevel"] = TAG_Int(1000) villager["Riches"] = TAG_Int(200) villager["FallDistance"] = TAG_Float(0) villager["CustomNameVisible"] = TAG_Byte(1) villager["CustomName"] = TAG_String(name) villager["Invulnerable"] = TAG_Byte(invincible) villager["NoAI"] = TAG_Byte(nomove) villager["id"] = TAG_String("Villager") villager["Motion"] = TAG_List( [TAG_Double(0.0), TAG_Double(0.0), TAG_Double(0.0)]) villager["Pos"] = TAG_List( [TAG_Double(x + 0.5), TAG_Double(y), TAG_Double(z + 0.5)]) villager["Rotation"] = TAG_List([TAG_Float(yaxis), TAG_Float(xaxis)]) villager["Willing"] = TAG_Byte(0) villager["Offers"] = TAG_Compound() villager["Offers"]["Recipes"] = TAG_List() if silent: villager["Silent"] = TAG_Byte(1) else: villager["Silent"] = TAG_Byte(0) for i in range(9): if (i in priceList or i in priceListB) and i in saleList: offer = TAG_Compound() if xp: offer["rewardExp"] = TAG_Byte(1) else: offer["rewardExp"] = TAG_Byte(0) if unlimited: offer["uses"] = TAG_Int(0) offer["maxUses"] = TAG_Int(2000000000) else: offer["uses"] = TAG_Int(0) offer["maxUses"] = TAG_Int(1) if i in priceList: offer["buy"] = priceList[i] if i in priceListB: if i in priceList: offer["buyB"] = priceListB[i] else: offer["buy"] = priceListB[i] offer["sell"] = saleList[i] villager["Offers"]["Recipes"].append(offer) if emptyTrade: offer = TAG_Compound() offer["buy"] = TAG_Compound() offer["buy"]["Count"] = TAG_Byte(1) offer["buy"]["Damage"] = TAG_Short(0) offer["buy"]["id"] = TAG_String("minecraft:barrier") offer["sell"] = TAG_Compound() offer["sell"]["Count"] = TAG_Byte(1) offer["sell"]["Damage"] = TAG_Short(0) offer["sell"]["id"] = TAG_String("minecraft:barrier") villager["Offers"]["Recipes"].append(offer) if IsCustomHead: Head = TAG_Compound() Head["id"] = TAG_Short(397) Head["Damage"] = TAG_Short(SkullType) if SkullType == 3 and PlayerName: Head["tag"] = TAG_Compound() Head["tag"]["SkullOwner"] = TAG_String(PlayerName) villager["Equipment"] = TAG_List([ TAG_Compound(), TAG_Compound(), TAG_Compound(), TAG_Compound(), Head ]) level.setBlockAt(x, y, z, 0) chunk = level.getChunk(x / 16, z / 16) chunk.Entities.append(villager) chunk.TileEntities.remove(chest) chunk.dirty = True
def performed(level, box, options): health = options["Health"] vx = options["VelocityX"] vy = options["VelocityY"] vz = options["VelocityZ"] fire = options["Fire"] fall = options["FallDistance"] air = options["Air"] attackTime = options["AttackTime"] hurtTime = options["HurtTime"] powered = options["Lightning Creeper"] blockId = options["Enderman Block Id"] blockData = options["Enderman Block Data"] profession = options["Villager Profession"] size = options["Slime Size"] breedTicks = options["Breeding Mode Ticks"] age = options["Child/Adult Age"] 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 health != noop: e["Health"] = TAG_Short(health) if vx != noop: e["Motion"][0] = TAG_Double(vx) if vy != noop: e["Motion"][1] = TAG_Double(vy) if vz != noop: e["Motion"][2] = TAG_Double(vz) if fire != noop: e["Fire"] = TAG_Short(fire) if fall != noop: e["FallDistance"] = TAG_Float(fall) if air != noop: e["Air"] = TAG_Short(air) if attackTime != noop: e["AttackTime"] = TAG_Short(attackTime) if hurtTime != noop: e["HurtTime"] = TAG_Short(hurtTime) if powered != "N/A" and (e["id"].value == "Creeper" or MCEDIT_IDS.get(e["id"].value) == "DEF_ENTITIES_CREEPER"): if powered == "Lightning": e["powered"] = TAG_Byte(1) if powered == "No Lightning": e["powered"] = TAG_Byte(0) if blockId != noop and (e["id"].value == "Enderman" or MCEDIT_IDS.get(e["id"].value) == "DEF_ENTITIES_ENDERMAN"): e["carried"] = TAG_Short(blockId) if blockData != noop and (e["id"].value == "Enderman" or MCEDIT_IDS.get(e["id"].value) == "DEF_ENTITIES_ENDERMAN"): e["carriedData"] = TAG_Short(blockData) if profession != "N/A" and (e["id"].value == "Villager" or MCEDIT_IDS.get(e["id"].value) == "DEF_ENTITIES_VILLAGER"): e["Profession"] = TAG_Int(Professions[profession]) if size != noop and (e["id"].value == "Slime" or MCEDIT_IDS.get(e["id"].value) == "DEF_ENTITIES_SLIME"): e["Size"] = TAG_Int(size) if breedTicks != noop: e["InLove"] = TAG_Int(breedTicks) if age != noop: e["Age"] = TAG_Int(age) chunk.dirty = True
def createXeno(level, x, y, z, customName, Invisible, CustomNameVisible, Invulnerable, Marker, NoGravity, MotionX, MotionY, MotionZ, RotationX, RotationY, Small,ShowArms,NoBasePlate,HandItem1,HandItem2,ArmorItem1,ArmorItem2,ArmorItem3,ArmorItem4,ArmorItem4Data,PoseBodyX,PoseBodyY,PoseBodyZ,PoseHeadX,PoseHeadY,PoseHeadZ,PoseRightArmX,PoseRightArmY,PoseRightArmZ,PoseLeftArmX,PoseLeftArmY,PoseLeftArmZ,PoseRightLegX,PoseRightLegY,PoseRightLegZ,PoseLeftLegX,PoseLeftLegY,PoseLeftLegZ): # After @Sethbling print("New Xeno named "+customName+" at "+str(x)+","+str(y)+","+str(z)) mob = TAG_Compound() mob["NoAI"] = TAG_Byte(1) mob["LeftHanded"] = TAG_Byte(1) mob["PersistenceRequired"] = TAG_Byte(1) mob["CustomName"] = TAG_String(customName) mob["Invisible"] = TAG_Byte(Invisible) mob["Small"] = TAG_Byte(Small) # mob["ShowArms"] = TAG_Byte(ShowArms) # mob["NoBasePlate"] = TAG_Byte(NoBasePlate) 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(40) 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)) tl_AI = TAG_List() tc_AI1 = TAG_Compound() tc_AI1["Count"] = TAG_Byte(1) tc_AI1["id"] = TAG_String(HandItem1) tl_AI.append(tc_AI1) tc_AI1 = TAG_Compound() tc_AI1["Count"] = TAG_Byte(1) tc_AI1["id"] = TAG_String(HandItem2) tl_AI.append(tc_AI1) mob["HandItems"] = tl_AI tl_AI = TAG_List() tc_AI1 = TAG_Compound() tc_AI1["Count"] = TAG_Byte(1) tc_AI1["id"] = TAG_String(ArmorItem1) tl_AI.append(tc_AI1) tc_AI1 = TAG_Compound() tc_AI1["Count"] = TAG_Byte(1) tc_AI1["id"] = TAG_String(ArmorItem2) tl_AI.append(tc_AI1) tc_AI1 = TAG_Compound() tc_AI1["Count"] = TAG_Byte(1) tc_AI1["id"] = TAG_String(ArmorItem3) tl_AI.append(tc_AI1) tc_AI1 = TAG_Compound() tc_AI1["Count"] = TAG_Byte(1) tc_AI1["id"] = TAG_String(ArmorItem4) tc_AI1["Damage"] = TAG_Short(ArmorItem4Data) tl_AI.append(tc_AI1) mob["ArmorItems"] = tl_AI # Cave Spider head tl_Pass = TAG_List() tc_Pass1 = TAG_Compound() tc_Pass1["id"] = TAG_String("CaveSpider") tc_Pass1["NoAI"] = TAG_Byte(1) tc_Pass1["PersistenceRequired"] = TAG_Byte(1) tc_Pass1["CustomName"] = TAG_String(customName) tc_Pass1["Invisible"] = TAG_Byte(Invisible) tc_Pass1["Small"] = TAG_Byte(Small) tc_Pass1["CustomNameVisible"] = TAG_Byte(CustomNameVisible) tc_Pass1["Invulnerable"] = TAG_Byte(Invulnerable) tc_Pass1["NoGravity"] = TAG_Byte(NoGravity) tc_Pass1["OnGround"] = TAG_Byte(1) tc_Pass1["Air"] = TAG_Short(300) tc_Pass1["DeathTime"] = TAG_Short(0) tc_Pass1["Fire"] = TAG_Short(-1) tc_Pass1["Health"] = TAG_Short(12) tc_Pass1["HurtTime"] = TAG_Short(0) tc_Pass1["Age"] = TAG_Int(0) tc_Pass1["FallDistance"] = TAG_Float(0) tc_Pass1["Motion"] = TAG_List() tc_Pass1["Motion"].append(TAG_Double(MotionX)) tc_Pass1["Motion"].append(TAG_Double(MotionY)) tc_Pass1["Motion"].append(TAG_Double(MotionZ)) tc_Pass1["Pos"] = TAG_List() tc_Pass1["Pos"].append(TAG_Double(x + 0.5)) tc_Pass1["Pos"].append(TAG_Double(y)) tc_Pass1["Pos"].append(TAG_Double(z + 0.5)) tc_Pass1["Rotation"] = TAG_List() tc_Pass1["Rotation"].append(TAG_Float(RotationX)) tc_Pass1["Rotation"].append(TAG_Float(RotationY)) tl_Pass.append(tc_Pass1) mob["Passengers"] = tl_Pass # End Cave Spider head mob["id"] = TAG_String("Enderman") chunk = level.getChunk(int(x) / CHUNKSIZE, int(z) / CHUNKSIZE) chunk.Entities.append(mob) chunk.dirty = True