Skip to content

Instantly share code, notes, and snippets.

@oO0oO0oO0o0o00
Created October 6, 2021 13:54
Show Gist options
  • Save oO0oO0oO0o0o00/27a9dbb3b2426d31e7af4a0051bcfd9b to your computer and use it in GitHub Desktop.
Save oO0oO0oO0o0o00/27a9dbb3b2426d31e7af4a0051bcfd9b to your computer and use it in GitHub Desktop.
Decode the position of Waystone (of Waystone mod)
import argparse
def sign_extend(value: int, bits: int) -> int:
""" Perform sign extension operation.
"""
sign_bit = 1 << (bits - 1)
mask = sign_bit - 1
return (value & mask) - (value & sign_bit)
def decode_waystone(x):
""" x, y, z """
return sign_extend(x >> 38, 25), sign_extend(x >> 26, 12), sign_extend(x, 25)
def __main__():
# 1. (for server) look for uuid given username in usernamecache.json
# 2. open the player's playerdata with nbt viewer
# 3. find tag with given name by digging down through ForgeData tag
# 4. copy the value of position and decode with this script
parser = argparse.ArgumentParser(description='Unpack Waystone position.')
parser.add_argument('x', metavar='position', type=int, help='position')
args = parser.parse_args()
print(decode_waystone(args.x))
if __name__ == '__main__':
__main__()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment