Skip to content

Commit 6b1ca5c

Browse files
0.27_SURVIVAL_TEST (0.27)
1 parent 9766ada commit 6b1ca5c

Some content is hidden

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

78 files changed

+1447
-506
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.25.tar.gz
15+
pip install dist/minecraft-python-0.27.tar.gz
1616

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

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

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

7-
This project is currently recreating the **Survival Test Classic** versions of Minecraft. The latest version is **Classic 0.25_05 SURVIVAL TEST** as released on _**September 3, 2009**_.
7+
This project is currently recreating the **Survival Test Classic** versions of Minecraft. The latest version is **Classic 0.27 SURVIVAL TEST** as released on _**October 24, 2009**_.
88

9-
Learn more about this version [here](https://minecraft.fandom.com/wiki/Java_Edition_Classic_0.25_05_SURVIVAL_TEST).
9+
Learn more about this version [here](https://minecraft.fandom.com/wiki/Java_Edition_Classic_0.27_SURVIVAL_TEST).
1010

1111
This project is organized so that every commit is strictly the finished Python version of the Java game of the same version number.
1212
This means that you can go back into this repository's commit history and see only the source code changes between versions of Minecraft,
@@ -20,7 +20,7 @@ you can play it just by specifying the Minecraft version you want to play in the
2020
For audio to work you will either need *PyOgg* which is recommended, or FFmpeg which is installed on the system.
2121
GStreamer is also supported on Linux through the *gst-python* library. PyOgg requires that your system have one of the *Opus*, *FLAC*, or *Vorbis* codecs. OpenAL is required.
2222

23-
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.25`.
23+
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.27`.
2424

2525
Alternatively, for a manual Cython build, run `python setup.py build_ext --inplace`.
2626

@@ -30,12 +30,16 @@ Run with the argument `-fullscreen` to open the window in fullscreen mode.
3030

3131
### Gameplay
3232

33-
This version features early mobs (pigs, creepers, skeletons, zombies) and basic combat. Press Tab to launch arrows at enemies.
33+
This version features early mobs (pigs, creepers, skeletons, zombies, spiders) and basic combat. Press Tab to launch arrows at enemies.
34+
35+
This is the first version to feature spiders.
3436

3537
There are pigs that drop brown mushrooms. Creepers explode only upon death.
3638

3739
To heal, pick up mushrooms and right click to eat. Red mushrooms are poisonous and will take away health.
3840

41+
TNT and ore blocks are featured in this version. There is also early weather; press F5 to toggle rain.
42+
3943
### Multiplayer
4044

4145
Since this is a Survival version of Classic, multiplayer support is disabled.

mc/Resources.py

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

mc/net/minecraft/Entity.pxd

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,19 @@ cdef class Entity:
4040
public float xOld
4141
public float yOld
4242
public float zOld
43+
public int textureId
44+
public float ySlideOffset
45+
public float footSize
4346

4447
cpdef tick(self)
4548
cpdef bint isFree(self, float xa, float ya, float za)
46-
cpdef move(self, float xa, float ya, float za)
49+
cpdef move(self, float x, float y, float z)
4750
cdef _causeFallDamage(self, float distance)
4851
cdef bint isInWater(self)
4952
cdef bint isInLava(self)
50-
cdef moveRelative(self, float xa, float za, float speed)
53+
cpdef moveRelative(self, float xa, float za, float speed)
5154
cpdef float getBrightness(self, float a)
5255
cpdef render(self, textures, float translation)
5356
cdef push(self, entity)
57+
cdef bint shouldRender(self, vec)
58+
cdef bint shouldRenderAtSqrDistance(self, float d)

mc/net/minecraft/Entity.pyx

Lines changed: 118 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ cdef class Entity:
4040
self.xOld = 0.0
4141
self.yOld = 0.0
4242
self.zOld = 0.0
43+
self.textureId = 0
44+
self.ySlideOffset = 0.0
45+
self.footSize = 0.0
4346

4447
def __init__(self, level):
4548
self.level = level
@@ -122,6 +125,14 @@ cdef class Entity:
122125
self.xRotO = self.xRot
123126
self.yRotO = self.yRot
124127

128+
def isFreeGrow(self, xa, ya, za, b):
129+
cdef AABB axisAlignedBB = self.bb.grow(b, b, b).cloneMove(xa, ya, za)
130+
aABBs = self.level.getCubes(axisAlignedBB)
131+
if len(aABBs) > 0:
132+
return False
133+
134+
return not self.level.containsAnyLiquid(axisAlignedBB)
135+
125136
cpdef bint isFree(self, float xa, float ya, float za):
126137
cdef AABB axisAlignedBB = self.bb.cloneMove(xa, ya, za)
127138
aABBs = self.level.getCubes(axisAlignedBB)
@@ -130,67 +141,114 @@ cdef class Entity:
130141

131142
return not self.level.containsAnyLiquid(axisAlignedBB)
132143

133-
cpdef move(self, float xa, float ya, float za):
144+
cpdef move(self, float x, float y, float z):
134145
cdef int tile
135-
cdef float xOrg, zOrg, xaOrg, yaOrg, zaOrg, xd, zd
146+
cdef float xOrg, zOrg, xaOrg, yaOrg, zaOrg, xo, yo, zo, xd, zd
136147
cdef bint onGround
137-
cdef AABB aABB
148+
cdef AABB aabbOrg, aABB, aabb
138149

139150
xOrg = self.x
140151
zOrg = self.z
141-
xaOrg = xa
142-
yaOrg = ya
143-
zaOrg = za
152+
xaOrg = x
153+
yaOrg = y
154+
zaOrg = z
144155

145-
aABBs = self.level.getCubes(self.bb.expand(xa, ya, za))
156+
aabbOrg = self.bb.copy()
157+
aABBs = self.level.getCubes(self.bb.expand(x, y, z))
146158
for aABB in aABBs:
147-
ya = aABB.clipYCollide(self.bb, ya)
159+
y = aABB.clipYCollide(self.bb, y)
148160

149-
self.bb.move(0.0, ya, 0.0)
150-
if not self.slide and yaOrg != ya:
151-
za = 0.0
152-
ya = 0.0
153-
xa = 0.0
161+
self.bb.move(0.0, y, 0.0)
162+
if not self.slide and yaOrg != y:
163+
z = 0.0
164+
y = 0.0
165+
x = 0.0
154166

167+
onGround = self.onGround or yaOrg != y and yaOrg < 0.0
155168
for aABB in aABBs:
156-
xa = aABB.clipXCollide(self.bb, xa)
169+
x = aABB.clipXCollide(self.bb, x)
157170

158-
self.bb.move(xa, 0.0, 0.0)
159-
if not self.slide and xaOrg != xa:
160-
za = 0.0
161-
ya = 0.0
162-
xa = 0.0
171+
self.bb.move(x, 0.0, 0.0)
172+
if not self.slide and xaOrg != x:
173+
z = 0.0
174+
y = 0.0
175+
x = 0.0
163176

164177
for aABB in aABBs:
165-
za = aABB.clipZCollide(self.bb, za)
166-
167-
self.bb.move(0.0, 0.0, za)
168-
if not self.slide and zaOrg != za:
169-
za = 0.0
170-
ya = 0.0
171-
xa = 0.0
172-
173-
self.horizontalCollision = xaOrg != xa or zaOrg != za
174-
self.onGround = yaOrg != ya and yaOrg < 0.0
175-
self.collision = self.horizontalCollision or yaOrg != ya
178+
z = aABB.clipZCollide(self.bb, z)
179+
180+
self.bb.move(0.0, 0.0, z)
181+
if not self.slide and zaOrg != z:
182+
z = 0.0
183+
y = 0.0
184+
x = 0.0
185+
186+
if self.footSize > 0.0 and onGround and self.ySlideOffset < 0.05 and (xaOrg != x or zaOrg != z):
187+
xo = x
188+
yo = y
189+
zo = z
190+
x = xaOrg
191+
y = self.footSize
192+
z = zaOrg
193+
aabb = self.bb.copy()
194+
self.bb = aabbOrg.copy()
195+
aABBs = self.level.getCubes(self.bb.expand(xaOrg, y, zaOrg))
196+
for aABB in aABBs:
197+
y = aABB.clipYCollide(self.bb, y)
198+
199+
self.bb.move(0.0, y, 0.0)
200+
if not self.slide and yaOrg != y:
201+
z = 0.0
202+
y = 0.0
203+
x = 0.0
204+
205+
for aABB in aABBs:
206+
x = aABB.clipXCollide(self.bb, x)
207+
208+
self.bb.move(x, 0.0, 0.0)
209+
if not self.slide and xaOrg != x:
210+
z = 0.0
211+
y = 0.0
212+
x = 0.0
213+
214+
for aABB in aABBs:
215+
z = aABB.clipZCollide(self.bb, z)
216+
217+
self.bb.move(0.0, 0.0, z)
218+
if not self.slide and zaOrg != z:
219+
z = 0.0
220+
y = 0.0
221+
x = 0.0
222+
223+
if xo * xo + zo * zo >= x * x + z * z:
224+
x = xo
225+
y = yo
226+
z = zo
227+
self.bb = aabb.copy()
228+
else:
229+
self.ySlideOffset += 0.5
230+
231+
self.horizontalCollision = xaOrg != x or zaOrg != z
232+
self.onGround = yaOrg != y and yaOrg < 0.0
233+
self.collision = self.horizontalCollision or yaOrg != y
176234

177235
if self.onGround:
178236
if self.fallDistance > 0.0:
179237
self._causeFallDamage(self.fallDistance)
180238
self.fallDistance = 0.0
181-
elif ya < 0.0:
182-
self.fallDistance -= ya
239+
elif y < 0.0:
240+
self.fallDistance -= y
183241

184-
if xaOrg != xa:
242+
if xaOrg != x:
185243
self.xd = 0.0
186-
if yaOrg != ya:
244+
if yaOrg != y:
187245
self.yd = 0.0
188-
if zaOrg != za:
246+
if zaOrg != z:
189247
self.zd = 0.0
190248

191-
self.x = (self.bb.x0 + self.bb.x1) / 2.0
192-
self.y = self.bb.y0 + self.heightOffset
193-
self.z = (self.bb.z0 + self.bb.z1) / 2.0
249+
self.x = (self.bb.x0 + self.bb.x1) * (1 / 2)
250+
self.y = self.bb.y0 + self.heightOffset - self.ySlideOffset
251+
self.z = (self.bb.z0 + self.bb.z1) * (1 / 2)
194252

195253
xd = self.x - xOrg
196254
zd = self.z - zOrg
@@ -205,6 +263,8 @@ cdef class Entity:
205263
soundType.getVolume() * 0.75,
206264
soundType.getPitch())
207265

266+
self.ySlideOffset *= 0.4
267+
208268
cdef _causeFallDamage(self, float distance):
209269
pass
210270

@@ -221,7 +281,7 @@ cdef class Entity:
221281
cdef bint isInLava(self):
222282
return self.level.containsLiquid(self.bb.grow(0.0, -0.4, 0.0), Liquid.lava)
223283

224-
cdef moveRelative(self, float xa, float za, float speed):
284+
cpdef moveRelative(self, float xa, float za, float speed):
225285
cdef float dist, si, co
226286

227287
dist = sqrt(xa * xa + za * za)
@@ -247,7 +307,7 @@ cdef class Entity:
247307
cpdef float getBrightness(self, float a):
248308
cdef int x, y, z
249309
x = <int>self.x
250-
y = <int>(self.y + self.heightOffset / 2.0)
310+
y = <int>(self.y + self.heightOffset / 2.0 - 0.5)
251311
z = <int>self.z
252312
return self.level.getBrightness(x, y, z)
253313

@@ -268,11 +328,10 @@ cdef class Entity:
268328
self.xRot = xRot
269329
self.setPos(x, y, z)
270330

271-
def distanceTo(self, entity):
272-
cdef float x, y, z
273-
x = self.x - entity.x
274-
y = self.y - entity.y
275-
z = self.z - entity.z
331+
def distanceTo(self, float x, float y, float z):
332+
x = self.x - x
333+
y = self.y - y
334+
z = self.z - z
276335
return sqrt(x * x + y * y + z * z)
277336

278337
def distanceToSqr(self, entity):
@@ -336,3 +395,17 @@ cdef class Entity:
336395

337396
def awardKillScore(self, entity, score):
338397
pass
398+
399+
cdef bint shouldRender(self, vec):
400+
cdef float xd, yd, zd
401+
xd = self.x - vec.x
402+
yd = self.y - vec.y
403+
zd = self.z - vec.z
404+
return self.shouldRenderAtSqrDistance(xd * xd + yd * yd + zd * zd)
405+
406+
cdef bint shouldRenderAtSqrDistance(self, float d):
407+
cdef float size = self.bb.getSize() * 64.0
408+
return d < size * size
409+
410+
def getTexture(self):
411+
return self.textureId

mc/net/minecraft/LevelLoaderListener.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def setLoadingProgress(self):
4242
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
4343

4444
t = tesselator
45-
gl.glEnable(gl.GL_TEXTURE_2D)
4645
id_ = self.__minecraft.textures.loadTexture('dirt.png')
4746
gl.glBindTexture(gl.GL_TEXTURE_2D, id_)
4847
s = 32.0

0 commit comments

Comments
 (0)