Skip to content

Commit 019c4cc

Browse files
0.31 20100124-2 (0.31.20100124-2)
1 parent 708c58c commit 019c4cc

File tree

137 files changed

+4072
-1560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+4072
-1560
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ minecraft_python.egg-info
1313
*.h
1414
.DS_Store
1515
*.so
16+
*.mclevel

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ install:
1212
CYTHONIZE=1 pip install .
1313

1414
install-from-source: dist
15-
pip install dist/minecraft-python-0.31.20100110.tar.gz
15+
pip install dist/minecraft-python-0.31.20100124.post2.tar.gz
1616

1717
clean:
1818
$(RM) -r build dist src/*.egg-info

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
_**Minecraft: Python Edition**_ is a project that strives to recreate each and every old Minecraft version in Python 3 using the **Pyglet** multimedia library and **Cython** for performance.
66

77
The project is currently working on the Indev versions of Minecraft.
8-
The latest version is **Indev 0.31 20100110** as released on _**January 10, 2010**_.
8+
The latest version is **Indev 0.31 20100124-2** as released on _**January 24, 2010**_.
99

10-
This version introduces fire, apples, functional tools, and the customizable Indev level generator to the game.
10+
This version has the Indev mossy cobblestone spawn house which contains chests with all of the items available in this version.
11+
It also has level file saving, the bow and arrow, advanced liquid spread, and powerful TNT explosion blasts.
1112

12-
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.31.20100110`.
13+
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.31.20100124-2`.
1314

14-
You can learn more about this version [on the Minecraft wiki.](https://minecraft.wiki/w/Java_Edition_Indev_0.31_20100110)
15+
You can learn more about this version [on the Minecraft wiki.](https://minecraft.wiki/w/Java_Edition_Indev_0.31_20100124-2)
1516

1617
### Organization
1718

@@ -21,7 +22,8 @@ To play any version, specify it in the `pip install` command as demonstrated bel
2122

2223
### General Usage
2324

24-
*Pyglet*, *Cython*, *Pillow*, *PyOgg*, and *NumPy* are required dependencies and can easily be installed with *pip*. Use the versions specified in `requirements.txt`.
25+
*Pyglet*, *Cython*, *Pillow*, *PyOgg*, *NumPy*, and *nbtlib* are required dependencies which can easily be installed with *pip*. Use the versions specified in `requirements.txt`.
26+
*wxPython* is an optional dependency for the level file picker, but if you don't have it then *Tkinter* is used instead.
2527

2628
For audio to work you will either need *PyOgg* which is recommended, or *FFmpeg* which has to be installed on your system.
2729
*GStreamer* is also supported on Linux through the *gst-python* library.
@@ -30,22 +32,28 @@ PyOgg requires that your system have one of the Opus, FLAC, or Vorbis codecs.
3032

3133
For a manual Cython source build, run `python setup.py build_ext --inplace`.
3234

33-
Run `python -m mc.net.minecraft.Minecraft` to launch the game. *Minecraft: Python Edition* should be compatible with any modern platform that supports OpenGL and Cython.
35+
Run `python -m mc.net.minecraft.client.Minecraft` to launch the game. *Minecraft: Python Edition* should be compatible with any modern platform that supports OpenGL and Cython.
3436

35-
Run with the argument `-fullscreen` to open the window in fullscreen mode. The argument `-creative` will force the game to be in creative mode.
37+
Run with the argument `-fullscreen` to open the window in fullscreen mode (or press F11 in-game).
38+
The argument `-creative` will force the game to be in creative mode.
3639

3740
### Gameplay
3841

39-
Press I to open your inventory. All available tools (shovel, axe, pickaxe, flint and steel) are in the hotbar in addition to some building blocks and torches.
40-
Press F7 to take a cool isometric screenshot and F5 to toggle rain. Q will drop items. Other keys are listed in the regular options menu.
42+
All available tools and blocks are in the chests in the spawn house.
43+
All controls are as you would expect for the game and they can be configured in the options menu.
44+
Press I to open your inventory, F5 to toggle rain and F7 to take a cool isometric screenshot.
4145

4246
The Indev level generator is customizable and you can choose between the *Inland*, *Island*, *Floating*, and *Flat* level types.
4347
You can specify the world theme as *Normal* or *Hell* (lava and dirt instead of water and grass), world size, and world shape (*Square*, *Long*, *Deep*).
4448

45-
The only mobs around are the MD3 Ranas, but they don't drop anything when killed. Mushrooms are unusable, but apples will restore health.
49+
Levels can be saved to a single *.mclevel* NBT file in the pause menu. The level files are perfectly compatible with Java and vice versa.
50+
51+
The only mobs around are the MD3 Ranas, but they don't drop anything when killed. Apples will restore health.
4652

4753
![Isometric screenshot](/map.png?raw=true)
4854

55+
*An isometric screenshot of a small and long Inland map generated by the game.*
56+
4957
### Additional Notes
5058

5159
The `mc.resources` directory contains all of the textures and sounds that this version uses. However,

map.png

-7.34 MB
Loading

mc/JavaUtils.pxd

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ cdef double signum(double val)
77

88
cdef class Random:
99

10-
cdef float randFloatM(self, float multiply)
11-
cdef float randFloat(self)
12-
cdef int nextInt(self, int limit)
10+
cdef:
11+
long long __seed
12+
double __nextNextGaussian
13+
bint __haveNextNextGaussian
14+
15+
cdef int _next(self, int bits)
16+
cpdef int nextInt(self, int limit=?)
17+
cpdef float nextFloat(self)
18+
cdef double nextDouble(self)
19+
cpdef double nextGaussian(self)
20+
21+
cpdef double random()
1322

1423
cdef class Bits:
1524

@@ -73,6 +82,7 @@ cdef class IntBuffer(Buffer):
7382
object __dataPtr
7483

7584
cpdef inline put(self, int value)
85+
cdef putInts(self, int* src, int offset, int length)
7686
cpdef inline int get(self)
7787
cpdef inline int getAt(self, int idx)
7888
cdef inline __getDataPtr(self)

mc/JavaUtils.pyx

Lines changed: 74 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,84 @@
44
cimport cython
55

66
from libc.string cimport memcpy
7-
from libc.stdlib cimport srand, rand, RAND_MAX
8-
from libc.time cimport time
7+
from libc.math cimport sqrt, log
98

109
from pyglet import gl
1110

1211
import ctypes
13-
import time as pytime
12+
import time
1413

1514
import numpy as np
1615
cimport numpy as np
1716

1817
cpdef unsigned long long getMillis():
19-
return <unsigned long long>(pytime.time() * 1000)
18+
return <unsigned long long>(time.time() * 1000)
2019

2120
cdef double signum(double val):
2221
return (0 < val) - (val < 0)
2322

24-
cdef bint Random_seeded = False
25-
2623
cdef class Random:
2724

28-
property seeded:
25+
def __init__(self):
26+
self.setSeed(time.perf_counter_ns())
27+
self.__haveNextNextGaussian = False
28+
29+
def setSeed(self, long long seed):
30+
self.__seed = (seed ^ 0x5DEECE66D) & ((1 << 48) - 1)
2931

30-
def __get__(self):
31-
return Random_seeded
32+
cdef int _next(self, int bits):
33+
self.__seed = (self.__seed * 0x5DEECE66D + 0xB) & ((1 << 48) - 1)
34+
return <int>(self.__seed >> (48 - bits))
3235

33-
def __set__(self, x):
34-
global Random_seeded
35-
Random_seeded = x
36+
cpdef int nextInt(self, int limit = 0):
37+
cdef int bits, val
3638

37-
def __init__(self, seed=0):
38-
if not self.seeded:
39-
if seed == 0:
40-
srand(time(NULL))
41-
else:
42-
srand(seed)
39+
if not limit:
40+
return self._next(32)
4341

44-
self.seeded = True
42+
if limit <= 0:
43+
raise ValueError('limit must be a positive integer')
4544

46-
cdef float randFloatM(self, float multiply):
47-
return self.randFloat() * multiply
45+
if limit & -limit == limit:
46+
return <int>((limit * <unsigned long long>self._next(31)) >> 31)
4847

49-
cdef float randFloat(self):
50-
return rand() / <float>RAND_MAX
48+
val = 0
49+
while True:
50+
bits = self._next(31)
51+
val = bits % limit
52+
if bits - val + (limit - 1) >= 0:
53+
break
5154

52-
cdef int nextInt(self, int limit):
53-
cdef double scaleFactor
54-
cdef int value
55+
return val
5556

56-
if limit <= 0:
57-
raise ValueError('limit must be a positive integer')
57+
cpdef float nextFloat(self):
58+
return self._next(24) / <float>(1 << 24)
5859

59-
scaleFactor = limit / (RAND_MAX + 1.0)
60-
value = <int>(rand() * scaleFactor)
60+
cdef double nextDouble(self):
61+
cdef unsigned long long l = (<unsigned long long>(self._next(26)) << 27) + self._next(27)
62+
return l / <double>(1 << 53)
6163

62-
return value
64+
cpdef double nextGaussian(self):
65+
cdef double v1, v2, s, multiplier
66+
if not self.__haveNextNextGaussian:
67+
s = 0
68+
while s >= 1 or s == 0:
69+
v1 = 2 * self.nextDouble() - 1
70+
v2 = 2 * self.nextDouble() - 1
71+
s = v1 * v1 + v2 * v2
72+
73+
multiplier = sqrt(-2 * log(s) / s)
74+
self.__nextNextGaussian = v2 * multiplier
75+
self.__haveNextNextGaussian = True
76+
return v1 * multiplier
77+
else:
78+
self.__haveNextNextGaussian = False
79+
return self.__nextNextGaussian
80+
81+
cdef Random rand = Random()
82+
83+
cpdef double random():
84+
return rand.nextDouble()
6385

6486
cdef class Bits:
6587

@@ -376,6 +398,23 @@ cdef class IntBuffer(Buffer):
376398
self[self.nextPutIndex()] = value
377399
return self
378400

401+
cdef putInts(self, int* src, int offset, int length):
402+
cdef int i, rem
403+
404+
assert self.checkBounds(offset, length, length)
405+
assert self._position <= self._limit
406+
rem = self._limit - self._position if self._position <= self._limit else 0
407+
if length > rem:
408+
raise Exception
409+
410+
cdef int[:] dest = self.__array[self._position + offset:self._position + offset + length]
411+
for i in range(length):
412+
dest[i] = src[i]
413+
414+
self._position += length
415+
416+
return self
417+
379418
cpdef inline int get(self):
380419
return self[self.nextGetIndex()]
381420

@@ -516,14 +555,18 @@ cdef class FloatBuffer(Buffer):
516555

517556
cdef class BufferUtils:
518557

558+
@staticmethod
519559
def wrapByteBuffer(byteArray):
520560
return ByteBuffer(len(byteArray)).clear().putBytes(byteArray).clear()
521561

562+
@staticmethod
522563
def createByteBuffer(capacity):
523564
return ByteBuffer(capacity).clear()
524565

566+
@staticmethod
525567
def createIntBuffer(capacity):
526568
return IntBuffer(capacity).clear()
527569

570+
@staticmethod
528571
def createFloatBuffer(capacity):
529572
return FloatBuffer(capacity).clear()

mc/Resources.py

Lines changed: 4 additions & 3 deletions
Large diffs are not rendered by default.

mc/net/minecraft/client/GameSettings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def setOptionValue(self, option, arg):
195195

196196
self.__saveOptions()
197197

198-
def setOptionString(self, option):
198+
def getOptionDisplayString(self, option):
199199
if option == 0:
200200
return 'Music: ' + ('ON' if self.music else 'OFF')
201201
elif option == 1:

mc/net/minecraft/client/LoadingScreenRenderer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from mc.net.minecraft.client.render.Tessellator import tessellator
33
from pyglet import clock, gl
44

5+
import nbtlib
6+
57
class LoadingScreenRenderer:
68

79
def __init__(self, minecraft):
@@ -73,3 +75,7 @@ def setLoadingProgress(self):
7375

7476
clock.tick()
7577
self.__mc.flip()
78+
79+
@staticmethod
80+
def writeLevelTags(file):
81+
return nbtlib.load(file, gzipped=True)

0 commit comments

Comments
 (0)