Skip to content

Commit

Permalink
fix world.getPlayerId() in multiuser settings
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Jun 23, 2016
1 parent 617c776 commit a69cdf8
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 10 deletions.
Binary file modified 194/.gradle/2.7/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file modified 194/.gradle/2.7/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified 194/.gradle/2.7/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified 194/.gradle/2.7/taskArtifacts/outputFileStates.bin
Binary file not shown.
Binary file modified 194/.gradle/2.7/taskArtifacts/taskArtifacts.bin
Binary file not shown.
6 changes: 3 additions & 3 deletions 194/.gradle/gradle.log
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
:sourceMainJava UP-TO-DATE
:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning

:processResources
:processResources UP-TO-DATE
:classes
:jar
:sourceTestJava UP-TO-DATE
Expand All @@ -46,4 +46,4 @@ remapping source...

BUILD SUCCESSFUL

Total time: 35.777 secs
Total time: 25.598 secs
Binary file modified python2-scripts.zip
Binary file not shown.
20 changes: 13 additions & 7 deletions python2-scripts/mcpipy/mcpi/minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,21 @@ def __init__(self, connection=None, autoId=True):
self.camera = CmdCamera(self.conn)
self.entity = CmdEntity(self.conn)

self.playerId = None

if autoId:
try:
playerId = int(environ['MINECRAFT_PLAYER_ID'])
self.player = CmdPlayer(self.conn,playerId=playerId)
self.playerId = int(environ['MINECRAFT_PLAYER_ID'])
self.player = CmdPlayer(self.conn,playerId=self.playerId)
except:
try:
playerId = self.getPlayerId(environ['MINECRAFT_PLAYER_NAME'])
self.player = CmdPlayer(self.conn,playerId=playerId)
self.playerId = self.getPlayerId(environ['MINECRAFT_PLAYER_NAME'])
self.player = CmdPlayer(self.conn,playerId=self.playerId)
except:
if security.AUTHENTICATION_USERNAME:
try:
playerId = self.getPlayerId(security.AUTHENTICATION_USERNAME)
self.player = CmdPlayer(self.conn,playerId=playerId)
self.playerId = self.getPlayerId(security.AUTHENTICATION_USERNAME)
self.player = CmdPlayer(self.conn,playerId=self.playerId)
except:
self.player = CmdPlayer(self.conn)
else:
Expand Down Expand Up @@ -337,7 +339,11 @@ def getHeight(self, *args):

def getPlayerId(self, *args):
"""Get the id of the current player"""
return int(self.conn.sendReceive_flat("world.getPlayerId", flatten(args)))
a = flatten(args)
if self.playerId is not None and len(a) == 0:
return self.playerId
else:
return int(self.conn.sendReceive_flat("world.getPlayerId", flatten(args)))

def getPlayerEntityIds(self):
"""Get the entity ids of the connected players => [id:int]"""
Expand Down
Binary file modified python3-scripts.zip
Binary file not shown.

0 comments on commit a69cdf8

Please sign in to comment.