示例#1
0
def boxToVillagerEgg(box, eggType):
    return Compound({
        'id':
        String(f"minecraft:{eggType}_spawn_egg"),
        'Count':
        Byte(1),
        'tag':
        Compound({
            'EntityTag':
            Compound({
                'id':
                String("minecraft:villager"),
                'Invulnerable':
                Byte(1),
                'CustomNameVisible':
                Byte(0),
                'CustomName':
                String(box['tag']['display']['Name']),
                'VillagerData':
                Compound({
                    'level': Int(99),
                    'profession': String("minecraft:librarian")
                }),
                'Offers':
                Compound({
                    'Recipes':
                    List[Compound]([{
                        'rewardExp':
                        Byte(0),
                        'maxUses':
                        Int(2147483647),
                        'buy':
                        Compound({
                            'id': String("minecraft:stick"),
                            'Count': Byte(1)
                        }),
                        'sell':
                        Compound({
                            'id':
                            box['id'],
                            'Count':
                            box['Count'],
                            'tag':
                            Compound({
                                'BlockEntityTag':
                                Compound({'Items': box['tag']['Items']}),
                                'display':
                                box['tag']['display']
                            })
                        })
                    }])
                })
            }),
            'display':
            Compound(box['tag']['display'])
        })
    })
示例#2
0
def boxToSpawnerEgg(box, eggType):
    return Compound({
        'id':
        String(f"minecraft:{eggType}_spawn_egg"),
        'Count':
        Byte(1),
        'tag':
        Compound({
            'EntityTag':
            Compound({
                'id':
                String("minecraft:falling_block"),
                'Time':
                Int(300),
                'BlockState':
                Compound({'Name': String("minecraft:spawner")}),
                'TileEntityData':
                Compound({
                    'RequiredPlayerRange':
                    Int(2),
                    'SpawnCount':
                    Int(1),
                    'SpawnRange':
                    Double(0.5),
                    'Delay':
                    Int(-1),
                    'MinSpawnDelay':
                    Int(20),
                    'MaxSpawnDelay':
                    Int(20),
                    'SpawnPotentials':
                    List[Compound]([{
                        'Entity':
                        Compound({
                            'id':
                            String("minecraft:falling_block"),
                            'Time':
                            Int(300),
                            'BlockState':
                            Compound({'Name': String(box['id'])}),
                            'TileEntityData':
                            Compound({
                                'CustomName':
                                box['tag']['display']['Name'],
                                'Items':
                                box['tag']['Items']
                            })
                        }),
                        'Weight':
                        Int(1)
                    }])
                })
            }),
            'display':
            Compound(box['tag']['display'])
        })
    })
示例#3
0
    async def resetspawn(self, ctx: commands.Context, node: str, server: str,
                         username: str):
        await ctx.send("Resetting player " + username + " to spawn...")
        if node == "london":
            serverid = utils.londonids[server]
        elif node == "canada":
            serverid = utils.canadaids[server]
        elif node == "germany":
            serverid = utils.germanyids[server]
        uuid = utils.getUUID(username)
        if uuid:
            if not os.path.exists(uuid + ".dat"):
                url = serverid + "/world/playerdata/" + uuid + ".dat"
                print(("Downloading " + url + "..."))
                utils.download(url, uuid + ".dat", node)
            dir_path = os.getcwd()
            nbtfile = nbtlib.load(dir_path + "/" + uuid + ".dat")

            url = serverid + "/world/level.dat"

            print(("Downloading " + url + "..."))
            utils.download(url, "level.dat", node)
            worldfile = nbtlib.load(dir_path + "/" + "level.dat")
            xCoord = worldfile.root["Data"]["SpawnX"]
            yCoord = worldfile.root["Data"]["SpawnY"]
            zCoord = worldfile.root["Data"]["SpawnZ"]

            print(
                ("Resetting " + username + "\'s coordinates to " +
                 str(xCoord) + "," + str(yCoord) + "," + str(zCoord) + "..."))
            await ctx.send("Original coords: " + str(nbtfile.root["Pos"][0]) +
                           ", " + str(nbtfile.root["Pos"][1]) + ", " +
                           str(nbtfile.root["Pos"][2]) + " in dim " +
                           str(nbtfile.root["Dimension"]))
            nbtfile.root["Pos"][0] = Double(xCoord)
            nbtfile.root["Pos"][1] = Double(yCoord)
            nbtfile.root["Pos"][2] = Double(zCoord)
            nbtfile.root["Dimension"] = Int(0)
            nbtfile.save()
            await ctx.send("New coords: " + str(nbtfile.root["Pos"][0]) +
                           ", " + str(nbtfile.root["Pos"][1]) + ", " +
                           str(nbtfile.root["Pos"][2]) + " in dim " +
                           str(nbtfile.root["Dimension"]))
            print("Uploading to server...")
            utils.upload(dir_path + "/" + uuid + ".dat",
                         serverid + "/world/playerdata/" + uuid + ".dat", node)
            print("Uploaded!")
            os.unlink(dir_path + "/" + uuid + ".dat")
            os.unlink(dir_path + "/" + "level.dat")
            await ctx.send("Done!")
