Navigation

Own programs

Snippets

Libraries

Deutsch

MCSchematicTool

Current supported minecraft version: 1.5.1

It'll probably still work with newer or older versions

04/18/2013: Update to 1.5.1. Added 30 blocks and 23 Items! Additionally, all texture images are now in a single file (as they are in current MC) and all items support names.
08/26/2012: Update to 1.3.2. Added additional tree types, sandstone types, 10 Blocks and 3 items. Also changed all block IDs to short (they are byte in the schematic, but unsigned while java's byte type is signed. Short was used for ease of use)
03/11/2012: Update to 1.2.3. Added 2 Items and 2 Blocks. Also added a workaround for the "ShortTag cannot be cast to IntTag"-Error (that is actually a problem with the exporting program, not with S2B)
01/22/2012: Update to final 1.1.0. 20 items and 13 blocks added. Added print and marker functionality to ImageGrid and fixed the memory problem by not using one component/block to draw the ImageGrid.
11/7/2011: Update to 1.8.1 and various bugfixes. 10 items and 22 blocks added.
7/8/2011: Added some info-messages to the ParseException
6/28/2011: Added an image export directly to Slice (was only aviable from ImageGrid) and added a text export to SliceStack that is compatible with the Builders-Mod

Contents

Description
Support for texture packs
Note concerning Redstone Circuits
Note concerning empty Dispensers and blank Signs
Sample Code
Licence
Download and Javadoc

Post comment (Allready 38)

Description

This is a tool (a java library) to handle schematic files, an export format of many MineCraft tools.

After reading a schematic file, it provides you with a SliceStack object. This object represents a cuboid inside MineCraft, a three-dimensional collection of blocks.
The SliceStack contains various Slices representing a single horizontal plane of the SliceStack, ordered so that the index 0,0 corresponds to the north-west corner of the slice (first index is width, second is height).
Each slice consists of various Blocks, each one representing a single block inside the world of MineCraft. All blocks that have a data value, such as the direction they're facing, have a subclass handling its special needs, for example, Redstone Torches have a direction (RedstoneTorch.getDirection()) and can be on or off (RedstoneTorch.isOn()). To ensure that everything can be written back to a schematic file, all changes to a block (such as RedstoneTorch.setOn(false)) will update its data values.

All those classes also have the ability to give you a graphic representation of them as a swing component, making it easy to build GUI programs. To enable this, you have to call ImageProvider.initialize(). For memory and speed reasons, images are not loaded if you don't so the tool can be used in the background just as well.
All Blocks have the function getImage() returning a BufferedImage-instance of the block and the function getComponent, returning a special swing component that displays the image and updates with changes to this block. It also has tooltips giving more informations about the block. Some blocks, like Chests, have a special tooltip that displays an image.
Slices have the function getImages() which gives you an ImageGrid, a swing component holding the representation of the slice (a graphical grid grid containing all its blocks). SliceStacks return an array of such slice components wrapped inside a ImageGridStack object (which handles zooming etc).

Back to contents

Support for texture packs

Because MCSchematicTool uses the default MineCraft terrain.png and items.png for most of its block images, one can easely just replace them with those from a (16x16) texture pack to change the looks. For example, the screenshot from above with the Painterly texture pack looks like this:

Back to contents

Note concerning Redstone Circuits

This is only of interest if you plan to use the graphic features

Redstone wires are the only blocks in MineCraft that require knowledge of their surrounding to determine their direction. This is rather costly compared with other blocks, therefore MCSchematicTool gives you the ability to not calculate that trough a parameter for the getImages()-method of slice and slicestack, which will result in all redstone wires looking like the default cross piece. If you plan to let MCSchematicTools calculate the redstone wire directions, it is better to always use the SliceStacks getImages() method and not the one of Slice.
Because Slice represents a single, well, slice, even when calculating the redstone directions, it can only calculate them according to the current slice, so redstone lines going up a hill will not be recognized, but they will be in SliceStack.

Also, because of the way MCSchematicTool updates the graphical representations, you will have to get the complete ImageGridStack again if you change any block that will change the display of the wires.

Note that this is for displaying only and does not concern MCRedstoneTool in any other way at all.

Back to contents

Note concerning empty Dispensers and blank Signs

This is not actually a bug of MCSchematicTool, but a bug in WorldEdit that does not export the content of signs and dispensers.

Back to contents

Sample Code

To read a schematic file and graphically display a single slice from it (used for above screenshots):

try {
	ImageProvider.initialize();
			
	JFrame frm = new JFrame();
	frm.setTitle("Test");
	frm.setSize(250, 250);

	File f = new File("/path/to/your/shematic");
	SliceStack stack = SchematicReader.readSchematicsFile(f);
	// get lowest slice
	Slice slice = stack.getSlice(0);
	
	// 2 = zoom value - display the blocks at double slice (1 would be 16px x 16px)
	// true = calculate redstone wires (only for the current slice in this case)
	JScrollPane scrPn = new JScrollPane(slice.getImages(2, true));
	
	frm.add(scrPn);
	frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frm.setVisible(true);
} catch (IOException e) {
	// file not found
	e.printStackTrace();
} catch (ClassicNotSupportedException e) {
	// schematic is in Minecraft classic format
	e.printStackTrace();
} catch (ParseException e) {
	// schematic is invalid
	e.printStackTrace();
}

To just output the contents of the schematics in the console:

try {
	File f = new File("/path/to/your/shematic");
	SliceStack s = SchematicReader.readSchematicsFile(f);
	System.out.println(s);
} catch (IOException e) {
	// file not found
	e.printStackTrace();
} catch (ClassicNotSupportedException e) {
	// schematic is in Minecraft classic format
	e.printStackTrace();
} catch (ParseException e) {
	// schematic is invalid
	e.printStackTrace();
}


Example output:
[Diamond Block][Chest, contents: [3x Bone, 2x Cobblestone, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -]]
[Gold Block][Glass]
-------------
[Cobblestone][Dirt]
[Iron Block][Stone]
-------------

To trim and rotate the content of the schematic and save it to a new file:

try {
	File source = new File("/path/to/your/source.shematic");
	File target = new File("/path/to/your/target.shematic");
	SliceStack stack = SchematicReader.readSchematicsFile(source);
	stack.trim();
	stack.turnCW();
	SchematicWriter.writeSchematicsFile(stack, target);
} catch (IOException e) {
	// file not found
	e.printStackTrace();
} catch (ClassicNotSupportedException e) {
	// schematic is in Minecraft classic format
	e.printStackTrace();
} catch (ParseException e) {
	// schematic is invalid
	e.printStackTrace();
}

Back to contents

Licence

Would be nice if you would drop a link back to me if you use it. As for the rest, you're only bound to the licence of JNBT. See the Licence directory in the jar file for the full licence text.

Back to contents

Download and Javadoc

MCSchematicTool.jar (also containing source)
MCSchematicTool JavaDoc

Back to contents

Comments

#35 Uebertreiberman wrote at 10/31/2015 03:19 PM (EST):
Hey, I have a small question, can I use your Library to generate new schematics from nothing?
Because I'm considering working on a program which can generate command block structures and output them as a schematic, and I wonder if I could use your Library for that.
Thanks in advance ;)

