#defining nbt values script help

1088 messages · Page 2 of 2 (latest)

potent spindle
#

oh nvm

#

its so clean i could barely read it for a second there

vital escarp
frosty basin
potent spindle
#

wait so do i do something like this? js if(!originPowers[resultKey].includes(2)) { e.cancel() }

vital escarp
#

so... we did it! heh

frosty basin
#

no just copy that whole shit

potent spindle
#

oh i see

frosty basin
#

its all done

#

also just a question

coral hedge
#

@potent spindle the book nbt data

potent spindle
#

my god hes actually done it

frosty basin
#

do we need to store every single level

#

or would checking vs the highest lvl be enough?

potent spindle
vital escarp
#

don't forget that I tried to help despair

potent spindle
frosty basin
#

okay

potent spindle
#

unless..

frosty basin
#

then this is perfect

#

bcause

#

i got lvl 2 and 4

potent spindle
#

oh good lol

frosty basin
#

but can't cast lvl 1

coral hedge
#

10 levels except the first

frosty basin
#

😛

coral hedge
#

And void has 6

potent spindle
#

1 is auto given to the player

#

so we ignore lvl 1 anyways

frosty basin
#

oh, then add them to the originpowers

potent spindle
#

how do i do that?

vital escarp
frosty basin
#
let originPowers = {

    fire: [],

    ender: [],

    blood: [],

    evocation: [],

    holy: [],

    ice: [],

    lightning: [],

    void: [],

    poison: []

}```
#

just put a 1in every list

potent spindle
#

oh i see

frosty basin
#

originPowers acts as a whitelist

potent spindle
#

wait like this? js let originPowers = { fire: [1], ender: [1], blood: [1], evocation: [1], holy: [1], ice: [1], lightning: [1], void: [1], poison: [1] }

#

ahh

frosty basin
#

👍

#

well, that would mean that any player gets it from any class

potent spindle
#

so ok ok so let me get this straight then

#

yeah thats good

#

so lets say i have a level 5 scroll and dont have the lvl 5 origin class, it wont fire?

frosty basin
#

nope

#

it will fire a lvl1 scroll

potent spindle
#

ok imma test it out real quick just to make sure i didnt mess anything up

#

oo

frosty basin
#

oki

potent spindle
#

doesnt

#

hmm

frosty basin
potent spindle
#

i tried firing lvl 1 scroll

#

lemme try lvl 5 or somethin

frosty basin
#

note, i only have fire lvl 2 and 4

potent spindle
#

everything else is working

#

there should be more in that top doublechest

#

on the middle isle

#

i put every level of fire in there i believe

#

er sorry the bottom doublechest

#

if you hold ctrl you should be able to see the nbt

frosty basin
#
ItemEvents.rightClicked('irons_spellbooks:scroll',e => {
    const {item, player, level} = e
    // Get Scroll Stuff
    let nbt = item.nbt
    let scrollLevel = nbt?.ISB_spell?.level
    let scrollType = nbt?.ISB_spell.type

    // Get Powers
    let originsOrigin = player.nbt.ForgeCaps['apoli:powers']
    let types = {
        fire: [2, 33, 59, 1, 10],
        ender: [60, 44, 42, 4, 3, 21, 30],
        blood: [8, 22, 25, 26, 29, 57, 39, 58, 66],
        evocation: [9, 13, 14, 16, 19, 20, 31, 32, 38, 45, 64],
        holy: [7, 15, 18, 27, 41, 43, 61, 62],
        ice: [6, 12, 34, 40, 48],
        lightning: [5, 23, 24, 37, 46, 65],
        void: [35, 47, 56],
        poison: [49, 50, 51, 52, 53, 54, 55]
    }
    let originPowers = {
        fire: [1],
        ender: [1],
        blood: [1],
        evocation: [1],
        holy: [1],
        ice: [1],
        lightning: [1],
        void: [1],
        poison: [1]
    }


    // Add all Powers to an Array
    for(let i = 0; i < originsOrigin['Powers'].length; i++){
    let power = originsOrigin['Powers'][i].Type
    let element = power.split('/')[0].split(':')[1]
    let powerType = power.split('/')[1].replace('lvl', '')
    originPowers[element].push(parseInt(powerType))
}

    // Get TypeKey
    let resultKey = Object.keys(types).find(key => types[key].includes(scrollType));

    // Check if Player has Level of Scroll and Cancel if not
    if(!originPowers[resultKey].includes(scrollLevel)) {
        e.cancel()
    }
})```
#

so this works, i can cast ALL lvl1 scrolls

potent spindle
frosty basin
#

and for fire i can cast lvl 1, 2 and 4

potent spindle
#

i can fire lvl 1s

#

yeah thats me being dumb rofl

