#How can I obtain the UUID int-array values of a player?
27 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
use split("-") to return an array
btw, just curious, why you need that?
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
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.
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
any particular reason to summon and not to give to player?
Yes, the item is meant to be dropped on the ground, not given in the player's inventory
doesn't look like when you have ~ ~1 ~
${event.getEntity().x} ${event.getEntity().y} ${event.getEntity().z} are the coordinates of an entity that took damage, not necessarily the player.
you are actually right
hope they dont
kill over lava
or something
but that is not your problem lol
Yeah.
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
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())
})
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
It actually didnt work until I put .toString() on the end of it 😅
oh well ¯_(ツ)_/¯