#(ticxo) Saving 1 string in trait

267 messages · Page 1 of 1 (latest)

shell raft
#

This is a continuation of https://discord.com/channels/315163488085475337/1220159284332204173

All Model Engine does is saving 1 json string to the trait. I can assure that the output is 100% correct because it is the same string saved using persistent data container on normal entities, which has worked flawlessly. Here is the full trait class:
https://gist.github.com/Ticxo/4174c1d0096bac29a8cbc91aaa9095a2

The part it bugs is at line 48, where it converts the modelData json string back into SavedData (just a HashMap with extra methods). The NPE error is (supposedly) only thrown when the modelData string is empty or blank, which if citizens has saved the string correctly, should never be empty as it would just load as {} for empty data or null if the modelData was null.

I will provide more code snippets on request.

Gist

Model Trait. GitHub Gist: instantly share code, notes, and snippets.

lime monolithBOT
#

(ticxo) Saving 1 string in trait

lime monolithBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

amber solar
#

An example JSON string would be good for testing, it may be interpreted incorrectly by yaml (configurationsections are used underneath the datakey api)

shell raft
#
{"models":[{"damage_tint":16737894,"lock_pitch":false,"default_tint":16777215,"block_light":-1,"lock_yaw":false,"animation_handler":{"defaults":{"WALK":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"FLY":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"JUMP_START":{"lerp_out":0.25,"lerp_in":0.0,"speed":1.0},"IDLE":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"STRAFE":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"HOVER":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"DEATH":{"lerp_out":0.0,"lerp_in":0.0,"speed":1.0},"JUMP_END":{"lerp_out":0.25,"lerp_in":0.0,"speed":1.0},"JUMP":{"lerp_out":0.0,"lerp_in":0.0,"speed":1.0},"SPAWN":{"lerp_out":0.25,"lerp_in":0.0,"speed":1.0}},"animations":{"idle":{"phase":"PLAY","force_override":false,"lerp_out":0.25,"force_loop_mode":"LOOP","last_time":1.4000000000000057,"name":"idle","lerp_in":0.0,"lerp_in_time":0.0,"id":"simple","time":1.4500000000000057,"lerp_out_time":0.0,"speed":1.0}},"id":"priority"},"can_hurt":true,"blueprint":"capybara","main_hitbox":true,"removed":[],"default_bones":{},"sky_light":-1,"shadow_visible":true,"hitbox_visible":true,"hitbox_scale":1.0,"render_scale":1.0}],"base_entity":{"body_rotation":{"head":false,"duration":10,"min_head":-75.0,"min_body":-75.0,"delay":10,"max_head":75.0,"max_body":75.0,"stable":15.0,"body":false,"player":false},"render_radius":48,"step":1.0,"collide_exemption":[]},"rotation_locked":false,"base_visible":false,"version":"R4.0.3"}
#

Do know that the citizens implementation works most of the time, and by most I mean whenever I was testing locally it works, including the string above. We might need to take a look at the saved data from @tribal pebble

tribal pebble
shell raft
#

or we can think of this differently, which is that DataKey#getString returns an empty string even when the data isn't present

shell raft
#

Citizens/saves.yml

tribal pebble
#

Yes

#

that's the whole save

