Skip to content

Commit c7e4e82

Browse files
0.0.14a_08
1 parent 8c6cd9f commit c7e4e82

Some content is hidden

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

43 files changed

+1401
-739
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.0.13a3.tar.gz
15+
pip install dist/minecraft-python-0.0.14a8.tar.gz
1616

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

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44

55
_**Minecraft: Python Edition**_ is a project that strives to recreate each and every old Minecraft version in Python using the **Pyglet** multimedia library and **Cython** for performance.
66

7-
This project is currently recreating the **Classic** versions of Minecraft. The latest version is **Classic 0.0.13a_03** as released on _**May 22, 2009**_.
7+
This project is currently recreating the **Classic** versions of Minecraft. The latest version is **Classic 0.0.14a_08** as released on _**May 28, 2009**_.
88

9-
Learn more about this version [here](https://minecraft.fandom.com/wiki/Java_Edition_Classic_0.0.13a_03).
9+
Learn more about this version [here](https://minecraft.fandom.com/wiki/Java_Edition_Classic_0.0.14a_08).
10+
11+
This project is organized so that every commit is strictly the completed release of the Python version of the Java game of the same version number.
12+
This means that you can go back into this repository's commit history and see only the source code changes between versions of Minecraft.
13+
For any version this project covers, you can play it just by specifying the Minecraft version you want to play in the `pip install` command as demonstrated below.
1014

1115
### General Usage
1216

1317
*Pyglet* and *Cython* are required dependencies and can easily be installed with *pip*. Use the versions specified in `requirements.txt`.
1418

15-
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.0.13a_03`.
19+
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.0.14a_08`.
1620

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

@@ -22,9 +26,10 @@ Run with the argument `-fullscreen` to open the window in fullscreen mode.
2226

2327
### Gameplay
2428

25-
This version features more advanced terrain (including caves and expanding water tiles), level saving, and human mobs. There are five different tiles you can place.
29+
This version features more advanced terrain (including caves and expanding water tiles), level saving, and human mobs.
30+
Use the number keys or the mouse scroll wheel to switch tiles.
2631

27-
Press *Esc* to pause. Press *R* to reset your position, *Y* to invert the mouse, *G* to spawn a mob, *F* to toggle render distance, *Enter* to save the level, and numbers *1-4* (*6* for sapling) to switch blocks.
32+
Press *Esc* to pause. Press *Enter* to set spawn position, *R* to teleport to your spawn position, *Y* to invert the mouse, *G* to spawn a mob, and *F* to toggle render distance.
2833

2934
### Additional Notes
3035

mc/Resources.py

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

mc/net/minecraft/Entity.py

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,40 @@ class Entity:
1919
removed = False
2020

2121
heightOffset = 0.0
22-
__bbWidth = 0.6
22+
_bbWidth = 0.6
2323
bbHeight = 1.8
2424

2525
def __init__(self, level):
26-
self.__level = level
27-
self.resetPos()
26+
self._level = level
27+
self.setPos(0.0, 0.0, 0.0)
2828

2929
def resetPos(self):
30-
x = random.random() * self.__level.width
31-
y = self.__level.depth + 10.
32-
z = random.random() * self.__level.height
33-
self.setPos(x, y, z)
30+
x = self._level.xSpawn + 0.5
31+
y = self._level.ySpawn
32+
z = self._level.zSpawn + 0.5
33+
while y > 0.0:
34+
self.setPos(x, y, z)
35+
if len(self._level.getCubes(self.bb)) == 0:
36+
break
37+
38+
y += 1.0
39+
40+
self.xd = self.yd = self.zd = 0.0
41+
self.yRot = self._level.rotSpawn
42+
self.xRot = 0.0
43+
44+
def remove(self):
45+
self.removed = True
3446

3547
def setSize(self, w, h):
36-
self.__bbWidth = w
48+
self._bbWidth = w
3749
self.bbHeight = h
3850

3951
def setPos(self, x, y, z):
4052
self.x = x
4153
self.y = y
4254
self.z = z
43-
w = self.__bbWidth / 2.0
55+
w = self._bbWidth / 2.0
4456
h = self.bbHeight / 2.0
4557
self.bb = AABB(x - w, y - h, z - w, x + w, y + h, z + w)
4658

@@ -57,21 +69,31 @@ def turn(self, xo, yo):
5769
self.xRotO += self.xRot - orgXRot
5870
self.yRotO += self.yRot - orgYRot
5971

72+
def interpolateTurn(self, xo, yo):
73+
self.yRot = self.yRot + xo * 0.15
74+
self.xRot = self.xRot - yo * 0.15
75+
if self.xRot < -90.0:
76+
self.xRot = -90.0
77+
if self.xRot > 90.0:
78+
self.xRot = 90.0
79+
6080
def tick(self):
6181
self.xo = self.x
6282
self.yo = self.y
6383
self.zo = self.z
84+
self.xRotO = self.xRot
85+
self.yRotO = self.yRot
6486

6587
def isFree(self, xa, ya, za):
6688
aABB = self.bb.cloneMove(xa, ya, za)
67-
return False if len(self.__level.getCubes(aABB)) > 0 else not self.__level.containsAnyLiquid(aABB)
89+
return False if len(self._level.getCubes(aABB)) > 0 else not self._level.containsAnyLiquid(aABB)
6890

6991
def move(self, xa, ya, za):
7092
xaOrg = xa
7193
yaOrg = ya
7294
zaOrg = za
7395

74-
aABBs = self.__level.getCubes(self.bb.expand(xa, ya, za))
96+
aABBs = self._level.getCubes(self.bb.expand(xa, ya, za))
7597
for aABB in aABBs:
7698
ya = aABB.clipYCollide(self.bb, ya)
7799

@@ -102,17 +124,20 @@ def move(self, xa, ya, za):
102124
self.z = (self.bb.z0 + self.bb.z1) / 2.0
103125

104126
def isInWater(self):
105-
return self.__level.containsLiquid(self.bb.grow(0.0, -0.4, 0.0), 1)
127+
return self._level.containsLiquid(self.bb.grow(0.0, -0.4, 0.0), 1)
106128

107129
def isInLava(self):
108-
return self.__level.containsLiquid(self.bb, 2)
130+
return self._level.containsLiquid(self.bb, 2)
109131

110132
def moveRelative(self, xa, za, speed):
111-
dist = xa * xa + za * za
133+
dist = math.sqrt(xa * xa + za * za)
112134
if dist < 0.01:
113135
return
114136

115-
dist = speed / math.sqrt(dist)
137+
if dist < 1.0:
138+
dist = 1.0
139+
140+
dist = speed / dist
116141
xa *= dist
117142
za *= dist
118143

@@ -123,7 +148,16 @@ def moveRelative(self, xa, za, speed):
123148
self.zd += za * cos + xa * sin
124149

125150
def isLit(self):
126-
return self.__level.isLit(int(self.x), int(self.y), int(self.z))
151+
return self._level.isLit(int(self.x), int(self.y), int(self.z))
152+
153+
def getBrightness(self):
154+
x = int(self.x)
155+
y = int(self.y + self.heightOffset / 2.0)
156+
z = int(self.z)
157+
return self._level.getBrightness(x, y, z)
127158

128159
def render(self, a):
129160
pass
161+
162+
def setLevel(self, level):
163+
self._level = level

0 commit comments

Comments
 (0)