Skip to content

Commit 33b35e2

Browse files
Indev 20100206-3 (20100206-3)
1 parent 5e56944 commit 33b35e2

File tree

153 files changed

+3032
-1430
lines changed

Some content is hidden

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

153 files changed

+3032
-1430
lines changed

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.20100202.tar.gz
15+
pip install dist/minecraft-python-20100206.post3.tar.gz
1616

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

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
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 20100202** as released on _**February 2, 2010**_.
8+
The latest version is **Indev 20100206-3** as released on _**February 6, 2010**_.
99

10-
This version re-adds pigs, sheep, skeletons, creepers, zombies and spiders to the game, however they are all passive.
11-
This is the last available version of 0.31.
10+
This version adds farming, hostile mobs that only spawn in dark areas, and difficulty settings to the game.
11+
This is the first available version of Minecraft Indev.
1212

13-
Features from previous Indev versions include the Indev mossy cobblestone spawn house, NBT level file saving,
13+
Features from previous Indev versions include the Indev mossy cobblestone spawn house, NBT level file saving, mobs,
1414
durable tools, torches, advanced liquid spread, TNT explosives, chests, the main menu, workbench crafting, and soup.
1515

16-
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.31.20100202`.
16+
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==20100206-3`.
1717

18-
You can learn more about this version [on the Minecraft wiki.](https://minecraft.wiki/w/Java_Edition_Indev_0.31_20100202)
18+
You can learn more about this version [on the Minecraft wiki.](https://minecraft.wiki/w/Java_Edition_Indev_20100206-3)
1919

2020
### Organization
2121

@@ -54,11 +54,11 @@ Levels can be saved to a single *.mclevel* NBT file in the pause menu. The level
5454

5555
Any mob may drop string, gunpowder, feathers, or flint and steel upon death.
5656

57-
Crafted mushroom bowl soup will restore health. Check the Wiki for crafting recipes added in this version.
57+
Mushroom bowl soup and bread will restore health. Check the Wiki for crafting recipes added in this version.
5858

5959
![Isometric screenshot](/map.png?raw=true)
6060

61-
*An isometric screenshot of a normal Island map generated by the game.*
61+
*An isometric screenshot of a Floating map generated by the game, showcasing mobs and farming.*
6262

6363
### Additional Notes
6464

map.png

-10.2 MB
Loading

mc/JavaUtils.pxd

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,56 @@ cdef class Buffer(Bits):
6868
@cython.final
6969
cdef class ByteBuffer(Buffer):
7070
cdef:
71-
unsigned char[:] __array
71+
unsigned char[:] _array
7272
object __dataPtr
73+
int __lastPos
7374

7475
cpdef inline put(self, unsigned char value)
76+
cdef inline putIntB(self, int bi, int x)
77+
cdef inline putFloatB(self, int bi, float x)
7578
cpdef inline unsigned char get(self)
7679
cpdef inline unsigned char getAt(self, int idx)
7780
cdef inline __getDataPtr(self)
81+
cdef IntBuffer asIntBuffer(self)
82+
cdef FloatBuffer asFloatBuffer(self)
7883

79-
@cython.final
8084
cdef class IntBuffer(Buffer):
8185
cdef:
8286
int[:] __array
83-
object __dataPtr
87+
object _dataPtr
88+
int _lastPos
8489

85-
cpdef inline put(self, int value)
90+
cpdef put(self, int value)
8691
cdef putInts(self, int[:] src, int offset, int length)
87-
cpdef inline int get(self)
88-
cpdef inline int getAt(self, int idx)
89-
cdef inline __getDataPtr(self)
92+
cpdef int get(self)
93+
cpdef int getAt(self, int idx)
94+
cdef _getDataPtr(self)
9095

91-
@cython.final
9296
cdef class FloatBuffer(Buffer):
9397
cdef:
9498
float[:] __array
95-
object __dataPtr
99+
object _dataPtr
100+
int _lastPos
96101

97-
cpdef inline put(self, float value)
102+
cpdef put(self, float value)
98103
cdef putFloats(self, float* src, int offset, int length)
99-
cpdef inline float get(self)
100-
cpdef inline float getAt(self, int idx)
104+
cpdef float get(self)
105+
cpdef float getAt(self, int idx)
101106
cdef getFloats(self, float*, int size)
102-
cdef inline __getDataPtr(self)
107+
cdef _getDataPtr(self)
108+
109+
cdef class ByteBufferAsIntBuffer(IntBuffer):
110+
cdef:
111+
ByteBuffer _bb
112+
int _offset
113+
114+
cpdef put(self, int value)
115+
cdef _getDataPtr(self)
116+
117+
cdef class ByteBufferAsFloatBuffer(FloatBuffer):
118+
cdef:
119+
ByteBuffer _bb
120+
int _offset
121+
122+
cpdef put(self, float value)
123+
cdef _getDataPtr(self)

mc/JavaUtils.pyx

Lines changed: 119 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ cdef class ByteBuffer(Buffer):
292292

293293
def __init__(self, capacity):
294294
Buffer.__init__(self, capacity)
295-
self.__array = np.zeros(capacity, dtype=np.ubyte)
295+
self._array = np.zeros(capacity, dtype=np.ubyte)
296296

297297
def __setitem__(self, key, value):
298298
cdef int i, k, idx
@@ -302,29 +302,38 @@ cdef class ByteBuffer(Buffer):
302302
raise ValueError('Slice assignment size does not match value size')
303303

304304
for i, idx in enumerate(indices):
305-
self.__array[idx] = value[i]
305+
self._array[idx] = value[i]
306306
elif isinstance(key, int):
307307
k = key
308308
if k < 0 or k >= self._capacity:
309309
raise IndexError
310310

311-
self.__array[k] = <unsigned char>(value & 0xFF)
311+
self._array[k] = <unsigned char>(value & 0xFF)
312312

313313
def __getitem__(self, key):
314314
cdef int i, k
315315
if isinstance(key, slice):
316-
return [self.__array[i] for i in range(*key.indices(self._capacity))]
316+
return [self._array[i] for i in range(*key.indices(self._capacity))]
317317
elif isinstance(key, int):
318318
k = key
319319
if k < 0 or k >= self._capacity:
320320
raise IndexError
321321

322-
return self.__array[k]
322+
return self._array[k]
323323

324324
cpdef inline put(self, unsigned char value):
325325
self[self.nextPutIndex()] = value
326326
return self
327327

328+
cdef inline putIntB(self, int bi, int x):
329+
self._array[bi + 3] = <char>(x >> 24)
330+
self._array[bi + 2] = <char>(x >> 16)
331+
self._array[bi + 1] = <char>(x >> 8)
332+
self._array[bi ] = <char>x
333+
334+
cdef inline putFloatB(self, int bi, float x):
335+
self.putIntB(bi, floatToRawIntBits(x))
336+
328337
cpdef inline unsigned char get(self):
329338
return self[self.nextGetIndex()]
330339

@@ -347,8 +356,9 @@ cdef class ByteBuffer(Buffer):
347356
return self
348357

349358
cdef inline __getDataPtr(self):
350-
if not self.__dataPtr:
351-
self.__dataPtr = np.asarray(self.__array).ctypes.data_as(ctypes.POINTER(ctypes.c_ubyte))
359+
if not self.__dataPtr or self._position != self.__lastPos:
360+
self.__dataPtr = np.asarray(self._array)[self._position:].ctypes.data_as(ctypes.POINTER(ctypes.c_ubyte))
361+
self.__lastPos = self._position
352362

353363
return self.__dataPtr
354364

@@ -366,6 +376,20 @@ cdef class ByteBuffer(Buffer):
366376
def glReadPixels(self, int x, int y, int width, int height, int format, int type):
367377
gl.glReadPixels(x, y, width, height, format, type, self.__getDataPtr())
368378

379+
def glColorPointer(self, int size, int stride):
380+
gl.glColorPointer(size, gl.GL_UNSIGNED_BYTE, stride, self.__getDataPtr())
381+
382+
def glBufferDataARB(self, int target, int usage):
383+
gl.glBufferDataARB(target, self.capacity(), self.__getDataPtr(), usage)
384+
385+
cdef IntBuffer asIntBuffer(self):
386+
cdef int size = self.remaining() >> 2
387+
return ByteBufferAsIntBuffer(self, -1, 0, size, size, self.position())
388+
389+
cdef FloatBuffer asFloatBuffer(self):
390+
cdef int size = self.remaining() >> 2
391+
return ByteBufferAsFloatBuffer(self, -1, 0, size, size, self.position())
392+
369393
cdef class IntBuffer(Buffer):
370394

371395
def __init__(self, capacity):
@@ -399,8 +423,8 @@ cdef class IntBuffer(Buffer):
399423

400424
return self.__array[k]
401425

402-
cpdef inline put(self, int value):
403-
self[self.nextPutIndex()] = value
426+
cpdef put(self, int value):
427+
self.__array[self.nextPutIndex()] = value
404428
return self
405429

406430
cdef putInts(self, int[:] src, int offset, int length):
@@ -412,33 +436,46 @@ cdef class IntBuffer(Buffer):
412436
if length > rem:
413437
raise Exception
414438

415-
cdef int[:] dest = self.__array[self._position + offset:self._position + offset + length]
416-
dest[:length] = src[:length]
417-
418-
self._position += length
439+
for i in range(offset, offset + length):
440+
self.put(src[i])
419441

420442
return self
421443

422-
cpdef inline int get(self):
444+
cpdef int get(self):
423445
return self[self.nextGetIndex()]
424446

425-
cpdef inline int getAt(self, int idx):
447+
cpdef int getAt(self, int idx):
426448
return self[self.checkIndex(idx)]
427449

428-
cdef inline __getDataPtr(self):
429-
if not self.__dataPtr:
430-
self.__dataPtr = np.asarray(self.__array).ctypes.data_as(ctypes.POINTER(ctypes.c_int))
450+
cdef _getDataPtr(self):
451+
if not self._dataPtr or self._position != self._lastPos:
452+
self._dataPtr = np.asarray(self.__array)[self._position << 2:].ctypes.data_as(ctypes.POINTER(ctypes.c_int))
453+
self._lastPos = self._position
431454

432-
return self.__dataPtr
455+
return self._dataPtr
433456

434-
def glCallLists(self, int n, int type):
435-
gl.glCallLists(n, type, self.__getDataPtr())
457+
def glCallLists(self):
458+
gl.glCallLists(self.remaining(), gl.GL_INT, self._getDataPtr())
436459

437460
def glDrawElements(self, int mode, int count, int type):
438-
gl.glDrawElements(mode, count, type, self.__getDataPtr())
461+
gl.glDrawElements(mode, count, type, self._getDataPtr())
439462

440463
def glInterleavedArrays(self, int format, int stride):
441-
gl.glInterleavedArrays(format, stride, self.__getDataPtr())
464+
gl.glInterleavedArrays(format, stride, self._getDataPtr())
465+
466+
def glGenBuffersARB(self):
467+
gl.glGenBuffersARB(self._getDataPtr())
468+
469+
def glGenQueriesARB(self):
470+
return gl.glGenQueriesARB(
471+
1, np.asarray(self.__array).ctypes.data_as(ctypes.POINTER(ctypes.c_uint))
472+
)
473+
474+
def glGetInteger(self, int opt):
475+
return gl.glGetIntegerv(gl.GL_QUERY_COUNTER_BITS, self._getDataPtr())
476+
477+
def glGetQueryObjectivARB(self, int id, int pname):
478+
gl.glGetQueryObjectivARB(id, pname, self._getDataPtr())
442479

443480
cdef class FloatBuffer(Buffer):
444481

@@ -473,8 +510,8 @@ cdef class FloatBuffer(Buffer):
473510

474511
return self.__array[k]
475512

476-
cpdef inline put(self, float value):
477-
self[self.nextPutIndex()] = value
513+
cpdef put(self, float value):
514+
self.__array[self.nextPutIndex()] = value
478515
return self
479516

480517
cdef putFloats(self, float* src, int offset, int length):
@@ -486,18 +523,15 @@ cdef class FloatBuffer(Buffer):
486523
if length > rem:
487524
raise Exception
488525

489-
cdef float[:] dest = self.__array[self._position + offset:self._position + offset + length]
490-
for i in range(length):
491-
dest[i] = src[i]
492-
493-
self._position += length
526+
for i in range(offset, offset + length):
527+
self.put(src[i])
494528

495529
return self
496530

497-
cpdef inline float get(self):
531+
cpdef float get(self):
498532
return self[self.nextGetIndex()]
499533

500-
cpdef inline float getAt(self, int idx):
534+
cpdef float getAt(self, int idx):
501535
return self[self.checkIndex(idx)]
502536

503537
def getBytes(self, b):
@@ -530,32 +564,71 @@ cdef class FloatBuffer(Buffer):
530564
self._position += size
531565
return self
532566

533-
cdef inline __getDataPtr(self):
534-
if not self.__dataPtr:
535-
self.__dataPtr = np.asarray(self.__array).ctypes.data_as(ctypes.POINTER(ctypes.c_float))
567+
cdef _getDataPtr(self):
568+
if not self._dataPtr or self._position != self._lastPos:
569+
self._dataPtr = np.asarray(self.__array)[self._position << 2:].ctypes.data_as(ctypes.POINTER(ctypes.c_float))
570+
self._lastPos = self._position
536571

537-
return self.__dataPtr
572+
return self._dataPtr
538573

539574
def glFogfv(self, int pname):
540-
gl.glFogfv(pname, self.__getDataPtr())
575+
gl.glFogfv(pname, self._getDataPtr())
541576

542577
def glLightfv(self, int light, int pname):
543-
gl.glLightfv(light, pname, self.__getDataPtr())
578+
gl.glLightfv(light, pname, self._getDataPtr())
544579

545580
def glLightModelfv(self, int pname):
546-
gl.glLightModelfv(pname, self.__getDataPtr())
581+
gl.glLightModelfv(pname, self._getDataPtr())
547582

548-
def glVertexPointer(self, int size, int type, int stride):
549-
gl.glVertexPointer(size, type, stride, self.__getDataPtr())
583+
def glVertexPointer(self, int size, int stride):
584+
gl.glVertexPointer(size, gl.GL_FLOAT, stride, self._getDataPtr())
550585

551-
def glNormalPointer(self, int type, int stride):
552-
gl.glNormalPointer(type, stride, self.__getDataPtr())
586+
def glNormalPointer(self, int stride):
587+
gl.glNormalPointer(gl.GL_FLOAT, stride, self._getDataPtr())
553588

554-
def glTexCoordPointer(self, int size, int type, int stride):
555-
gl.glTexCoordPointer(size, type, stride, self.__getDataPtr())
589+
def glTexCoordPointer(self, int size, int stride):
590+
gl.glTexCoordPointer(size, gl.GL_FLOAT, stride, self._getDataPtr())
556591

557592
def glMultMatrix(self):
558-
gl.glMultMatrixf(self.__getDataPtr())
593+
gl.glMultMatrixf(self._getDataPtr())
594+
595+
cdef class ByteBufferAsIntBuffer(IntBuffer):
596+
597+
def __init__(self, ByteBuffer bb, int mark, int pos, int lim, int cap, int off):
598+
IntBuffer.__init__(self, cap)
599+
self.limit(lim)
600+
self.position(pos)
601+
self._bb = bb
602+
self._offset = off
603+
604+
cpdef put(self, int value):
605+
self._bb.putIntB((self.nextPutIndex() << 2) + self._offset, value)
606+
607+
cdef _getDataPtr(self):
608+
if not self._dataPtr or self._position != self._lastPos:
609+
self._dataPtr = np.asarray(self._bb._array)[self._position << 2:].ctypes.data_as(ctypes.POINTER(ctypes.c_int))
610+
self._lastPos = self._position
611+
612+
return self._dataPtr
613+
614+
cdef class ByteBufferAsFloatBuffer(FloatBuffer):
615+
616+
def __init__(self, ByteBuffer bb, int mark, int pos, int lim, int cap, int off):
617+
FloatBuffer.__init__(self, cap)
618+
self.limit(lim)
619+
self.position(pos)
620+
self._bb = bb
621+
self._offset = off
622+
623+
cpdef put(self, float value):
624+
self._bb.putFloatB((self.nextPutIndex() << 2) + self._offset, value)
625+
626+
cdef _getDataPtr(self):
627+
if not self._dataPtr or self._position != self._lastPos:
628+
self._dataPtr = np.asarray(self._bb._array)[self._position << 2:].ctypes.data_as(ctypes.POINTER(ctypes.c_float))
629+
self._lastPos = self._position
630+
631+
return self._dataPtr
559632

560633
cdef class BufferUtils:
561634

mc/Resources.py

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

0 commit comments

Comments
 (0)