mcthings package¶
Submodules¶
mcthings.block module¶
-
class
mcthings.block.
Block
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
create
()¶ Create the Thing in memory (BlocksMemory) :return:
-
mcthings.blocks module¶
mcthings.blocks_gallery module¶
-
class
mcthings.blocks_gallery.
BlocksGallery
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
MAX_BLOCK_NUMBER
= 247¶
-
create
()¶ Show all possible block types in a line :return:
-
mcthings.blocks_memory module¶
-
class
mcthings.blocks_memory.
BlockMemory
(block_id, block_data, pos)¶ Bases:
object
-
class
mcthings.blocks_memory.
BlocksMemory
¶ Bases:
object
Blocks memory for a Thing
-
add
(block_memory)¶ Add a new block to the memory.
Parameters: block_memory – memory for a block Returns:
-
build_schematic
()¶
-
fill
(fill_block)¶ Fill all blocks in memory with fill_block
Parameters: fill_block – block to be used to fill all memory Returns:
-
find_block_at_pos
(pos)¶ Find a block in memory give its position TODO: Improve performance
Parameters: pos – position for the block Returns: the block found or None
-
find_init_end_pos
()¶ Find the init and end cuboid positions from all the blocks in the memory
-
flip_x
(position)¶ Flip based on x-axis the blocks in memory using position as base position from which to rotate :param position: base position from which to rotate :return:
-
is_cuboid
()¶ Check if the memory is a filled cuboid
-
memory_equal
()¶ Check if all the blocks in the memory are equal
-
rotate
(degrees, position)¶ Rotate degrees the blocks in memory using position as base position from which to rotate :param degrees: degrees to rotate (90, 180, 270) :param position: base position from which to rotate :return:
-
set_block
(pos, block_id, block_data=None)¶
-
set_blocks
(vertex, vertex_opposite, block_id)¶ Add a cuboid with the same block for all blocks and without specific data
-
to_nbt
(init_pos, end_pos)¶ Convert the blocks of memory to NBT format for exporting as Schematic The NBT must be a complete cuboid with air in the positions where there are no data in blocks memory.
Returns: bytearrays for blocks ids and block data
-
to_schematic
(file_path)¶ Convert the blocks memory to a Schematic Object
File_path: file in which to export the memory in Schematic format Returns: the Schematic object
-
mcthings.bridge module¶
mcthings.building module¶
mcthings.circle module¶
-
class
mcthings.circle.
Circle
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
build
()¶ Build the thing and show it using the renderer at position coordinates
Returns:
-
radius
= None¶ radius of the Sphere
-
mcthings.collage module¶
mcthings.fence module¶
-
class
mcthings.fence.
Fence
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
Build a block plane and empty it to create the fence
-
create
()¶ Create a fence around the configured thing :return:
-
fence_space
= 5¶ Space between the fence and the thing fenced
-
height
= None¶
-
thick
= 1¶
-
thing
= None¶
-
mcthings.house module¶
mcthings.line module¶
-
class
mcthings.line.
Line
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
create
()¶ Create the Thing in memory (BlocksMemory) :return:
-
length
= 10¶
-
width
= 3¶
-
mcthings.platform module¶
-
class
mcthings.platform.
Platform
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
create
()¶ Create the Thing in memory (BlocksMemory) :return:
-
height
= 10¶
-
top_size
= 3¶
-
mcthings.pyramid module¶
-
class
mcthings.pyramid.
Pyramid
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
create
()¶ Create the Thing in memory (BlocksMemory) :return:
-
height
= 10¶
-
-
class
mcthings.pyramid.
PyramidHollow
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
create
()¶ Create the Thing in memory (BlocksMemory) :return:
-
height
= 10¶
-
thick
= 2¶
-
mcthings.river module¶
mcthings.scene module¶
-
class
mcthings.scene.
Scene
¶ Bases:
object
A scene is a container for all the things built using McThings. A scene can be built, unbuilt and moved. There is only one scene in a program using McThings. Things built are added automatically to the Scene. A Scene can also be loaded from a file, and it can be saved to a file.
Before adding Things to the Scene, it must be connected to a Minecraft server (fill the Scene.server attribute)
-
add
(thing)¶ Add a new thing to the scene
-
add_decorator
(decorator)¶ Add a new decorator to the scene
-
build
()¶ Build all the things inside the Scene
-
create
()¶ Create all the things inside the Scene
-
decorate
()¶ Call all decorators for the current Scene
Returns:
-
end_position
¶ end position of the thing
-
find_bounding_box
()¶ Compute the bounding box of the Scene
-
load
(file_path)¶ Load a scene from a file (but no build it yet)
-
move
(position)¶ Move the scene to a new position
Parameters: position – new position Returns:
-
position
¶ initial position of the thing
-
reposition
(position)¶ Move all the things in the scene to a new relative position
Parameters: position – new position for the Scene Returns:
-
save
(file_path)¶ Save a scene to a file
-
things
= None¶ map with the things in the scene
-
to_schematic
(file_path, block_data=False)¶ Save the Scene into a Schematic file
Parameters: - file_path – file in which to export the Scene in Schematic format
- block_data – extract blocks ids and data (much slower)
Returns: the Schematic object
-
unbuild
()¶ Unbuild all the things inside the Scene
-
mcthings.schematic module¶
-
class
mcthings.schematic.
Schematic
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
change_blocks
= {0: 0}¶ Change a block with other
-
create
()¶ Create the Thing in memory (BlocksMemory) :return:
-
file_path
= None¶ file path for the schematic file
-
find_bounding_box
()¶ In a Schematic the bounding box is inside the file data
-
rotate_degrees
= 0¶ rotate the schematic
-
mcthings.sphere module¶
-
class
mcthings.sphere.
Sphere
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
build
()¶ Build the thing and show it using the renderer at position coordinates
Returns:
-
radius
= 5¶ radius of the Sphere
-
-
class
mcthings.sphere.
SphereHollow
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
build
()¶ Build the thing and show it using the renderer at position coordinates
Returns:
-
height
= 0¶
-
radius
= None¶ radius of the Hollow Sphere
-
mcthings.thing module¶
-
class
mcthings.thing.
Thing
(position, parent=None, scene=None)¶ Bases:
object
base class for all objects in mcthings library
-
add_child
(child)¶ Add a children to this Thing
-
add_decorator
(decorator)¶ Add a new Decorator to be called once the Thing is decorated
Parameters: decorator – a Decorator to be called Returns:
-
block
= Block(45, 0)¶ block type used by the thing. Default to BRICK_BLOCK
-
build
()¶ Build the thing and show it using the renderer at position coordinates
Returns:
-
create
()¶ Create the Thing in memory (BlocksMemory) :return:
-
decorate
()¶ Call all decorators for the current Thing
Returns:
-
end_position
¶ end position of the thing
-
find_bounding_box
()¶ Compute the bounding box of the Thing
-
flip_x
()¶ Flip x-axis the things using the blocks memory.
Returns:
-
move
(position)¶ Move the thing to a new position
Parameters: position – new position Returns:
-
parent
¶ parent Thing in which this one is included
-
position
¶ initial position of the thing
-
render
()¶ Render the Thing from memory (BlocksMemory) to show it
Returns:
-
rotate
(degrees)¶ Rotate the thing in the x,z space using the blocks memory.
Parameters: degrees – degrees to rotate (90, 180, 270) Returns:
-
scene
¶ scene which this thing is included
-
set_block
(pos, block_id, block_data=None)¶
-
set_blocks
(init_pos, end_pos, block_id)¶ Add a cuboid with the same block for all blocks and without specific data
-
to_schematic
(file_path, blocks_data=False)¶ Convert the Thing to a Schematic Object
File_path: file in which to export the Thing in Schematic format Blocks_data: include blocks data (much slower) Returns: the Schematic object
-
unbuild
()¶ Unbuild the thing in Minecraft
Returns:
-
mcthings.town module¶
mcthings.utils module¶
-
mcthings.utils.
build_schematic_nbt
(init_pos, end_pos, block_data=False, memory_data=None)¶ Creates a NBT Object with the schematic data
Parameters: - init_pos – initial position for extracting the Schematic
- end_pos – end position for extracting the Schematic
- block_data – extract blocks ids and data (much slower)
- memory_data – get blocks from memory
Returns: The NBT object with the Schematic
-
mcthings.utils.
extract_region
(init_pos, end_pos)¶ Extract a Minecraft world region with the id of the blocks
Returns: bytearrays for blocks ids and block data
-
mcthings.utils.
extract_region_with_data
(init_pos, end_pos)¶ Extract a Minecraft world region with the id and data of the blocks
Returns: bytearrays for blocks ids and block data
-
mcthings.utils.
find_min_max_cuboid_vertex
(vertex, vertex_opposite)¶ Find the min vertex and the max vertex for a given cuboid defined from two opposite vertexes
Parameters: - vertex – a vertex in the cuboid
- vertex_opposite – the opposite vertex of the cuboid
Returns: vertex_min, vertex_max
-
mcthings.utils.
size_region
(init_pos, end_pos)¶ Measure (size) the cuboid between init_pos and end_pos :param init_pos: :param end_pos: :return:
mcthings.vox module¶
-
class
mcthings.vox.
Color
(hex_str)¶ Bases:
object
RGBA format palette
-
compare
(color)¶
-
minecraft
()¶
-
rgb
()¶
-
-
class
mcthings.vox.
Vox
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
create
()¶ Create the Thing in memory (BlocksMemory) :return:
-
file_path
= None¶ file path for the MagicaVoxel vox file
-
classmethod
find_minecraft_material
(material)¶
-
parse_vox_file
()¶
-
-
class
mcthings.vox.
VoxDefaultPalette
¶ Bases:
object
-
palette
= ['0xffffffff', '0xffccffff', '0xff99ffff', '0xff66ffff', '0xff33ffff', '0xff00ffff', '0xffffccff', '0xffccccff', '0xff99ccff', '0xff66ccff', '0xff33ccff', '0xff00ccff', '0xffff99ff', '0xffcc99ff', '0xff9999ff', '0xff6699ff', '0xff3399ff', '0xff0099ff', '0xffff66ff', '0xffcc66ff', '0xff9966ff', '0xff6666ff', '0xff3366ff', '0xff0066ff', '0xffff33ff', '0xffcc33ff', '0xff9933ff', '0xff6633ff', '0xff3333ff', '0xff0033ff', '0xffff00ff', '0xffcc00ff', '0xff9900ff', '0xff6600ff', '0xff3300ff', '0xff0000ff', '0xffffffcc', '0xffccffcc', '0xff99ffcc', '0xff66ffcc', '0xff33ffcc', '0xff00ffcc', '0xffffcccc', '0xffcccccc', '0xff99cccc', '0xff66cccc', '0xff33cccc', '0xff00cccc', '0xffff99cc', '0xffcc99cc', '0xff9999cc', '0xff6699cc', '0xff3399cc', '0xff0099cc', '0xffff66cc', '0xffcc66cc', '0xff9966cc', '0xff6666cc', '0xff3366cc', '0xff0066cc', '0xffff33cc', '0xffcc33cc', '0xff9933cc', '0xff6633cc', '0xff3333cc', '0xff0033cc', '0xffff00cc', '0xffcc00cc', '0xff9900cc', '0xff6600cc', '0xff3300cc', '0xff0000cc', '0xffffff99', '0xffccff99', '0xff99ff99', '0xff66ff99', '0xff33ff99', '0xff00ff99', '0xffffcc99', '0xffcccc99', '0xff99cc99', '0xff66cc99', '0xff33cc99', '0xff00cc99', '0xffff9999', '0xffcc9999', '0xff999999', '0xff669999', '0xff339999', '0xff009999', '0xffff6699', '0xffcc6699', '0xff996699', '0xff666699', '0xff336699', '0xff006699', '0xffff3399', '0xffcc3399', '0xff993399', '0xff663399', '0xff333399', '0xff003399', '0xffff0099', '0xffcc0099', '0xff990099', '0xff660099', '0xff330099', '0xff000099', '0xffffff66', '0xffccff66', '0xff99ff66', '0xff66ff66', '0xff33ff66', '0xff00ff66', '0xffffcc66', '0xffcccc66', '0xff99cc66', '0xff66cc66', '0xff33cc66', '0xff00cc66', '0xffff9966', '0xffcc9966', '0xff999966', '0xff669966', '0xff339966', '0xff009966', '0xffff6666', '0xffcc6666', '0xff996666', '0xff666666', '0xff336666', '0xff006666', '0xffff3366', '0xffcc3366', '0xff993366', '0xff663366', '0xff333366', '0xff003366', '0xffff0066', '0xffcc0066', '0xff990066', '0xff660066', '0xff330066', '0xff000066', '0xffffff33', '0xffccff33', '0xff99ff33', '0xff66ff33', '0xff33ff33', '0xff00ff33', '0xffffcc33', '0xffcccc33', '0xff99cc33', '0xff66cc33', '0xff33cc33', '0xff00cc33', '0xffff9933', '0xffcc9933', '0xff999933', '0xff669933', '0xff339933', '0xff009933', '0xffff6633', '0xffcc6633', '0xff996633', '0xff666633', '0xff336633', '0xff006633', '0xffff3333', '0xffcc3333', '0xff993333', '0xff663333', '0xff333333', '0xff003333', '0xffff0033', '0xffcc0033', '0xff990033', '0xff660033', '0xff330033', '0xff000033', '0xffffff00', '0xffccff00', '0xff99ff00', '0xff66ff00', '0xff33ff00', '0xff00ff00', '0xffffcc00', '0xffcccc00', '0xff99cc00', '0xff66cc00', '0xff33cc00', '0xff00cc00', '0xffff9900', '0xffcc9900', '0xff999900', '0xff669900', '0xff339900', '0xff009900', '0xffff6600', '0xffcc6600', '0xff996600', '0xff666600', '0xff336600', '0xff006600', '0xffff3300', '0xffcc3300', '0xff993300', '0xff663300', '0xff333300', '0xff003300', '0xffff0000', '0xffcc0000', '0xff990000', '0xff660000', '0xff330000', '0xff0000ee', '0xff0000dd', '0xff0000bb', '0xff0000aa', '0xff000088', '0xff000077', '0xff000055', '0xff000044', '0xff000022', '0xff000011', '0xff00ee00', '0xff00dd00', '0xff00bb00', '0xff00aa00', '0xff008800', '0xff007700', '0xff005500', '0xff004400', '0xff002200', '0xff001100', '0xffee0000', '0xffdd0000', '0xffbb0000', '0xffaa0000', '0xff880000', '0xff770000', '0xff550000', '0xff440000', '0xff220000', '0xff110000', '0xffeeeeee', '0xffdddddd', '0xffbbbbbb', '0xffaaaaaa', '0xff888888', '0xff777777', '0xff555555', '0xff444444', '0xff222222', '0xff111111']¶
-
-
class
mcthings.vox.
Voxel
(bytes)¶ Bases:
object
mcthings.wall module¶
mcthings.wool module¶
-
class
mcthings.wool.
Wool
(position, parent=None, scene=None)¶ Bases:
mcthings.thing.Thing
-
COLORS
= ['White', 'Orange', 'Magenta', 'Light Blue', 'Yellow', 'Lime', 'Pink', 'Grey', 'Light grey', 'Cyan', 'Purple', 'Blue', 'Brown', 'Green', 'Red', 'Black']¶
-
create
()¶ Show all wool colors :return:
-
mcthings.world module¶
-
class
mcthings.world.
World
¶ Bases:
object
A world is a container for all the scenes built using McThings. Its mapping is direct to Minecraft world concept.
Before adding Things to the World, it must have a renderer
-
classmethod
add_scene
(scene)¶ Add a new scene to the world
-
classmethod
build
()¶ Build all the scenes inside the world
-
classmethod
first_scene
()¶ Return the first scene used be default
-
renderer
= None¶ Render used to render the scenes
-
scenes
= []¶ Scenes included in the world
-
classmethod
set_renderer
(renderer)¶
-
classmethod
unbuild
()¶ Unbuild all the scenes inside the world
-
classmethod