예제 #1
0
 def _save_painting_to_tag(self, painting, tag):
     tag["Dir"] = TAG_Byte(painting.direction)
     tag["Motive"] = TAG_String(painting.motive)
     # Both tile and position will be the center of the image.
     tag["TileX"] = TAG_Int(painting.location.pos.x)
     tag["TileY"] = TAG_Int(painting.location.pos.y)
     tag["TileZ"] = TAG_Int(painting.location.pos.z)
예제 #2
0
    def _save_level_to_tag(self, level):
        tag = Alpha._save_level_to_tag(self, level)

        # Beta version and accounting.
        # Needed for Notchian tools to be able to comprehend this world.
        tag["Data"]["version"] = TAG_Int(19132)
        tag["Data"]["LevelName"] = TAG_String("Generated by Bravo :3")

        return tag
예제 #3
0
    def test_load_entity_from_tag_painting(self):
        tag = TAG_Compound()
        tag["Pos"] = TAG_List(type=TAG_Double)
        tag["Pos"].tags = [TAG_Double(10), TAG_Double(5), TAG_Double(-15)]
        tag["Rotation"] = TAG_List(type=TAG_Double)
        tag["Rotation"].tags = [TAG_Double(90), TAG_Double(0)]
        tag["OnGround"] = TAG_Byte(1)
        tag["id"] = TAG_String("Painting")

        tag["Dir"] = TAG_Byte(1)
        tag["Motive"] = TAG_String("Sea")
        tag["TileX"] = TAG_Int(32)
        tag["TileY"] = TAG_Int(32)
        tag["TileZ"] = TAG_Int(32)

        entity = self.s._load_entity_from_tag(tag)
        self.assertEqual(entity.motive, "Sea")
        self.assertEqual(entity.direction, 1)
예제 #4
0
    def _save_tile_to_tag(self, tile):
        tag = NBTFile()
        tag.name = ""

        tag["id"] = TAG_String(tile.name)

        tag["x"] = TAG_Int(tile.x)
        tag["y"] = TAG_Int(tile.y)
        tag["z"] = TAG_Int(tile.z)

        self._tile_savers[tile.name](tile, tag)

        return tag
예제 #5
0
    def _save_level_to_tag(self, level):
        tag = NBTFile()
        tag.name = ""

        tag["Data"] = TAG_Compound()
        tag["Data"]["RandomSeed"] = TAG_Long(level.seed)
        tag["Data"]["SpawnX"] = TAG_Int(level.spawn[0])
        tag["Data"]["SpawnY"] = TAG_Int(level.spawn[1])
        tag["Data"]["SpawnZ"] = TAG_Int(level.spawn[2])
        tag["Data"]["Time"] = TAG_Long(level.time)

        # Beta version and accounting.
        # Needed for Notchian tools to be able to comprehend this world.
        tag["Data"]["version"] = TAG_Int(19132)
        tag["Data"]["LevelName"] = TAG_String("Generated by Bravo :3")

        return tag
예제 #6
0
    def test_load_entity_from_tag(self):
        tag = TAG_Compound()
        tag["Pos"] = TAG_List(type=TAG_Double)
        tag["Pos"].tags = [TAG_Double(10), TAG_Double(5), TAG_Double(-15)]
        tag["Rotation"] = TAG_List(type=TAG_Double)
        tag["Rotation"].tags = [TAG_Double(90), TAG_Double(0)]
        tag["OnGround"] = TAG_Byte(1)
        tag["id"] = TAG_String("Item")

        tag["Item"] = TAG_Compound()
        tag["Item"]["id"] = TAG_Short(3)
        tag["Item"]["Damage"] = TAG_Short(0)
        tag["Item"]["Count"] = TAG_Short(5)

        entity = self.serializer._load_entity_from_tag(tag)
        self.assertEqual(entity.location.x, 10)
        self.assertEqual(entity.location.yaw, 90)
        self.assertEqual(entity.location.grounded, True)
        self.assertEqual(entity.item[0], 3)
예제 #7
0
    def _save_entity_to_tag(self, entity):
        tag = NBTFile()
        tag.name = ""

        tag["id"] = TAG_String(entity.name)

        position = entity.location.pos
        tag["Pos"] = TAG_List(type=TAG_Double)
        tag["Pos"].tags = [TAG_Double(i) for i in position]

        rotation = entity.location.ori.to_degs()
        tag["Rotation"] = TAG_List(type=TAG_Double)
        tag["Rotation"].tags = [TAG_Double(i) for i in rotation]

        tag["OnGround"] = TAG_Byte(int(entity.location.grounded))

        self._entity_savers[entity.name](entity, tag)

        return tag
예제 #8
0
 def _save_sign_to_tag(self, sign, tag):
     tag["Text1"] = TAG_String(sign.text1)
     tag["Text2"] = TAG_String(sign.text2)
     tag["Text3"] = TAG_String(sign.text3)
     tag["Text4"] = TAG_String(sign.text4)
예제 #9
0
 def _save_mobspawner_to_tag(self, ms, tag):
     tag["EntityId"] = TAG_String(ms.mob)
     tag["Delay"] = TAG_Short(ms.delay)
예제 #10
0
 def _save_wolf_to_tag(self, wolf, tag):
     tag["Owner"] = TAG_String(wolf.owner)
     tag["Sitting"] = TAG_Byte(wolf.sitting)
     tag["Angry"] = TAG_Byte(wolf.angry)