Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying Minecraft World files Programatically (Java)

I have a forge server/client project setup in Eclipse and am running a vanilla server. I'd like to copy some structures my children have built in another vanilla world and modify them slightly (ie. change the scale, replace block types, etc) and place them in the new world. The end goal is to create large towns based on their "designs". Do I need to be looking at the source world mca files and processing them for the relevant data and then injecting that into my target world? I know of MCEdit but haven't used it. Would looking at that source code be a good place to begin?

like image 360
Casey Murray Avatar asked Jul 01 '18 14:07

Casey Murray


1 Answers

You have a few different strategies you can follow depending exactly what you want to do.

  1. Create a pre-made map.

http://www.mcedit.net/ is an OFFLINE editor (runs outside the game) of Minecraft worlds that allows you to easily copy and paste, edit, and write python scripts to filter and transform blocks.

https://github.com/sk89q/worldedit/ Is an ONLINE editor (runs within the game) of Minecraft worlds that allows you to easily copy and paste (Using schematics) run different commands to run different transformations / brushes, as well as writing javascript scripts, or hooking directly into it's API using Java.

  1. World Gen

This option requires creating custom world generation via a Mod, Plugin or DataPack

But you can create your own villages that generate naturally in the world.

Minecraft itself has limited support for this without any programming whatsover.

This feature is known as 'structures' and you can create custom structures and export them, for use within DataPacks by using the structure block.

Additionally, if you are creating a mod, the structure block is the easiest way to export buildings from your kids for inclusion in random generation.

Changing scale will be tricky, but you could totally filter the blocks, and save out multiple schematics/structures or else programmatically replace some of the blockstates.

like image 171
Ryan Leach Avatar answered Oct 05 '22 12:10

Ryan Leach