Topic category: Troubleshooting, bugs, and solutions
What I'm about to describe is a situation that was so strange that it made me lose my sanity. What happened here is impossible...~
I Created a procedure that simply sets a value to 0 only upon joining a world for the first time:
------------------------------------------------------------------------------------
Event Trigger: Player joins the world
If not Get entity data logic NBT tag "JoinedBefore"
Do Set entity data logic NBT tag "JoinedBefore" to true
Do Set entity data number NBT tag "Counter" to zero
------------------------------------------------------------------------------------
So I created 2 Overlay elements with only a slight difference. They become visible after the counter hits 1 for the first overlay and when it hits 2 for the 2nd overlay:
------------------------------------------------------------------------------------
Condition true if: Get entity data number NBT tag "Counter" > 0
Condition true if: Get entity data number NBT tag "Counter" > 1
------------------------------------------------------------------------------------
I simply made food to be able to (test) increase the counter to test whether the Overlay elements become visible.
------------------------------------------------------------------------------------
On Food Eaten:
Set entity data number NBT tag "Counter" to Get entity data number NBT tag "Counter" + 1
------------------------------------------------------------------------------------
I even created an additional "print" for testing to be able to see the value for myself:
------------------------------------------------------------------------------------
On food right clicked
Send message to provided entity create text with "Counter: "
Get entity data number NBT tag "Counter"
Show in action bar: false
------------------------------------------------------------------------------------
So here I go starting up a new world. I right click and yup: Counter = 0. Neither overlay elements are visible. (As intended)
So I eat the food once and there you go! Now the counter is 1 and 1 overlay element is visible. (As intended) Eating food for the 2nd time makes the 2nd overlay element visible! (As intended)
So I close the world and reopen it, to find out that the NBT counter is still 2... as intended! But yet... the overlay elements have both gone missing and only appear upon increasing the NBT counter to 3 and for the second... 4...
The value is literally saved. Counter is visibly 2, yet in the overlay procedure it returns False for Get entity data number NBT tag "Counter" > 0...
Every time you close the world and reopen it, it treats Counter as if it is 0 in the Overlay system, yet when printing it's value, it is not...
How is this possible?
Okey, I definitely found a bug of some sorts. I did some testing around:
I created a BLUE block that makes a dirt sound when placed ( through basic settings) and added this procedure:
------------------------------------------------------
------------------------------------------------------
When loading the world up for the first time and placing this block (counter = 0), you'll place the BLUE block with a sand sound.
When increasing the counter to 1, the block will now spawn stone with the stone sound.
When reloading the world with counter = 1 you will still spawn the Stone block but THIS TIME with a sand sound! Only after you increase it to 2 will it start spawning with a stone sound!
The bug somehow resets an NBT tag back to 0. So if you have a condition where if x > 5. If you reopen the world with x being 7, you'll need to reach 12 because it somehow treats x as 0 instead of 7, while treating it as 7 for different parts of the program!
When it comes to placing the block, it works, but strangely for the sound aspect of it, it doesn't. And it also doesn't work in the Overlay procedures.
I hope that helped.
If this delays the beautiful update that is 1.9.1, I'm sorry xD
Overlays are client-side, while events happen on both server and client-side. Related tickets and resolutions that will be published in 1.9.1:
Make sure that you are getting/setting NBT tags on the same side too as there are two contexts for variables - server and client context. For global variables, MCreator will sync them in 1.9.1.
How can I create client side variables that persist upon leaving and rejoining the world?
Not yet, will be possible in 1.9.1.
In 1.9.0, you can make a server-side variable and then copy it into a session variable for the overlay use.
This page might help: https://mcreator.net/wiki/variables
The video on this page explains how to do this in 1.9.0 and how one will do this in 1.9.1.
Damn, 1.9.1 sounds amazing. So many useful things. I can't wait xD
Hi,
I'm using the most current 1.9.1, and I don't understand how entity nbt data can't be passed to an overlay I'm using.
Basically I have an nbt tag set when a player does something like activate a skill, then in the overlay check the nbt tag of that player and render something if the tag is set. Right now the nbt tags are synced throughout normal player activities, but in the overlay it does NOT get the same values for the tag.
You mentioned server/client side nbt data. Is normal player activities server side and overlay client side? Can I use client side nbt data only for all contexts? If so, how do I do that?
No, client side is for one client, server side for server only.
That means I can't use player nbt tags in overlays right? since I'm usually modifying the nbt tag on the server side.
So now I tested using a global session variable instead, but when one player sets the variable, other players have it set too. What can I use to have a global private variable that only applies to a specific player?
As long as you set the value of tags in a procedure that sets them on both sides, it should work. But we are working on improving this in the future updates, you can open as support ticket for this too so we don't forget about this one :D
I will open a ticket. But in the mean time:
I'm not very proficient in server/client coding. How do I set an nbt tag on server and client side?
Found a way to send the data to the client via simplenetworkwrapper packet using what I learned from you last time we talked about detecting key releases.
But this just seems so much work just to send one darn variable down to the client. If I had to implement this in every overlay I'd go nuts. Is there an easier way?
No, I don't think there is, you need to sync the data manually if you intend to.