Skip to content

Commit

Permalink
Fix item tooltip tests failing
Browse files Browse the repository at this point in the history
  • Loading branch information
ApexModder committed May 28, 2024
1 parent aecfd05 commit 797447a
Showing 1 changed file with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,22 @@

package net.neoforged.neoforge.debug;

import net.minecraft.gametest.framework.GameTest;
import net.minecraft.network.chat.Component;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent;
import net.neoforged.testframework.DynamicTest;
import net.neoforged.testframework.TestFramework;
import net.neoforged.testframework.annotation.ForEachTest;
import net.neoforged.testframework.annotation.TestHolder;
import net.neoforged.testframework.gametest.EmptyTemplate;
import net.neoforged.testframework.annotation.OnInit;

@ForEachTest(groups = "item.tooltip.event")
public class ItemTooltipTests {
@GameTest
@EmptyTemplate
@TestHolder(description = "Tests if tooltips are added in correct orderings")
static void itemTooltipTest(DynamicTest test) {
var forge = test.eventListeners().forge();

forge.addListener((ItemTooltipEvent.AfterName event) -> event.getToolTip().add(Component.literal("After Name")));
forge.addListener((ItemTooltipEvent.BeforeComponents event) -> event.getToolTip().add(Component.literal("Before Components")));
forge.addListener((ItemTooltipEvent.AfterComponents event) -> event.getToolTip().add(Component.literal("After Components")));
forge.addListener((ItemTooltipEvent.BeforeDebug event) -> event.getToolTip().add(Component.literal("Before Debug")));
forge.addListener((ItemTooltipEvent.AfterDebug event) -> event.getToolTip().add(Component.literal("After Debug")));
forge.addListener((ItemTooltipEvent.AfterAll event) -> event.getToolTip().add(Component.literal("After All")));
@OnInit
static void itemTooltipTest(TestFramework framework) {
NeoForge.EVENT_BUS.addListener((ItemTooltipEvent.AfterName event) -> event.getToolTip().add(Component.literal("After Name")));
NeoForge.EVENT_BUS.addListener((ItemTooltipEvent.BeforeComponents event) -> event.getToolTip().add(Component.literal("Before Components")));
NeoForge.EVENT_BUS.addListener((ItemTooltipEvent.AfterComponents event) -> event.getToolTip().add(Component.literal("After Components")));
NeoForge.EVENT_BUS.addListener((ItemTooltipEvent.BeforeDebug event) -> event.getToolTip().add(Component.literal("Before Debug")));
NeoForge.EVENT_BUS.addListener((ItemTooltipEvent.AfterDebug event) -> event.getToolTip().add(Component.literal("After Debug")));
NeoForge.EVENT_BUS.addListener((ItemTooltipEvent.AfterAll event) -> event.getToolTip().add(Component.literal("After All")));
}
}

0 comments on commit 797447a

Please sign in to comment.