Jump to content

[1.8]Best way to build structures step by step


Recommended Posts

Hey guys,

I want to have a structure that will be building itself step by step, using tickRandomly from the block class.

That means I want to have one base block which will be placed down that will be building a whole base.

My question right now is what would be the best way to store the information of how to build the building?


Use a static final array of IBlockstates which would be called via index?


Use a method in which I would use a switch case to find out which block to set right now?


Or save the blocks via numbers (cobble 0 glass 1 ... ) and save the structure as numbers and translate these into the fitting IBlockstates


Greetz Fail

Link to comment
Share on other sites

I would agree with your proposed approach. Basically I would have a text-based resource file that contains information about the blocks in your structure. There is actually a "schematic" format that many people use, but frankly I find it easier to just record the block name, metadata value and positions. I then read them into an array, and then cycle through the array and place the blocks (offset by starting position).


I was originally tempted to just code the array directly into the class, but even for modest size structures (10 x 10 x 10) you quickly get into the thousands of lines and that is better put into an external text file.


Lastly, I use block names instead of IDs, especially since that allows you to reference blocks from other mods confidently.


Another key point when placing the blocks is that some blocks require other blocks to be placed first otherwise they won't place properly (like tripwire). I found that what works best is to place all the blocks with metadata = 0 first (except for some special blocks like tripwire), then place all the ones with metadata, then place a few special types of block.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

A scanner should so the trick, but I would recommend to use a BufferedReader instead. Its a bit faster, and you can separate lines easily. If you wonder how to use it, just google it, or look at my N2ConfigAPI(link at the bottum). If you want, you can use the api to automaticly generate a premade custom file in custom folder etc. storing the data. Though that would require a bit of hardcoding.



- N2ConfigAPI

- Meachanical Crafting Table



- CollectionUtils



- InGameConfigManager

Link to comment
Share on other sites

Well separating lines with a scanner is also kinda easy, since you can just read each line, proceed it and read the next line.

But if you recommend the BufferedReader for performance reasons I guess I'll be using that one.

I aready worked with both, but might take a peak at your code, thank you sir!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.