Пример #1
0
    def move_existing_remote_player_to_local_player(self):
        world = LeveldatWorldInfo(self.worldName)

        # get remoter player's data
        remotePlayerData = nbt.read_from_nbt_file(self.absPlayerPath)

        # overwrite local player's data with remote player's
        world.worldLeveldat['Data']['Player'] = remotePlayerData
        nbt.write_to_nbt_file(f'{self.absWorldPath}/level.dat',
                              world.worldLeveldat)
Пример #2
0
    def move_local_player_to_remote_player(
            self):  # probably wont use this function
        world = LeveldatWorldInfo(self.worldName)

        # get current local player's data
        currLocalPlayer = world.worldLeveldat['Data']['Player']
        currLocalPlayerUUID = self.unparse_UUID_array(
            currLocalPlayer['UUID'].json_obj(full_json=True)['value'])

        # move current local player's data to it's player remote data
        nbt.write_to_nbt_file(
            f'{self.absWorldPath}/playerdata/{currLocalPlayerUUID}.dat',
            currLocalPlayer)
Пример #3
0
    def setup_template_for_player(self):
        playerTemplate = nbt.read_from_nbt_file('GamerJuice.dat')
        world = LeveldatWorldInfo(self.worldName)
        world.get_default_gamershit()

        playerTemplate['playerGameType'] = world.gameType
        playerTemplate['Pos'] = world.spawnCoords
        playerTemplate['UUID'] = nbt.TAG_Int_Array(self.playerUUIDArray)
        world.worldLeveldat['Data']['Player'] = playerTemplate

        nbt.write_to_nbt_file(f'{self.absWorldPath}/level.dat',
                              world.worldLeveldat)
        nbt.write_to_nbt_file(f'{self.absWorldPath}/level.dat_old',
                              world.worldLeveldat)
