KubeJS-Mods / KubeJS

https://kubejs.com
GNU Lesser General Public License v3.0
299 stars 89 forks source link

Unable to collapse spawn eggs into a REI category, if Insepcio is installed #633

Open SplendidAlakey opened 1 year ago

SplendidAlakey commented 1 year ago

Minecraft Version

1.19.2

KubeJS Version

1902.6.0-build.142

Rhino Version

1902.2.2-build.268

Architectury Version

6.5.85

Forge/Fabric Version

Quilt 0.18.10 or Fabric 0.14.21

Describe your issue

I'm unable to group spawn eggs together in REI, if Inspecio is installed. Could be affecting other items, but I can only confirm the issue to be present with the eggs.

  1. Create the following KubeJS script in kubejs/client_scripts:
    
    // priority: 9

REIEvents.groupEntries((event) => {

// Group spawn eggs together

event.groupItems("kubejs:rei_groups/spawn_eggs", "Spawn Eggs", [
    '/spawn_egg/'
]);

});


2. Run the game and look at spawn eggs in REI - they aren't grouped together
3. Remove Inspecio and launch the game again - now the eggs are grouped up

This happens even if spawn egg tooltips are disabled in the config.

To reproduce this on Fabric, you can install [Advanced Tooltips](https://www.curseforge.com/minecraft/mc-mods/advanced-tooltips).

Initially reported to Inspecio, but also reporting here, as based on the logs it has something to do with KubeJS specifically, unless I'm reading it wrong.

### Crash report/logs

https://gist.github.com/SplendidAlakey/16ef59aa89fb590c6d9ddbbff09fee30
ChiefArug commented 10 months ago

This is weird. The REI log says the group does exist, but its very clearly not grouping. Advanced Tooltips has one mixin into the spawn egg item class that adds the image of the mob, which i wouldnt think affects it...

It also seems to do weird stuff to tipped arrows (which it also mixins to for the same purpose, and notably has a weird rei hackaround in there) image This is grouping by the regex /arrow/. Only regular, glowing and poison are actually grouped.

ChiefArug commented 10 months ago

Disabling that mixin fixes the issue. Makes me thing it might be an issue with REI not handling those special image tooltips properly.

ChiefArug commented 10 months ago

Workaround for now:

REIEvents.groupEntries((event) => {
  const $VanillaEntryTypes = Java.loadClass('me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes') // This cannot be initialized outside of the event due to REI being weird and relying on class loading order.

  event.registry.group("kubejs:rei_groups/spawn_eggs", "Spawn Eggs", $VanillaEntryTypes.ITEM, item => item.value.id.contains('spawn_egg'))
})

It is a lot uglier than I thought it would be. This is mainly caused by #703, and isn't helped by rhino thinking an ArrowFunction is a List not a Predicate