anykey
Posts: 14
Joined: Fri Nov 29, 2013 8:11 pm
Location: Netherlands
Contact: Website

Change Minecraft PI player name

Fri Jun 16, 2017 9:07 pm

For our coderdojo I needed to be able to change the "fixed" player name StevePi for minecraft, so I wrote a simple python script for it. (Tested on the latest Jessie release 2017-04-10)

Here it is, in case somebody else wants to use it.

Code: Select all

# Set the player name (7 chars) for Minecraft PI Edition
# Written by Richard Garsthagen - richard@coderdojo-zoetermeer.nl
#
# Use at own risk. Please make a backup of minecraft-pi first!

namestart= 1026250

try:

 fh = open("/opt/minecraft-pi/minecraft-pi", "r+b")
 fh.seek(namestart)

 print ("Current name: {} ".format(fh.read(7)))

 piname = raw_input("New player name: ")

 if len(piname) > 1:
  if len(piname) > 7: piname = piname[:7]
  if len(piname) < 7:
   extraspaces = 7 - len(piname)
   for x in xrange(0,extraspaces):
     piname = piname + " "
  print ("Changed name to:" + piname + " - " + str(len(piname)))
  fh.seek(namestart)
  fh.write(piname)
 else:
  print ("No new name given")

 fh.close()

except:
 print ("Can not change name, is minecraft running? Please close the app first")

Return to “Raspbian”

Who is online

Users browsing this forum: No registered users and 14 guests