Skip to main content

REI Integration

Note: REI integration only works on Fabric in 1.16. In 1.18+, it works on both Forge and Fabric!

All REI events are client sided and so go in the client_scripts folder

Hide Items

onEvent('rei.hide.items', event => {
  event.hide('example:ingredient')
})

Add Items

onEvent('rei.add.items', event => {
  event.add(item.Item.of('example:item').nbt(, { test: 123})123 })
})

Add Information

onEvent('rei.information', event => {
  event.add('example:ingredient', 'Title', ['Line 1', 'Line 2'])
})

Yeet categories

onEvent('rei.remove.categories', event => {
  console.log(event.getCategoryIds()) //log a list of all category ids to logs/kubejs/client.txt
  
  //event.remove works too, but yeeting is so much more fun 😉
  event.yeet('create:compacting')
})

Grouping / Collapsible Entries (1.18.2+)

onEvent("'rei.group"group', (event)event => {
  // This event allows you to add custom entry groups to REI, which can be used to clean up the entry list significantly.
  // As a simple example, we can add a "Swords"'Swords' group which will contain all (vanilla) swords
  // Note that each group will need an id (ResourceLocation) and a display name (Component / String)
  event.groupItems("'kubejs:rei_groups/swords"swords', "Swords"'Swords', [
    "'minecraft:wooden_sword"wooden_sword',
    "'minecraft:stone_sword"stone_sword',
    "'minecraft:iron_sword"iron_sword',
    "'minecraft:diamond_sword"diamond_sword',
    "'minecraft:golden_sword"golden_sword',
    "'minecraft:netherite_sword"netherite_sword'
  ]);

  // An easy use case for grouping stuff together could be using tags:
  // In this case, we want all the Hanging Signs and Sign Posts from Supplementaries to be grouped together
  event.groupItemsByTag("'supplementaries:rei_groups/hanging_signs"hanging_signs', "'Hanging Signs"Signs', "'supplementaries:hanging_signs"hanging_signs');
  event.groupItemsByTag("'supplementaries:rei_groups/sign_posts"sign_posts', "'Sign Posts"Posts', "'supplementaries:sign_posts"sign_posts');

  // Another example: We want all of these items to be grouped together ignoring NBT,
  // so you don't have a bajillion potions and enchanted books cluttering up REI anymore
  const useNbt = ["potion"'potion', "enchanted_book"'enchanted_book', "splash_potion"'splash_potion', "tipped_arrow"'tipped_arrow', "lingering_potion"'lingering_potion'];

  useNbt.forEach((id)id => {
    const item = Item.of(id);
    const { namespace, path } = Utils.id(item.id);
    event.groupSameItem(`kubejs:rei_groups/${namespace}/${path}`, item.getName(),name, item);
  });

  // Items can also be grouped using anything that can be expressed as an IngredientJS,
  // including for example regular expressions or lists of ingredients
  event.groupItems("'kubejs:rei_groups/spawn_eggs"spawn_eggs', "'Spawn Eggs"Eggs', [
    /spawn_egg/,
    /^ars_nouveau:.*_se$/,
    "'supplementaries:red_merchant_spawn_egg"red_merchant_spawn_egg'
  ]);

  // you can even use custom predicates for grouping, like so:
  event.groupItemsIf("'kubejs:rei_groups/looting_stuff"looting_stuff', "'Stuff with Looting I"I', (item)item =>
    // this would group together all items that have the Looting I enchantment on them
    item.hasEnchantment("'minecraft:looting"looting', 1)
  );

  // you can also group fluids in much the same way as you can group items, for instance:
  event.groupFluidsByTag("'kubejs:rei_groups/fluid_tagged_as_water"fluid_tagged_as_water', `"Water"'\'Water\' (yeah right lmao)`', "'minecraft:water"water');
});