-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
160 lines (131 loc) · 4.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import sys
import os
import log
import globals as G
import shutil
log.printMSG(
"--------------------------------------------------------------------------------"
)
log.printMSG(
"- MCPYTHON VERSION "
+ G.VERSION_NAME.upper()
+ " " * (60 - len(G.VERSION_NAME))
+ "-"
)
log.printMSG(
"--------------------------------------------------------------------------------\n\n"
)
import exceptionhandler
exceptionhandler.add_header()
if sys.version_info[0] == 2:
log.printMSG("[MAINTHREAD][ERROR] unsupported python version: ", sys.version_info)
sys.exit(-1)
log.printMSG("[MAINTHREAD][INFO] clearing tmp-dir")
if not os.path.exists(G.local + "/tmp"):
os.makedirs(G.local + "/tmp")
for e in os.listdir(G.local + "/tmp"):
if e not in ["file.info"]:
if os.path.isfile(G.local + "/tmp/" + e):
os.remove(G.local + "/tmp/" + e)
else:
try:
shutil.rmtree(G.local + "/tmp/" + e)
except PermissionError:
pass
log.printMSG("[MAINTHREAD][INFO] finished! Now looking after the packages we need")
os.makedirs(G.local + "/tmp/gui")
os.makedirs(G.local + "/tmp/entity")
try:
import pyglet
except ImportError:
log.printMSG(
"can't load pyglet. PLEASE INSTALL IT. IT IS USED FOR RENDERING EVERYTHING"
)
try:
import PIL
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
except ImportError:
log.printMSG("can't load pillow. PLEASE INSTALL IT. IT IS USED FOR IMAGE HANDLING")
try:
import numpy
except ImportError:
log.printMSG("can't load numpy. PLEASE INSTALL IT. IT IS USED FOR 3D THINGS")
try:
import noise
except ImportError:
log.printMSG("can't load noise. IT IS USED FOR WORLD GEN")
try:
import json
except ImportError:
log.printMSG(
"can't load json. This is a strange thing because your python setup should have it installed"
+ " by installing it"
)
log.printMSG(
"[MAINTHREAD][INFO] everything fine (or not?). Starting loading submoduls step by step"
)
import gen.biomes.Biome
import eventhandler
import crafting
import language
import ticksystem
import scoreboard.ScoreboardHandler
import command.Command
import soundhandler
import state.State
import Block.block, Item.item, entity.entity, Inventory.inventory
import textures.modelloader
import textures.TextureAtlas
import gen.biomes.Biome
import state
import state.State
import storage.storagehandler
import crafting.CraftingHandler, crafting.CraftingTableGrid, crafting.FurnesGrid
import texturegenerator
log.printMSG("[MAINTHREAD][INFO] we are ready to start, only a few things to do")
pyglet.options["audio"] = ("openal", "pulse", "directsound", "silent")
import globals as G
import glfunctions
import soundhandler
from pyglet.gl import *
def main():
"""main function"""
log.printMSG("[MAINTHREAD][INFO] creating window")
import Inventory.inventory
import window
# window = window.Window(width=800, height=600, caption='mcp#ython 2', resizable=True)
try:
# Try and create a window with multisampling (antialiasing)
config = Config(
sample_buffers=1,
samples=4,
depth_size=16,
double_buffer=True,
)
window = window.Window(
resizable=True,
config=config,
width=1200,
height=620,
caption="mcpython " + str(G.VERSION_NAME),
)
except pyglet.window.NoSuchConfigException:
# Fall back to no multisampling for old hardware
window = pyglet.window.Window(
resizable=True, width=1200, height=620, caption="mcpython 2"
)
# Hide the mouse cursor and prevent the mouse from leaving the window.
log.printMSG("[MAINTHREAD][INFO] setting up OpenGL")
window.set_exclusive_mouse(True)
glfunctions.setup()
log.printMSG("[MAINTHREAD][INFO] nothing to do here, starting pyglet")
pyglet.app.run()
import modsystem.ModLoader
G.modloader.searchForMods()
G.statehandler.setState("minecraft:titlescreen")
if __name__ == "__main__":
try:
main()
except:
exceptionhandler.add_crash()