#defining nbt values script help
1088 messages · Page 2 of 2 (latest)


wait so do i do something like this? js if(!originPowers[resultKey].includes(2)) { e.cancel() }
so... we did it! 
no just copy that whole shit
@potent spindle the book nbt data
my god hes actually done it
do we need to store every single level
or would checking vs the highest lvl be enough?
yeah i just saw rofl dang
don't forget that I tried to help 
every single level
okay
unless..
oh good lol
but can't cast lvl 1
10 levels except the first
😛
And void has 6
oh, then add them to the originpowers
how do i do that?
actually, the p in the originPowers is uppercase 🤓
let originPowers = {
fire: [],
ender: [],
blood: [],
evocation: [],
holy: [],
ice: [],
lightning: [],
void: [],
poison: []
}```
just put a 1in every list
oh i see
originPowers acts as a whitelist
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
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?
oki

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
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
im an idiot who didnt save the 1 additions
and for fire i can cast lvl 1, 2 and 4
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
yo it all works, thank you so much lmao
i shouldve sent the project to you earlier rofl
¯_(ツ)_/¯
l00000000000000000000l
thank you everyone who helped out
closing this ticket before we get to 2k
XD
Ticket closed!
@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
lmao
im cursed indeed
@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