#on right click item uses twice, how to fix? also, i need to add requirement of click amount

32 messages · Page 1 of 1 (latest)

raw magnet
proper mantleBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

maiden umbraBOT
#

Paste version of server.log, world_interacting.js from @raw magnet

foggy elm
sharp bison
#
if (e.hand != "MAIN_HAND") return```
#

theres 2 kinds of people out there i see

raw magnet
#

what is better?

#

optional?

sharp bison
#

they're both the same

#

also you probably want to change it to e.hand in this case since the var is e and not event

raw magnet
#

yooo, it works now, thx

#

but what about requirement of click amount?

sharp bison
#

do you want it to have a random chance to fail or require a certain amount of right clicks for it to happen?

raw magnet
#

certain amount pls

sharp bison
# raw magnet certain amount pls

try this js BlockEvents.rightClicked(e => { const { block, hand, player, facing } = e if (hand != "MAIN_HAND") return let item = player.mainHandItem if (item.count > 0 && item.id == 'minecraft:bone' && block.hasTag('forge:stone')) { if (!player.persistentData.KnapTime) player.persistentData.KnapTime = 0 if (player.persistentData.KnapTime >= 3) { block.popItemFromFace('kubejs:bone_shard', Math.random() * 2), facing player.swing() item.count-- player.persistentData.KnapTime = 0 } player.persistentData.KnapTime++ } })

raw magnet
#

It's like random doesn't work

sharp bison
sharp bison
#

and if that doesnt work then try this one js let random = (Math.random() * 2).toFixed(0) + 1 block.popItemFromFace(Item.of("kubejs:bone_shard", random), facing)

green cloak
#

amount has to be an int

#

1-64, not 0-1

sharp bison
sharp bison
sharp bison
raw magnet
#

@sharp bison what is knaptime?

#

does kubejs have it?

sharp bison
#

its the name of the persistent data we're labeling on the player, it can be anything, i named it KnapTime to keep it consistent with the overal premise of the script so nobody gets confused

#

think of it as a custom nbt tag

raw magnet
#

after much agony, I finished the script

#

BlockEvents.rightClicked(e => {
if(e.player.mainHandItem.id == 'minecraft:bone') {
if (e.hand != 'MAIN_HAND') {
if (e.block.hasTag('forge:stone')) {
e.player.swing("main_hand", true)
if (!e.player.persistentData.bKnapTime) {
e.player.persistentData.bKnapTime = Math.floor(Math.random() * (7 - 3) + 3)
}
e.player.persistentData.bKnapTime--
if (e.player.persistentData.bKnapTime == 0) {
e.player.mainHandItem.count--
e.block.popItemFromFace(Item.of('kubejs:bone_shard', Math.floor(Math.random() * (3 - 1) + 1)), e.facing)
}
}
}
}
})