Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tooltip from kubejs buged with ModerFix #400

Open
Kisuny opened this issue May 3, 2024 · 9 comments
Open

tooltip from kubejs buged with ModerFix #400

Kisuny opened this issue May 3, 2024 · 9 comments
Labels
cannot reproduce The issue is not reproducible with the information given

Comments

@Kisuny
Copy link

Kisuny commented May 3, 2024

Bug Description

When I add kubejs items tooltops with ModernFix all the tooltips added this way are displayed twice.

Disabling mixin.perf.resourcepacks removes this problem, but judging from the descriptions of this feature - it's a major fix, is there another way to fix this problem?

Screenshot:
image
image

kubejs code exmaple:

ItemEvents.tooltip(tooltip => {
let artifactsTooltip = (args) => {
            tooltip.addAdvanced(args.item, (item, advanced, text) => {
                if (!tooltip.ctrl) {
                    text.add(1, ctrlText)
                } else {
                    text.add(1, Text.gold('Способ получения:').bold(true))
                    text.add(2, Text.gray(args.text1))
                    text.add(3, Text.darkGray(args.text2))
                }
            })
        };

artifactsTooltip(
            {
                item: 'artifacts:cloud_in_a_bottle', 
                text1: 'some text for description after press ctrl',
                text2: 'second exmaple text'
        });
});

Reproduction Steps

Everything is described in detail above

Log File

latest.log

@Kisuny
Copy link
Author

Kisuny commented May 3, 2024

Wrong, mixin.perf.resourcepacks does not help...

Empirically I managed to find out that the problem is in these parameters:
mixin.perf.mojang_registry_size=false
mixin.perf.reduce_blockstate_cache_rebuilds=false

@embeddedt
Copy link
Owner

Neither of those options should have an impact on tooltips.

Can you reproduce this with just ModernFix, KubeJS, and one other content mod? There are many mods installed that could be causing this.

I would also suggest ensuring you are using the latest version of KubeJS (6.1 or later), as older versions had concurrency bugs that could cause these types of problems randomly.

@embeddedt embeddedt added the cannot reproduce The issue is not reproducible with the information given label May 3, 2024
@Kisuny
Copy link
Author

Kisuny commented May 3, 2024

Neither of those options should have an impact on tooltips.

Can you reproduce this with just ModernFix, KubeJS, and one other content mod? There are many mods installed that could be causing this.

I would also suggest ensuring you are using the latest version of KubeJS (6.1 or later), as older versions had concurrency bugs that could cause these types of problems randomly.

I did it again with fewer mods.

image
latest.log

mod list:
fabric-api-0.77.0+1.19.2.jar
rhino-fabric-1902.2.3-build.284.jar
architectury-6.6.92-fabric.jar
modernfix-fabric-5.17.0+mc1.19.2.jar
RoughlyEnoughItems-9.2.724-fabric.jar
artifacts-7.1.1+fabric.jar (added for test tooltips)
cloth-config-8.3.115-fabric.jar
trinkets-3.4.2.jar
kubejs-fabric-1902.6.2-build.63.jar (last version for 1.19.2)

Only one client side scritps:

ItemEvents.tooltip(tooltip => {
    
        const shiftText = [Text.of('Зажми ').gold(), Text.of('Shift ').yellow(), Text.of('для подробной информации.').gold()]
        const ctrlText = [Text.of('Зажми ').gray(), Text.of('CTRL ').gold(), Text.of('Чтобы узнать как получить.').gray()]
        tooltip.addAdvanced('artifacts:helium_flamingo', (item, advanced, text) => {
            // shift, alt and ctrl are all keys you can check!
            if (!tooltip.shift) {
                text.add(1, shiftText)
            } else {
                text.add(1, Text.gold('Способ получения:').bold(true))
                text.add(2, Text.gray('🎣 Выбить при рыбной ловле существ, из ночной фурии.'))
                text.add(3, Text.darkGray('Условия поимки ночной фурии: ночь, вода, обычный мир.'))
                text.add(4, Text.gray('🗡 Мешок с добычей плоти и крови.'))
            }
        })
    
    
    
        // тултипы для артефактов
        let artifactsTooltip = (args) => {
            tooltip.addAdvanced(args.item, (item, advanced, text) => {
                if (!tooltip.ctrl) {
                    text.add(1, ctrlText)
                } else {
                    text.add(1, Text.gold('Способ получения:').bold(true))
                    text.add(2, Text.gray(args.text1))
                    text.add(3, Text.darkGray(args.text2))
                }
            })
        };
        artifactsTooltip(
            {
                item: 'artifacts:cloud_in_a_bottle', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Призрака».',
                text2: 'Условия поимки призрака: ночь, вода, обычный мир.'
        });
        artifactsTooltip(
            {
                item: 'artifacts:vampiric_glove', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Вампира».',
                text2: 'Условия поимки вампира: ночь, вода, обычный мир.'
        });
        artifactsTooltip(
            {
                item: 'artifacts:crystal_heart', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Гаснущий Хризолит».',
                text2: 'Условия поимки «Гаснущий Хризолит»: Кристаллическая жидкость'
        });
        artifactsTooltip(
            {
                item: 'artifacts:superstitious_hat', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Гаснущий Хризолит».',
                text2: 'Условия поимки «Гаснущий Хризолит»: кристаллическая жидкость'
        });
        artifactsTooltip(
            {
                item: 'artifacts:flippers', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Кракен», «Мегалодон», «Морской император».',
                text2: 'Условия поимки «Кракен»: ночь, вода, обычный мир.\nУсловия поимки «Мегалодон»: вода, обычный мир.\nУсловия поимки «Морской император»: вода, обычный мир.'
        });
        artifactsTooltip(
            {
                item: 'artifacts:snorkel', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Кракен», «Морской император».',
                text2: 'Условия поимки «Кракен»: ночь, вода, обычный мир.\nУсловия поимки «Морской император»: вода, обычный мир.'
        });
        artifactsTooltip(
            {
                item: 'artifacts:night_vision_goggles', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Смотрящий».',
                text2: 'Условия поимки «Смотрящий»: вода, энд.'
        });
        artifactsTooltip(
            {
                item: 'artifacts:antidote_vessel', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Багровая плоть», «Оживший корень».',
                text2: 'Условия поимки «Багровая плоть»: лава, ад.\nУсловия поимки «Оживший корень»: жидкая грязь'
        });
        artifactsTooltip(
            {
                item: 'artifacts:digging_claws', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Тёмный дракон», «Восставший из драконьей гнили»',
                text2: 'Условия поимки «Тёмный дракон»: драконья гниль.\nУсловия поимки «Восставший из драконьей гнили»: драконья гниль.'
        });
        artifactsTooltip(
            {
                item: 'artifacts:feral_claws', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Тёмный дракон»',
                text2: 'Условия поимки «Тёмный дракон»: драконья гниль.'
        });
        artifactsTooltip(
            {
                item: 'artifacts:lucky_scarf', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Восставший из драконьей гнили»',
                text2: 'Условия поимки «Восставший из драконьей гнили»: драконья гниль.'
        });
        artifactsTooltip(
            {
                item: 'artifacts:running_shoes', 
                text1: '🎣 Выбить при рыбной ловле существ, из «Зубастик»',
                text2: 'Условия поимки «Зубастик»: драконья гниль.'
        });
    });

@embeddedt
Copy link
Owner

I tried using just these mods, but still don't see the bug.

image

@Kisuny
Copy link
Author

Kisuny commented May 3, 2024

I tried using just these mods, but still don't see the bug.

image

Do you have an REI?

@embeddedt
Copy link
Owner

embeddedt commented May 3, 2024

Yes, you can see the search bar at the edge of the image, and the buttons next to it.

@Kisuny
Copy link
Author

Kisuny commented May 3, 2024

Yes, you can see the search bar at the edge of the image, and the buttons next to it.

How is that even possible?

@Inqie
Copy link

Inqie commented May 12, 2024

KubeJS loads the tooltips late enough that REI renders them twice. Try the below in client scripts, obviously with your own list of items, to load the tooltips earlier. If it doesn't work, check the support Discord server for KubeJS.

const $TooltipFlag$Default = Java.loadClass('net.minecraft.world.item.TooltipFlag$Default')
REIEvents.hide("item", e => {
  let items = ["minecraft:apple"];
  items.forEach((i) => {
    Item.of(i).getTooltipLines(
      Client.player,
      $TooltipFlag$Default.ADVANCED
    );
  });
});

@Mickeon
Copy link

Mickeon commented May 16, 2024

I can confirm that we are experiencing a form of this bug, as well. I "fixed" it by storing whether the tooltips were already processed in a variable, but it's quite unideal and not guaranteed to work all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot reproduce The issue is not reproducible with the information given
Projects
None yet
Development

No branches or pull requests

4 participants