1
Fork 0
mirror of https://github.com/Steffo99/lihzahrd.git synced 2024-11-21 15:44:24 +00:00

Parse mob data

This commit is contained in:
Steffo 2019-08-12 18:22:48 +02:00
parent d9f7afe199
commit 7fac0d3be5
8 changed files with 724 additions and 15 deletions

View file

@ -0,0 +1,5 @@
from .npc import NPC
from .mob import Mob
from .entitytype import EntityType
__all__ = ["NPC", "Mob", "EntityType"]

View file

@ -0,0 +1,654 @@
import enum
class EntityType(enum.IntEnum):
"""An enumeration of all entity types.
From https://github.com/tModLoader/tModLoader/wiki/Vanilla-NPC-IDs ."""
BIG_HORNET_STINGY = -65
LITTLE_HORNET_STINGY = -64
BIG_HORNET_SPIKEY = -63
LITTLE_HORNET_SPIKEY = -62
BIG_HORNET_LEAFY = -61
LITTLE_HORNET_LEAFY = -60
BIG_HORNET_HONEY = -59
LITTLE_HORNET_HONEY = -58
BIG_HORNET_FATTY = -57
LITTLE_HORNET_FATTY = -56
BIG_RAIN_ZOMBIE = -55
SMALL_RAIN_ZOMBIE = -54
BIG_PANTLESS_SKELETON = -53
SMALL_PANTLESS_SKELETON = -52
BIG_MISASSEMBLED_SKELETON = -51
SMALL_MISASSEMBLED_SKELETON = -50
BIG_HEADACHE_SKELETON = -49
SMALL_HEADACHE_SKELETON = -48
BIG_SKELETON = -47
SMALL_SKELETON = -46
BIG_FEMALE_ZOMBIE = -45
SMALL_FEMALE_ZOMBIE = -44
DEMON_EYE2 = -43
PURPLE_EYE2 = -42
GREEN_EYE2 = -41
DIALATED_EYE2 = -40
SLEEPY_EYE2 = -39
CATARACT_EYE2 = -38
BIG_TWIGGY_ZOMBIE = -37
SMALL_TWIGGY_ZOMBIE = -36
BIG_SWAMP_ZOMBIE = -35
SMALL_SWAMP_ZOMBIE = -34
BIG_SLIMED_ZOMBIE = -33
SMALL_SLIMED_ZOMBIE = -32
BIG_PINCUSHION_ZOMBIE = -31
SMALL_PINCUSHION_ZOMBIE = -30
BIG_BALD_ZOMBIE = -29
SMALL_BALD_ZOMBIE = -28
BIG_ZOMBIE = -27
SMALL_ZOMBIE = -26
BIG_CRIMSLIME = -25
LITTLE_CRIMSLIME = -24
BIG_CRIMERA = -23
LITTLE_CRIMERA = -22
GIANT_MOSS_HORNET = -21
BIG_MOSS_HORNET = -20
LITTLE_MOSS_HORNET = -19
TINY_MOSS_HORNET = -18
BIG_STINGER = -17
LITTLE_STINGER = -16
HEAVY_SKELETON = -15
BIG_BONED = -14
SHORT_BONES = -13
BIG_EATER = -12
LITTLE_EATER = -11
JUNGLE_SLIME = -10
YELLOW_SLIME = -9
RED_SLIME = -8
PURPLE_SLIME = -7
BLACK_SLIME = -6
BABY_SLIME = -5
PINKY = -4
GREEN_SLIME = -3
SLIMER2 = -2
SLIMELING = -1
BLUE_SLIME = 1
DEMON_EYE = 2
ZOMBIE = 3
EYEOF_CTHULHU = 4
SERVANTOF_CTHULHU = 5
EATEROF_SOULS = 6
DEVOURER_HEAD = 7
DEVOURER_BODY = 8
DEVOURER_TAIL = 9
GIANT_WORM_HEAD = 10
GIANT_WORM_BODY = 11
GIANT_WORM_TAIL = 12
EATEROF_WORLDS_HEAD = 13
EATEROF_WORLDS_BODY = 14
EATEROF_WORLDS_TAIL = 15
MOTHER_SLIME = 16
MERCHANT = 17
NURSE = 18
ARMS_DEALER = 19
DRYAD = 20
SKELETON = 21
GUIDE = 22
METEOR_HEAD = 23
FIRE_IMP = 24
BURNING_SPHERE = 25
GOBLIN_PEON = 26
GOBLIN_THIEF = 27
GOBLIN_WARRIOR = 28
GOBLIN_SORCERER = 29
CHAOS_BALL = 30
ANGRY_BONES = 31
DARK_CASTER = 32
WATER_SPHERE = 33
CURSED_SKULL = 34
SKELETRON_HEAD = 35
SKELETRON_HAND = 36
OLD_MAN = 37
DEMOLITIONIST = 38
BONE_SERPENT_HEAD = 39
BONE_SERPENT_BODY = 40
BONE_SERPENT_TAIL = 41
HORNET = 42
MAN_EATER = 43
UNDEAD_MINER = 44
TIM = 45
BUNNY = 46
CORRUPT_BUNNY = 47
HARPY = 48
CAVE_BAT = 49
KING_SLIME = 50
JUNGLE_BAT = 51
DOCTOR_BONES = 52
THE_GROOM = 53
CLOTHIER = 54
GOLDFISH = 55
SNATCHER = 56
CORRUPT_GOLDFISH = 57
PIRANHA = 58
LAVA_SLIME = 59
HELLBAT = 60
VULTURE = 61
DEMON = 62
BLUE_JELLYFISH = 63
PINK_JELLYFISH = 64
SHARK = 65
VOODOO_DEMON = 66
CRAB = 67
DUNGEON_GUARDIAN = 68
ANTLION = 69
SPIKE_BALL = 70
DUNGEON_SLIME = 71
BLAZING_WHEEL = 72
GOBLIN_SCOUT = 73
BIRD = 74
PIXIE = 75
NONE2 = 76
ARMORED_SKELETON = 77
MUMMY = 78
DARK_MUMMY = 79
LIGHT_MUMMY = 80
CORRUPT_SLIME = 81
WRAITH = 82
CURSED_HAMMER = 83
ENCHANTED_SWORD = 84
MIMIC = 85
UNICORN = 86
WYVERN_HEAD = 87
WYVERN_LEGS = 88
WYVERN_BODY = 89
WYVERN_BODY2 = 90
WYVERN_BODY3 = 91
WYVERN_TAIL = 92
GIANT_BAT = 93
CORRUPTOR = 94
DIGGER_HEAD = 95
DIGGER_BODY = 96
DIGGER_TAIL = 97
SEEKER_HEAD = 98
SEEKER_BODY = 99
SEEKER_TAIL = 100
CLINGER = 101
ANGLER_FISH = 102
GREEN_JELLYFISH = 103
WEREWOLF = 104
BOUND_GOBLIN = 105
BOUND_WIZARD = 106
GOBLIN_TINKERER = 107
WIZARD = 108
CLOWN = 109
SKELETON_ARCHER = 110
GOBLIN_ARCHER = 111
VILE_SPIT = 112
WALLOF_FLESH = 113
WALLOF_FLESH_EYE = 114
THE_HUNGRY = 115
THE_HUNGRY_II = 116
LEECH_HEAD = 117
LEECH_BODY = 118
LEECH_TAIL = 119
CHAOS_ELEMENTAL = 120
SLIMER = 121
GASTROPOD = 122
BOUND_MECHANIC = 123
MECHANIC = 124
RETINAZER = 125
SPAZMATISM = 126
SKELETRON_PRIME = 127
PRIME_CANNON = 128
PRIME_SAW = 129
PRIME_VICE = 130
PRIME_LASER = 131
BALD_ZOMBIE = 132
WANDERING_EYE = 133
THE_DESTROYER = 134
THE_DESTROYER_BODY = 135
THE_DESTROYER_TAIL = 136
ILLUMINANT_BAT = 137
ILLUMINANT_SLIME = 138
PROBE = 139
POSSESSED_ARMOR = 140
TOXIC_SLUDGE = 141
SANTA_CLAUS = 142
SNOWMAN_GANGSTA = 143
MISTER_STABBY = 144
SNOW_BALLA = 145
NONE3 = 146
ICE_SLIME = 147
PENGUIN = 148
PENGUIN_BLACK = 149
ICE_BAT = 150
LAVABAT = 151
GIANT_FLYING_FOX = 152
GIANT_TORTOISE = 153
ICE_TORTOISE = 154
WOLF = 155
RED_DEVIL = 156
ARAPAIMA = 157
VAMPIRE_BAT = 158
VAMPIRE = 159
TRUFFLE = 160
ZOMBIE_ESKIMO = 161
FRANKENSTEIN = 162
BLACK_RECLUSE = 163
WALL_CREEPER = 164
WALL_CREEPER_WALL = 165
SWAMP_THING = 166
UNDEAD_VIKING = 167
CORRUPT_PENGUIN = 168
ICE_ELEMENTAL = 169
PIGRON_CORRUPTION = 170
PIGRON_HALLOW = 171
RUNE_WIZARD = 172
CRIMERA = 173
HERPLING = 174
ANGRY_TRAPPER = 175
MOSS_HORNET = 176
DERPLING = 177
STEAMPUNKER = 178
CRIMSON_AXE = 179
PIGRON_CRIMSON = 180
FACE_MONSTER = 181
FLOATY_GROSS = 182
CRIMSLIME = 183
SPIKED_ICE_SLIME = 184
SNOW_FLINX = 185
PINCUSHION_ZOMBIE = 186
SLIMED_ZOMBIE = 187
SWAMP_ZOMBIE = 188
TWIGGY_ZOMBIE = 189
CATARACT_EYE = 190
SLEEPY_EYE = 191
DIALATED_EYE = 192
GREEN_EYE = 193
PURPLE_EYE = 194
LOST_GIRL = 195
NYMPH = 196
ARMORED_VIKING = 197
LIHZAHRD = 198
LIHZAHRD_CRAWLER = 199
FEMALE_ZOMBIE = 200
HEADACHE_SKELETON = 201
MISASSEMBLED_SKELETON = 202
PANTLESS_SKELETON = 203
SPIKED_JUNGLE_SLIME = 204
MOTH = 205
ICY_MERMAN = 206
DYE_TRADER = 207
PARTY_GIRL = 208
CYBORG = 209
BEE = 210
BEE_SMALL = 211
PIRATE_DECKHAND = 212
PIRATE_CORSAIR = 213
PIRATE_DEADEYE = 214
PIRATE_CROSSBOWER = 215
PIRATE_CAPTAIN = 216
COCHINEAL_BEETLE = 217
CYAN_BEETLE = 218
LAC_BEETLE = 219
SEA_SNAIL = 220
SQUID = 221
QUEEN_BEE = 222
ZOMBIE_RAINCOAT = 223
FLYING_FISH = 224
UMBRELLA_SLIME = 225
FLYING_SNAKE = 226
PAINTER = 227
WITCH_DOCTOR = 228
PIRATE = 229
GOLDFISH_WALKER = 230
HORNET_FATTY = 231
HORNET_HONEY = 232
HORNET_LEAFY = 233
HORNET_SPIKEY = 234
HORNET_STINGY = 235
JUNGLE_CREEPER = 236
JUNGLE_CREEPER_WALL = 237
BLACK_RECLUSE_WALL = 238
BLOOD_CRAWLER = 239
BLOOD_CRAWLER_WALL = 240
BLOOD_FEEDER = 241
BLOOD_JELLY = 242
ICE_GOLEM = 243
RAINBOW_SLIME = 244
GOLEM = 245
GOLEM_HEAD = 246
GOLEM_FIST_LEFT = 247
GOLEM_FIST_RIGHT = 248
GOLEM_HEAD_FREE = 249
ANGRY_NIMBUS = 250
EYEZOR = 251
PARROT = 252
REAPER = 253
ZOMBIE_MUSHROOM = 254
ZOMBIE_MUSHROOM_HAT = 255
FUNGO_FISH = 256
ANOMURA_FUNGUS = 257
MUSHI_LADYBUG = 258
FUNGI_BULB = 259
GIANT_FUNGI_BULB = 260
FUNGI_SPORE = 261
PLANTERA = 262
PLANTERAS_HOOK = 263
PLANTERAS_TENTACLE = 264
SPORE = 265
BRAINOF_CTHULHU = 266
CREEPER = 267
ICHOR_STICKER = 268
RUSTY_ARMORED_BONES_AXE = 269
RUSTY_ARMORED_BONES_FLAIL = 270
RUSTY_ARMORED_BONES_SWORD = 271
RUSTY_ARMORED_BONES_SWORD_NO_ARMOR = 272
BLUE_ARMORED_BONES = 273
BLUE_ARMORED_BONES_MACE = 274
BLUE_ARMORED_BONES_NO_PANTS = 275
BLUE_ARMORED_BONES_SWORD = 276
HELL_ARMORED_BONES = 277
HELL_ARMORED_BONES_SPIKE_SHIELD = 278
HELL_ARMORED_BONES_MACE = 279
HELL_ARMORED_BONES_SWORD = 280
RAGGED_CASTER = 281
RAGGED_CASTER_OPEN_COAT = 282
NECROMANCER = 283
NECROMANCER_ARMORED = 284
DIABOLIST_RED = 285
DIABOLIST_WHITE = 286
BONE_LEE = 287
DUNGEON_SPIRIT = 288
GIANT_CURSED_SKULL = 289
PALADIN = 290
SKELETON_SNIPER = 291
TACTICAL_SKELETON = 292
SKELETON_COMMANDO = 293
ANGRY_BONES_BIG = 294
ANGRY_BONES_BIG_MUSCLE = 295
ANGRY_BONES_BIG_HELMET = 296
BIRD_BLUE = 297
BIRD_RED = 298
SQUIRREL = 299
MOUSE = 300
RAVEN = 301
SLIME_MASKED = 302
BUNNY_SLIMED = 303
HOPPIN_JACK = 304
SCARECROW1 = 305
SCARECROW2 = 306
SCARECROW3 = 307
SCARECROW4 = 308
SCARECROW5 = 309
SCARECROW6 = 310
SCARECROW7 = 311
SCARECROW8 = 312
SCARECROW9 = 313
SCARECROW10 = 314
HEADLESS_HORSEMAN = 315
GHOST = 316
DEMON_EYE_OWL = 317
DEMON_EYE_SPACESHIP = 318
ZOMBIE_DOCTOR = 319
ZOMBIE_SUPERMAN = 320
ZOMBIE_PIXIE = 321
SKELETON_TOP_HAT = 322
SKELETON_ASTONAUT = 323
SKELETON_ALIEN = 324
MOURNING_WOOD = 325
SPLINTERLING = 326
PUMPKING = 327
PUMPKING_BLADE = 328
HELLHOUND = 329
POLTERGEIST = 330
ZOMBIE_XMAS = 331
ZOMBIE_SWEATER = 332
SLIME_RIBBON_WHITE = 333
SLIME_RIBBON_YELLOW = 334
SLIME_RIBBON_GREEN = 335
SLIME_RIBBON_RED = 336
BUNNY_XMAS = 337
ZOMBIE_ELF = 338
ZOMBIE_ELF_BEARD = 339
ZOMBIE_ELF_GIRL = 340
PRESENT_MIMIC = 341
GINGERBREAD_MAN = 342
YETI = 343
EVERSCREAM = 344
ICE_QUEEN = 345
SANTA_NK1 = 346
ELF_COPTER = 347
NUTCRACKER = 348
NUTCRACKER_SPINNING = 349
ELF_ARCHER = 350
KRAMPUS = 351
FLOCKO = 352
STYLIST = 353
WEBBED_STYLIST = 354
FIREFLY = 355
BUTTERFLY = 356
WORM = 357
LIGHTNING_BUG = 358
SNAIL = 359
GLOWING_SNAIL = 360
FROG = 361
DUCK = 362
DUCK2 = 363
DUCK_WHITE = 364
DUCK_WHITE2 = 365
SCORPION_BLACK = 366
SCORPION = 367
TRAVELLING_MERCHANT = 368
ANGLER = 369
DUKE_FISHRON = 370
DETONATING_BUBBLE = 371
SHARKRON = 372
SHARKRON2 = 373
TRUFFLE_WORM = 374
TRUFFLE_WORM_DIGGER = 375
SLEEPING_ANGLER = 376
GRASSHOPPER = 377
CHATTERING_TEETH_BOMB = 378
CULTIST_ARCHER_BLUE = 379
CULTIST_ARCHER_WHITE = 380
BRAIN_SCRAMBLER = 381
RAY_GUNNER = 382
MARTIAN_OFFICER = 383
FORCE_BUBBLE = 384
GRAY_GRUNT = 385
MARTIAN_ENGINEER = 386
MARTIAN_TURRET = 387
MARTIAN_DRONE = 388
GIGA_ZAPPER = 389
SCUTLIX_RIDER = 390
SCUTLIX = 391
MARTIAN_SAUCER = 392
MARTIAN_SAUCER_TURRET = 393
MARTIAN_SAUCER_CANNON = 394
MARTIAN_SAUCER_CORE = 395
MOON_LORD_HEAD = 396
MOON_LORD_HAND = 397
MOON_LORD_CORE = 398
MARTIAN_PROBE = 399
MOON_LORD_FREE_EYE = 400
MOON_LORD_LEECH_BLOB = 401
STARDUST_WORM_HEAD = 402
STARDUST_WORM_BODY = 403
STARDUST_WORM_TAIL = 404
STARDUST_CELL_BIG = 405
STARDUST_CELL_SMALL = 406
STARDUST_JELLYFISH_BIG = 407
STARDUST_JELLYFISH_SMALL = 408
STARDUST_SPIDER_BIG = 409
STARDUST_SPIDER_SMALL = 410
STARDUST_SOLDIER = 411
SOLAR_CRAWLTIPEDE_HEAD = 412
SOLAR_CRAWLTIPEDE_BODY = 413
SOLAR_CRAWLTIPEDE_TAIL = 414
SOLAR_DRAKOMIRE = 415
SOLAR_DRAKOMIRE_RIDER = 416
SOLAR_SROLLER = 417
SOLAR_CORITE = 418
SOLAR_SOLENIAN = 419
NEBULA_BRAIN = 420
NEBULA_HEADCRAB = 421
NEBULA_BEAST = 423
NEBULA_SOLDIER = 424
VORTEX_RIFLEMAN = 425
VORTEX_HORNET_QUEEN = 426
VORTEX_HORNET = 427
VORTEX_LARVA = 428
VORTEX_SOLDIER = 429
ARMED_ZOMBIE = 430
ARMED_ZOMBIE_ESKIMO = 431
ARMED_ZOMBIE_PINCUSSION = 432
ARMED_ZOMBIE_SLIMED = 433
ARMED_ZOMBIE_SWAMP = 434
ARMED_ZOMBIE_TWIGGY = 435
ARMED_ZOMBIE_CENX = 436
CULTIST_TABLET = 437
CULTIST_DEVOTE = 438
CULTIST_BOSS = 439
CULTIST_BOSS_CLONE = 440
GOLD_BIRD = 442
GOLD_BUNNY = 443
GOLD_BUTTERFLY = 444
GOLD_FROG = 445
GOLD_GRASSHOPPER = 446
GOLD_MOUSE = 447
GOLD_WORM = 448
BONE_THROWING_SKELETON = 449
BONE_THROWING_SKELETON2 = 450
BONE_THROWING_SKELETON3 = 451
BONE_THROWING_SKELETON4 = 452
SKELETON_MERCHANT = 453
CULTIST_DRAGON_HEAD = 454
CULTIST_DRAGON_BODY1 = 455
CULTIST_DRAGON_BODY2 = 456
CULTIST_DRAGON_BODY3 = 457
CULTIST_DRAGON_BODY4 = 458
CULTIST_DRAGON_TAIL = 459
BUTCHER = 460
CREATURE_FROM_THE_DEEP = 461
FRITZ = 462
NAILHEAD = 463
CRIMSON_BUNNY = 464
CRIMSON_GOLDFISH = 465
PSYCHO = 466
DEADLY_SPHERE = 467
DR_MAN_FLY = 468
THE_POSSESSED = 469
CRIMSON_PENGUIN = 470
GOBLIN_SUMMONER = 471
SHADOW_FLAME_APPARITION = 472
BIG_MIMIC_CORRUPTION = 473
BIG_MIMIC_CRIMSON = 474
BIG_MIMIC_HALLOW = 475
BIG_MIMIC_JUNGLE = 476
MOTHRON = 477
MOTHRON_EGG = 478
MOTHRON_SPAWN = 479
MEDUSA = 480
GREEK_SKELETON = 481
GRANITE_GOLEM = 482
GRANITE_FLYER = 483
ENCHANTED_NIGHTCRAWLER = 484
GRUBBY = 485
SLUGGY = 486
BUGGY = 487
TARGET_DUMMY = 488
BLOOD_ZOMBIE = 489
DRIPPLER = 490
PIRATE_SHIP = 491
PIRATE_SHIP_CANNON = 492
LUNAR_TOWER_STARDUST = 493
CRAWDAD = 494
CRAWDAD2 = 495
GIANT_SHELLY = 496
GIANT_SHELLY2 = 497
SALAMANDER = 498
SALAMANDER2 = 499
SALAMANDER3 = 500
SALAMANDER4 = 501
SALAMANDER5 = 502
SALAMANDER6 = 503
SALAMANDER7 = 504
SALAMANDER8 = 505
SALAMANDER9 = 506
LUNAR_TOWER_NEBULA = 507
LUNAR_TOWER_VORTEX = 422
TAX_COLLECTOR = 441
WALKING_ANTLION = 508
FLYING_ANTLION = 509
DUNE_SPLICER_HEAD = 510
DUNE_SPLICER_BODY = 511
DUNE_SPLICER_TAIL = 512
TOMB_CRAWLER_HEAD = 513
TOMB_CRAWLER_BODY = 514
TOMB_CRAWLER_TAIL = 515
SOLAR_FLARE = 516
LUNAR_TOWER_SOLAR = 517
SOLAR_SPEARMAN = 518
SOLAR_GOOP = 519
MARTIAN_WALKER = 520
ANCIENT_CULTIST_SQUIDHEAD = 521
ANCIENT_LIGHT = 522
ANCIENT_DOOM = 523
DESERT_GHOUL = 524
DESERT_GHOUL_CORRUPTION = 525
DESERT_GHOUL_CRIMSON = 526
DESERT_GHOUL_HALLOW = 527
DESERT_LAMIA_LIGHT = 528
DESERT_LAMIA_DARK = 529
DESERT_SCORPION_WALK = 530
DESERT_SCORPION_WALL = 531
DESERT_BEAST = 532
DESERT_DJINN = 533
DEMON_TAX_COLLECTOR = 534
SLIME_SPIKED = 535
THE_BRIDE = 536
SAND_SLIME = 537
SQUIRREL_RED = 538
SQUIRREL_GOLD = 539
PARTY_BUNNY = 540
SAND_ELEMENTAL = 541
SAND_SHARK = 542
SANDSHARK_CORRUPT = 543
SANDSHARK_CRIMSON = 544
SANDSHARK_HALLOW = 545
TUMBLEWEED = 546
DD2ATTACKER_TEST = 547
DD2ETERNIA_CRYSTAL = 548
DD2LANE_PORTAL = 549
DD2BARTENDER = 550
DD2BETSY = 551
DD2GOBLIN_T1 = 552
DD2GOBLIN_T2 = 553
DD2GOBLIN_T3 = 554
DD2GOBLIN_BOMBER_T1 = 555
DD2GOBLIN_BOMBER_T2 = 556
DD2GOBLIN_BOMBER_T3 = 557
DD2WYVERN_T1 = 558
DD2WYVERN_T2 = 559
DD2WYVERN_T3 = 560
DD2JAVELINST_T1 = 561
DD2JAVELINST_T2 = 562
DD2JAVELINST_T3 = 563
DD2DARK_MAGE_T1 = 564
DD2DARK_MAGE_T3 = 565
DD2SKELETON_T1 = 566
DD2SKELETON_T3 = 567
DD2WITHER_BEAST_T2 = 568
DD2WITHER_BEAST_T3 = 569
DD2DRAKIN_T2 = 570
DD2DRAKIN_T3 = 571
DD2KOBOLD_WALKER_T2 = 572
DD2KOBOLD_WALKER_T3 = 573
DD2KOBOLD_FLYER_T2 = 574
DD2KOBOLD_FLYER_T3 = 575
DD2OGRE_T2 = 576
DD2OGRE_T3 = 577
DD2LIGHTNING_BUG_T3 = 578
BARTENDER_UNCONSCIOUS = 579
def __repr__(self):
return f"{self.__class__.__name__}.{self.name}"

