I run a server with, among many other thins, enhanced celestials. I made a token that I want to use to start blue moons. I already wrote a function that sets the time to the beginning of night, then starts a blue moon. I also have it so that the item executes the function via right-click. I was wondering what the easiest way would be to get the item to disappear after being used, and also to only be usable in the overworld.
#Right-Click, Consume Item
85 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
ItemEvents.rightClicked("kubejs:celestial_token",event=> event.server.runCommandSilent("function nivs:bluemoon") )
I have tried a few things to get it to get rid of the item, but I haven't gotten any to work, and I guess I don't know where to start to get it to only work in the overworld
event.item.count--```
would that delete the whole stack? Or do I set the count to something like -1?
-1
ayyy, im starting to get it 😄 thanks
any ideas for making it only work in the overworld?
if (event.level.dimension == "minecraft:overworld")```
huh, thats somehow both simpler than I anticipated, yet about as simple as I should have expected it to be
code is funny that way, im still rather fresh into this, thanks a bunch
ItemEvents.rightClicked("kubejs:celestial_token",event=> event.server.runCommandSilent("function nivs:bluemoon"), event.item.count(-1) )
does it matter where I put the 'if', phrase?
whered you get .count(number) from?
not count(-1)^^
just like this:
ItemEvents.rightClicked("kubejs:celestial_token", event => {
if (!event.level.dimension == "minecraft:overworld") return
event.server.runCommandSilent("function nivs:bluemoon")
event.item.count--
})
its count--
actually it'd be like js if (event.level.dimension != "minecraft:overworld") return

it should works booth way^^
what no
doing !event.level.dimension would default to (event.level.dimension == undefined)
then you'd be detecting if undefined equals "minecraft:overworld"
okay, that makes sense to me, thanks a bunch, I tried to figure this out for like 2 hours last night, and while I'm proud of how far I got by myself, it would have taken me A WHILE to get this far alone.
learning is a process lmao
thanks again
Ticket re-opened!
sorry to be a bother, but I have tried like 20 different ways and clearly something is going over my head
if I also wanted this to play a sound, would this be correct?
ItemEvents.rightClicked("kubejs:celestial_token", event => { if (!event.level.dimension == "minecraft:overworld") return event.server.runCommandSilent("function nivs:bluemoon") event.item.count-- player.playSound("block.amethyst_block.step", 1.0, 1.0) })
^
like i said before his implementation is wrong
as for the playsound it should be like so #1294898796798545982 message
oh, that part was working fine, but I can update it regardless in case it is causuing issues down the line
[➤](#1294898796798545982 message)
try this js player.level.playSound(null, entity.x, entity.y, entity.z, 'kubejs:red_hands_teleport', 'hostile', 1, 0.5);
well no it doesnt work though, not for me at least
does nothing
it should be not consuming the diamond if you're in the nether for example @uncut island
oh, you know what, dont htink i remembered to even check other dimensions when I said it was working the other way, I was just excited they were consuming properly in the overworld and didnt fully test
ItemEvents.rightClicked("kubejs:celestial_token", event => { if (event.level.dimension != "minecraft:overworld") return event.server.runCommandSilent("function nivs:bluemoon") event.item.count-- player.level.playSound(null, entity.x, entity.y, entity.z, 'minecraft:block.amethyst_block.step', 'block', 1, 0.5);
does the "null" need to be replaced with something specific?
thats the player, it should be null so it plays wherever the set coordinates are
its weird logic i know 
I mean, thats the "cool" thing about this stuff, its weird, but there is a method to the madness
I will know the method eventually >.<
Paste version of item_events.js from @uncut island
well thats the whole file, is that pooking proper? because I still don't hear anything
hmm
entity isnt defined
should be event.entity
you can also define it at the start of the event with js let entity = event.entity
Paste version of item_events.js from @uncut island
still silent 😦

player is also not defined anywhere
if it doesnt connect to event keyword somehow its probably undefined
I see, what is the best way to define it?
Paste version of item_events.js from @uncut island
bah, still silent lmao
I expected this to be the easy part DX, was just gonna be icing on the cake after getting the rest going
thanks for bearing with me though
??kjslogs
You can find your KubeJS server log in /minecraft/logs/kubejs/server.log.
If you are on 1.18 or 1.16 it will be called server.txt.
Please send it if asked, as it contains helpful information.
send me that
Paste version of server.log from @uncut island
I could clean that up, im in a test instance and some of that is clutter from other things I had tested
ah its blocks not block
event.player.level.playSound(null, event.entity.x, event.entity.y, event.entity.z, "minecraft:block.amethyst_block.step", "blocks", 1, 0.5);
you were close