#
ItemEvents.rightClicked('irons_spellbooks:scroll',e => {
    const {item, player, level} = e
    // Get Scroll Stuff
    let nbt = item.nbt
    let scrollLevel = nbt?.ISB_spell?.level
    let scrollType = nbt?.ISB_spell.type

    // Get Powers
    let originsOrigin = player.nbt.ForgeCaps['apoli:powers']
    let types = {
        fire: [2, 33, 59, 1, 10],
        ender: [60, 44, 42, 4, 3, 21, 30],
        blood: [8, 22, 25, 26, 29, 57, 39, 58, 66],
        evocation: [9, 13, 14, 16, 19, 20, 31, 32, 38, 45, 64],
        holy: [7, 15, 18, 27, 41, 43, 61, 62],
        ice: [6, 12, 34, 40, 48],
        lightning: [5, 23, 24, 37, 46, 65],
        void: [35, 47, 56],
        poison: [49, 50, 51, 52, 53, 54, 55]
    }
    let originPowers = {
        fire: [1],
        ender: [1],
        blood: [1],
        evocation: [1],
        holy: [1],
        ice: [1],
        lightning: [1],
        void: [1],
        poison: [1]
    }

    
    // Add all Powers to an Array
    for(let i = 0; i < originsOrigin['Powers'].length; i++){
    let power = originsOrigin['Powers'][i].Type
    let element = power.split('/')[0].split(':')[1]
    let powerType = power.split('/')[1].replace('lvl', '')
    originPowers[element].push(parseInt(powerType))
}
    
    // Get TypeKey 
    let resultKey = Object.keys(types).find(key => types[key].includes(scrollType));

    // Check if Player has Level of Scroll and Cancel if not
    if(!originPowers[resultKey].includes(scrollLevel)) {
        e.cancel()
    }
})```its working now
#

lemme try giving myself something like ender 10

potent spindle
frosty basin
potent spindle
#

i shouldve sent the project to you earlier rofl

frosty basin
#

¯_(ツ)_/¯

potent spindle
#

l00000000000000000000l

#

thank you everyone who helped out

#

closing this ticket before we get to 2k

#

XD

mint kernelBOT
#

Ticket closed!

umbral hatch
#

@vital escarp just to let you know

#
const transpiledTypes = {
  1: "fire",
  2: "fire",
  3: "ender",
  4: "ender",
  5: "lightning",
  6: "ice",
  7: "holy",
  8: "blood",
  9: "evocation",
  10: "fire",
  12: "ice",
  13: "evocation",
  14: "evocation",
  15: "holy",
  16: "evocation",
  18: "holy",
  19: "evocation",
  20: "evocation",
  21: "ender",
  22: "blood",
  23: "lightning",
  24: "lightning",
  25: "blood",
  26: "blood",
  27: "holy",
  29: "blood",
  30: "ender",
  31: "evocation",
  32: "evocation",
  33: "fire",
  34: "ice",
  35: "void",
  37: "lightning",
  38: "evocation",
  39: "blood",
  40: "ice",
  41: "holy",
  42: "ender",
  43: "holy",
  44: "ender",
  45: "evocation",
  46: "lightning",
  47: "void",
  48: "ice",
  49: "poison",
  50: "poison",
  51: "poison",
  52: "poison",
  53: "poison",
  54: "poison",
  55: "poison",
  56: "void",
  57: "blood",
  58: "blood",
  59: "fire",
  60: "ender",
  61: "holy",
  62: "holy",
  64: "evocation",
  65: "lightning",
  66: "blood"
};

ItemEvents.rightClicked("stone", (e) => {
  if (e.hand == "MAIN_HAND") {
    let { player, item } = e;
    let typeId = item?.nbt?.ISB_spell?.type
    let typeString = transpiledTypes[typeId]
    let scrollLevel = item?.nbt?.ISB_spell?.level
    let searchString = typeString+":"+scrollLevel
    let powers = player.nbt.ForgeCaps["apoli:powers"].Powers;
    if (!powers.isEmpty()) {
      let found = powers.stream().anyMatch(power => {
        // replacing "origins:fire_immunity" with "magicunlock:fire/lvl2" to simulate
        return power.Type.replace("origins:fire_immunity","magicunlock:fire/lvl2").replace('magicunlock:', '').replace('lvl', '').replace('/', ':') == searchString
      })
      if (found) player.tell("Found")
    }
  }
});

your replace solution works, @potent spindle is just cursed
also I transpiled the types for easier access

umbral hatch
#

@potent spindle do you know why there is some missing numbers, looks like it is not complete or dev just skipped some for whatever reason

potent spindle
#

yeah i think youre right, idk what was going on when he was making the types

#

i mean if it works it works but yeah mad lad Xd

#

makes you wonder what other "spells" there are hidden in the mod >.>