def create_quest(item):
    global counter
    tag = nbt.NBTTagCompound()
    tag['x'] = nbt.NBTTagDouble(counter // 21 - 10)
    tag['y'] = nbt.NBTTagDouble(counter % 21 - 10)
    tag['rewards'] = nbt.NBTTagList(tag_type=nbt.NBTTagCompound)
    tag['tasks'] = nbt.NBTTagList(tag_type=nbt.NBTTagCompound)
    cmp_task = nbt.NBTTagCompound()
    cmp_task['consume'] = nbt.NBTTagByte(1)
    cmp_task['count'] = nbt.NBTTagLong(64)
    cmp_task['item'] = nbt.NBTTagString(item['namespace'] + ':' + item['item'])
    cmp_task['type'] = nbt.NBTTagString('item')
    cmp_task['uid'] = nbt.NBTTagInt(JavaInteger.to_signed(gen_id(), base=16))
    tag['tasks'].append(cmp_task)
    cmp_reward = nbt.NBTTagCompound()
    cmp_reward['ftb_money'] = nbt.NBTTagLong(50)
    cmp_reward['type'] = nbt.NBTTagString('ftbmoney:money')
    cmp_reward['uid'] = nbt.NBTTagInt(JavaInteger.to_signed(gen_id(), base=16))
    tag['rewards'].append(cmp_reward)
    nbt.write_to_nbt_file(os.path.join(chapter, gen_id() + '.nbt'), tag)
    print(item['namespace'], ':', item['item'])
    counter += 1
Пример #5
0
 def test_write(self):
     nbt.write_to_nbt_file('test/test_write.nbt', self.tag)
     read_tag = nbt.read_from_nbt_file('test/test_write.nbt')
     self.assertEqual(read_tag, self.tag)
Пример #6
0
for (subdir, dirs, files) in os.walk("toconvert", topdown=True):
    for file in files:
        directory = subdir + os.sep
        filepath = directory + file

        if filepath.endswith(".nbt"):
            nbtfile = nbt.read_from_nbt_file(filepath)
            traverse_dicts(nbtfile)

            directory = directory.replace("toconvert", "converted").replace(
                originalBiome, newBiome)
            Path(directory).mkdir(parents=True, exist_ok=True)
            newFile = directory + file.replace(originalBiome, newBiome)

            nbt.write_to_nbt_file(newFile, nbtfile)
            continue
        else:
            continue

for x in blockPalette:
    print(x)

print("FINISHED!")
input()

#------------------------------------------------------------------------
'''
# Caves and Cliffs backporting
conversion_partial_dict = {
}
Пример #7
0
 def write_schema(self, file_name: str):
     bd = [int(v) for v in self.block_data.reshape(math.prod(self.block_data.shape))]
     self.dungeon['BlockData'] = nbt.NBTTagByteArray(bd)
     nbt.write_to_nbt_file(file_name, self.dungeon)
Пример #8
0
chapters = [gen_id(int(i, base=16)) for i in ["a2d67590", "b2a6a21a", "9a4d850c", "f764b037", "92df22db", "2ccc878e"]]
for i in range(len(chapters)):
    chapter = chapters[i]
    chapter_dir = os.path.join(result, chapter)
    if not os.path.exists(chapter_dir):
        os.mkdir(chapter_dir)
    chapter_tag = nbt.NBTTagCompound()
    chapter_tag['group'] = nbt.TAG_Int(int(base_chapter, base=16))
    chapter_tag['always_invisible'] = nbt.TAG_Byte(0)
    chapter_tag['title'] = nbt.TAG_String(garden_names[i] + "特产")
    chapter_tag['description'] = nbt.TAG_List(tag_type=nbt.TAG_String)
    chapter_tag['description'].append(nbt.TAG_String("集齐%s菜园掉落的所有农作物." % garden_names[i]))
    import json
    print(json.dumps(chapter_tag.json_obj(False), indent=2))
    print(chapter_dir)
    nbt.write_to_nbt_file(os.path.join(chapter_dir, "chapter.nbt"), chapter_tag)
    
    j = 0
    for crops in gardens[i]:
        quest_tag = nbt.NBTTagCompound()
        quest_tag['tasks'] = nbt.TAG_List(tag_type=nbt.NBTTagCompound)
        task = nbt.TAG_Compound()
        task['type'] = nbt.TAG_String('item')
        task['uid'] = nbt.TAG_Int(int(gen_id(), base=16))
        task['item'] = nbt.TAG_String(crops)
        task['count'] = nbt.TAG_Long(64)
        task['consume'] = nbt.TAG_Byte(1)
        quest_tag['tasks'].insert(0, task)
        quest_tag['x'] = nbt.TAG_Double(j // 6)
        quest_tag['y'] = nbt.TAG_Double(j % 6)
        quest_tag['rewards'] = nbt.TAG_List(tag_type=nbt.TAG_Compound)
Пример #9
0
counter = 0

for s in strings:
   if re.match("harvestcraft:[^_]*_sapling", s):
        quest_tag = nbt.NBTTagCompound()
        quest_tag['tasks'] = nbt.NBTTagList(tag_type=nbt.NBTTagCompound)
        task = nbt.NBTTagCompound()
        task['type'] = nbt.NBTTagString('item')
        task['uid'] = nbt.NBTTagInt(JavaInteger.to_signed(gen_id(), base=16))
        task['count'] = nbt.NBTTagLong(64)
        name = s.split('_')[0] + 'item'
        print(name)
        task['item'] = nbt.NBTTagString(name)
        task['consume'] = nbt.NBTTagByte(1)
        quest_tag['tasks'].append(task)
        quest_tag['x'] = nbt.NBTTagDouble(counter // 6)
        quest_tag['y'] = nbt.NBTTagDouble(counter % 6)
        quest_tag['rewards'] = nbt.NBTTagList(tag_type=nbt.TAG_Compound)
        reward = nbt.TAG_Compound()
        reward['ftb_money'] = nbt.NBTTagLong(5)
        reward['type'] = nbt.NBTTagString('ftbmoney:money')
        reward['uid'] = nbt.NBTTagInt(JavaInteger.to_signed(gen_id(), base=16))
        quest_tag['rewards'].append(reward)
        counter += 1
        nbt.write_to_nbt_file(os.path.join(nbt_path, gen_id()+".nbt"), quest_tag)
        

                  

        
Пример #10
0
    task['item']['tag']['StoredEnchantments'] = nbt.NBTTagList(
        tag_type=nbt.NBTTagCompound)

    enchantment = nbt.NBTTagCompound()
    enchantment['id'] = nbt.NBTTagShort(_id)
    enchantment['lvl'] = nbt.NBTTagShort(lvl)

    task['item']['tag']['StoredEnchantments'].append(enchantment)

    quest['tasks'].append(task)

    quest['rewards'] = nbt.NBTTagList(tag_type=nbt.NBTTagCompound)
    reward = nbt.NBTTagCompound()
    reward['uid'] = nbt.NBTTagInt(JavaInteger.to_signed(gen_id(), base=16))
    reward['type'] = nbt.NBTTagString('ftbmoney:money')
    reward['ftb_money'] = nbt.NBTTagLong(1000)
    quest['rewards'].append(reward)
    ench_count += 1
    return quest


log_file = open('./ench_max_lvl.csv', 'w', encoding='gbk')
chapter = os.path.join('chapters', 'ebeae9f8')
for k in ench_id.keys():
    quest = gen_quest(ench_id[k], ench_name[k], ench_lvl[k])
    quest_id = gen_id()
    nbt.write_to_nbt_file(os.path.join(chapter, quest_id + '.nbt'), quest)
    log_file.write(ench_name[k] + ',' + str(ench_lvl[k]) + ',' + quest_id +
                   '\n')
log_file.close()
Пример #11
0
import python_nbt.nbt as nbt
from python_nbt import JavaInteger

chapters = [
    "61404d4e", "a2d67590", "b2a6a21a", "9a4d850c", "f764b037", "92df22db",
    "2ccc878e"
]

file = nbt.read_from_nbt_file("./config/ftbquests/normal/chapters/index.nbt")

print(hex(JavaInteger.number_bits))
print(file['index'])
[
    file['index'].append(JavaInteger.to_signed(idx, base=16))
    for idx in chapters if idx not in file['index']
]
print(file['index'])

nbt.write_to_nbt_file("./.workspace/nbt/index.nbt", file)