Create a pixel art of Levi Captain with Python programming!

Finished product

Vertical 204 x horizontal 197 リヴァイ

How to make outline

Roughly speaking, I programmed in Python. I think it took about 2 hours to build the environment and prepare the blueprints. After that, run the program and make an instant! It was completed by making fine adjustments after creation.

From the following, I will write an outline of the procedure.

Get original image

I borrowed it from here. https://bibi-star.jp/posts/6881

Blueprint creation

It is a site that outputs an Excel dot picture file when the original image is read. Pixel art Nanika

Color setting

Since it is not a Minecraft block code etc. in the output Excel, Reset the corresponding color. This is a little annoying.

In the case of Levi, the settings were reset as follows.

Color number output to Excel: Color number set in Excel output by pixel art Nanika Block number: Minecraft block number (24: sandstone, 35: wool) Block data number: A number that becomes a branch number of the block number (corresponding to the type of block number)

block number Block data number

Python installation

Details will be given to the following site. https://www.python.jp/install/windows/install.html

Install Forge and Raspberry Jam Mod

For the installation of Forge and Raspberry Jam Mod, refer to the following. Minecraft 5 steps to do python programming in

In my case, since the version of Minecraft was 1.16.4, Forge also installed 1.16.4, but I could not read it well probably because the version that can be used with "Raspberry Jam Mod" is different, so 1.12.2 (Raspberry) It matches the latest version of Jam Mod).

Raspberry Jam Mod downloads "mods.zip" from the following. https://github.com/arpruss/raspberryjammod/releases/tag/0.94

Of the unzipped folders, "RaspberryJamMod.jar" in 1.12.2, Place it in your Minecraft mods folder.

Color code conversion

Converts the color code in Excel to the color code in Minecraft. I made my own (VBA) conversion tool that corresponds to the previous setting.

The color code of Minecroft is "block number_block data number", I try to separate them with an underscore (_). This is to make it easier to handle later on the Python side.

module.bas


Sub main()
'//Speeding up
Application.ScreenUpdating = False 'Stop drawing
Application.EnableEvents = False 'Event suppression
Application.Calculation = xlCalculationManual 'Manual calculation

'//Acquisition source sheet
Dim targetSt As Worksheet: Set targetSt = ThisWorkbook.Worksheets("dot-e-nanika")

'//Setting sheet
Dim colorConfig As Worksheet: Set colorConfig = ThisWorkbook.Worksheets("Color setting")
Dim configRange As Range: Set configRange = colorConfig.Range("A2:A16")

'//Rightmost,Get the bottom
Dim cols, rows As Long
cols = 197
rows = 204

'//Array
Dim blockDataArray() As String
ReDim blockDataArray(rows - 1, cols - 1)

'//Vertical loop
For i = 1 To rows
    '//Horizontal loop
    For j = 1 To cols
        '//Get value
        targetVal = Cells(i, j)
        Set findRng = configRange.Find(What:=targetVal, LookIn:=xlValues, LookAt:=xlWhole)
        
        '//conversion
        blockData = "Nothing"
        If Not findRng Is Nothing Then
            blockNo = findRng.Offset(0, 1)
            blockDataNo = findRng.Offset(0, 2)
            blockData = "'" & blockNo & "_" & blockDataNo & "'"
        End If
        
        '//Store in array
        blockDataArray(i - 1, j - 1) = blockData
    Next j
Next i

    
'//Output the array to another sheet
Worksheets.Add after:=Worksheets(Worksheets.Count)
For i = 0 To rows - 1
    colors_str = "["
    For j = 0 To cols - 1
        colors_str = colors_str & blockDataArray(i, j)
        If j < cols - 1 Then
            colors_str = colors_str & ","
        End If
    Next j
    colors_str = colors_str + "]"
    If i < rows - 1 Then
        colors_str = colors_str & ","
    End If
    ActiveSheet.Cells(i + 1, 1) = colors_str
Next i

'//Release speed
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic

End Sub


Output result
['35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0','35_0'], … (Similar matrix continues up to line 204)

Source code (Python)

dot_levi.py


