#Block interaction (opening new cause bot clutter)

31 messages · Page 1 of 1 (latest)

acoustic obsidian
#

Hello, just reposting my issue cause I still haven't gotten advice other than changing the value in the let random chain.

Here is the code I am working with in the current 1.20.1 version of Kube, I have base, additions, utils, and packages.

BlockEvents.rightClicked(event => {
 if (event.hand != "MAIN_HAND") return 

 if (event.item.isEmpty() || !event.item.hasTag("forge:shears")) return 

 if (!event.block.hasTag("tardis:roundel_tab")) return 

 if (!event.player.isShiftKeyDown()) return 

let loot = [ 
    "minecraft:redstone",
    "tardis:xion",
    "ae2:fluix_crystal",
    "mekanism:basic_control_circuit",
 ] 

let random = Math.floor(Math.random() * 1 * loot.length)
let chosen = loot[random] ? loot[random] : "minecraft:charcoal" let dropItem = Item.of(chosen) 

event.block.popItemFromFace(dropItem, event.facing)
event.player.damageHeldItem(5)
event.player.swing() })

the main problem is that Kube is not giving me any actionable errors, it just says
"reload failed; keeping old data"
"Reloaded with no KubeJS errors!"
it feels like i heav read those dang messages hundreds of times at this point.

I have included the server script log but I am not sure how it would help.

covert lodgeBOT
#

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

languid talonBOT
#

Paste version of server.log from @acoustic obsidian

twilit kite
#

@acoustic obsidian damageHeldItem takes in 2 arguements js event.player.damageHeldItem("main_hand", 5)
the one youre calling doesn't exist

#

also side note, your random equation doesnt need the x1, its redundant

let random = Math.floor(Math.random() * loot.length)
#

one more thing you'll want to do if all that doesnt work is surround your || operand in your 2nd return statement with parenthases like so, this way it checks it as one boolean value js if ((event.item.isEmpty() || !event.item.hasTag("forge:shears"))) return

#

one last thing is you can simplify your chosen variable like so js let chosen = loot[random] ?? "minecraft:charcoal"

acoustic obsidian
#

@twilit kite so something like this?

BlockEvents.rightClicked(event => {
 if (event.item.isEmpty() || !event.item.hasTag("forge:shears")) return 
 if (!event.block.hasTag("tardis:roundel_tab")) return
 if (!event.player.isShiftKeyDown()) return 

let loot = [ 
    "minecraft:redstone",
    "tardis:xion",
    "ae2:fluix_crystal",
    "mekanism:basic_control_circuit",
 ] 

let random = Math.floor(Math.random() * loot.length)
let chosen = loot[random] ?? "minecraft:charcoal" 

event.block.popItemFromFace(dropItem, event.facing)
event.player.damageHeldItem("main_hand", 5)
event.player.swing() })
#

it is still failing to load

twilit kite
#

hmm

#

are there any other scripts/events in your server scripts?

#

also make sure your tags are correct and that they exist

#

also what editor are you using to find syntax errors, vsc?

twilit kite
acoustic obsidian
#

@twilit kite my appologies, did not get the notification your message had come in.

#

I did implement most of what you said, I accidentially copied over the wrong version, (I was initally using notepad, but switched to VSC)

#

and VSC isnt showing any syntax errors.

#

here is a picture with the block tag

twilit kite
#

i think thats an item tag

#

do /kjs hand while holding it to make sure

#

another thing to do is to console.log("test") in various places in the script to see exactly where it fails

acoustic obsidian
#
[22:17:23] [INIT] KubeJS 2001.6.5-build.16; MC 2001 forge
[22:17:23] [INIT] Loaded plugins:
[22:17:23] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgePlugin
[22:17:23] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgeClientPlugin
[22:17:23] [INIT] - thedarkcolour.exdeorum.compat.kubejs.ExDeorumKubeJsPlugin
[22:17:23] [INIT] - com.almostreliable.kubeio.kube.KubePlugin
[22:17:23] [INIT] - com.xiaohunao.createheatjs.KubeJSCreatePlugin
[22:17:23] [INIT] - com.oierbravo.createsifter.compat.kubejs.KubeJSCreatesifterPlugin
[22:17:23] [INIT] - dev.bluephs.vintage_grinder.compat.kubejs.VINTAGEKubeJSPlugin
[22:17:23] [INIT] - dev.latvian.mods.kubejs.create.KubeJSCreatePlugin
[22:17:23] [INIT] - qinomed.kubejsdelight.KubeJSDelightPlugin
[22:17:23] [INIT] - com.probejs.ProbeJSPlugin
[22:17:23] [INIT] - com.blakebr0.cucumber.compat.kubejs.CucumberKubeJSPlugin
[22:17:23] [INIT] - com.klikli_dev.theurgykubejs.kubejs.TheurgyKubeJSPlugin
[22:17:23] [INFO] Loaded script server_scripts:mods/exdeorum/pebbles.js in 0.024 s
[22:17:23] [INFO] Loaded script server_scripts:mods/tardis/roundel.js in 0.002 s
[22:17:23] [INFO] Loaded 2/2 KubeJS server scripts in 0.223 s with 0 errors and 0 warnings
[22:17:23] [INFO] Scripts loaded
[22:17:40] [INFO] Server resource reload complete!
#

@twilit kite is it possible that kube just isnt compatable with the New Tardis Mod?

twilit kite
#

huh

#

why wouldnt it be?

#

you should try troubleshooting with console.log before giving up on it

#

one thing to understand about kubejs is that it interacts with mods through rhino, rhino accesses fields and methods the same as other mods are able to. its not a matter of compatibility, id say its a matter of one of your checks not passing

acoustic obsidian
twilit kite
#

well there you have it

#

glad you figured it out

languid talonBOT
#

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue!
This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You should create a new post for unrelated issues.