#
    metadata:
      nameplate-visible: 'false'
    name: ''
    uuid: a32bc27b-2de0-4ce8-99b6-9d58cc5896f1
    traits:
      location:
        bodyYaw: -21.1622
        world: Spawn
        x: '-33.5'
        y: '100.0'
        z: '-6.5'
        yaw: '-21.1622'
        pitch: '-12.1525'
      spawned: true
      type: PLAYER
      lookclose:
        range: '10.0'
        disablewhilenavigating: true
        enabled: true
        enableRandomLook: false
        headonly: false
        linkedbody: false
        perplayer: false
        randomLookDelay: 60
        randomSwitchTargets: false
        realisticlooking: false
        targetnpcs: false
        randomPitchRange:
          '0': 0.0
          '1': 0.0
        randomYawRange:
          '0': 0.0
          '1': 360.0
      skintrait:
        fetchDefaultSkin: true
        updateSkins: false
      meg_model:
        model_data: '{"models":[{"damage_tint":16737894,"lock_pitch":false,"default_tint":16777215,"lock_yaw":false,"animation_handler":{"defaults":{"WALK":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"FLY":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"JUMP_START":{"lerp_out":0.25,"lerp_in":0.0,"speed":1.0},"IDLE":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"STRAFE":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"HOVER":{"lerp_out":0.25,"lerp_in":0.25,"speed":1.0},"DEATH":{"lerp_out":0.0,"lerp_in":0.0,"speed":1.0},"JUMP_END":{"lerp_out":0.25,"lerp_in":0.0,"speed":1.0},"JUMP":{"lerp_out":0.0,"lerp_in":0.0,"speed":1.0},"SPAWN":{"lerp_out":0.25,"lerp_in":0.0,"speed":1.0}},"animations":{"idle":{"phase":"PLAY","force_override":false,"lerp_out":0.25,"force_loop_mode":"LOOP","last_time":1.0500000000000267,"name":"idle","lerp_in":0.0,"lerp_in_time":0.0,"id":"simple","time":1.1000000000000267,"lerp_out_time":0.0,"speed":1.0}},"id":"priority"},"can_hurt":true,"blueprint":"bug_catcher","main_hitbox":true,"removed":[],"default_bones":{},"shadow_visible":true,"hitbox_visible":true,"hitbox_scale":1.0,"render_scale":1.0}],"base_entity":{"body_rotation":{"head":false,"duration":10,"min_head":-75.0,"min_body":-75.0,"delay":10,"max_head":75.0,"max_body":75.0,"stable":15.0,"body":false,"player":false},"render_radius":48,"step":1.0,"collide_exemption":[]},"rotation_locked":false,"base_visible":false,"version":"R4.0.3"}'
    traitnames: type,mounttrait,rotationtrait,location,inventory,lookclose,spawned,scoreboardtrait,meg_model,skintrait
    navigator:
      speedmodifier: '1.0'
      avoidwater: false
      usedefaultstuckaction: false```
#

I have 3 npcs i'm trying to use with meg_data.

#

90, 81, and 79.

#

when I restart the whole server all the meg_data gets removed

shell raft
#

so those are the data you just generated?

#

with /citizens save I assume

tribal pebble
#

Yeah

shell raft
#

and when you restart it just throws those errors again?

tribal pebble
#

Yeah

shell raft
#

does citizens save the data when you just shut down the server

tribal pebble
#

I can check my latest log however I assume so because all the other npcs save

shell raft
#

you can just stop the server and check the saves yml and tell us CenturionShrug

tribal pebble
#

[05:22:13 INFO]: [Citizens] Disabling Citizens v2.0.33-SNAPSHOT (build 3366)

#

just disables

shell raft
#

well no thats normal

#

look at the saves

tribal pebble
#

ah ok

shell raft
#

(I assume thats normal who knows what its actually doing CenturionShrug

tribal pebble
#

the model_data is still there after shutting down

#

for 1 at least

#

the others don't have any after save

shell raft
#

by that do you mean it only saved 1 of 3 models or you mean you only gave one npc a model so it only saved that

tribal pebble
#

It only saved 1 out of 3 after doing /citizens save and shutting down

#

however i'm booting up

#

and I believe it removes all 3

#

ok nvm it still has it which is good

#

so 1 saves

shell raft
#

I spawned 2 npcs with meg_model trait and both of them saved so

tribal pebble
#

yeah it did it again

#

I gave them the trait then assigned the model then saved and reloaded the plugin and error

shell raft
#

reloaded the plugin?

tribal pebble
#

yeah /citizens reload

#

after I do /citizens save

shell raft
#

yea its not bugging for me

tribal pebble
#

making me seem crazy NOOOO

#

lmao

#

maybe there's a limit?

shell raft
#

a limit of?

tribal pebble
#

how many it'll save

#

I have 3

#

that i'm doing

#

which shouldn't make a difference

#

i'm also doing them in different worlds

shell raft
#

probably not

tribal pebble
#

I have 1 npc in 1 world and 2 in another

#

and the 1 in the other world wont save

shell raft
#

does it depend on which world you run the save command?

tribal pebble
#

it doesn't matter

shell raft
#

multiverse right?

tribal pebble
#

its always that 1 or they all don't save

#

my_worlds

shell raft
#

my_worlds?

#

no I mean the plugin you used to handle multiple worlds

tribal pebble
#

yeah MyWorlds

#

I was using multiverse however I switched to this as my world generator doesn't support multiverse for some reason

shell raft
#

let me try using that

#

but at this point a lot of indications are pointing towards this being a Citizens problem. Like, in no way me simply saving and loading a string using the Citizens API can cause so much problems

tribal pebble
#

I can't thank you both enough for coming together

#

this is what I love about the development community

shell raft
#

or its a my worlds problem, that can be a possibility too

tribal pebble
#

I'll reach out

shell raft
#

give me a quick run down on my worlds btw

tribal pebble
#

MyWorlds from my experience in using it is just another World Management plugin that allows you to create worlds and teleport to said worlds. It can load and unload worlds and what not

shell raft
#

I meant the commands

#

so I can test

tribal pebble
#

ah

#

/mw create "worldname"

#

/mw tp "worldname"

shell raft
#

@tribal pebble can you try using a non player type

#

like a pig

tribal pebble
#

yeah

#

does it matter which world?

shell raft
#

Im trying in a mw so I guess?

#

maybe it doesnt matter

tribal pebble
#

yeah, it still turns back into a pig after I give it the model_data

#

so it saves the type

#

but not the model_data in the seperate world

shell raft
#

how are you creating the npc

#

like the commands in sequence

tribal pebble
#

/npc create

#

/npc look

#

/trait meg_model

#

/meg npc model citizen:#:[] add modelname

#

I've also tested with names and without names

#

with skins and without skins

shell raft
#

and then you just citizens save and reload?

tribal pebble
#

yeah

shell raft
#

and then it bugs?

tribal pebble
#

well all of them would however now its just the one in the seperate world from what i'm seeing testing it

shell raft
tribal pebble
#

I went to record the response that it was giving me and it gave me the result I wanted after repeating the steps multiple times

shell raft
#

Ill wait for fullwall

#

if the data loaded fine but the model didnt load, then its a meg problem, but right now its pretty apparent that something went wrong on the save load cycle and meg is definitely not responsible for that

#

whether thats a citizens problem or a my world problem, Im not sure. It worked for me so maybe its not even them

tribal pebble
#

well, it looks like its now for some reason after I made a big problem about it working...

shell raft
#

wait so everything is fine now?

tribal pebble
#

As of my final trial of doing those steps that I presented you. yeah

shell raft
#

KEKW yea no Im fucking clueless to say the least

tribal pebble
#

I definitely believe its a saving issue at the least

shell raft
#

lets see if fullwall can help us

daring hingeBOT
amber solar
#

I can't reproduce any issue

#

in this case @tribal pebble is using /citizens reload which may be confusing things

#

a log with the exact commands issued would be helpful, since I still can't reproduce any issue

#

I really doubt it is an issue with citizens, there has never been a similar issue report to this in 13 years, almost invariably it is a setup issue

shell raft
#

and I really doubt it is an issue with model engine as well

amber solar
#

yes it doesn't seem that way, but let's see what the command sequence looks like

amber solar
shell raft
#

I have modified it so the parser ignores data string that is null, empty or blank, but that just silence the error and doesnt actually fix the issue of models disappearing

shell raft
#

but thats unrelated to this either so CenturionShrug

amber solar
shell raft
#

CenturionShrug so change it. Thats not an excuse

amber solar
#

it's an external API so it would have to go through a deprecation cycle. The keyExists API and defaulted API both exist for time being

#

perhaps a new optional API would be better

#

I'm happy to make API changes if you request them.

shell raft
#

keyExists works so whatever

#

I have faith in 0Ticks megizen to replace my implementation

tribal pebble
#

yeah, I just woke up and all of them are null

#

meaning the error still occurs

amber solar
#

!logs

fresh roostBOT
# amber solar !logs
Info: logs

Please post your full latest log file.

Background Info: One of the most helpful tools to identifying the source of a problem is your server logs file! Logs contain all sorts of important information like server and plugin versions, any error messages, and a lot more important information (More Info).

How To: Your log can be found in the logs folder within your server folder. The most recent log is a text file labeled latest.log. To get help using these logs, please open that file in a text editor and copy all of the text, then open https://paste.denizenscript.com/New/Log and paste the text into the box on the page. Then click "Submit" and copy the URL and paste that back into this channel.

Please do not upload the file to Discord or to other pastebin services, use the log pastebin linked above.

amber solar
#

@tribal pebble

tribal pebble
#

I got you

amber solar
#

why are you running /citizens reload?

amber solar
#

@tribal pebble can you update citizens please

#

!update citizens

fresh roostBOT
tribal pebble
#

last build correct?

amber solar
#

@tribal pebble 3371

tribal pebble
#

booting the server now

#

putting the models on them worked, and saving/reloading the plugin worked. I'm restarting the server to see if they're still there after restarting the server

#

As of current all the models have saved, and the model data is in the saves file

amber solar
#

@tribal pebble so... should we close this thread? I haven't changed anything related to model JSON saving, just a fix to empty models

tribal pebble
#

the error is still occuring. I'm trying to figure out if its a me issue however

#

the models save and when I restart it stays

#

however when my server crashes even when I already do /citizens save

#

the models disappear

#

and all previous npcs with the model_data lose their meg model data

amber solar
#

!logs

fresh roostBOT
# amber solar !logs
Info: logs

Please post your full latest log file.

Background Info: One of the most helpful tools to identifying the source of a problem is your server logs file! Logs contain all sorts of important information like server and plugin versions, any error messages, and a lot more important information (More Info).

How To: Your log can be found in the logs folder within your server folder. The most recent log is a text file labeled latest.log. To get help using these logs, please open that file in a text editor and copy all of the text, then open https://paste.denizenscript.com/New/Log and paste the text into the box on the page. Then click "Submit" and copy the URL and paste that back into this channel.

Please do not upload the file to Discord or to other pastebin services, use the log pastebin linked above.

tribal pebble
amber solar
#

and your saves.yml

tribal pebble
#

the saves.yml doesn't have the meg_model data currently

#

would you like me to apply some?

#

here's my current saves.yml

amber solar
#

it should have model data @tribal pebble the exception there is from modelengine, not related to citizens

#

so I'm looking for a model data that is applied then doesn't save correctly @tribal pebble

tribal pebble
#

sounds good! i'm putting models on npcs currently

daring hingeBOT
tribal pebble
#

this has all the model_data

amber solar
#

@tribal pebble ok, so is there a log with an error?

tribal pebble
#

yeah

amber solar
#

that NPC ID has no model saved

#

so it's not a relevant error

#

that is a modelengine bug

tribal pebble
#

when my server crashes, all model data gets removed

#

everything else stays

amber solar
#

when you say your server "crashes"

#

what do you mean

tribal pebble
#

my server has been doing this "silent crash"

#

where all commands pretty much freeze however the server is up

amber solar
#

I'm not able to help with "silent crash"es

tribal pebble
#

yeah I figured

#

i'm not asking help

#

i'm trying to figure out why my server is doing taht

amber solar
#

ok so is there an issue with models not saving correctly?

#

or not

tribal pebble
#

there is

amber solar
#

@tribal pebble ok... do you have a model data that fails to save?

#

is it a specific model for example

tribal pebble
#

its all of them

amber solar
#

ok so the models that are in saves.yml aren't loading?

tribal pebble
#

they're loading as current

#

its super weird and confusing

amber solar
tribal pebble
#

I say that because they'll be correct one moment then they'll disappear if my server does this little freeze

amber solar
#

the citizens part of this ends when the saves.yml is loaded and saved

tribal pebble
#
DISABLED

1. headdatabase 
2. GUIPlus
3. epicrename 
4. economyshopgui-premium 
5. discordsrv 
6. deluxetags 
7. deluxetags
8. deluxe menus
9. deluxecombatflags
10. deluxecombat
11. decentholograms 
12. dailyrewards+
13. crazyvouchers
14. cmilib
15. cmi
16. citizens
17. chunky
18. chatitem
19. bigdoors
20. bigdoorsphysics
21. bigdoorsopener 
22. advancedenderchest
23. advancedenchantments
24. advanceditems```
#

