#How to change rarity of block without using 'ItemEvents.modification'?

11 messages · Page 1 of 1 (latest)

random lava
#

I changed like this and it works but I am wonder if it can be changed when creating block

ItemEvents.modification(event => {
  event.modify('kubejs:perfect_alloy_block', item => {
    item.maxStackSize = 16
    item.setFireResistant()
    item.rarity = 'uncommon'
  })```
harsh pawnBOT
#

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

pure lion
#

Rarities are for items, not for blocks

#

When you create a block in KubeJS, KJS automatically creates a block item for you

rocky haven
#

As KonSola brought up, rarity is for items only, meaning this rarity will only apply to the itemstack version of it, not when the block is placed

Furthermore, the BlockBuilder and it's associated BlockItemBuilder do not offer any methods to assign a rarity to the BlockItem.
Using ItemEvents.modification is the only easy option, outside of creating your own extended version of the BlockItemBuilder and adding a custom rarity setter with a JavaAdapter

pure lion
#

Or, KubeJS' block builder offers an item method allowing you to modify the block item

#
StartupEvents.registry('block', event => {
  event.create("custom_block").item(item => item.rarity("epic"))
})

Try this

#

So your block will be defined like this:

StartupEvents.registry('block', event => {
  event
    .create('perfect_alloy_block')
    .item(item => item
      .rarity('uncommon')
      .fireResistant()
      .maxStackSize(16)
    )
})
rocky haven
#

oh yeah, completely forgot you could get the ItemBuilder from the BlockBuilder nekocat_facepalm

random lava
#

thanks