#How do I make an if statement to check for an item's nbt? 1.19 Forge

35 messages · Page 1 of 1 (latest)

river arrow
#

I have searched everywhere in this discord and cant get it to work

signal ingotBOT
#

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

river arrow
#

ItemEvents.rightClicked('minecraft:paper',{display:{Name:'["",{"text":"The Storm","italic":false}]',Lore:['["",{"text":"Right-Click to Play","italic":false}]']}}, event => {

event.server.runCommandSilent(say sex)

event.server.runCommandSilent(execute at @p run openguiscreen Vision-1)
//title ${event.entity.username} {"text":"stage change detected"}`)

})

#

this doesnt work

#

ItemEvents.rightClicked('minecraft:paper', event => {
const item = event.getItem();
const nbt = item.getNbt();
const nbt2 = {display:{Name:'["",{"text":"The Storm","italic":false}]',Lore:['["",{"text":"Right-Click to Play","italic":false}]']}};
event.server.runCommandSilent(say sex)

if (nbt == nbt2) {
event.server.runCommandSilent(execute at @p run openguiscreen Vision-1)
}
//title ${event.entity.username} {"text":"stage change detected"}`)

})

#

nor this

#

nor a bunch of other stuff i tried

#

because 1.19 doesnt recognize half the damn methods i found in search

#

and this mod has zero goddamn documentation

lyric sable
#

try this

ItemEvents.rightClicked('minecraft:paper', e => {
  const nbt = `{display:{Name:'["",{"text":"The Storm","italic":false}]',Lore:['["",{"text":"Right-Click to Play","italic":false}]']}}`

  if (e.item.nbt == nbt)
    e.server.runCommandSilent('execute at @p run openguiscreen Vision-1')
})
river arrow
#

i got it to kinda work with /clear but you have to clear the item to make sure the nbt matches lol

#

ItemEvents.firstLeftClicked(enigmaticlegacy:enigmatic_eye,event => {

// event.server.runCommandSilent(say sex)

if (event.server.runCommandSilent(execute as ${event.player.name.string} at @s run clear @s enigmaticlegacy:enigmatic_eye{display:{Name:'["",{"text":"The Storm","italic":false}]',Lore:['["",{"text":"Left-Click to Play","italic":false}]']}})) {
event.server.runCommandSilent(execute as ${event.player.name.string} at @s run openguiscreen Vision-1)
}

river arrow
#

other than clear

lyric sable
#

try debugging the method i wrote, as it should work
see what the actual nbt shows up as in the kjs logs and manually compare them to see if something is off

river arrow
#

you did write this method for 1.19 forge right?

#

just making sure cuz it doesnt show any errors but idk a lot of methods on 1.19 straight up dont work

#

ItemEvents.rightClicked('minecraft:potion', e => {
const nbt = {Potion: "friendsandfoes:reaching"}
e.server.runCommandSilent('say sexy')

if (e.item.nbt == nbt)
e.server.runCommandSilent('say sex')
})
did this code and this is all thats in the latest log

#

theres nothing in the kubejs log

#

maybe the gl errors are it?

#

OH IT WORKS

#

i did /kubejs hand it the nbt didnt have a space in it LMAO

#

ty!!

river arrow
#

but this doesnt

ItemEvents.foodEaten('minecraft:potion', e => {
//drinkcd
const nbt = {Potion:"friendsandfoes:reaching"}

if (e.item.nbt == nbt){
  e.server.runCommandSilent('say sexy')

  e.player.addItemCooldown("minecraft:potion", 3600)
}

})

#

im assuming the foodeaten event doesnt track the corresponding item to give a cooldown to?

#

also idek where to begin for only giving cooldowns to that specific potion nbt

#

and not all potions

#

I guess i could do a scheduleinticks for 32 ticks which is how long it takes to eat the potion but that also means you can just click it and not drink and get that cd

graceful coralBOT
#

You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes

```js :arrow_left:

ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})

``` :arrow_left:

This example will look like this:

ServerEvents.recipes(event => {
  event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
lyric sable
#

did you debug it to see if it gets called and what it does?

river arrow