#BetterX mods + KubeJS help

181 messages · Page 1 of 1 (latest)

fathom canyon
#

Hello, im by no means an experienced coder. Ive recently taken the decision to make a Vanilla+ like modpack for me and my friends on a private server. And one thing ive come across is that i want/need to change some +armor values for 2 mods "BetterEnd & "BetterNether" and ive tried almost everything i feel like. I frist tried doing a resourcepack, then datapack and lastly KuebJS
(since i dont know coding, i took help using AI [which i have seen in the rules, it isnt allowed]) therefore i will not post the code here.
But do you guys think something like this is possible using KubeJS? if so how do i get started to solve such a "simple" issue? I have been on this annoying issue for 4 days straight now. Ive even contacted BetterX mod "admin" and he said "ask in KuebJS discord why it isnt working"

Thanks in advande

wheat pewterBOT
#

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

west nova
fathom canyon
#

going on that link you sent me. Does this mean you cant change values atm?

west nova
fathom canyon
# west nova Just put it here, yes.

thanks, here it is

// priority: 0

ItemEvents.modification(event => {
  // Flaming Ruby (BetterNether) — knockback resistance: 1.0
  const flamingRuby = [
    'betternether:flaming_ruby_helmet',
    'betternether:flaming_ruby_chestplate',
    'betternether:flaming_ruby_leggings',
    'betternether:flaming_ruby_boots'
  ]

  flamingRuby.forEach(id => {
    event.modify(id, item => {
      item.attributes.remove('minecraft:knockback_resistance')
      item.attributes.add('minecraft:knockback_resistance', 1.0, 'addition')
    })
  })

  // Aeternium (BetterEnd) — custom armor values
  event.modify('betterend:aeternium_helmet', item => {
    item.attributes.remove('minecraft:armor')
    item.attributes.add('minecraft:armor', 3.5, 'addition')
  })

  event.modify('betterend:aeternium_chestplate', item => {
    item.attributes.remove('minecraft:armor')
    item.attributes.add('minecraft:armor', 8.0, 'addition')
  })

  event.modify('betterend:aeternium_leggings', item => {
    item.attributes.remove('minecraft:armor')
    item.attributes.add('minecraft:armor', 6.0, 'addition')
  })

  event.modify('betterend:aeternium_boots', item => {
    item.attributes.remove('minecraft:armor')
    item.attributes.add('minecraft:armor', 3.5, 'addition')
  })

  // Enderium (Majrusz's) — knockback resistance: 2.0
  const enderium = [
    'majruszsdifficulty:enderium_helmet',
    'majruszsdifficulty:enderium_chestplate',
    'majruszsdifficulty:enderium_leggings',
    'majruszsdifficulty:enderium_boots'
  ]

  enderium.forEach(id => {
    event.modify(id, item => {
      item.attributes.remove('minecraft:knockback_resistance')
      item.attributes.add('minecraft:knockback_resistance', 2.0, 'addition')
    })
  })
})
#

another thing to note.
my script runs when it's just console.log(...), but fails silently when ItemEvents.modification(...) orServerEvents.itemAttributeModifiers(...) is used.

west nova
#

Try running /kubejs errors in game

fathom canyon
#

alright sec

#

the only error it gives me is from another code script, which has nothing to do with this. It gives 0 errors for this one

#

this was a script i have not yet removed, it was to change some recipes

west nova
#

What is the file called, that script you posted is in?

west nova
#

Jep

fathom canyon
#

armor_modifications.js

#

i tested it with aconsole.log(...) and went into latest.log file to make sure it loads

#

which it does

west nova
#

It probably can run the log even if the main script fails. Don't know. What KubeJS tells you there in the error message is that the file "armor_modifications.js" has a problem right there in line 3.

#

And then it tells you why: ItemEvents belong in the Startup folder, not the Server folder.

#

That's step 1 😉

#

So it actually tells you the first major problem with your script.

fathom canyon
#

ah ok, so its supposed to be in client_scripts instead of server_scripts?

west nova
fathom canyon
#

ok let me try that. Thanks!

west nova
#

Wait

fathom canyon
#

sure

west nova
#

I mean, try it - but it will prob not work 😄

#

Try it and then explain again what you want it to do, please

fathom canyon
#

sure sec

#

yeah, did /reload, and it came out saying there was no errors now. But still item values are wrong(default). So what i want the script to do is change some values of the armor. Like aeternium has a total of +24, i want to change the values so its +21 instead (in total) and then some other changes on 2 other gear sets. You want info on that too?

west nova
#

Sorry, I'm not too familiar with betternether armor - can you explain what you want with one piece of armor but more precise?
Let's do the first one, the ruby helmet thing.

#

We will do one item together, and then you can probably do the rest alone 🙂

fathom canyon
#

sure thing i will exaplin it precicely for you!

Flaming ruby set: Base knockback resistance is 3 (on all pieces) i want to change that valuer to 1 (on all pieces)

