Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

[TOOL] mIDas - ID Changer V0.3.1 (Open Source)


  • Please log in to reply
185 replies to this topic

#1

Pfaeff
    Pfaeff

    Redstone Miner

  • Members
  • 503 posts

Posted 10 April 2011 - 01:03 AM

mIDas - ID Changer V0.3.2
for Minecraft Beta 1.3


What is mIDas?


mIDas is a very simple open source tool that allows you to change the IDs of certain blocks and items in your world files.
You can for example replace all blocks of dirt with blocks of cobblestone if you want to. This tool is especially useful for modders and mod users. As many of you know, the number of Block IDs in minecraft is limited and some mods use the same IDs. It might also happen that Notch introduces a new block with the same ID as one of your mods. The mod would then become unplayable. As a modder, you may want to change your Block IDs for several reasons during the development process, but you can't, because they are already stored in your world files. mIDas allows to change the IDs stored in those files to circumvent these problems. It can also be used to remove certain blocks after uninstalling a mod by setting the target ID to 0 (air).

Since version 0.2, mIDas is also capable of exchanging item IDs. At the moment, this will only affect items that are in chests, furnaces and so on. It will not change the IDs of items in your inventory or those of items that lie on the ground.

Here is a youtube video that I made, which explains what it does and how it works (fullscreen recommended):




Which Minecraft versions are supported?

mIDas supports all Minecraft versions that use the MCRegion world saving system (i.e. version Beta 1.3 and maybe even later versions). It has been tested with version Beta 1.4_01. It should work with future versions, if the level format isn't changed drastically. I also can add support for the old system if there is a need for it.


Why the name?

The mod is name after King Midas, because of the fact that the first thing I tried was to change blocks into gold Posted Image.


Screenshots

Posted Image
Posted ImagePosted ImagePosted Image



Download / Sourcecode / Bugtracker
mIDas is released under the GNU GPL v3 license

mIDas V0.3.2 Download

mIDas Sourcecode

mIDas Bugtracker



Installation

Extract mIDas.jar and IDNames.txt into the same folder and doubleclick mIDas.jar to start.
If that doesn't work, use the console command "java -jar mIDas.jar".


Usage

You need to select a savegame first (you can add external savgames using the "add savegame" button).
You can then add the IDs that you want to exchange to the list. Choose a target ID and click start.
Depending on the world size, this may take some time.
Note that this process can not be undone. If you exchange ID 15 with 0 for example and then change
0 back to 15, all blocks that were 0 before now get changed, too. So use this tool at your own risk.
There is an option for backing up your region folder, but it is highly recommended to do a manual backup.

I am pretty confident that it won't destroy your savegame, though I can not ensure that it works with all modifications. It most probably won't work with mods that alter the way block/item IDs are stored in world files and also with mods that drastically change the way worlds are being saved.


Additional notes / issues

