Python script to locate mobs you've named with Name Tags in Minecraft save files ...because my son lost his dog, Turbo. :)
Python
Pull request Compare This branch is 7 commits ahead, 49 commits behind Fenixin:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
nbt
.gitignore
CONTRIBUTORS.txt
COPYING.txt
DONORS.txt
README.rst
TectonicusLog.txt
interactive.py
name_tags.json
progressbar.py
region-fixer.py
scan.py
setup.py
util.py
whitelist.json
world.py

README.rst

Minecraft Entity Finder

(or more accurately "Minecraft Named Entity Finder")

Forked from "Minecraft Region Fixer" by Scott Bratcher (swbratcher)

Locates mob entities that have had name tags applied to them giving them the CustomName attribute in their entity data, then returning that they were found and at what position they were found using the entity's Pos array to deliver the X,Z coordinates.

My son lost his dog, Turbo, and we found it with my mods to this fork. Pretend your name tag offers the GPS chip that fancy dogs are afforded.

FIRST TODO:

Really soon, I plan to add for the script to also list locations and owners of owned dogs and locations and owners of owned horses, whether named with name tags or not.

MAYBE TODO:

Will be removing all past functionality that tries to fix corrupted chunks in region files using old backup copies of the Minecraft world. It will no longer fix or modify after I gut the script set and it won't fix any problem in these files.

Web page: https://github.com/swbratcher/Minecraft-Entity-Finder

Supported platforms

This program seems to work with Python 2.7.x, and DOESN'T work with python 3.x. There is also a windows executable for ease of use, if you use the windows executable you don't need to install Python. (But I don't use windows, so hopefully I don't gut what allows that to work.)

Usage

You can read the program help running: “python region-fixer.py --help”

Here's what I used to find Turbo, my son's dog:

$ python region-fixer.py --name-tags /Users/[my_user]/Library/ApplicationSupport/minecraft/saves/[my_world]/

Where [my_user] was swbratcher and [my_world] was world (the default minecraft world save file name).

Here are some other (likely gutted) examples of pre-fork functionality:

From v0.1.0 Region-Fixer can scan single region files and arbitrary region sets. For example, if you know where the problem is you could scan a single region file instead of scanning the whole world. You can also scan a few region files from different locations. Example:

$ python region-fixer.py ~/.minecraft/saves/World1/region/r.0.0.mca

Welcome to Region Fixer!

