Minecraft using python

How could this be improved ?

from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController

app = Ursina()

window.title = 'Minercraft'
window.borderless = False
window.fullscreen = False
window.exit_button.visible = False
window.fps_counter.enabled = True

bedrock_texture = load_texture('textures/bedrock.png')
stone_texture   = load_texture('textures/stone.png')
wood_texture    = load_texture('textures/log_oak.png')
grass_texture   = load_texture('textures/grass_side.png')

for tex in [bedrock_texture, stone_texture, wood_texture, grass_texture]:
    tex.filtering = False

block_types = {
    1: ('Bedrock', bedrock_texture),
    2: ('Stone',   stone_texture),
    3: ('Wood',    wood_texture),
    4: ('Grass',   grass_texture)
}

current_block = 1
selected_slot = 1
inventory_open = False

block_display = Text(
    text=f'Block: {block_types[current_block][0]}',
    position=window.top_left,
    origin=(0, 0),
    scale=2,
    background=True
)

class Block(Button):
    def __init__(self, position=(0,0,0), texture=bedrock_texture):
        super().__init__(
            parent=scene,
            model='cube',
            texture=texture,
            position=position,
            origin_y=0.5,
            scale=1,
            color=color.white,
            alpha=1,
            texture_scale=(1, 1),
            collider='box'
        )

for x in range(20):
    for y in range(5):
        for z in range(20):
            Block(position=(x, y, z), texture=grass_texture)

player = FirstPersonController()
player.gravity = 0.5
player.jump_height = 1.5
player.cursor.visible = True

inventory = {
    1: 10,
    2: 5,
    3: 3,
    4: 8
}

inventory_display = []

for i in range(3):
    for j in range(9):
        slot = Button(
            parent=camera.ui,
            model='quad',
            scale=(0.1, 0.1),
            color=color.gray,
            position=(-0.45 + j * 0.15, 0.35 - i * 0.15),
            texture='white_cube',
            collider='box'
        )
        inventory_display.append(slot)

hotbar_display = []
for j in range(9):
    slot = Button(
        parent=camera.ui,
        model='quad',
        scale=(0.1, 0.1),
        color=color.gray,
        position=(-0.45 + j * 0.15, -0.45),
        texture='white_cube',
        collider='box'
    )
    hotbar_display.append(slot)

selected_border = Entity(
    parent=camera.ui,
    model='quad',
    color=color.yellow,
    scale=(0.11, 0.11),
    visible=False,
    texture='white_cube'
)

item_count_text = []

def update_inventory_display():
    global inventory_open, selected_slot
    for idx, slot in enumerate(inventory_display):
        block_id = idx + 1
        if inventory.get(block_id, 0) > 0:
            slot.texture = block_types[block_id][1]
        else:
            slot.texture = 'white_cube'

        if len(item_count_text) <= idx:
            item_count_text.append(Text(
                parent=camera.ui,
                text=str(inventory.get(block_id, 0)),
                scale=1,
                position=slot.position,
                origin=(0.5, 0.5),
                color=color.black
            ))
        else:
            item_count_text[idx].text = str(inventory.get(block_id, 0))

    for idx, slot in enumerate(hotbar_display):
        block_id = idx + 1
        if inventory.get(block_id, 0) > 0:
            slot.texture = block_types[block_id][1]
        else:
            slot.texture = 'white_cube'

    if inventory_open:
        for slot in inventory_display:
            slot.enabled = True
        for slot in hotbar_display:
            slot.enabled = True
    else:
        for slot in inventory_display:
            slot.enabled = False
        for slot in hotbar_display:
            slot.enabled = True

    selected_border.visible = True
    selected_border.position = inventory_display[selected_slot - 1].position

def input(key):
    global current_block, selected_slot, inventory_open

    if key in ['1', '2', '3', '4']:
        current_block = int(key)
        block_display.text = f'Block: {block_types[current_block][0]}'

    if key == 'e':
        inventory_open = not inventory_open
        update_inventory_display()

    if inventory_open:
        if key == 'left mouse down':
            mouse_pos = mouse.world_point
            for idx, slot in enumerate(inventory_display):
                if slot.collide_point(mouse_pos):
                    selected_slot = idx + 1
                    current_block = selected_slot
                    block_display.text = f'Block: {block_types[current_block][0]}'
                    break

    if key == 'right mouse down':
        hit_info = raycast(camera.world_position, camera.forward, distance=8)
        if hit_info.hit:
            pos = hit_info.entity.position + hit_info.normal
            if inventory[current_block] > 0:
                Block(position=pos, texture=block_types[current_block][1])
                inventory[current_block] -= 1
                update_inventory_display()

    if key == 'left mouse down' and not inventory_open:
        hit_info = raycast(camera.world_position, camera.forward, distance=8)
        if hit_info.hit and hit_info.entity != player:
            destroy(hit_info.entity)
            inventory[current_block] += 1
            update_inventory_display()

update_inventory_display()

app.run()

bedrock