I only tested this tool under Windows, so there might be problems on other systems. Though it might work with some restrictions.
ID names can be customized in the IDNames.txt.
I know the gui (and its code) is a mess. It will either be rewritten or cleaned up.

    For coders: How to read/write/manipulate chunk data

    To make it easier to reuse my code, I will give a short explanation on how to read/write data from Minecraft's region files.

    Finding all region files

    To find all region files for a certain save game, you can use the getRegionFiles() method of the RegionFileIO class:
    ArrayList<RegionFile> regionFiles = RegionFileIO.getRegionFiles(saveGameLocation);

    Finding a specific region file

    To find the region file, that belongs to a specific chunk, there is a method in the RegionFileCache class:
    RegionFile regionFile = RegionFileCache.getRegionFile(saveGameLocation, x, z);

    Finding chunks contained in a region file

    To find out, which chunks are present in the region file, you can use this:
    ArrayList<Point> chunks = new ArrayList<Point>();
    // Go through all possible chunk locations
    for (int x = 0; x < 32; x++) {
    	for (int z = 0; z < 32; z++) {
    		// Check if the chunk is present in this file
    		if (regionFile.hasChunk(x, z)) {
    			// Add it to our list of available chunks
    			chunks.add(new Point(x, z));
    		}
    	}
    }

    Loading chunks

    To load the chunk data, you then need to get a DataInputStream to it from the region file.
    x and z represent the chunk's position and can for example be read from the above mentioned ArrayList "chunks":
    int x = chunks.get(index).x;
    int z = chunks.get(index).y;
    DataInputStream input = regionFile.getChunkDataInputStream(x, z);
    Retrieving and parsing the chunk data is now very easy:
    Tag root = (new TagInputStream(input)).readTag(true);
    input.close();

    Manipulate chunk data

    You can now traverse the NBT tree ("root" in our case) and manipulate everything you want.
    For example to change Block IDs:
    // Find blocks
    Tag t = root.findChildByName("Blocks", true);
    if (t instanceof TagByteArray) {
    	TagByteArray blocks = (TagByteArray) t;
    	for (int i = 0; i < blocks.payload.length; i++) {
    		// Change IDs
    		if (fromIDs.contains(new Byte(blocks.payload[i]))) {
    			blocks.payload[i] = toID;
    		}
    	}
    }

    Saving chunks

    To write it back to the region file, you need to obtain an Outputstream like so:
    DataOutputStream output = regionFile.getChunkDataOutputStream(x, z);
    You can then write back your modified NBT data:
    (new TagOutputStream(output)).writeTag(root, true);
    output.close();
    It is important to use close() in this case, because otherwise data won't be written to the file. Just writing the data to the stream will result in it being stored in a byte buffer. The close() method then writes the contents of this buffer to the correct position in the region file.


    Greetings,
    Pfaeff


    Posted Image

    Register or log in to remove.

    #2

    soydaniel96
    • Location: Peru

    Posted 10 April 2011 - 01:33 AM

    Yay, I've wanted to remove some modded blocks I left somewhere in order to prevent crashes and play old worlds.

    Also, a question:
    It is possible to change any block to the 0 ID ? (Air, aka nothing)
    Maps I support:
    - Imperial Lands by lolo500
    - PortalCraft by Leggos_My_Eggos

    Mods & Tools I support:
    - DJoslin's Creations by DJoslin
    - mIDas by Pfaeff
    - Programmable CPU by Biohazard

    #3

    CmdrQuartz

    Posted 10 April 2011 - 06:14 AM

    Wow, I see this as being a very very helpful tool. So great job on this! It might be a bit soon to be really suggesting things but another useful tool would be changing item IDs from items left in chests and inventory for the same reason you'd want to change the block IDs

    #4

    Pfaeff
      Pfaeff

      Redstone Miner

    • Members
    • 503 posts

    Posted 10 April 2011 - 12:56 PM

    soydaniel96 said:

    Also, a question:
    It is possible to change any block to the 0 ID ? (Air, aka nothing)
    Yes it is :Pig:

    CmdrQuartz said:

    Wow, I see this as being a very very helpful tool. So great job on this! It might be a bit soon to be really suggesting things but another useful tool would be changing item IDs from items left in chests and inventory for the same reason you'd want to change the block IDs
    That is definitely something I'd like to do in a future version.
    Posted Image

    #5

    soydaniel96
    • Location: Peru

    Posted 11 April 2011 - 12:43 AM

    Thank you very much, I rescued a save with modded items inside a chest from the recycle bin.
    Pity I also changed the ones with my diamonds, iron, tools, wood, etc.

    If you can really add a chest editor, I will forever love you.

    Keep up the good work :Notch:
    Maps I support:
    - Imperial Lands by lolo500
    - PortalCraft by Leggos_My_Eggos

    Mods & Tools I support:
    - DJoslin's Creations by DJoslin
    - mIDas by Pfaeff
    - Programmable CPU by Biohazard

    #6

    Pfaeff
      Pfaeff

      Redstone Miner

    • Members
    • 503 posts

    Posted 12 April 2011 - 01:07 PM

    I added a little explanation for coders on how to load, save and manipulate chunk data.
    Posted Image

    #7

    Pfaeff
      Pfaeff

      Redstone Miner

    • Members
    • 503 posts

    Posted 12 April 2011 - 05:02 PM

    Version 0.2 now has the capability of handling item IDs. I also fixed some bugs in the code, that appeared when trying to find those IDs in the NBT.
    Posted Image

    #8

    soydaniel96
    • Location: Peru

    Posted 12 April 2011 - 10:11 PM

    Pfaeff said:

    Version 0.2 now has the capability of handling item IDs.

    What does this mean ? Can I change a block into a dropped item ?
    Maps I support:
    - Imperial Lands by lolo500
    - PortalCraft by Leggos_My_Eggos

    Mods & Tools I support:
    - DJoslin's Creations by DJoslin
    - mIDas by Pfaeff
    - Programmable CPU by Biohazard

    #9

    Pfaeff
      Pfaeff

      Redstone Miner

    • Members
    • 503 posts

    Posted 13 April 2011 - 10:55 AM

    If you have chests full of certain blocks/items, you can now change them, too. For example exchange stacks of cobblestone with stacks of diamonds or the other way round. Placed blocks can't be turned into items though.
    Posted Image

    #10

    Luttik
      Luttik

      Tree Puncher

    • Members
    • 13 posts

    Posted 28 April 2011 - 06:46 PM

    I tried to make a quickbuilder for minecraft witch fills a selected Area with a selected Block ID but when i use it it doesn't change anything.. its based on your code so i hope you would look at it for me and maybe find the problem.
    source code can be found here http://daanluttik.10...ace.net/qbc.zip.

    Can't wait to hear from you,
    Daab Luttik

    #11

    Pfaeff
      Pfaeff

      Redstone Miner

    • Members
    • 503 posts

    Posted 28 April 2011 - 08:07 PM

    Maybe you position calculations are wrong, but I am not sure. Your way of accessing the block IDs looks absolutely right to me.
    t.payload[(ab.y % 16) + ((ab.z % 16) * 128 + ((ab.x % 16) * 2048))] = (byte) ab.ID;
    This is the same formular that is mentioned in the wiki, so I guess it's correct.


    Did you check if your program ever reaches this line above? How big is BPCPR.get(i).get(j).size() in that case?

    Maybe it has something to do with the IO streams. I had problems with that, too. Did you try to do something crazy, like changing all blocks (except air), so you can see if it does anything? Because if it doesn't, then something is definitely wrong with the IO. It's best to process one file and one chunk at a time. Though the RegionFile class creates a random access file, things get more complicated and error-prone in those cases.
    Posted Image

    #12

    Luttik
      Luttik

      Tree Puncher

    • Members
    • 13 posts

    Posted 28 April 2011 - 10:18 PM

    I'm really afraid that is a IO problem because handling files is still quite new for me that's why i use you code. but to answer your question id does reaches the line above. and the size op bpcpr witch means Blocks per chunk per region is always between 1 and 16x16x128 witch is the capacity of a chunk. could it be a problem that 1 first load all the chunks that i modify an then save them all instead of loading and saving 1 before continuing with the next one.

    #13

    Pfaeff
      Pfaeff

      Redstone Miner

    • Members
    • 503 posts

    Posted 28 April 2011 - 11:22 PM

    That could be a problem indeed.
    Posted Image

    #14

    Luttik
      Luttik

      Tree Puncher

    • Members
    • 13 posts

    Posted 28 April 2011 - 11:34 PM

    I'll rewrite the code in a hour or 10 after because it's time to sleep here in the Netherlands but ill let you know how it went

    #15

    Gkardos
      Gkardos

      Retired Staff

    • Retired Staff
    • Curse Premium
    • 2012 posts
    • Location: Back in California, USA
    • Minecraft: Gkardos

    Posted 29 April 2011 - 12:21 AM

    Does this actually change the IDs? Or just swap the blocks.
    Posted Image
    Sig made by llama66613
    Follow me on twitter
    Spoiler:

    #16

    Pfaeff
      Pfaeff

      Redstone Miner

    • Members
    • 503 posts

    Posted 29 April 2011 - 09:54 AM

    Gkardos said:

    Does this actually change the IDs? Or just swap the blocks.
    I don't see the difference ;) It doesn't change the IDs that are used by the game, because you would have to change the minecraft code for that, if that is what you mean.
    Posted Image

    #17

    Luttik
      Luttik

      Tree Puncher

    • Members
    • 13 posts

    Posted 29 April 2011 - 12:22 PM

    Thank you so much for your help it works now.
    ill give it some last touches and it'll be online soon...

    #18

    Gkardos
      Gkardos

      Retired Staff

    • Retired Staff
    • Curse Premium
    • 2012 posts
    • Location: Back in California, USA
    • Minecraft: Gkardos

    Posted 29 April 2011 - 03:08 PM

    Pfaeff said:

    Gkardos said:

    Does this actually change the IDs? Or just swap the blocks.
    I don't see the difference ;) It doesn't change the IDs that are used by the game, because you would have to change the minecraft code for that, if that is what you mean.
    That is what i mean. But how would that help modders? If it doesnt change the ids used, it wouldnt have any affect on the game/code, other than changing what items/blocks are there.
    Posted Image
    Sig made by llama66613
    Follow me on twitter
    Spoiler:

    #19

    Pfaeff
      Pfaeff

      Redstone Miner

    • Members
    • 503 posts

    Posted 29 April 2011 - 03:53 PM

    Imagine a modder created a new block with ID 110. Then someone else releases a mod with that ID, too. Those two mods would not be compatible. With mIDas, one of the two modders now can choose another ID and users can update their maps to this new ID, which will allow them to use both mods.
    Posted Image

    #20

    MidnightTheCat1

    Posted 16 June 2011 - 01:52 AM

    So I'm trying to figure out how to change a conflicting modded item ID. two items have 189 ID. Can I fix that with this? If so could you explain how or if there is an easier way please share?

    By the way, I've already tried just opening the .PROP file. I can view but not edit.

    Posted Image