these plugins were disabled and my server didn't do the freeze thing

#

the "slient crash"

amber solar
tribal pebble
#

sounds good ty

amber solar
#

all I can say is that I made my own copy of the modelengine trait data and I did not experience any saving or loading issues

tribal pebble
#

I figured it out

#

its Itemsadder removing the model data

amber solar
tribal pebble
#

when you reload the texturepack with new data (even without changing any of the data corresponding to the npcs) all npcs models get removed

amber solar
#

ok, so if you remove itemsadder it works?

tribal pebble
#

possibly

#

I found a work around it

#

as long as you /citizens save

#

then export the saves.yml to a safe location, zip the texturepack with itemsadder then import the saves file back all the models are correct and nothing disappears

amber solar
#

ok, hopefully @shell raft can look at this, seems like a bug with modelengine / itemsadder

shell raft
#

Ah it's item sadder all over again

#

So @tribal pebble right now if you remove IA it works?

opaque nexus
#

Model Engine 4 itemsadder I'm using, but when I restart the server, the model drops. Is there a way to fix it in Citizen? Or is there a setting where I need to turn it on or off in Worldguard?

amber solar
#

@opaque nexus we are looking for reproduction steps. if you disable ItemsAdder does it work?

opaque nexus
amber solar
opaque nexus
#

