#How can I obtain the UUID int-array values of a player?

27 messages · Page 1 of 1 (latest)

elfin cairn
#

event.getSource().getPlayer().uuid gives me a UUID in a hyphenated hexadecimal format which is not useful to me

turbid whaleBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

teal leaf
#

use split("-") to return an array

btw, just curious, why you need that?

elfin cairn
#

Owner tag on item entities so only specific players can pick it up

#

Also the hyphenated hexadecimal format looks like this “7ad5c0ff-7b73-47f3-b104-7c78cc362649”, so splitting the string won’t really solve the issue

teal leaf
#

@elfin cairn why do you want that? do you want to compare?

#

??XY

lapis burrowBOT
# teal leaf ??XY

The XY problem is when you really want to do X, and you think that Y can achieve X. However, you can't get Y to work, and so ask for help exclusively about Y.

This can lead to a lot of confusion from the people trying to help you, as Y can seem like a very random thing to want to do, and a lot of the time isn't the best way to achieve X anyway.

Its fine to ask about Y, just always include some context about X so you can be put on the right track if Y won't do X well, or there is an easier way to do X.

elfin cairn
#

This command summons an stone block item that only I can pickup because the nbt tagOwner:[I;2060828927,2071152627,-1325106056,-868866487] matches the same int-array UUID as me. The issue is that I have only found ways to extract the player's UUID in the hyphenated hexadecimal format “7ad5c0ff-7b73-47f3-b104-7c78cc362649” which wont work for what im trying to do.

event.server.runCommand(`execute positioned ${event.getEntity().x} ${event.getEntity().y} ${event.getEntity().z} run summon minecraft:item ~ ~1 ~ {Item:{id:"minecraft:stone",Count:1b},Owner:[I;2060828927,2071152627,-1325106056,-868866487]}`)
#

The int-array UUID values are in the nbt data of the player however I dont know how to access them with kubejs

teal leaf
#

any particular reason to summon and not to give to player?

elfin cairn
#

Yes, the item is meant to be dropped on the ground, not given in the player's inventory

teal leaf
#

doesn't look like when you have ~ ~1 ~

elfin cairn
#

${event.getEntity().x} ${event.getEntity().y} ${event.getEntity().z} are the coordinates of an entity that took damage, not necessarily the player.

teal leaf
#

raha you are actually right

#

hope they dont

#

kill over lava

#

or something

#

but that is not your problem lol

elfin cairn
#

Yeah.

teal leaf
#

damn those classes all changing places...

#
const $UUIDUtil = Java.loadClass("net.minecraft.core.UUIDUtil")

BlockEvents.rightClicked("stone", event =>{
    let playerUUID = event.entity.uuid
    console.log(playerUUID)
    let intArrays = $UUIDUtil.uuidToIntArray(playerUUID)
    console.log(intArrays[0])
    console.log(intArrays[1])
    console.log(intArrays[2])
    console.log(intArrays[3])
})
#

so you can adapt to what you need

elfin cairn
#

Thank you! For some reason it puts it into scientific notation but that was an easy fix

const $UUIDUtil = Java.loadClass("net.minecraft.core.UUIDUtil")

BlockEvents.rightClicked('minecraft:oak_leaves', event =>{
    let playerUUID = event.entity.uuid
    console.log(playerUUID)
    let intArrays = $UUIDUtil.uuidToIntArray(playerUUID)
    console.log(parseFloat(intArrays[0]).toString())
    console.log(parseFloat(intArrays[1]).toString())
    console.log(parseFloat(intArrays[2]).toString())
    console.log(parseFloat(intArrays[3]).toString())
})
teal leaf
#

yes, but you don't need .toString() when you use inside the command that contains ${array[0]}
everything that is not a explicit string get called a .toString() internally

elfin cairn
#

It actually didnt work until I put .toString() on the end of it 😅

teal leaf
#

oh well ¯_(ツ)_/¯