#Adding a new rarity to the game

10 messages · Page 1 of 1 (latest)

sharp tangle
#

Does anyone know if title is possible with KubeJS?

quasi dragonBOT
#

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

sharp tangle
#

Just a little bumpin'

atomic hemlock
#
// 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)
sharp tangle
#

I cannot believe I missed that in my search

#

Thank you so much

sharp tangle
atomic hemlock
#

I don't think there's a easy way

#

Rarity only gives a Style, not new texts

sharp tangle
#

Yeah I thought so. Guess Displayname changes it is