Yes, yes, but it works well even if it's active. Sometimes when you shut down and restart the server, the model is missing.

amber solar
#

@opaque nexus if you disable ItemsAdder, does the model save?

opaque nexus
#

It will be saved even if it is activated.

amber solar
#

@opaque nexus is it a certain model that doesn't save properly?

opaque nexus
amber solar
#

when itemsadder is disabled, do all models save correctly or not

opaque nexus
#

Both deactivation activations save the model well. Also, both sometimes restart the server and the model is missing.

amber solar
opaque nexus
#

no

amber solar
#

I don't understand

#

need to understand clearly when this happens to find out why

opaque nexus
#

What I have Sometimes checked is that it falls out when I restart the server after I put the model on it.

amber solar
#

if you haven't checked, then maybe someone else will

opaque nexus
#

The model is just all the models applied to the npc. And the itemsadder is used separately for resource pack purposes, and it doesn't seem to be a problem with the itemsadder.

amber solar
#

@shell raft the fact that it only seems to not save sometimes makes me wonder if there is an issue with ordering of onDespawn with your methods. I would recommend adding some debug logging targeted what is actually getting written to modelData and when. unfortunately the issue is all happening in modelengine codebase so I can't really help much from my end. seems to happen at random. I can keep asking people questions but no luck so far. I created a trait to test but there was no issue with the sample JSON provided.

timid swift
opaque nexus
#

oh If you keep the server on for a long time, the npc disappears. To be exact, the model disappears. (remains transparent) It comes back when I do a separate /citizen reload.. is there a way to keep it from disappearing?

shell raft
shell raft
#

Unless that isn't the problem anymore

timid swift
tribal pebble
#

the error is similar

#

sometimes my server restarts or sometimes I reload my texturepacks and the citizens model_data drops

#

its inconsistent results

shell raft
#

Ill patch that up first then go from there

#

the reload resource pack stuff I have no idea why would be related

shell raft
amber solar
shell raft
white bane
ornate gulch
#

make your own thread for your own questions please

amber solar
#

@shell raft in my testing I only get one invocation of onDespawn which is legitimate because the skin loads and respawns the player to apply it

zenith ironBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@shell raft