Mod dev question - How to check if a chunk has been cached to sqlite?
Hi.
I am currently creating a crude mod to cache chunks on singleplayer or multiplayer by teleporting the player around the spawn area to have their client cache the chunks into DH.
What I have currently works on a basic level, however I believe the way I am checking if a chunk is already in the sqlite db is sub optimal:
(Full repo: https://gitlab.com/billyg270/bb-preload-world)
My question is if there is a more preformant way to preform this check.
Thanks!
Solution:Jump to solution
That code looks good to me I can’t think of a faster way to check for present/absent data in the DB.
19 Replies
@Moderator
don't ping every mod
:unhappy:
Bro lived up to his name
Why did you ping the moderators anyway, this isn’t even your question?
Solution
That code looks good to me I can’t think of a faster way to check for present/absent data in the DB.
is
DhApi.Delayed.worldProxy.getSinglePlayerLevel(),
necessary here? what's it returnIt returns the level.
DH’s api needs to know what level (dimension) to query.
can this not be automatically fetched by
blockPos
No, a block pos is just 3 integers (x,y,z) the position by itself doesn’t know if it’s in the end or overworld.
might be reading this wrong, is
blockPos
not a method that's being calledNope, it’s a variable Bill wants to check.
And with DH’s API it requires both a level and X, Y, Z coordinate.
OOP is funky, i need to make an effort to properly understand it some day
Ok fair enough ty, do you think I could run these checks in other threads to help or would that cause issues?
Running on a separate thread is a great idea and will work just fine.
Nice! I will give that a go, thanks!
speaking of threads, is there a chance of having race conditions when writing to the db or does DH/sqlite handle multiple threads writing at the same time gracefully
SQLite handles it gracefully.
That’s one of the big benefits of running a DB vs flat files.
Using threads has greatly improved the system! The FPS maintains 60 as the process happens now.
Final question on this topic, when using
getSingleDataPointAtBlockPos
will sucess only return true if all detail levels have been cached? If not if there something else I can call to confirm this?Aha! Think I have found what I am looking for