Aeternium set: I want to change base armor values to a lower number. This is default (current) - Helmet +4, Chest +9, Leggings +7, Boots +4.

I want to change to the(current, default) values in correct order (helmet to boots) +3.5, +8, +6, +3.5.

Enderium set: Base knockback resistance is 1 (on all pieces) i want to change that value to 2 (on all pieces)

west nova
#

For changes in Startup Scripts you usually have to restart the game, though.

#

Let's try this:

ItemEvents.modification(event => {
  event.modify('betternether:flaming_ruby_helmet', item => {
    item.armorKnockbackResistance = 0.1
  })
 })
fathom canyon
#

sure thing, give me a second! 🙂

west nova
#

I'm not sure if armorKnockbackResistance get's called correctly and I am not sure if 0.1 is the proper value for setting it to 1.

fathom canyon
#

but im not certain

west nova
#

We'll find out 😄

fathom canyon
#

the thing is, are values in tooltip supposed to change aswell? what if values actually are chaning but just not the tooltip.

Here are the results btw

west nova
fathom canyon
#

ah true

west nova
#

Okay, do /kubejs errors again

fathom canyon
#

/kubejs errors startup ?

west nova
#

jup

fathom canyon
#

without a third word, it wont let me do that command.

#

no errors were found

west nova
#

Well that's good 😄

fathom canyon
#

haha indeed!

west nova
#

So it should work.

fathom canyon
#

hmmm

west nova
#

Are you running this script only?

fathom canyon
#

no

#

some crafting recipe changes

#

for the gear sets

west nova
#

ah, but they work, i guess?

fathom canyon
#

yeah

#

i used datapacks to remove the old recipes, and i used kubejs to add new ones

#

or the other way around i dont remember

#

because one of them just wouldnt work on kubejs

west nova
#

Also interesting 😄

#

let's check if other methods work for armor...

#
ItemEvents.modification(event => {
  event.modify('betternether:flaming_ruby_helmet', item => {
    item.armorKnockbackResistance = 0.1
    item.armorProtection = 20
  })
 })
#

Try this instead. We will set the helmet's armor to 20 to see if it changes.

fathom canyon
#

sure

#

i just replace the old code with this and restart the game?

west nova
#

Jep

#

Not just the world but full game

fathom canyon
#

yy

west nova
#

If you are playing Singleplayer. If on a server, restart the server

west nova
#

Hm.

#

Press F3+H please

fathom canyon
#

sec

west nova
#

To turn on additional tooltips

fathom canyon
west nova
#

Alright, i double-checked it and everything seems correct.

#

There are some comments here, that say that this methods might not work on some modded items.

#

Let's try the other one

#
ItemEvents.modification(event => {
  event.modify('majruszsdifficulty:enderium_helmet', item => {
    item.armorKnockbackResistance = 0.2
  })
 })
fathom canyon
#

sure thing, give me a second! 🙂

fathom canyon
#

starting game btw

#

it just doesnt want to override the base stats... :/

west nova
#

We just do the helmet atm

fathom canyon
#

yea mb

#

sec

#

😮

west nova
#

Good, so we know the method works, but betternether has something going on there.

#

I just took a quick look into betternethers code on github.

#

The Flaming Ruby stuff does not seem to be it's own item but a variant of the nether armor set.

fathom canyon
#

wtf

#

what about ruby set then? because there is a "stage" before 'flaming'

west nova
#

Same, i guess.

#

Ah, found it.

fathom canyon
west nova
#

They add the nether armor regularly as one would expect. Then they add all those different materials on top and write the armor ratings etc there. Great.

#

And I don't know how to touch that.

fathom canyon
#

is it the same with aeternium? or how does that look?

#

its from BetterEnd

west nova
#

Let's see for BetterEnd.

#

Background trivia here: BetterEnd and BetterNether both are from the same developers and use the same code often with BCLib.

#

So, chances are, we will run into the same block.

fathom canyon
west nova
#

Wanna try do the code yourself?

fathom canyon
#

ItemEvents.modification(event => {
event.modify('betterend:aeternium_helmet', item => {
item.armorProtection = 3.5
})
})

west nova
#

That should work 🙂

fathom canyon
#

when adding a new line, how do i do that?

#

like on top of what we did

#

ItemEvents.modification(event => {
event.modify('majruszsdifficulty:enderium_helmet', item => {
item.armorKnockbackResistance = 0.2
})
})
ItemEvents.modification(event => {
event.modify('betterend:aeternium_helmet', item => {
item.armorProtection = 3.5
})
})

#

like this?

west nova
#

Ah, no

#

The first line "ItemEvents.modification(event => {" is the start of everything else you want to do.

#

Then, you do the modifications one by one.

event.modify('majruszsdifficulty:enderium_helmet', item => {
    item.armorKnockbackResistance = 0.2
  })

This is one modifiation

fathom canyon
#