示例#4
0
 async def resetcoords(self, ctx: commands.Context, node: str, server: str,
                       player: str, x: int, y: int, z: int, dim: int):
     """Reset a player's coords"""
     await ctx.send("Resetting player " + player + " to coords: " + str(x) +
                    ", " + str(y) + ", " + str(z) + " " + "in dimension " +
                    str(dim) + "...")
     if node == "london":
         serverid = utils.londonids[server]
     elif node == "canada":
         serverid = utils.canadaids[server]
     elif node == "germany":
         serverid = utils.germanyids[server]
     uuid = utils.getUUID(player)
     if uuid:
         url = serverid + "/world/playerdata/" + uuid + ".dat"
         print("Downloading " + url + "...")
         utils.download(url, uuid + ".dat", node)
         dir_path = cwd = os.getcwd()
         nbtfile = nbtlib.load(dir_path + "/" + uuid + ".dat")
         print("Resetting " + player + "\'s coordinates to " + str(x) +
               "," + str(y) + "," + str(z) + "...")
         await ctx.send("Original coords: " + str(nbtfile.root["Pos"][0]) +
                        ", " + str(nbtfile.root["Pos"][1]) + ", " +
                        str(nbtfile.root["Pos"][2]) + " in dim " +
                        str(nbtfile.root["Dimension"]))
         nbtfile.root["Pos"][0] = x
         nbtfile.root["Pos"][1] = y
         nbtfile.root["Pos"][2] = z
         nbtfile.root["Dimension"] = Int(dim)
         nbtfile.save()
         await ctx.send("New coords: " + str(nbtfile.root["Pos"][0]) +
                        ", " + str(nbtfile.root["Pos"][1]) + ", " +
                        str(nbtfile.root["Pos"][2]) + " in dim " +
                        str(nbtfile.root["Dimension"]))
         print("Uploading to server...")
         utils.upload(dir_path + "/" + uuid + ".dat",
                      serverid + "/world/playerdata/" + uuid + ".dat", node)
         print("Uploaded!")
         os.unlink(dir_path + "/" + uuid + ".dat")
     await ctx.send("Done!")
示例#5
0
 def test_incompatible_without_subtype(self):
     with pytest.raises(IncompatibleItemType):
         List([Int(2), String('5')])
示例#6
0
 def test_incompatible_with_subtype(self):
     with pytest.raises(IncompatibleItemType):
         List[String]([4, Int(-1)])
