Giter Site home page Giter Site logo

tca166 / mcsavefileparsers Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 6.4 MB

A collection of tools and libraries for extraction of data from Minecraft savefiles and 3d model generation

Home Page: https://tca166.github.io/mcSavefileParsers/

License: MIT License

C 88.32% Shell 0.19% Python 7.10% Makefile 4.39%
c minecraft savefile 3d-models 3d-reconstruction minecraft-saves nbt nbt-files wavefront-obj c-library

mcsavefileparsers's Introduction

mcSavefileParsers

GitHub Pages Documentation CodeQL Linux Windows

Multiple programs for Minecraft save file data extraction and 3D model generation based on save files. Also several well documented custom C libraries with minimal prerequisites for wavefront 3d model handling and Minecraft save file handling.

User Manual

Capabilities

  • Generate a 3d model based on your Minecraft savefile blazing fast
  • extract chunk nbt from region files
  • generate mtl from minecraft resource packs
  • generate obj files from minecraft resource packs

Getting started

In order to get started either download the parts of the precompiled release that apply to your system or compile the source code yourself. In order to compile use make, which is configured to allow for separate compilation of each utility, or complete compilation using the 'all' target ('windows' for cross-compilation).

Data extraction utilities

Multiple utilities for Minecraft region file parsing. Either extract all chunk NBTs in a region file or just a single one.

regionFileReader

This program extracts all the chunks in the given region file into nbt files that will be created in the provided directory.

regionFileReader <path to region file> <output directory>

chunkExtractor

This program extracts only a single chunk with the given chunk coordinates into an nbt file.

chunkExtractor <path to region directory> <x> <z>

3D model generation

Multiple tools that can take in Minecraft related files as input and create 3D representations of your worlds

modelGenerator

An open customizable chunk to 3d model converter. Takes in a chunk nbt file, a material file defining the look of blocks, an object file for non cube blocks and creates a 3d model based on that. Ideally the nbt file will be extracted using one of the tools above.

modelGenerator <path to nbt file> ...

The program accepts the following additional arguments:

  • -l $y+ $y- :limits the result model to the given vertical range
  • -f :disables face culling
  • -h :displays help
  • -s $s :changes the block side in the result side to the given s argument
  • -m $filename :sets the given filename as the source mtl file
  • -o $filename :sets the given filename as the source special objects file
  • -out $filename :sets the given filename as the output filename

Mtl format

The generator if provided with the -m flag followed by the mtl file filepath will use the provided file as a material source and generate the obj file to support mtl materials. Blocks of minecraft:dirt will use a mtl material called dirt and so on. Feel free to create your own mtl file or use the mtl Gen to create one quickly.

Obj format

So in order to handle non cube blocks the generator needs an obj file defining models for those "special" blocks. If that file isn't provided the generator will simply assume everything is a cube. In order for the special obj file to get interpreted properly the vertex coordinates in each object must be relative to the center of the object.

radiusGenerator

A version of modelGenerator using multiprocessing that can generate models same as modelGenerator, but with multiple chunks at the same time. This is the program you are going to want to use to generate your model. You provide coordinates of a chunk that will act as a center for your model, a radius in which surrounding chunks will be added to the model and the radiusGenerator will create a large model for you. The argument interface is very similar to modelGenerator and all rules about assets and limitations from modelGenerator apply here. That being said here is how you use radiusGenerator:

radiusGenerator <path to region directory> <x> <z> <radius> ...

Cygwin

You may want to compile the Linux version of radiusGenerator and use it under Windows for speed. You may accomplish that by installing Cygwin and compiling radiusGenerator in their environment. However due to POSIX shared memory management differing too greatly from Windows the cygserver needs to be running. In order to do that install the correct package, then run:

cygserver-config
net start cygserver

Asset extractors

Minecraft stores it's assets in it's own unique way. Due to this, and a need to provide assets for 3D model generators scripts were created. Naturally those assets aren't provided here since I want these programs to be Minecraft version independent (and I don't want to be sued).

mtlGen

A script for generating complete and valid mtl files for modelGenerator

mtlGen.py <path to /assets/minecraft/textures/block directory of a resource pack> ...

The script accepts the following additional arguments:

  • -s :Generates a simplified mtl file that doesn't use textures, but solid colors generated by averaging out RGBA values of all pixels
  • -t :Causes all textures with _top in name to be generated without it
  • -c :Enables green color correction to correct for the fact most vegetation textures are stored in greyscale

Distribute the result at your own risk.

objGen

A script for generating a complete obj file containing special object definition for modelGenerator

objGen.py <path to /assets/minecraft directory of a resource pack>

Distribute the result at your own risk.

quickGen

Batch script combining objGen.py and mtlGen.py in case you don't want to figure out how to use the two scripts

./quickGen.sh <path to /assets/minecraft directory of a resource pack>

Minecraft default assets

You may generate mtl and obj files based on resource packs, or Minecraft default assets. In order to find them, extract your minecraft version jar file as if it is a file archive. Inside you will find default Minecraft textures and models.

cNBT

For parsing of the nbt files I have chosen to use the cNBT library. These are compiled automatically using make, and then linked together into cNBT.o.

API

Most of the code has been organized into four "libraries". These may prove to be useful should you want to parse Minecraft save files or generate wavefront 3D models. Feel free to use these as libraries in your projects just make sure to read the license before you do so. The documentation for functions in these libraries should be mainly in header files and on GitHub Pages, and I will gladly expand it should there be a need so just let me know.

  • regionParser
    This library provides three functions for parsing region files. You can either extract an entire chunk from the given region file, or extract all of them at once.
  • chunkParser
    This library utilizes the cNBT library to extract information about blocks from Minecraft NBTs
  • model
    This library is capable of generating wavefront 3D models
  • generator
    This library utilizes chunkParser and model to provide a simple interface with which you can quickly generate a 3D model from a Minecraft save file

License

This work is licensed under the MIT license.

mcsavefileparsers's People

Contributors

tca166 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.