18
lihzahrd/entities/mob.py Normal file
View file

@ -0,0 +1,18 @@
import typing
from .entitytype import EntityType
from ..fileutils import Coordinates
class Mob:
"""A Mob somewhere in the world."""
def __init__(self,
type_: int,
position: Coordinates, ):
self.type: int = type_
"""The type of mob this object represents."""
self.position: Coordinates = position
"""The position of the mob in the game world."""
def __repr__(self):
return f"<Mob {repr(self.type)} at {self.position}>"

View file

@ -1,18 +1,26 @@
import typing
from .entitytype import EntityType
from ..fileutils import Coordinates
class NPC:
"""A NPC somewhere in the world."""
def __init__(self,
sprite_id: int,
type_: EntityType,
name: str,
position: Coordinates,
home: typing.Optional[Coordinates] = None):
self.sprite_id: int = sprite_id
self.type: EntityType = type_
"""The NPC this object represents."""
self.name: str = name
"""The name of this NPC."""
self.position: Coordinates = position
"""The position of the mob in the game world."""
self.home: typing.Optional[Coordinates] = home
"""The coordinates of the home of this NPC, or None if the NPC is homeless."""
def __repr__(self):
return f"<NPC {self.name if self.name else '_'} at {self.position}>"
return f"<NPC {repr(self.type)} at {self.position}>"