示例#7
0
if uuid:
    if not os.path.exists(uuid + ".dat"):
        url = serverid + "/world/playerdata/" + uuid + ".dat"
        print(("Downloading " + url + "..."))
        download(url, uuid + ".dat", node)
    dir_path = cwd = os.getcwd()
    nbtfile = nbtlib.load(dir_path + "/" + uuid + ".dat")

    url = serverid + "/world/level.dat"

    print(("Downloading " + url + "..."))
    download(url, "level.dat", node)
    worldfile = nbtlib.load(dir_path + "/" + "level.dat")
    xCoord = worldfile.root["Data"]["SpawnX"]
    yCoord = worldfile.root["Data"]["SpawnY"]
    zCoord = worldfile.root["Data"]["SpawnZ"]

    print(("Resetting " + username + "\'s coordinates to " + str(xCoord) +
           "," + str(yCoord) + "," + str(zCoord) + "..."))
    nbtfile.root["Pos"][0] = Double(xCoord)
    nbtfile.root["Pos"][1] = Double(yCoord)
    nbtfile.root["Pos"][2] = Double(zCoord)
    nbtfile.root["Dimension"] = Int(0)
    nbtfile.save()
    print("Uploading to server...")
    upload(dir_path + "/" + uuid + ".dat",
           serverid + "/world/playerdata/" + uuid + ".dat", node)
    print("Uploaded!")
    os.unlink(dir_path + "/" + uuid + ".dat")
    os.unlink(dir_path + "/" + "level.dat")
示例#8
0
    ('little', b'\xFF', Byte(-1)),
    ('little', b'\x7F', Byte(127)),
    ('little', b'\x80', Byte(-128)),

    # Short tag
    ('big', b'\x00\x00', Short(0)),
    ('big', b'\xFF\xFF', Short(-1)),
    ('big', b'\x7F\xFF', Short(32767)),
    ('big', b'\x80\x00', Short(-32768)),
    ('little', b'\x00\x00', Short(0)),
    ('little', b'\xFF\xFF', Short(-1)),
    ('little', b'\xFF\x7F', Short(32767)),
    ('little', b'\x00\x80', Short(-32768)),

    # Int tag
    ('big', b'\x00\x00\x00\x00', Int(0)),
    ('big', b'\xFF\xFF\xFF\xFF', Int(-1)),
    ('big', b'\x7F\xFF\xFF\xFF', Int(2147483647)),
    ('big', b'\x80\x00\x00\x00', Int(-2147483648)),
    ('little', b'\x00\x00\x00\x00', Int(0)),
    ('little', b'\xFF\xFF\xFF\xFF', Int(-1)),
    ('little', b'\xFF\xFF\xFF\x7F', Int(2147483647)),
    ('little', b'\x00\x00\x00\x80', Int(-2147483648)),

    # Long tag
    ('big', b'\x00\x00\x00\x00\x00\x00\x00\x00', Long(0)),
    ('big', b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF', Long(-1)),
    ('big', b'\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF', Long(9223372036854775807)),
    ('big', b'\x80\x00\x00\x00\x00\x00\x00\x00', Long(-9223372036854775808)),
    ('little', b'\x00\x00\x00\x00\x00\x00\x00\x00', Long(0)),
    ('little', b'\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF', Long(-1)),
示例#9
0
parser.add_argument("zCoord", nargs=1, type=float)
parser.add_argument("dim", nargs=1, type=int)
args = parser.parse_args()

if args.node[0] == "london":
    serverid = utils.londonids[args.server[0]]
elif args.node[0] == "canada":
    serverid = utils.canadaids[args.server[0]]
elif args.node[0] == "germany":
    serverid = utils.germanyids[args.server[0]]
uuid = utils.getUUID(args.player[0])
if uuid:
    url = serverid + "/world/playerdata/" + uuid + ".dat"
    print("Downloading " + url + "...")
    utils.download(url, uuid + ".dat", args.node[0])
    dir_path = cwd = os.getcwd()
    nbtfile = nbtlib.load(dir_path + "/" + uuid + ".dat")
    print("Resetting " + args.player[0] + "\'s coordinates to " +
          str(args.xCoord[0]) + "," + str(args.yCoord[0]) + "," +
          str(args.zCoord[0]) + "...")
    nbtfile.root["Pos"][0] = args.xCoord[0]
    nbtfile.root["Pos"][1] = args.yCoord[0]
    nbtfile.root["Pos"][2] = args.zCoord[0]
    nbtfile.root["Dimension"] = Int(args.dim[0])
    nbtfile.save()
    print("Uploading to server...")
    utils.upload(dir_path + "/" + uuid + ".dat",
                 serverid + "/world/playerdata/" + uuid + ".dat", args.node[0])
    print("Uploaded!")
    os.unlink(dir_path + "/" + uuid + ".dat")