import mcpi.minecraft as minecraft
mc = minecraft.Minecraft()
x, y, z = mc.player.getPos()

rows = 204
cols = 197 

colors = [
#The color code output by VBA is entered here.
]

for i in range(rows):
	row = colors[i]
	for j in range(cols):
		blockNo, blockDataNo = row[j].split('_')
		mc.setBlock(x + j, y + rows - i, z, int(blockNo), int(blockDataNo))

blockNo, blockDataNo = row[j].split('') ⇒ Here, the block number and block data number separated by an underscore () are stored in each variable. If you fix it to one block number, it will not be possible to handle if there is a color you want to use other than that block number, so I tried to keep it in this format. As a result, "smooth sandstone (24_8])" and wool (35_XX), which are close to the skin color, are added. I am trying to handle it at the same time.

Program execution

・ Start Minecraft. -At the command prompt, move to the folder where dot_levi.py is located, and Type python dot_levi.py and press Enter.

Summary

-Large-scale pixel art can be programmed with Python. -To program Python, you need to install Python / Forge / Raspberry Jam Mod. ・ If you use a site called Pixel Art Nanika, you can almost complete the blueprint. -In order to give flexibility in specifying the block at the time of creation, it is recommended to use the format "block number_block data number". -You can make anything if you have the original image, blueprint, and color code corresponding to Micra! !!

Recommended Posts

Create a pixel art of Levi Captain with Python programming!
Create a directory with python
Create a virtual environment with Python!
I tried to create a list of prime numbers with python
Create a compatibility judgment program with the random module of python.
Create a dummy image with Python + PIL.
Create a word frequency counter with Python 3.4
Create a frame with transparent background with tkinter [Python]
[AtCoder] Solve A problem of ABC101 ~ 169 with Python
I made a competitive programming glossary with Python
[python] Create a list of various character types
Create a LINE BOT with Minette for Python
Make a simple pixel art generator with Flask
Create a virtual environment with conda in Python
Create a page that loads infinitely with python
[Note] Create a one-line timezone class with python
You can easily create a GUI with Python
Solve A ~ D of yuki coder 247 with python
Create a color bar with Python + Qt (PySide)
Create a decision tree from 0 with Python (1. Overview)
Create a new page in confluence with Python
Create a color-specified widget with Python + Qt (PySide)
Create a Photoshop format file (.psd) with python
Create a Python console application easily with Click
Create a table of contents with IPython notebook
3. 3. AI programming with Python
Python programming with Atom
Competitive programming with python
Create a Python environment
Programming with Python Flask
A memo connected to HiveServer2 of EMR with python
Recommendation of building a portable Python environment with conda
[Python] Create a ValueObject with a complete constructor using dataclasses
Why not create a stylish table easily with Python?
Create a python development environment with vagrant + ansible + fabric
Create a batch of images and inflate with ImageDataGenerator
Create a Layer for AWS Lambda Python with Docker
[python] Create a date array with arbitrary increments with np.arange
[Python] How to create a 2D histogram with Matplotlib
[Python] Create a Tkinter program distribution file with cx_Freeze
Create a fake Minecraft server in Python with Quarry
Create a company name extractor with python using JCLdic
Create a 2d CAD file ".dxf" with python [ezdxf]
[Python] I tried to automatically create a daily report of YWT with Outlook mail
Image processing with Python (I tried binarizing it into a mosaic art of 0 and 1)
Create a Wox plugin (Python)
Create a function in Python
Create a dictionary in Python
[Python] Create a file & folder path specification screen with tkinter
Create a list in Python with all followers on twitter
Try programming with a shell!
Create a Mastodon bot with a function to automatically reply with Python
Create 3d gif with python3
A collection of competitive pro techniques to solve with Python
Create a child account for connect with Stripe in Python
Let's create a script that registers with Ideone.com in Python.
Probably the easiest way to create a pdf with Python3
Create a homepage with django
Let's create a PRML diagram with Python, Numpy and matplotlib.
Get a list of purchased DMM eBooks with Python + Selenium
Detect objects of a specific color and size with Python