Optimisation
GaspardCulis opened this issue ยท 3 comments
Hi, love your tool !
But I'd suggest a more optimised method (to me) that hasn't to check a bunch of things in the same tick.
You are currently checking the in hand item of the player each tick, but I'd rather use advancements, especially the "item_used_on_block" criteria, see example :
{
"criteria": {
"requirement": {
"trigger": "minecraft:item_used_on_block",
"conditions": {
"item": {
"tag": "minecraft:music_discs",
"nbt": "{tag:{jaajMusic:"truck"}}"
},
"location": {
"block": {
"blocks": [
"minecraft:jukebox"
]
}
}
}
}
}
}
I think it could work and use less performance, would work for playing, but i have no idea for stopping
I thought about switching to advancements but decided against it for some reason. I think it had something to do with reliability, like the advancement-based detection couldn't handle as many edge cases as the scoreboard-based detection.
But maybe things have changed since then! I'll take another look when I get around to rewriting the datapack.
The rewritten datapack uses advancements to register jukeboxes with the datapack, so they can detect if they contain a custom music disc (placed by player, hopper, dropper, etc). I would have liked to trigger all the datapack logic using advancements, but now you can insert discs with hoppers so the jukeboxes have to monitor for a disc to get placed.
I also removed a lot of @a selectors and entity NBT checks in the per-tick logic, hopefully it ends up being faster.