def rewards(money): result = nbt.NBTTagList(tag_type=nbt.NBTTagCompound) r = nbt.NBTTagCompound() r['ftb_money'] = nbt.NBTTagLong(money) r['type'] = nbt.NBTTagString('ftbmoney:money') r['uid'] = nbt.NBTTagInt(JavaInt.to_signed(gen_id(), 16)) result.append(r) return result
def tasks(item, count): result = nbt.NBTTagList(tag_type=nbt.NBTTagCompound) r = nbt.NBTTagCompound() r['item'] = nbt.NBTTagString(item.idx) r['type'] = nbt.NBTTagString('item') r['uid'] = nbt.NBTTagInt(JavaInt.to_signed(gen_id(), 16)) result.append(r) return result
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
def create_template(self): dungeon = nbt.NBTTagCompound() dungeon['Version'] = nbt.NBTTagInt(2) dungeon['DataVersion'] = nbt.NBTTagInt(2584) dungeon['Width'] = nbt.NBTTagShort(self.dimensions.width) dungeon['Length'] = nbt.NBTTagShort(self.dimensions.length) dungeon['Height'] = nbt.NBTTagShort(self.dimensions.total_height) dungeon['BlockData'] = nbt.NBTTagList(tag_type_id=10) dungeon['BlockEntities'] = nbt.NBTTagByteArray() oy = self.dimensions.levels * self.dimensions.height md = nbt.NBTTagCompound() md['WEOffsetX'] = nbt.NBTTagInt(0) md['WEOffsetY'] = nbt.NBTTagInt(-oy) md['WEOffsetZ'] = nbt.NBTTagInt(0) dungeon['Metadata'] = md dungeon['Offset'] = nbt.NBTTagByteArray([0, 0, 0]) # TODO handle palette better std_stairs = 'half=bottom,shape=straight,waterlogged=false' p, pm = create_palette({ 'stone': 0, 'smooth_stone': 1, 'air': AIR, f'stone_brick_stairs[facing=north,{std_stairs}]': 3, f'stone_brick_stairs[facing=east,{std_stairs}]': 4, f'stone_brick_stairs[facing=south,{std_stairs}]': 5, f'stone_brick_stairs[facing=west,{std_stairs}]': 6, 'polished_granite': 7, 'gold_block': 8, }) dungeon['Palette'] = p dungeon['PaletteMax'] = pm self.dungeon = dungeon block_data = np.zeros(self.dimensions.total_area, dtype=int) self.block_data = block_data.reshape(*self.dimensions.measurements)
class InterfaceTest(unittest.TestCase): tag = nbt.NBTTagCompound() def test01_setter(self): self.tag.setTagByte('byte', 8) self.tag.setTagShort('short', 32767) self.tag.setTagInt('int', 16777216) self.tag.setTagLong('long', -8000000000000) self.tag.setTagString('string', 'test') self.tag.setTagByteArray('byte_array', [1, 2, 3]) self.tag.setTagIntArray('int_array', [400, 500, 600]) self.tag.setTagLongArray('long_array', [606664, 46164546]) self.assertEqual(self.tag.getTagByte('byte'), 8) self.assertEqual(self.tag.getTagShort('short'), 32767) self.assertEqual(self.tag.getTagInt('int'), 16777216) self.assertEqual(self.tag.getTagLong('long'), -8000000000000) self.assertEqual(self.tag.getTagString('string'), 'test') self.assertEqual(self.tag.getTagByteArray('byte_array'), [1, 2, 3]) self.assertEqual(self.tag.getTagIntArray('int_array'), [400, 500, 600]) self.assertEqual(self.tag.getTagLongArray('long_array'), [606664, 46164546])
def gen_quest(_id, name, lvl): global ench_count quest = nbt.NBTTagCompound() quest['x'] = nbt.NBTTagDouble(5.5 + ench_count // 7) quest['y'] = nbt.NBTTagDouble(-1 + ench_count % 7) quest['tasks'] = nbt.NBTTagList(tag_type=nbt.NBTTagCompound) task = nbt.NBTTagCompound() task['uid'] = nbt.NBTTagInt(JavaInteger.to_signed(gen_id(), base=16)) task['type'] = nbt.NBTTagString('item') task['title'] = nbt.NBTTagString( '附魔书 - %s' % (name + (intoRoman(lvl) if lvl > 1 else ''))) task['ignore_nbt'] = nbt.NBTTagByte(2) task['ignore_damage'] = nbt.NBTTagByte(1) task['item'] = nbt.NBTTagCompound() task['item']['id'] = nbt.NBTTagString("minecraft:enchanted_book") task['item']['tag'] = nbt.NBTTagCompound() 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
def create_palette(d: typing.Dict[str,int]): palette = nbt.NBTTagCompound() for k in d: palette[f'minecraft:{k}'] = nbt.NBTTagInt(d[k]) return palette, nbt.NBTTagInt(len(d))
"harvestcraft:flaxitem", "harvestcraft:amaranthitem", "harvestcraft:elderberryitem", ] gardens = [aridGarden, frostGarden, shadedGarden, soggyGarden, tropicalGarden, windyGarden] garden_names = ['贫瘠', '严寒', '荫蔽', '湿润', '热带', '多风'] base_chapter = gen_id(0x61404d4e) 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()
value = value[2:] value = "0" * (8 - len(value)) + value id_list.append(value) return hex(n)[2:] dump_path = "../../dumps/item.csv" nbt_path = "./chapters/6c4b954f" file = open(dump_path) strings = file.readlines() file.close() 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)