#36 klaue wrote at 11/03/2015 12:13 PM (EST):
still the same answer as below

#37 Uebertreiberman wrote at 11/03/2015 12:28 PM (EST):
Oh, that's strange, I'm pretty sure I've only send that once...
Sorry :D

#33 Uebertreiberman wrote at 10/29/2015 02:05 PM (EST):
Hey, I have a small question, can I use your Library to generate new schematics from nothing?
Because I'm considering working on a program which can generate command block structures and output them as a schematic, and I wonder if I could use your Library for that.
Thanks in advance ;)

#34 Klaue wrote at 10/30/2015 12:09 AM (EST):
Yeah that should be possible. Just keep in mind that this is a bit outdated, I don't know if command blocks changed much in the last few releases.

Though sources are provided and updating a single block might be easier than implementing all of schematics yourself :)

#30 SimPlaysGames wrote at 03/28/2015 01:00 PM (EST):
How do i download this?

#31 SimPlaysGames wrote at 03/28/2015 01:16 PM (EST):
Forget it

#28 M. Gentilcore wrote at 10/29/2013 07:25 PM (EST):
I've been using your program pretty well for the last little while, but I ran into a problem with it today. When I try to open it, it says that the program cannot be launched. It used to work just fine up until a little while ago, do you have any thoughts as to why it suddenly isn't working?

#29 Klaue wrote at 11/01/2013 11:36 AM (EST):
Sounds like either you uninstalled java, or you updated it and the update fucked it up. Open the command line (Win-R -> cmd) and type in "java -version" without the quotes. If it outputs the same error, your java path doesn't work anymore. you can fix this by opening the start bat in a text editor (like notepad) and replace "javaw" with the full path to your javaw.exe

#32 Kodi wrote at 06/24/2015 06:21 PM (EST):
is there an updated version of this program?

#27 Bierfreund wrote at 04/25/2013 02:39 PM (EST):
Danke, das ist genau das Tool, dass mir gefehlt hat. Gute Arbeit



Blender, binvox, constructor, mcedit und dein schematic2blueprint, ein perfektes lineup.

