#How would I create a cooldown for drops with Kubejs
10 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
would have to use lootjs
id also attach the timer to the killing entity, so that its per player
that would also require the player tick event to decrease it tho. which is getting rather complex
LootJS is an addon for KubeJS that allows modifying loot from all sources dynamically (much nicer than loot tables)!
It also supports removing loot added by mods, unlike KubeJS' current loot table events.
You don't need the tick event. Just store the Gametime. Then you can use apply from lootjs to check for the current Gametime if the delta between the two gametimes is > 15 seconds. If yes, add loot and store the Gametime again.
ah yeah, that works too
So at my PC now. Probably something like this
let lastCheckedGameTicks = 0;
let DELTA_TIME = 20 * 15; // 15 seconds
LootJS.modifiers((event) => {
event.addLootTypeModifier(LootType.ENTITY).apply((ctx) => {
let gameTicks = ctx.server.tickCount;
if (gameTicks - lastCheckedGameTicks > DELTA_TIME) {
lastCheckedGameTicks = gameTicks;
ctx.addLoot("minecraft:diamond");
}
});
});
@rain mirage Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!
Sorry I know this was forever ago that you sent it and the script works great. Im just wondering what I would add to it in order to make the item have a chance of dropping every 15 seconds, not a 100% chance of a drop every 15 seconds. I've been looking through the Lootjs and Kubejs wikis to try and find an answer but I havent been able to add one without my game crashing. I have tried doing ctx.addWeightedLoot, and adding .randomChance(.03) after the item but it doesnt work. Any more help would be appreciated greatly, especially since I am really not good at Kubejs haha
@rain mirage Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!