-
Notifications
You must be signed in to change notification settings - Fork 0
Adding block
Timaaos edited this page Feb 13, 2021
·
4 revisions
In this tutorial you will add your own block to craft.py!
We need to draw texture of this block, i will draw wilber(GIMP wolf)
Now we need to import Block class:
from Block import Block
Now we need to create variable of our block:
WILBER_BLOCK = Block()
Now we need to change name and texture:
WILBER_BLOCK.name = "Wilber"
WILBER_BLOCK.texture = mc.tex_coords((2,2),(2,2),(2,2))
You can change many things, but in this tutorial we will just add wilber block! Now we need to add to inventory our block:
window.inventory.append(WILBER_BLOCK)
You need add block to inventory before mc.setup()
"Wilber" is name of block in inventory
5 is default quantity of block
Full code:
import api as mc
import pyglet
import sys, os
from Block import Block
pathname = os.path.dirname(sys.argv[0])
texture = pathname + "\texture.png"
mc.TEXTURE_PATH = texture
WILBER_BLOCK = Block()
WILBER_BLOCK.texture = mmc.tex_coords((2,2),(2,2),(2,2))
WILBER_BLOCK.name = "Wilber"
window = mc.Window(width=800, height=600, caption='CraftPy', resizable=True)
window.addToInventory(WILBER_BLOCK,"Wilber",5)
model = mc.Model()
model._initialize()
window.model = model
mc.setup()
pyglet.app.run()