#Adding a new rarity to the game
10 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Just a little bumpin'
// https://discord.com/channels/303440391124942858/1237440577809944576/
const $Rarity = Java.loadClass("net.minecraft.world.item.Rarity")
const $UnaryOperator = Java.loadClass("java.util.function.UnaryOperator")
const $UtilsJS = Java.loadClass("dev.latvian.mods.kubejs.util.UtilsJS")
const $Style = Java.loadClass("net.minecraft.network.chat.Style")
const withColorMethod = $Style.EMPTY.class.declaredMethods.filter((method) => method.name.includes("m_131148_"))[0]
function createRarity (/** @type {string} */ name, /** @type {number} */ colorCode) {
let color = $UtilsJS.makeFunctionProxy("startup", $UnaryOperator, (style) => {
return withColorMethod.invoke(style, Color.of(colorCode).createTextColorJS())
})
return $Rarity["create(java.lang.String,java.util.function.UnaryOperator)"](name, color)
}
createRarity("MYTHIC", 0xFF5555)
Another small question I've got if you have the time - I would like that rarity to have a rainbow-coloured name (using https://www.curseforge.com/minecraft/mc-mods/text-animator)
Is it possible to apply that to the rarity somehow or would I have to apply that to the display name of each item individually?
Yeah I thought so. Guess Displayname changes it is