Skip to content

Commit 985e56f

Browse files
0.0.13a (0.0.13)
1 parent be550f7 commit 985e56f

Some content is hidden

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

58 files changed

+2062
-802
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.11.tar.gz
15+
pip install dist/minecraft-python-0.0.13.tar.gz
1616

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

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@
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.11a** as released on _**May 17, 2009**_.
7+
This project is currently recreating the **Classic** versions of Minecraft. The latest version is **Classic 0.0.13a** as released on _**May 22, 2009**_.
88

9-
Learn more about this version [here](https://minecraft.fandom.com/wiki/Java_Edition_Classic_0.0.11a).
9+
Learn more about this version [here](https://minecraft.fandom.com/wiki/Java_Edition_Classic_0.0.13a).
1010

1111
### General Usage
1212

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

15-
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.0.11`.
15+
To easily install this version of *Minecraft: Python Edition*, just run `python -m pip install minecraft-python==0.0.13`.
1616

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

1919
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.
2020

21+
Run with the argument `-fullscreen` to open the window in fullscreen mode.
22+
2123
### Gameplay
2224

23-
Basic terrain, block picking and placing, level saving, and human mobs are featured in this version. There are five different blocks you can place.
25+
Basic terrain and caves, block picking and placing, level saving, and human mobs are featured in this version. There are five different blocks you can place.
2426

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

2729
### Additional Notes
2830

mc/Resources.py

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

mc/net/minecraft/Entity.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,34 @@ class Entity:
1717
onGround = False
1818

1919
removed = False
20-
heightOffset = 0.0
20+
_heightOffset = 0.0
2121

22-
bbWidth = 0.6
23-
bbHeight = 1.8
22+
_bbWidth = 0.6
23+
_bbHeight = 1.8
2424

2525
def __init__(self, level):
26-
self.level = level
26+
self._level = level
2727
self.resetPos()
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
30+
x = random.random() * self._level.width
31+
y = self._level.depth + 10.
32+
z = random.random() * self._level.height
3333
self.setPos(x, y, z)
3434

3535
def remove(self):
3636
self.removed = True
3737

3838
def setSize(self, w, h):
39-
self.bbWidth = w
40-
self.bbHeight = h
39+
self._bbWidth = w
40+
self._bbHeight = h
4141

4242
def setPos(self, x, y, z):
4343
self.x = x
4444
self.y = y
4545
self.z = z
46-
w = self.bbWidth / 2.0
47-
h = self.bbHeight / 2.0
46+
w = self._bbWidth / 2.0
47+
h = self._bbHeight / 2.0
4848
self.bb = AABB(x - w, y - h, z - w, x + w, y + h, z + w)
4949

5050
def turn(self, xo, yo):
@@ -65,12 +65,22 @@ def tick(self):
6565
self.yo = self.y
6666
self.zo = self.z
6767

68+
def isFree(self, xa, ya, za):
69+
box = self.bb.cloneMove(xa, ya, za)
70+
aABBs = self._level.getCubes(box)
71+
if len(aABBs) > 0:
72+
return False
73+
if self._level.containsAnyLiquid(box):
74+
return False
75+
76+
return True
77+
6878
def move(self, xa, ya, za):
6979
xaOrg = xa
7080
yaOrg = ya
7181
zaOrg = za
7282

73-
aABBs = self.level.getCubes(self.bb.expand(xa, ya, za))
83+
aABBs = self._level.getCubes(self.bb.expand(xa, ya, za))
7484
for aABB in aABBs:
7585
ya = aABB.clipYCollide(self.bb, ya)
7686

@@ -86,6 +96,7 @@ def move(self, xa, ya, za):
8696

8797
self.bb.move(0.0, 0.0, za)
8898

99+
self.horizontalCollision = xaOrg != xa or zaOrg != za
89100
self.onGround = yaOrg != ya and yaOrg < 0.0
90101

91102
if xaOrg != xa:
@@ -96,9 +107,15 @@ def move(self, xa, ya, za):
96107
self.zd = 0.0
97108

98109
self.x = (self.bb.x0 + self.bb.x1) / 2.0
99-
self.y = self.bb.y0 + self.heightOffset
110+
self.y = self.bb.y0 + self._heightOffset
100111
self.z = (self.bb.z0 + self.bb.z1) / 2.0
101112

113+
def isInWater(self):
114+
return self._level.containsLiquid(self.bb.grow(0.0, -0.4, 0.0), 1)
115+
116+
def isInLava(self):
117+
return self._level.containsLiquid(self.bb, 2)
118+
102119
def moveRelative(self, xa, za, speed):
103120
dist = xa * xa + za * za
104121
if dist < 0.01:
@@ -115,7 +132,7 @@ def moveRelative(self, xa, za, speed):
115132
self.zd += za * cos + xa * sin
116133

117134
def isLit(self):
118-
return self.level.isLit(self.x, self.y, self.z)
135+
return self._level.isLit(int(self.x), int(self.y), int(self.z))
119136

120137
def render(self, a):
121138
pass

mc/net/minecraft/HitResult.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,30 @@ def __init__(self, type_, x, y, z, f):
55
self.y = y
66
self.z = z
77
self.f = f
8+
9+
def isCloserThan(self, player, o, editMode):
10+
dist = self.__distanceTo(player, 0)
11+
dist2 = o.__distanceTo(player, 0)
12+
if dist < dist2:
13+
return True
14+
dist = self.__distanceTo(player, editMode)
15+
dist2 = o.__distanceTo(player, editMode)
16+
if dist < dist2:
17+
return True
18+
return False
19+
20+
def __distanceTo(self, player, editMode):
21+
xx = self.x
22+
yy = self.y
23+
zz = self.z
24+
if editMode == 1:
25+
if self.f == 0: yy -= 1
26+
elif self.f == 1: yy += 1
27+
elif self.f == 2: zz -= 1
28+
elif self.f == 3: zz += 1
29+
elif self.f == 4: xx -= 1
30+
elif self.f == 5: xx == 1
31+
xd = xx - player.x
32+
yd = yy - player.y
33+
zd = zz - player.z
34+
return xd * xd + yd * yd + zd * zd

0 commit comments

Comments
 (0)