Skip to content
UrsaCraft
Profile icon
NVVC008

Hey guys!

@NVVC008
here! My old account got hacked, so I'm using this for now. In this tutorial, I'm gonna be teaching you how to make Minecraft in python. First, you're gonna need to download PyCharm Community Edition. Also, sorry MacOS users, this package is only available on windows. Speaking of which, you need to download ursina with pip install ursina or:

  1. Click on 'File' on the top right corner of the PyCharm window.
  2. Click on 'Settings'...
  3. Click on 'Project: (Project name)' and select python interpreter...
  4. Click Alt + Insert...
  5. Enter the name: ursina...
  6. Download the package, and you're done!
    BTW, download the folder 'Minecraft-in-Python-main' included with the project. Do not download the code file Minecraft.py.
    Let's start with our code in the file main.py.
    I bet you can guess what's coming first.
import ursina

Well, you were close. Instead, it's:

from ursina import *

That's like saying, "Get me some glass bottles from amazon, without the box." Basically, the guy is gonna give you unpackaged bottles.

Next, we're gonna need our first-person controller.

from ursina.prefabs.first_person_controller import FirstPersonController

Then:

app = Ursina()

Basically, we're creating a name/shortcut for the Ursina package.
Now, the textures.

grass_texture = load_texture('assets/grass_block.png') stone_texture = load_texture('assets/stone_block.png') brick_texture = load_texture('assets/brick_block.png') dirt_texture = load_texture('assets/dirt_block.png') sky_texture = load_texture('assets/skybox.png') arm_texture = load_texture('assets/arm_texture.png') punch_sound = Audio('assets/punch_sound',loop = False, autoplay = False) block_pick = 1

So far, your code should be like this:

from ursina import * from ursina.prefabs.first_person_controller import FirstPersonController app = Ursina() grass_texture = load_texture('assets/grass_block.png') stone_texture = load_texture('assets/stone_block.png') brick_texture = load_texture('assets/brick_block.png') dirt_texture = load_texture('assets/dirt_block.png') sky_texture = load_texture('assets/skybox.png') arm_texture = load_texture('assets/arm_texture.png') punch_sound = Audio('assets/punch_sound',loop = False, autoplay = False) block_pick = 1

If you want to exit or see your fps, you can add this:

window.fps_counter.enabled = True window.exit_button.visible = True

Or, you can just set them to false. But, they have to be there.
Now, we need to have our screen constantly update, right? So, add:

def update():

Here, we created the action that will keep updating our screen.
Add:

global block_pick

This converts it into a global variable.
Make sure the definition so far is:

def update(): global block_pick

Let's add the rest of it.

def update(): global block_pick if held_keys['left mouse'] or held_keys['right mouse']: hand.active() else: hand.passive() if held_keys['1']: block_pick = 1 if held_keys['2']: block_pick = 2 if held_keys['3']: block_pick = 3 if held_keys['4']: block_pick = 4

You know what, I don't care anymore. Just take the code and leave.

You are viewing a single comment. View All
Profile icon
David202008

If you don't give up then tomorrow will be a better day, Learn from mistakes when they happen instead of wishing there was a time machine. Sames goes with the one I write my essay and you must take a close look at that.