arpruss / raspberryjammod

Raspberry Jam Mod - a Mod Forge Minecraft mod implementing most of Raspberry Juice/Pi API
http://www.instructables.com/id/Python-coding-for-Minecraft/
Other
355 stars 95 forks source link

mc.getPlayerEntityIds() doesn't work when player died in single-player mod #17

Closed byemypast closed 7 years ago

byemypast commented 7 years ago

try this: ` import mcpi.minecraft as minecraft import mcpi.block as block import time mc = minecraft.Minecraft.create()

while (1): time.sleep(0.2) try: entitys = mc.getPlayerEntityIds() except: print("err") for nplayer in entitys: print(mc.entity.getTilePos(nplayer))`

Once you get killed (by TNT for example) and try to respawn, at first getPlayerEntityIds() would throw an exception(show 'err' in the script above) and then the function wouldn't work. (function getTilePos would always output the same location even the player moved)

arpruss commented 7 years ago

Which Minecraft version is this?

byemypast commented 7 years ago

1.11

arpruss commented 7 years ago

What happens if you save the old player ID, kill the player, and let the player respawn? Does the player come back with the same ID?

E.g.: id = mc.getPlayerId() while True: time.sleep(0.2) try: except: print("err") print(mc.entity.getTilePos(id))

byemypast commented 7 years ago

It seems that the ID doesn't change when the player respawn, however the id doesn't work anymore. See this --> debug.zip

test.py for the test script debug.txt for recording the ID and its function after the respawn. After line 54(time tick 1482516792.878217), which is the time of respawn, the getTilePos doesn't work

arpruss commented 7 years ago

Fixed in 0.86

byemypast commented 7 years ago

Excuse me, but the problem still exists in 0.86. Run test.py and try to get died for 3 minutes, the getTilePos works sometimes but loses function the other time.


Merry Christmas! Really nice work and benefit a lot from your project. Thanks!

arpruss commented 7 years ago

Merry Christmas to you, too.

I think 0.87 should work better.