#QIDB V3.9.0 | A database for saving ItemStacks without stringifying
1 messages · Page 2 of 1
really?
i tested it, it wasnt...
and there should be an issue with the background saving
what's the lagging part?
because i only save and get the items for kits
and i wasnt even getting anything
and the whole world was lagging
background saving is handled by runJob it should automatically adjust the rate
maybe i should optimize the firing of the runjob
well not if one operation is very demanding
yea
when are you running runJob?
every tick?
runjob runs always, if there are no keysw it just doesnt do anything
:u
but runjob run more than 50 times per tick
damm thats really bad
yeah but for me it worked normally i didnt see any issues
try running it maybe 1 per tick or 1 every 20 ticks
they are high, 32GB ram 3200mhz
i7-12700F
that's weird
so the ticking entity isnt doing anything bad?
yea, no problems
import { QIDB } from './QIDB.js'
import { world, system, ItemStack, Player } from '@minecraft/server';
const db = new QIDB('inventories', 270)
world.beforeEvents.chatSend.subscribe(e => {
const { message } = e
if (message != '.stress') return;
else e.cancel = true
system.run(() => {
for (let i = 0; i < 10000; i++) {
db.set(i.toFixed(0), new Array(255).fill(new ItemStack('dirt', 64), 0, 255))
}
world.sendMessage('END ____________________')
})
})
that's the code i used to test
wait look
try that same code and tell me if it lags
try the same code
this will be really funny
During the test there is no lag XD
but once its over the lag returns
that's really strange
average programming errors
why doesnt work | why does it work
this thread has reached 1k messages!!!
@steep crystal bro
the script is so heavy...?
QIDB
i was loosing my mind thinking it was one of my other addons
this was like 3 minutes
of profiler
just existing is what i gather
That’s therunJob, it works wrongly
Basically the script is heavy if you don’t use it, and light if you use it
better to warn it in original messege, till it's fixed
good to know haha,
was showing 125% on my server, and then without the item db you have its running stable 5-7%
that is the total hang time around the run duration
Same
It’s an incorrect use of the runJob
@edgy mulch on my pc i dont see any lag even with 7 databases
that's so strange
this is 100 databases
cpu usage doesnt change much
neither ram does go up
import { QIDB } from './QIDB.js'
import { world, system } from '@minecraft/server';
world.beforeEvents.chatSend.subscribe(e => {
const { message } = e
if (message != '.load') return;
else e.cancel = true
system.run(() => {
for (let i = 0; i < 100; i++) {
new QIDB(`db${i}`, 100)
}
})
})
@hazy sable idk how to fix this, this problem isnt a thing in my pc
i even tried with 10 addons at once and sill 0 lag
hmm
...
dont run it all the time the runJob
like the saving part
im pretty sure you are not using it right
Do it with a Minecraft Debugger, even if you got +100 FPS, that doesnt means you got Full TPS
tps?
One tick only should take less 50ms
TPS, Ticks per Second
Minecraft is capped to 20
Script should take less than 20ms (5ms were even better) each tick
runJob does automatically adjust its rate based on the tick per second
Good, but try it with a real minecraft debugger
runJob is meant for this
what's that
world.beforeEvents.chatSend.subscribe(e => {
const { message } = e
if (message != '.load') return;
else e.cancel = true
system.run(() => {
for (let i = 0; i < 100; i++) {
const db = new QIDB(`db${i}`, 100)
db.set('a', new ItemStack('dirt', 64))
db.has('a')
db.get('a')
}
})
})
let lastDate = Date.now()
let tickspeed = 20;
system.runInterval(() => {
let currDate = Date.now();
let TPS = tickspeed * 50 / (currDate - lastDate) * 20
lastDate = currDate
world.getPlayers()[0].onScreenDisplay.setActionBar('TPS: ' + TPS.toFixed(2))
}, tickspeed
)
i just used that
A Debugger API that shows the real stats
like TPS, Script TPS etc
how do i do that
what's host?
host: localhost
port. 1944 (if i remember it correctly)
but you need a launcher file for it, read the docs about the extension
i alredy have it
{
"version": "0.3.0",
"configurations": [
{
"type": "minecraft-js",
"request": "attach",
"name": "Debug with Minecraft",
"mode": "listen",
"preLaunchTask": "build",
"targetModuleUuid": "3818803b-e5a0-4dd5-a8fb-48a1acaeb627",
"localRoot": "${workspaceFolder}",
"port": 19144
}
]
}
it says failed to start debug
damn
ye..
Maybe ask in #1067535382285135923
It should look like tha
Its well running
you mean in a good or bad way?
so there isnt any problems?
idk
in my pc and in LeGend077 ones the script works without issues
the script shows 30ms is that good or bad?
30ms only while runJob is okay
I mean the debugger
oh i just started the debug in listening mode, then i typed connect in minecraft and it connected
whats your launcher.json
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "minecraft-js",
"request": "attach",
"name": "Attach to Minecraft",
"mode": "listen",
"localRoot": "${workspaceFolder}/scripts",
"port": 19144
}
]
}
launch is in the .vscode
And what did you run on minecraft to connect it
so what's the issue that gameza and leefy are getting?
Idk, maybe bad devices
gameza got a far better pc than me
well. idk why i get errors
that doesnt make any sense
minecraft version?
1.21.62
btw the runJob works perfectly, it automatically adjust its rate when there is world lag
so even if it was very heavy it just wouldnt create any issues
ye
foundn't
i am not seeing any issue here, if the lag you are concerned about is based on Leefy screenshot, you guys are reading reading things wrong
so you re saying that is leefy that got wrong information?
no, the debugger telling you the total hang spike around the run duration
if i run a loop with 1000 iterations, and for each iteration the code spike 5 ms, the total will show as 5000ms for that loop
im not understanding.
i measured the script duration per tick, leefy measured a total duration of the script and said that was very high, gameza showed me a gameplay that was lagging and stuttering a lot (same issue as leefy)
and also gameza said that the script was lagging in game while it was just a while (true) { yield; }
when there was the actual structure saving he was not experiencing lag
didn't see any video here so idk
.
.
.
look at gameza's one when the db was sleeping and when it was saving 100 structures per second
that's his script
the database was using the runjob
yeah? that what causing the lag
no, lemme explain
runJob is not related to the issue here
he is running 10000 code that include your function
that will lag no matter what your function do
before doing /scriptevent the world was lagging,
after doing /scriptevent it saved 10 000 keys all at once,
the database handled that 10 000 keys with a runjob saving about 100 keys per second, while it was saving 100 keys per second the game was not lagging
you can see in chat that shows END ____________ when the for ends running
and if it was the for the game would just freeze and crash
you see the issue?
runJob run in queue
if the for loop is done that don't mean all the code it triggered is done too
if the database said that it was saving 10 000 keys it means that they were done
runJob:
set() function:
queueSaving function
database log
if its saying remaining: 10000 keys it means that queuedKeys are 10000 and this means that the queueSaving() method was called 10 000 times so the set actually ran 10 000 times
what does his script run when reloading? sense the lag is only in reload
if you see the lag is when is breaking blocks, the particles spawns later
only when reloading
no its all the time, and when he does the stress test the script stops lagging (the stress is supposed to create more lag)
No
The reloading was to show the difference between the 2 databases
The old one and the new one
Reload doesn’t have anything to do with it, it will free memory
@steep crystal also yea minato is right, i should have run that in another runJob with yield
I just copy and paste your code without thinking of it
But still that’s not the main issue
@steep crystal the new beta works fine, here is the code snippet
system.afterEvents.scriptEventReceive.subscribe(({
id
}) => {
if (id === "idb:test")
system.runJob((function* () {
for (let i = 0; i < 10000; i++) {
new ItemDatabase(`db${i}`, 100)
yield;
}
})())
})
but still the old one performs better
ill show it in a bit
As you can see in the video, look at the TPS.
First im trying the new beta db, and it doesnt have any issues in idle state we can call it like that, but it kind of lags in this stress test, but just at the beggining!
In Second test, this doesnt seems like an issue, yea it drops but by -1 or -2 tps, there is a huge difference, in the first test we had a drop of -8 or -7 tps
the test was made with this code snippet
system.afterEvents.scriptEventReceive.subscribe(({
id
}) => {
if (id === "idb:test")
system.runJob((function* () {
for (let i = 0; i < 10000; i++) {
const db = new ItemDatabase(`db${i}`, 100)
yield;
db.set('a', new ItemStack('dirt', 64))
yield;
db.has('a')
yield;
db.get('a')
yield;
}
})())
})
and its lagging even tho im using yield; this could mean that the has, get or set method are a heave load
For now i will just stick with the old db for my projects
Can you show the results with bedrock debugger as i did I want to check something
Yeah in real usage you should not to this but that’s a test it works fine
Like it needs to stress the game
ik but still the old one performs better in the stress test
Show me this graph in your pc
not how it works. You still have to setup the stuff running inside to yield correctly
It does yeild correctly
In my pc it doesn’t create any problems if you see the debug it is perfectly fine
@steep crystal how can i add the whole inventory to the database ?
nvm
db.set(itemstack[])
@young river pin the Github first message, that is an old version
.
Carchi may I dm you?
Go ahead
QIDB V3.8.5 | A database for saving ItemStacks without stringifying
fixed all the lag issues, and added new logs and their options.
edited the readme to make it more undestandable.
changelog V3.8.5
- added new logs option
- added new log types
- added back saverate
- removed logs option (replaced by log options database.logs)
- deleted runjob saving (lag issues)
https://github.com/Carchi777/QUICK-ITEM-DATABASE/releases/tag/V3.8.5
This is what I did with my Combat Mode 2.0 a few months ago, I've been meaning to fix a bug where entering and exiting a world sometimes won't give you the items back because the entity that stored the items probably disappears too quickly. Overall I like how we both have the same concept of storing stuff in entities and saving them with structures.
yeah i agree, i made that initially for my backpack system its a very reliable, fast and precise way to save ItemStacks then I decided to make this a pubblic resource becouse i want bedrock addons to keep getting better and better.
This isn't updated for v2.0.0 right?
Nope, I didn’t even test that version
I'll be waiting for the update lol, a ton of changes are needed I believe
Yeah ive seen that they removed player leave and player join
Yup, and most of things no longer have privileges bruh
Everything seems to work for me in the new version
Saving/accessing items anyways
doesnt for me
Sure?
I use the item database to save the item and use it to access it
I use an older version tho so I’m not sure about the newer ones
so basically it doesnt work becouse some functions like world.getDimension() has not priviledges
basically in the new update they just added world.afterEvents.worldLoad that basically the java public static void main function
the easiest quick fix is to wrap your script to setup the database in a system.run() or worldLoad
world.afterEvents.worldLoad.subscribe(() => {
const db = new QIDB(`database`, 100, 2)
})
system.run(() => {
const db = new QIDB(`database`, 100, 2)
})
alright, I'll get it tested
im alredy doing a fix, but that means that you cant use database methods outside system.run or events
Ah, alright!
Supporting 2.0.0-beta
- 2.0.0-beta requires the world to full load to use the database, you cant use the database if the world isnt fully loaded yet.
- added date in logs
https://github.com/Carchi777/QUICK-ITEM-DATABASE/releases/tag/V3.8.6
Thanks!!!
QIDB V3.8.6 | A database for saving ItemStacks without stringifying
Realised why mine worked. I use the method for using the “1.9.0-beta” api instead of 2.0 so nothing broke for me
Basically wrapping all my main imports like this
I found out that using
await null
At the start of the script fixes it
Oh weird
I was about to say that
The database works fine with the update, no need for a fix
All you need is to make your own plugin loader if we can call it like that
Which is Basicly this
yeah i did that too lol
I just added a system run in the constructor, it doesn’t change much but makes the database script load when the world is loaded
can u please read dm
anybody can help me to make backpack entity? is basicly entity shulket box with 65 slots
Yea just ask
sorry for saying this 5 th time idk
“Idk” what? What’s the problem with your shulker?
items doesnt saving basicly i want make a entity shulker box**(if dies inventory and color,nametag,owner saved an id of entity and item on placed shulker back with own data)**
create a post on script api thread
?
what
wdym by when the entity is reloaded?
what is that entity
i dont get what's the problem
show the script
try using quick memory access not set to 0
forget it
maybe its a world loading issue
what's that
thanks for reporting the issue
ill make an update asap
don't you love it when someone report a bug and solve it himself
Ye but like these bugs are always from world loading and they variate form one user to another, in my case i always used the tatabase and it never had this problem
yeah, testing across devices is time consuming
QIDB V3.8.7 | A database for saving ItemStacks without stringifying
YIPPE new update
I just changed 1 line of the entity json 😭
lol
i know, i saw it
How do you get those nice screenshots
Extension in vsc
extension CodeSnap
Okk
It looks nice, but such an overkill. Codeblocks are better unless you showcase the code to a bigger audience.
CodeSnap is nice, but regular codeblocks are much more easier to deal with
I like the fancy screenshots for showcasing code, because sometimes its nicer to have it in an image, e.g. forum post thumbnails. Every other time its much better to use code blocks.
✅
255
If inv size is 255 or less it will work fine
NEW UPDATE COMING TOMORROW
- new max size 1024
ItemStackper key. - new times to load
Tested on:
CPU: I5-10400F 4.30 Ghz (Desktop)
RAM: Kingston fury beast 2x8Gb DDR4 3600mhz
SSD: GigaByte nvme m.2 2280, 1 TeraByte
Without cache memory
256 values in 1 key 5 ms avg
512 values in 1 key 10 ms avg
768 values in 1 key 16 ms avg
1024 values in 1 key 21 ms avg
Sick
i meant values not keys
Yea yea Ik what you mean lol still awesome
i cant use 2048 becouse it will take 1 entire tick to set/get a value
Still not bad
That's the test
304 ms to queue the world saving for
1024000 ItemStacks
it totally takes 2/3 minutes to fully save them in the world
Relased V3.9.0
1024 ItemStacks per key
https://github.com/Carchi777/QUICK-ITEM-DATABASE/releases/tag/V3.9.0
QIDB V3.9.0 | A database for saving ItemStacks without stringifying
Is it more than one line now 😆
Can anyone explain to me this pls
this is a database to store ItemStack instances in a easy without using JSON.stringify
it does provide also a caching system
Basically this is a class i've made becouse script API doesn't have something reliable to store items, i initially needed this for my backpack addon, becouse you cant store items into an item, so i made this database to link items to my backpack.
This is a database for saving itemstacks as NBT data becouse it uses structures, you can save things like shulkerboxes saving also their content. This is useful for like a server item shop where players can buy and sell their items, you can create backpacks that work like real inventories..
This is an example of usage, its an item shop, if i didnt use my database to save the map, the map would be empty
Oh that's great but what is the max inventory space u can use is it a double chest (9×6) 54 slots or can u exceed that
Also this creation seems awesome
basically the database works like this
key (identifier) => value (item/items)
- you can assign as much keys as you want, the rule is that a key needs to be a different id than another key.
- the value (items) can occupate be 1 slot but can also occupate 1024 slots. depend on how many items you need to store.
so you have infinite space to save items
you can save a player inventory like this:
const database = new QIDB("inventories")
database.set("PlayerInventory", [ item1, item2, item3...])
where inventories is the namespace of the database, and PlayerInventory is the identifier linked to the items
Oh yeah this sounds very useful for map makers and server hosters
this could be a life saver for synchronisation
@steep crystal can you connect this to multiple bds instances, or is it local to a behavior pack ?
local
Local for world
It’s Made to work for addons also
That has nothing online, since you can use thing online only in bds
@lofty sail https://github.com/Carchi777/QUICK-ITEM-DATABASE/blob/main/Samples/Inventory_swapper.js
this is the example
Basically you just do
Const items = ……….
Db.set(player.id, items)
yeah it doesnt make sense
I'll just stick with what I have, thanks
@steep crystal did you ever complete your backpack add-on? Basically im passing the player's hot bar inventory to the database inventory when mounting an entity. Basically i just want to access the entity's inventory, something similar on how a back-pack would work.
Yeah I completed it but I never released it, it was an year ago so it isn’t updated to mc version and also to qidb version, it still uses additemfromto(0,36,[…………])
I did it using inventory controls lemme search the video
found it
@steep crystal that's is actually really cool how thats works. But how can I view the database storage that I transferred my items too?
Do I have to spawn the storage entity in front of the player?
what?
He’s asking how to retrieve stored items
const key = player.id + "_backpack"
// you can use whatever you want this is just an example of key
const items = database.has(key) ? database.get(key) : [];
the database automatically does it
it automatically spawns the entity and gets the items
Okay nice let me try it out
import { QIDB } from "./QIDB.js";
const Backpacks = new QIDB("Backpacks", 10, 1)
function getBackpackItems(backpackId) {
return Backpacks.has(backpackId) ? Backpacks.get(backpackId) : []
}
function updateBackPackItems(backpackId, newItems) {
Backpacks.set(backpackId, newItems)
}
I've made a TypeScript version of this database in case someone is using that.
It's not exactly the same; it's a bit more strict on what you can do:
- You must have a namespace
- The return type for
getis onlyItemStack[], not singleItemStackinstances
The intellisense comments will also tell you more about what's happening in the background.
https://github.com/Aevarkan/item-database
Also linked on the first message #1252014916496527380 message.
why are you promoting this here, this is totaly a different thing
Well, it's also a database.
but why do you need to send the message here
If someone asks for apples, let's talk about bananas, after all, they're fruits, right? 
Right
bruh
piggybacking off of an established database post to advertise ur own entirely different one is shitty behaviour
and uve been doing this in a couple of these threads
I don't think this is an advertisement.
just posting a link is still promoting no matter what u say. dont promote ur lib in other peoples threads
it is
who pinged me and deleted the message?
can this store potion types and items with can_place_on and can_destroy
and multiple inventory saves for multiple players
Can save anything, no limits on types and no limits on quantity
The only limit on this database is how you use it
can i ask you some questions if you dont mind:
- how can you save the armor slots and offhand, as i tested my kit editor code and it doesnt save the armor and offhand
- why you limit key.length to <= 30
maybe my 1st question is my bad at coding, but can you explain the 2nd question
i managed to fixed my kit editor code! This db is the best!!!
ill test more if that supports multiplayer as well
1 the database just saves items it’s up to you to get the items and give them to the database, you have the 256 slots on a key you can add the 36 inventory slots and also get the 5 equippable slots after the 36th
2 the limit is 30 becouse I’m using Minecraft structures to save items since it’s the most efficient reliable and keeps all the data in the items and Minecraft uses a 30 character limit on structure ids
If you use player.id in the key you have the key id matching the player id so you know who’s inventory is that
so if i understand it right, i can have unlimited players, each having unlimited kits (inventories saved), as long as each kit is under 36 slots limit of total items right
Nope you can go up to 256 items without having performance issues but if you really need you can also use 1024 items in a key but it takes 4x the time to load
alr ill do more test bout that. thanks
No problem
this saves lots of time for me doing the kit editor stuff
Is there a reason you're setting the dynamic property to null instead of undefined to remove them? Update 1.21.40 had this in the changelog:
- Removed function removeDynamicProperty - Please use setDynamicProperty with a value of undefined to remove a property
Has there been a change I'm not aware of?
In the .setDynamicProperty() function, trying to set undefined doesn't actually remove the value. It works and actually removes the Key, only when, setting it to null OR you can just leave the parameter and don't fill it up, like world.setDynamicProperty("key") and the value will be deleted.
@steep crystal Hi, is there any way to avoid using the ticking area in the database? For example, using the spawn area.
yes but you need to select an area that is ALWAYS ticking
whats wrong with https://github.com/smell-of-curry/bedrock-item-database ?
Im wondering which I should use
my database (even Aevarkan's version) work with
+ structures: They dont impact the in real time performance becouse are saved into your drive and not RAM.
+ uses entities with 256 slots, keys have Array values so it can handle 1024 different itemStacks per key (4 entities per key).
+ more control on cache management
+ more control on saving speed
- doesnt save metadata for the item, you'll have to do it by yourself with dynamic properties or itemStack lore.
smell of curry's database:
+ you can set your metadata of the items easily
- doesnt use structures, entities are always loaded in the world increasing constant ram and cpu usage.
- uses entities with 200 slots and each key is paired with only 1 item, so you'll end up calling lot of times the database (not efficient).
if your database does not save metadata why would anyone use your db?
what would you need metadata for?
also 35 people liked the post so i think someone there is
It's going to be very useful for storing items to rollback (like how you can do in Core Protect). That's what I'm currently working on, and the reason I made a TypeScript version.
cheated enchantments?
or isnt this metadata?
no it isnt
whats metadata in items
metadata is the data for like shops or auctions where you put the price, the seller name and the date where you put the item
you could just simply say dynamic properties
that's something different
you cant link a dynamic property to an item that can have more than 1 item in the stack
I'm not sure why you pinged me; I haven't seen that database before.
doesnt change the fact that you could still save that data using dynamic property
btw in the future if someone asks simple questions avoid answering in a passive aggressive way please
i also never
yes? that's what i suggested to do
am i being aggressive?
Since you're here, I do have a question: how come you're using async?
idk i started making the database when i was a complete beginner so i thought that if i did async the function would ran like its in a runjob and i never changed it
35% of the current database is wrote like garbage when i was beginner but it works so i never changed it
If it doesn't break, I'll remove the async since it's preventing me from running a structure command.
i think ill have to completely remove it its just useless doesnt do anything
you dismissed my message, I said you could simply say dynamic properties and you said it is something different.
I said "passive aggressive" not "aggressive"
becouse it is something different
metadata = data that the item has to know is price etc
dynamic properties are a way to store metadata
maybe we re just trying to say the same thing in 2 different ways
yeah probably a language barrier
youre contradicting yourself so probably
where?
i was just saying that
item.setDynamicProperty() is wrong becouse the stack size limit
but
world.setDynamicProperty("item_X:metadata") is rightg
you said that dp is something different than metadata but then said dynamic properties are a way to store metadata
that's what i meant to say,
dp != metadata
dp = method to store metadata
Okay, structures are interesting. I am going to ask him about that.
Also, why did you use 256 slots in the entity's inventory component? What is the true max?
His DB saves instantly so wdum more control on save speed?
Also, what do you mean each key is only paired with 1 item? Let's say you have an item saved to a key like some-cool-item, you call the DB to retrieve that item, and the DB:
- Checks the cache to see which entityId stores that itemId
- Fetches the item from that entity and returns it.
How is that not efficient?
the true max is 256,
its the same with 1 item but take a look at saving 200 items
in my database you just call the database 1 time db.set("items", items),
in the other database you have to call it 200 items
and that's not something that is small its 200x more performance heavy
wdum call 200 times? You just call await testItemDB.setItem(itemStack, { id }); which you can see in the tests? If its a new item it first trys to add it to a entity with a empty slot, if none is found it create a new entity and sets it on it. Creating infinite storage.
im saying for 200 items
Yeah I am confused how its 200x more performance. heavy?
Also, wouldn't loading in a structure to fetch an item, then loading it out later to be loaded in again, be inefficient as in a server that is fetching items every second that would be a lot of unnecessary calls to the structure API?
But structure managment would be good in a backup sense
nope, there is cache memory, and also 1024 items = 1 structure, so it isnt a big deal and minecraft structures are pretty fast
couse for saving 200 items in my database is
const items = [itemStack........ x200]
db.set("my_items", items) // this runs 1 time
saving 200 items in the other database is
const items = [itemStack........ x200]
for (let i = 0; i < 200; i++) {
db.addItem(`item_${i}`,items[i]) // this runs 200 times
}
How many blocks are needed?
For example, can I use the player's spawn chunk?
just 1
depends if the players spawn is ticking ALWAYS
Perfect
I thought it covered a larger area
ohhhh I see what your saying
interesting, so you store a key->items relationship not a key->item
Were you using any of the dynamic property values? I can't find any getDynamicProperty calls that actually use the value.
I only found
if (world.getDynamicProperty(key)) { this.#quickAccess.set(key, items); return items }
else { this.#quickAccess.set(key, items[0]); return items[0]; }
which I replaced with
this.quickAccess.set(fullKey, items)
return items
Was that just for returning a singleton versus an array?
Apologies if this feels overly critical, but I need to know how the database works before I can use it in my add-on.
Yeah if you set the value not using an array it will end up returning the item without array with the .get method
I see, in that case I won't add that functionality back into my version.
Having it return both arrays and singletons is too confusing.
Wait if you re editing the 1024 itemStack per key version dynamic properties are important since it needs to know how many entities to spawn
I only saw getDynamicProperty inside the get method. I didn't see the values being used elsewhere. The properties themselves I still have, but only the keys are used.
Yes, setDynamicProperty, but I didn't see anywhere else getDynamicProperty was being used.
Doesn't it spawn the entities by counting the length of the array? And then spawns more if it's larger than 256.
Anyone tried apply impulse in the new preview?
This is NOT the post to be asking about that 😭
Oh, how did i get here, lol
honestly its 3 months that im not touching the code i dont remember, all the code needs a rewrite becouse its too messy to read
I did rewrite quite a lot of it for my version. There aren't that many functional changes - I mostly added documentation to all the different methods so it'd be less confusing for me to use.
https://github.com/Aevarkan/item-database/releases/tag/v1.0.0
I could make a pull request from mine if you'd like, but I'll have to fork the original JavaScript version so there won't be too big of a diff - unless if you're fine with a really big diff.
are there any differences between v3.9.0 and aevarkan's one
Comments mostly - if you're using IntelliSense they'll come into use, otherwise not really.
The changes that are there include:
- return type for
getis an array only, not single instances - namespace has more restrictions
- scoreboard is not used (that's why there's a namespace restriction)
Basically stuff that makes it more compatible with other add-ons. If you're not using it for something major, there won't really be a difference.
Since I'm using it for an add-on that has major effects on a world, it has to be safe (by either limiting global pollution, or by clearly documenting all side effects). That's why I made my version in the first place.
Hello,
Approximately how many items and how many different keys can I create in the database without causing lag or errors? @steep crystal
There isnt a specific quantity, items are saved in your drive so the more items you store the more memory your world is going to use, so if you save large quantity of items like 1 million items you will end up with a world that uses 5GB of space in your disk
the lag is just opening the world that will take a while after too much items
Wow, that's quite a lot. I thought there was a limit, but now I see there isn't.
Well, I think that's not a serious problem.
it isnt
it is
because the world wont start if it takes too much time
the best you can do is limit the data or delete the old data
Of course, but I don't think it will ever have that magnitude of items, 1 million would take a long time to store that amount.
Exactly, that's why I say that I don't think I can reach that amount of items
:D.
@steep crystal hey can using qidb in two seperate addons cause items to vanish, the items from 1 addon remains after start but from the other, it vanishes after restart
have you used different namespaces?
different namespaces means that the items stored in an addon will not be accessible on the other one
Ok
@steep crystal how i can use this for anything? like saving for players with 2 diffrent saves, entity saves
also it is lattest-beta or lattest?
what do you mean it saves items, you will have to make the script to save player items
what does this mean?
if its about the version i honestly dont even know i dint touch that for 5 months
saving players items with different 2 saves like skygen save survival save
also i m thinking to do for backpack entity
you can save whatever you want, the database saves items, context doesnt matter.
it is works on 2.20-beta api?
i think idk i didnt test but should if there arent no major changes
beause i m gonna use for my bedrock server
.
two diffrent items saves
skygen and survival
beause using custom private shulker entities looks amazing but when someone doesnt read command blocks has go back to lobby (clears inv) all items are rip
i dont know how this works too
@steep crystal
in 2.2.0-beta api?
also how this work and how i can use for 2 inventory saves like skygen save survival save
@steep crystal @novel mural script is broken
Compiler found 4 errors:
[36mQIDB.js[0m:[33m47[0m:[33m36[0m - [31merror[0m[30m TS2339: [0mProperty 'isOp' does not exist on type 'Player'.
[7m47[0m if (player.isOp) {
[7m [0m [31m ~~~~[0m
``````ansi
[36mQIDB.js[0m:[33m171[0m:[33m19[0m - [31merror[0m[30m TS2304: [0mCannot find name 'Container'.
[7m171[0m /**@type {Container[]} */
[7m [0m [31m ~~~~~~~~~[0m
``````ansi
[36mQIDB.js[0m:[33m194[0m:[33m92[0m - [31merror[0m[30m TS2322: [0mType '"World"' is not assignable to type 'StructureSaveMode'.
[7m194[0m world.structureManager.createFromWorld(key, this.#dimension, this.#sL, this.#sL, { saveMode: "World", includeEntities: true });
[7m [0m [31m ~~~~~~~~[0m
[36m@minecraft/server.d.ts[0m:[33m21538[0m:[33m5[0m
[7m21538[0m saveMode?: StructureSaveMode;
[7m [0m [36m ~~~~~~~~[0m
The expected type comes from property 'saveMode' which is declared here on type 'StructureCreateOptions'
``````ansi
[36mQIDB.js[0m:[33m334[0m:[33m9[0m - [31merror[0m[30m TS2322: [0mType '(ItemStack | ItemStack[])[]' is not assignable to type 'ItemStack[][]'.
Type 'ItemStack | ItemStack[]' is not assignable to type 'ItemStack[]'.
Type 'ItemStack' is missing the following properties from type 'ItemStack[]': entries, keys, values, includes, and 35 more.
[7m334[0m return values;
[7m [0m [31m ~~~~~~[0m
Send console logs and script
Just dm me, don't flood here :/
Those are logs from TSC
You haven't updated pack to the latest version.
i tried new version on 2.20-beta
Player.isOp is not a thing, there's a new permission system.
I don't use tsc so welllllllll 🙁
I did make a TypeScript version a while back, although I'm not sure if it'll be error free for 2.2.0-beta. The logic doesn't really change much, it's just more explicit. There are minor changes though. I removed that isOp completely from my version.
#1252014916496527380 message
I've just checked on 2.2.0-beta.1.21.102-stable, and the only errors were coming from // @ts-expect-error. You can safely remove that; I put those two lines there in the first place to suppress an error popping up in a different version.
it is from jayly's debugger
u can give me?
oh it is type script nevermind
i going to remove isop thing
I thought you were using TypeScript? The errors you posted are TypeScript errors. None of those errors break the database itself.
How to know if the db it's ready to use
if it is the first time at least 1 player needs to be valid in the world for the db to start
if it isnt the first time just wait for the world to load
@faint grotto
In the world there is a command block command that runs before the db and causes the data to be deleted, I make sure to accept the command only after 3 seconds of the world loading, to be sure
@steep crystal
Ok
Hi @steep crystal do you know why this error occurs
[Scripting][inform]-§aQIDB > Set key PlayerShop:Plund_mgeyo28y succesfully. 2ms §r10/06/2025, 10:01:23.556 AM
[Scripting][inform]-§eQIDB > Saving, Dont close the world.
§r[Stats]-§eRemaining: 1 keys | speed: NaN keys/s §r10/06/2025, 10:01:23.726 AM
[Scripting][inform]-1
[Scripting][error]-Unhandled promise rejection: InvalidArgumentError: Invalid value passed to argument [0]. 'qidb:storage' is not a valid entity type. at #load (db/QIDB.js:167)
at #romSave (db/QIDB.js:204)
at <anonymous> (db/QIDB.js:110)
[Scripting][inform]-§aQIDB >Saved, You can now close the world safely. §r10/06/2025, 10:01:23.745 AM
You have to put also the entity in your addon
This script needs bug fixes
I use an older modified version of this addon, workss great!
Definitely needs to be updated. I've been updating it on my own
You guys can fork the github and share it here to make it work better
Can you share
^ someone fork it 🙏
From just checking with the latest npm packages, I didn't see any new errors pop up in regards to before.
I don't believe any update has broken this, unless if it's breaking in-game (I didn't check in-game). I've only checked my fork, however.
anyone does have javascript version?
you solve this issue yet? its probably not even the database issue soemthing else
you need to import the full script in the worldLoad
from another file is easier
yep, I've made another thread on script-api channel and someone pointed out the issue
Yeh thats a privilege error, most commonly now arising from the release of script api ver 2. With the change to adding early execution
do i have to handle, when a certain item (parent key) is deleted from world to delete from the database? Or is it already covered by this @steep crystal ?
Like for example, a backpack item that holds a parent key with dynamic property. When this backpack item is destroyed either from fire, lava, cactus, explosions, etc.
Since I'm concern if let's say i have a 500+ backpack item which has an individual items saved from this database, and without garbage collection which could affect the performance of the game.
Great package, btw. I'm using it rn with my big project
Just need to clarify some stuffs, if should I implement this, or is this technically not a problem for performance in the long run.
Cause, if it's not really a problem, then I'll probably waste some time trying to implement the edge cases.
obviously no, the database its just a Map (string to items) it will not know if the backpack exist or not
in the database the key its just a string, not a property of another "parent" item .
just to clarify, its just a database and its up to you to create the logic and the linkage to the database
the parent key you re refering to isnt an object, its linked to a string (sequence of characters)
its like the difference between Map and WeakMap, and in this case the database works like a map
Ah okay, got it. Thank you @steep crystal for this.
would this cause lag for realms and servers
it can if you save too much data every second
but i think i'll rebuild it from zero with the skills i currently have, couse i made this when i was a beginner
i think i'll make this as a separate pack to dowload to handle all the dependencies
to avoid pack data conflicts
I'm talking like light usage for example just one db is set for one inventory that works for each player
U should be fine
looking forward to it

where the latest?