CraftTweaker

CraftTweaker

151M Downloads

Tracking the dimension the player is in

puncrafter opened this issue ยท 2 comments

commented

Is there a way to make a variable persist even after relogging?

I want to track what dimension the player is by using the PlayerChangedDimension event, and it works fine until the player relogs and the variable resets.

Alternatively, is there a better way to check which dimension the player is in?

Pastebin of the script in question, if it helps: https://pastebin.com/eTmKz12y

commented

You should ask here:
https://discord.blamejared.com

To set you in the right direction though, IPlayer extends IEntity
IEntity has:

IData getNBT();
void update(IData data);

So you can get the current data, and update it with new data
Entity NBT is saved to file (for players their .dat files) and would allow storing variables across scripts / world loads

commented

You can additionally add event handlers to the playerlogin event and get the player's world and dimension from there as well.

Though you may want to change your script in any case since it wouldn't work on servers like that ๐Ÿ˜›