Quickstart¶
Loading/Initializing a Structure¶
You can load a pre-existing structure by using the mcstructure.Structure.load() method.
from mcstructure import Structure
with open("house.mcstructure", "rb") as f:
struct = Structure.load(f)
Alternatively, create a new empty structure:
from mcstructure import Block, Structure
struct = Structure(
(12, 20, 5), # size of the structure
Block("minecraft:wool", color="red") # fill the structure with red wool
)
Inspecting a Structure¶
struct.size # The size of the structure
struct.get_block(1, 1, 1) # Get the block at (1, 1, 1)
struct.get_structure() # Get the numpy array representing the structure
Viewing a Structure¶
You can simply print the structure object:
print(struct)
Modifying a Structure¶
Simple modifications such as placing blocks:
from mcstructure import Block
struct.set_block((1, 1, 1), Block("minecraft:wool", color="red")) # Places a red wool block at (1, 1, 1)
struct.set_blocks((1, 1, 1), (5, 5, 5), Block("minecraft:wool", color="red")) # Places red wool blocks from (1, 1, 1) to (5, 5, 5)
Advanced modifications can be achieved with numpy.
A structure object consists of an array of integers representing IDs. Each ID is associated
with a mcstructure.Block in a list.
import numpy as np
np.rot90(struct.structure)
struct.structure = np.transpose(struct.structure)
Saving a Structure¶
with open("mansion.mcstructure", "wb") as f:
struct.dump(f)