PS: Gabs wirklich keinen kürzeren Namen dafür? ;)

#25 Zeke wrote at 08/20/2012 10:58 AM (EST):
What do I do once I have the .jar file downloaded? How do I use/run the program?

#26 Klaue wrote at 08/31/2012 03:20 PM (EST):
This is not a program, this is a library. Hence why it's listed under "Library". What you want is the Program Schematic2Blueprint.

#21 Tom Baer wrote at 10/19/2011 10:09 PM (EST):
I am loving your kindness in the amount of comments.

#17 Tom Baer wrote at 10/19/2011 03:05 PM (EST):
It doesn't let me extract it. WinRar and 7Zip give a broken archive error. Is that some kind of protection? How could I look at the source? I am making an applet that can convert schematics to components for 1.8.1.

#18 Klaue wrote at 10/19/2011 04:14 PM (EST):
I just tested it and it extracts fine here. Maybe redownload it and try again?
As for your project: the lib is jurrently still on 1.6 (it works with newer schematics, or it should at least, but it would not recognise the new blocks and therefore just treat them as a general "unknown" block) as I had no time to update it...

#19 Tom Baer wrote at 10/19/2011 09:44 PM (EST):
That is fine, after my third time downloading it worked. I will write in the new blocks, and likely the fix the rotation stuff. The tile entities I will need to look into, because things like saving chests full of items or mob spawners is a big deal for some things.

#20 Tom Baer wrote at 10/19/2011 09:45 PM (EST):
If you want after it's written in, I can send it to you.

#22 Klaue wrote at 10/19/2011 11:16 PM (EST):
The chests with all the items should allready work. Some schematic exporters do not save them, though, and my tool cannot read what's not in the file, that's why some chests appear to be empty even if they weren't inside minecraft. Signs have the same problem.

If you want, I could give you the "beta" with my current status, it allready contains most of the new blocks and items.
It would contain Shears, Melon Slice, Pumpkin Seeds, Melon Seeds, Raw Chicken, Cooked Chicken, Raw Beef, Steak, Rotten Flesh, Ender Pearl, Stone Brick (Normal, Mossy, Cracked), Stone Brick Slabs, Brick Slabs, Stone Brick Stairs, Brick Stairs, Glass Pane, Iron Bars, Melon, Melon Stem / Pumpkin Stem, Vines, Fence Gate

It still lacks the red and brown mushroom caps and the mushroom stem (95% done, only direction stuff still incomplete) and the pistons.
By the way, there was some confusion because notch had to state that the sun rises in the north instead of east which fucked up all the directions, but I decided to still act like sun rising = east because a) it makes more sense to users and b) changing that would mean mayor work,

Note that I diddn't test any of the new blocks yet, so each one in the "done" list could fail. Still, probably way less work to take the beta.
Just tell me if you want it, but you'd have to wait until evening (central european time) because I'm off to work now.
Best would be to type in your email adress in the comment form here (if you diddn't allready do it). Nowbody but me can see that so spam is no issue ;)

#23 Tom Baer wrote at 10/20/2011 06:32 AM (EST):
Cool, that'd be great, I just set up my eclipse workspace yesterday and looked at some of the code, but I plan to getting to work later today.

#24 Klaue wrote at 10/24/2011 02:15 PM (EST):
Hey, did you receive the code? haven't heard anything since I sent it to you last thursday

#14 DV8FromTheWorld wrote at 09/10/2011 12:01 PM (EST):
Did I miss something? because after I downloaded it and tried to run it, it says "A Java Exception has occured" in the Java Virtual Machine Launcher

#16 Klaue wrote at 09/10/2011 08:31 PM (EST):
This is a programming library to build other programs with, not a program itself.
Maybe you're looking for Schematic2Blueprint, which uses this lib?
http://klaue.net16.net/programme/ownprogs/java/schematic2blueprint.en.php

#13 Serge wrote at 08/26/2011 09:08 AM (EST):
Does he copy modded blocks to the schematic file?

#15 Klaue wrote at 09/10/2011 08:30 PM (EST):
If you mean if it can handle modded blocks, then the short answer is "most of the time".
The long answer is:
Depends. it does care for unknown blocks, but if the modded block uses additional data in Tile Entities (only very few original ones, like the chest and the sign, use them), that will be lost. Also, it will be handled as if it had no direction (like most normal blocks), so if you rotated the schematic, the block will be moved to the right place, but without changing it's data value (that is where, for example, torches save their direction)


Add comment

*Name:

Email:
(Optional, hidden. Only if you want to be notified of replies)

Homepage:

* Spam check: 2 * 2 =
*Comment:

Back to contents