Giter Club home page Giter Club logo

minecraft-utils's Introduction

mkmcfunction.py

Purpose

This script mkmcfunction.py is used to convert an image (JPG/PNG for example) into an mcfunction that you can use to render the image in your Minecraft world.

Usage

Create a datapack. In your minecraft world folder create the directory datapacks/your_data_pack_name/data/io/functions.

In the directory your_data_pack_name create a file pack.mcmeta with these contents,

{
  "pack": {
    "pack_format": 3,
    "description": "Custom datapack"
  }
}

Now clone this repository and run the mkmcfunction.py script on an image file. It can be a .jpg or .png file, and probably many others. Transparent (alpha channel) pixels will be replaced with minecraft:air. After running this script, it will output an mcfunction file with the same base name as the image. Copy this mcfunction file into your datapaack functions folder.

To configure the script open it and scroll down to the bottom where we check for args.image. Update these variables.

# If you have an image that is 5000x1000, this will scale the image so that neither the width
# nor the height is greater than 100. The result here would be 100x20.
max_dimension = 100
# This is the minimum height any block will be placed.
min_z = 100
# If you want to look down from the sky and see your photo printed on the ground, set this to True
# If you want your print to stand like a cardboard cutout, set this to False
is_horizontal = False

Then render a .mcfunction file. I usually just put mkmcfunction.py in my datapack functions folder and omit the cp command.

python3 mkmcfunction.py <image.png>
cp image.mcfunction path/to/world/datapacks/your_data_pack_name/data/io/functions/

You can also use a custom color block map by passing the --json-file option. There are a few provided.

python3 mkmcfunction.py <image.png> --json-file blockcolormap-glass.json

In Minecraft open a terminal and run reload. You can also do this from your server command line.

Since we processed image.png and created image.mcfunction we can run that function in a Minecraft terminal,

/function io:image

Below is a sample screenshot.

sample image render in-game minecraft

Here's another view using the blockcolormap-glass.json color block map.

sample image render in-game minecraft with glass color block map

minecraft-utils's People

Contributors

wsams avatar

Watchers

 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.