#checking nbt of armor and canceling an event

25 messages · Page 1 of 1 (latest)

magic bronze
#

i have this script here which applies radiation to a player when they get near a certain distance, i tried but didnt find a way on how to make it nbt specific, only working version is with item ids

onEvent("player.tick",event => {
    let player = event.player
    if (player.ticksExisted % 20 != 0) return
    if (player.headArmorItem == 'tconstruct:slime_helmet' && player.chestArmorItem == 'tconstruct:slime_chestplate' && player.legsArmorItem == 'tconstruct:slime_leggings' && player.feetArmorItem == 'tconstruct:slime_boots') return
    let radioactiveBlockPos = BlockPos.findClosestMatch(player.block.pos, 3, 3, pos => event.level.getBlock(pos).hasTag("forgedingears:radioactive"))
    radioactiveBlockPos.ifPresent(() => player.potionEffects.add('kubejs:radiation', 21, 2, false, true))
    if (player.inventory.find("#forgedingears:radioactive") > -1) player.potionEffects.add('kubejs:radiation', 201, 3, false, true)
  })
agile dustBOT
#

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

drifting flume
#

so this is working with item ids, right?

magic bronze
#

yes but havent found a way to make it work for nbt

drifting flume
#

i see

#

can you post again a sample item with may have the nbt?

magic bronze
#
Item.of('tconstruct:plate_helmet', '{Damage:0,tic_broken:0b,tic_modifiers:[{level:1s,name:"tconstruct:embellishment"}],tic_persistent_data:{abilities:1,defense:5,"tconstruct:embellishment":"forgedingears:element_zero",upgrades:2},tic_stats:{"tconstruct:armor":2.0f,"tconstruct:armor_toughness":2.0f,"tconstruct:durability":440.0f,"tconstruct:knockback_resistance":0.05f},tic_upgrades:[{level:1s,name:"tconstruct:embellishment"}]}')

Item.of('tconstruct:plate_chestplate', '{Damage:0,tic_broken:0b,tic_modifiers:[{level:1s,name:"tconstruct:embellishment"}],tic_multipliers:{"tconstruct:attack_damage":0.4f},tic_persistent_data:{abilities:1,defense:5,"tconstruct:embellishment":"forgedingears:element_zero",upgrades:1},tic_stats:{"tconstruct:armor":6.5f,"tconstruct:armor_toughness":2.0f,"tconstruct:attack_damage":0.0f,"tconstruct:durability":640.0f,"tconstruct:knockback_resistance":0.05f},tic_upgrades:[{level:1s,name:"tconstruct:embellishment"}]}')

Item.of('tconstruct:plate_leggings', '{Damage:0,tic_broken:0b,tic_modifiers:[{level:1s,name:"tconstruct:embellishment"}],tic_persistent_data:{abilities:1,defense:5,"tconstruct:embellishment":"forgedingears:element_zero",upgrades:1},tic_stats:{"tconstruct:armor":5.5f,"tconstruct:armor_toughness":2.0f,"tconstruct:durability":520.0f,"tconstruct:knockback_resistance":0.05f},tic_upgrades:[{level:1s,name:"tconstruct:embellishment"}]}')

Item.of('tconstruct:plate_boots', '{Damage:0,tic_broken:0b,tic_modifiers:[{level:1s,name:"tconstruct:embellishment"}],tic_persistent_data:{abilities:1,defense:5,"tconstruct:embellishment":"forgedingears:element_zero",upgrades:1},tic_stats:{"tconstruct:armor":2.0f,"tconstruct:armor_toughness":2.0f,"tconstruct:durability":400.0f,"tconstruct:knockback_resistance":0.05f},tic_upgrades:[{level:1s,name:"tconstruct:embellishment"}]}')
#

i want to check the tconstruct:embellishment : forgedingears:element_zero

#

basically just forgedingears:element_zero

drifting flume
#

does upgrade matter?

magic bronze
#

idk

#

tconstuct armor modifiers

#

embellishments they are basically just cosmetic modifiers

magic bronze
#

i mean it doesnt have to be this exact scenario for now

#

it can also be like iron armor with a specific nbt

prisma apex
magic bronze
#

done

prisma apex
#

thank you

magic bronze
#

damn

night ledge
#

maybe a Item.of().ignoreNBT() ?

magic bronze
#

how?

night ledge
#

idk.. just thinking.. maybe player.headArmorIte.id == tconstruct:slime_helmet could work? Strip odd the nbt that way? Gotta get the nbt off before comparison....

magic bronze
#

yea i aint a coder i got no clue what that means

night ledge
#

damage and other effects like enchantments are nbt. Extra stuff on the item.

magic bronze
#

thats not what im confused about