############################################################
############## Scanning separate region files ##############
############################################################
Scanning:  1 /  1 100% [########################################] Time: 00:00:01

Found 0 corrupted, 0 wrong located chunks and 0 chunks with too many entities of a total of 976

The next example will scan your world and report any problems:

$ python region-fixer.py ~/.minecraft/saves/corrupted-world

Welcome to Region Fixer!

############################################################
############ Scanning world: Testing corruption ############
############################################################
Scanning directory...
Info: No nether dimension in the world directory.
Info: No end dimension in the world directory.
There are 1 region files and 1 player files in the world directory.

-------------------- Checking level.dat --------------------
'level.dat' is redable

------------------ Checking player files -------------------
All player files are readable.

------------------ Scanning the overworld ------------------
Scanning:  1 /  1 100% [########################################] Time: 00:00:20

Found 19 corrupted, 0 wrong located chunks and 0 chunks with too many entities of a total of 625

You can use --verbose or -v option if you want more info. This option will print a line per region file showing problems found in that region file.

To delete corrupted chunks you can use "--delete-corrupted" or "--dc":

$ python region-fixer.py --delete-corrupted ~/.minecraft/saves/corrupted-world

Welcome to Region Fixer!

############################################################
############ Scanning world: Testing corruption ############
############################################################
Scanning directory...
Info: No nether dimension in the world directory.
Info: No end dimension in the world directory.
There are 1 region files and 1 player files in the world directory.

-------------------- Checking level.dat --------------------
'level.dat' is redable

------------------ Checking player files -------------------
All player files are readable.

------------------ Scanning the overworld ------------------
Scanning:  1 /  1 100% [########################################] Time: 00:00:19

Found 19 corrupted, 0 wrong located chunks and 0 chunks with too many entities of a total of 625

################ Deleting  corrupted chunks ################
 Deleting chunks in region set "/home/alejandro/.minecraft/saves/corrupted-world/region/": Done! Removed 19 chunks
Done!
Deleted 19 corrupted chunks

If we have a backup of our world we can use them to fix the problems found chunks, this method can spam a lot of output text, because writes a log for every chunk that is trying to fix:

$ python region-fixer.py --backups ~/backup/2013.01.05/ --replace-corrupted ~/.minecraft/saves/corrupted-world

Welcome to Region Fixer!

############################################################
############ Scanning world: Testing corruption ############
############################################################
Scanning directory...
Info: No nether dimension in the world directory.
Info: No end dimension in the world directory.
There are 1 region files and 1 player files in the world directory.

-------------------- Checking level.dat --------------------
'level.dat' is redable

------------------ Checking player files -------------------
All player files are readable.

------------------ Scanning the overworld ------------------
Scanning:  1 /  1 100% [########################################] Time: 00:00:19

Found 19 corrupted, 0 wrong located chunks and 0 chunks with too many entities of a total of 625

############ Trying to replace corrupted chunks ############

---------- New chunk to replace! Coords (-16, 9) -----------
Backup region file found in:
  ~/backup/2013.01.05/region/r.-1.0.mca
Replacing...
Chunk replaced using backup dir: ~/backup/2013.01.05/

---------- New chunk to replace! Coords (-10, 19) ----------
Backup region file found in:
  ~/backup/2013.01.05/region/r.-1.0.mca
Replacing...
Chunk replaced using backup dir: ~/backup/2013.01.05/

    ... long log of replaced chunks ...

---------- New chunk to replace! Coords (-13, 16) ----------
Backup region file found in:
  ~/backup/2013.01.05/region/r.-1.0.mca
Replacing...
Chunk replaced using backup dir: ~/backup/2013.01.05/

---------- New chunk to replace! Coords (-13, 25) ----------
Backup region file found in:
  ~/backup/2013.01.05/region/r.-1.0.mca
Replacing...
Chunk replaced using backup dir: ~/backup/2013.01.05/

19 replaced chunks of a total of 19 corrupted chunks

These options have an equivalent for wrong located chunks.

Another problem that Region Fixer can fix is an entity problem. Sometimes worlds store thousands of entities in one chunk, hanging the server when loaded. This can happen with squids, spiders, or even items. A very common way to make this happen in your server is to ignite a few thousands of TNTs at the same time. All those TNTs are entities and the server will hang trying to move them all.

This problem can be fixed with this method. Using the option "--delete-entities" Region Fixer will delete all the entities in that chunk if it does have more entities than entity-limit (see the help). It doesn't touch TileEntities (chests, singposts, noteblocks, etc...). At the moment of writing this Entities stored in chunks are:

  • mobs
  • projectiles (arrows, snowballs...)
  • primed TNT
  • ender crystal
  • paintings
  • items on the ground (don't worry chests are safe)
  • vehicles (boats and minecarts)
  • dynamic tiles (falling sand and activated TNT)

Note that you still need to load the chunk in Region Fixer to fix it, and it may need GIGs of RAM and lot of time. You can use this in combination with "--entity-limit" to set your limit (default 300 entities, note that a chunk has 256 square meters of surface and if you put a mob in every sun lighted block of a chunk that will make 256 mobs, so it's a big limit!):

python region-fixer.py --entity-limit 50 --delete-entities ~/.minecraft/saves/corrupted-world

Welcome to Region Fixer!

############################################################
############ Scanning world: Testing corruption ############
############################################################
Scanning directory...
Info: No nether dimension in the world directory.
Info: No end dimension in the world directory.
There are 1 region files and 1 player files in the world directory.

-------------------- Checking level.dat --------------------
'level.dat' is redable

------------------ Checking player files -------------------
All player files are readable.

------------------ Scanning the overworld ------------------
Deleted 102 entities in chunk (14,8) of the region file: r.-1.0.mca
Deleted 111 entities in chunk (14,10) of the region file: r.-1.0.mca
Deleted 84 entities in chunk (15,4) of the region file: r.-1.0.mca
Deleted 75 entities in chunk (21,4) of the region file: r.-1.0.mca
Scanning:  1 /  1 100% [########################################] Time: 00:00:20

Found 0 corrupted, 0 wrong located chunks and 0 chunks with too many entities of a total of 625

From version v0.1.0 there is also an interactive mode for Region-Fixer. If you don't know what's wrong with your world this mode can be very useful. To start using the mode use the '--interactive' option:

$ python region-fixer.py --interactive ~/.minecraft/saves/corrutped-world

In this mode the scan results are saved in memory, so one scanned you can delete chunks, delete entities, replace chunks, replace chunks with too many entities and read a summary of what's wrong without needing to scan the world again. Example of usage:

$ python region-fixer.py --interactive ~/.minecraft/saves/corrupted-world
Welcome to Region Fixer!
Minecraft Region-Fixer interactive mode.
(Use tab to autocomplete. Type help for a list of commands.)

#-> scan
Scanning directory...
Info: No nether dimension in the world directory.
Info: No end dimension in the world directory.
There are 1 region files and 1 player files in the world directory.

-------------------- Checking level.dat --------------------
'level.dat' is redable

------------------ Checking player files -------------------
All player files are readable.

------------------ Scanning the overworld ------------------
Scanning:  1 /  1 100% [########################################] Time: 00:00:21

#-> summary

############################################################
############## World name: Testing corruption ##############
############################################################

level.dat:
    'level.dat' is readable

Player files:
    All player files are readable.

Overworld:
Region file: r.-1.0.mca
 |-+-Chunk coords: header (16, 9), global (-16, 9).
 | +-Status: Corrupted

    ... big summary...

 |-+-Chunk coords: header (19, 25), global (-13, 25).
 | +-Status: Corrupted
 |
 +


#-> remove_chunks corrupted
 Deleting chunks in region set "/home/alejandro/.minecraft/saves/corrupted-world/region/": Done! Removed 19 chunks
Done! Removed 19 chunks
#->

For more info: “python region-fixer.py --help”

Bugs, suggestions, feedback, questions

Suggestions and bugs should go to the github page:

https://github.com/swbratcher/Minecraft-Entity-Finder

Feedback and questions should go preferably to the forums posts:

(server administration) http://www.minecraftforum.net/ ... TODO

(mapping and modding) http://www.minecraftforum.net/ ... TODO

Contributors

See CONTRIBUTORS.txt

Warning

This program has been tested with a lot of worlds, but there may be bugs, so please, MAKE A BACKUP OF YOUR WORLD BEFORE RUNNING it, I'M NOT RESPONSIBLE OF WHAT HAPPENS TO YOUR WORLD. Other way to say it is USE THIS TOOL AT YOUR OWN RISK.

Think that you are playing with you precious saved games :P .

Good luck! :)