ah ok, yeah i wanted to do a new line / section to keep it sorted, one are with aeternium changes, one area with enderium etc

west nova
#

Ah, yeah you could. But it would just be like telling someone: Take the Hammer. Put the nail there. Now put down the hammer. Now pick up the Hammer again. Do put a nail there.

fathom canyon
#

i see

west nova
#

Could spare the poor gal the hussle of putting the tool down and picking it up again. Same goes for Minecraft. This shit runs so slow modded anyway,.

fathom canyon
#

ItemEvents.modification(event => {
event.modify('majruszsdifficulty:enderium_helmet', item => {
item.armorKnockbackResistance = 0.2
event.modify('betterend:aeternium_helmet', item => {
item.armorProtection = 3.5
})
})

so it would be like this?

west nova
#

I mean, in your case, it really does not matter. But stuff stacks up and suddendly you got 10 seconds more loading time.

#

Almost

#

ItemEvents.modification(event => {
event.modify('majruszsdifficulty:enderium_helmet', item => {
item.armorKnockbackResistance = 0.2
})
event.modify('betterend:aeternium_helmet', item => {
item.armorProtection = 3.5
})
})

fathom canyon
#

ah ok

west nova
#

The }) need to close every statement

fathom canyon
#

gotcha

#

the last }) at the bottom of the code, why is there a space first? and not like the "})" where you closed the satement?

west nova
#

Hm, that's mostly coder style to help reading the code better.

west nova
#

You do indentations for every statement block or item together.

#

Works?

fathom canyon
#

no

#

its still 4

west nova
#

Ah.

fathom canyon
#

supposed to be 3.5 :/

west nova
#

Yeah, thought so.

fathom canyon
#

well you did manage to help me with one of the sets at least, which i am super greatfull for! ❤️

west nova
#

Your welcome. I'm sorry, that the other two will probably not work.

fathom canyon
#

i do wonder something do. you said that "i need to figure out/find someone" that knows how to work ArmorMaterial. Just so i know what to ask/look for, what exactly is " ArmorMaterial" and how do i ask such a question when comparing it to normal armor to explain what im looking for? if that makes sense

west nova
#

Depending on how important it is to you:

  1. Try CraftTweaker
  2. Fork BetterNether and BetterEnd on Github and change the code there 😄
fathom canyon
#

i tried crafttweaker, didnt work on fabric apparently for the specific thing i was doing, only neoforge was supported

#

what does fork mean sorry? im a complete noob to all this D:

west nova
#

But I'm not sure if this is just a thing for them or if ArmorMaterials is actually a Minecraft thing, too. But i guess, if it was, KubeJS would be able to tinker with it.

fathom canyon
#

maybe im stupid, but isnt the values of all items in a mod written somewhere in the .jar? why cant i just go in there and modify the code or such?

fathom canyon
#

i been on this for like 5 days now, lmao, i just want to get this fixed so me and my friends can play D:

west nova
west nova
#

But: the acutal Java code is on github. Check the link. Forking means, you take the code there and make a copy for yourself. It is a standardized process called "forking" on github and many other coding platforms.

#

And when you got a local copy, you change the values you want and re-compile it. Giving you your own Jar file of the mod.

fathom canyon
#

i see, so the actual best solution for all of this would to just fork the mods, so no extra "third party" mods are needed?

#

-like CraftTweaker for an example

west nova
#

But this will take you through a few days of learning tbh.

fathom canyon
#

yeah, i dont think i will be doing that sadly, i dont even know where to start ngl

#

all of this just for some simple values 🫠 😩

west nova
#

The easy part is changing the mod. The hard part is setting up your stuff to compile it again 😄

west nova
#

You could ask around for someone to recompile it for you.

#

I don't have the time now, but for someone more pro than me it would not be too much work.

#

You are playing 1.21?

fathom canyon
#

just so you are aware, i dont evne know what recompile means, im so "ignorant" of all this coding language. I wouldnt even know when the "mod" would be ready for recompiling ngl hahah

fathom canyon
fathom canyon
west nova
#

I have to leave in a sec, but here are some basic steps:

  1. Get a github account.
  2. Fork both mods (google how)
  3. Change here for BetterNether: https://github.com/quiqueck/BetterNether/blob/1.20/src/main/java/org/betterx/betternether/items/materials/BNArmorMaterial.java
  4. Change here for BetterEnd: https://github.com/quiqueck/BetterEnd/blob/1.20/src/main/java/org/betterx/betterend/item/material/EndArmorMaterial.java
  5. Ask someone to fork your fork and compile it. They will know.
GitHub

BetterNether Mod. Contribute to quiqueck/BetterNether development by creating an account on GitHub.

GitHub

Better End MC Mod. Contribute to quiqueck/BetterEnd development by creating an account on GitHub.

#

If you are interested in learning MC modding and Java (or programming) watch Kaupenjoe in YT. He's great.

#

Good luck! 🙂