View file

@ -8,7 +8,9 @@ class Pointers:
chests: int,
signs: int,
npcs: int,
entities: int,
tile_entities: int,
pressure_plates: int,
town_manager: int,
footer: int,
*unknown):
self.file_format: int = 0
@ -17,6 +19,8 @@ class Pointers:
self.chests: int = chests
self.signs: int = signs
self.npcs: int = npcs
self.entities: int = entities
self.tile_entities: int = tile_entities
self.pressure_plates: int = pressure_plates
self.town_manager: int = town_manager
self.footer: int = footer
self.unknown: typing.List[int] = list(unknown)

View file

@ -1,3 +0,0 @@
from .npc import NPC
__all__ = ["NPC"]

View file

@ -475,7 +475,6 @@ class BlockType(enum.IntEnum):
CONTAINERS2 = 467
FAKE_CONTAINERS2 = 468
TABLES2 = 469
COUNT = 470
def __repr__(self):
return f"{self.__class__.__name__}.{self.name}"

View file

@ -6,7 +6,7 @@ from .header import *
from .tiles import *
from .chests import *
from .signs import *
from .npcs import *
from .entities import *
from .timer import Timer
@ -45,6 +45,9 @@ class World:
cultist_delay: int,
tiles: typing.List[typing.List[Tile]],
chests: typing.List[Chest],
signs: typing.List[Sign],
npcs: typing.List[NPC],
mobs: typing.List[Mob],
unknown_file_format_data: bytearray,
unknown_world_header_data: bytearray,
unknown_world_tiles_data: bytearray,
@ -131,9 +134,19 @@ class World:
self.anglers_quest: AnglerQuest = anglers_quest
"""Information about today's Angler's Quest."""
self.chests: typing.List[Chest] = chests
self.tiles: typing.List[typing.List[Tile]] = tiles
"""A matrix of all the tiles present in the world."""
self.chests: typing.List[Chest] = chests
"""A list of all the containers (chests, barrels) in the world."""
self.signs: typing.List[Sign] = signs
"""A list of all non-empty signs in the world."""
self.npcs: typing.List[NPC] = npcs
"""A list of all the NPCs currently living in the world, including the Old Man."""
self.mobs: typing.List[Mob] = mobs
self.clouds: Clouds = clouds
self.cultist_delay: int = cultist_delay
@ -528,11 +541,12 @@ class World:
unknown_signs_data = f.read_until(pointers.npcs)
with Timer("NPCs", display=True):
with Timer("Entities", display=True):
npcs = []
mobs = []
while f.bool():
npc_sprite_id = f.int4()
npc_type = EntityType(f.int4())
npc_name = f.string()
npc_position = Coordinates(f.single(), f.single())
is_homeless = f.bool()
@ -540,12 +554,22 @@ class World:
if is_homeless:
npc_home = None
npc = NPC(sprite_id=npc_sprite_id,
npc = NPC(type_=npc_type,
name=npc_name,
position=npc_position,
home=npc_home)
npcs.append(npc)
while f.bool():
mob_type = EntityType(f.int4())
mob_position = Coordinates(f.single(), f.single())
mob = Mob(type_=npc_type,
position=npc_position)
mobs.append(mob)
unknown_npcs_data = f.read_until(pointers)
world = World(version=version, savefile_type=savefile_type, revision=revision, is_favorite=is_favorite,
name=name, generator=generator, uuid_=uuid_, id_=id_, bounds=bounds, size=world_size,
is_expert=is_expert, created_on=created_on, styles=world_styles, backgrounds=backgrounds,