mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 01:04:24 +00:00
Add TooltipContext and TooltipDisplay to ItemTooltipEvent (#10879)
This commit is contained in:
1 parent
e14159c05d
commit
b1008b481b
3 files changed
+30
-5
No files matched your search
@@ -21,6 +21,7 @@ import net.minecraft.core.component.DataComponentMap;
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.component.TooltipDisplay;
|
||||
import net.minecraft.world.level.chunk.storage.SerializableChunkData;
|
||||
import net.minecraftforge.common.util.Result;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -354,8 +355,8 @@ public final class ForgeEventFactory {
|
||||
return BlockEvent.FluidPlaceBlockEvent.BUS.fire(new BlockEvent.FluidPlaceBlockEvent(level, pos, liquidPos, state)).getNewState();
|
||||
}
|
||||
|
||||
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags) {
|
||||
return ItemTooltipEvent.BUS.fire(new ItemTooltipEvent(itemStack, entityPlayer, list, flags));
|
||||
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags, Item.TooltipContext context, TooltipDisplay display) {
|
||||
return ItemTooltipEvent.BUS.fire(new ItemTooltipEvent(itemStack, entityPlayer, list, flags, context, display));
|
||||
}
|
||||
|
||||
public static SummonAidEvent fireZombieSummonAid(Zombie zombie, Level level, int x, int y, int z, LivingEntity attacker, double summonChance) {
|
||||
|
||||
@@ -8,12 +8,15 @@ package net.minecraftforge.event.entity.player;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.component.TooltipDisplay;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -25,17 +28,38 @@ public final class ItemTooltipEvent extends MutableEvent implements PlayerEvent
|
||||
@NotNull
|
||||
private final ItemStack itemStack;
|
||||
private final List<Component> toolTip;
|
||||
private final Item.TooltipContext context;
|
||||
private final TooltipDisplay display;
|
||||
|
||||
/**
|
||||
* This event is fired in {@link ItemStack#getTooltipLines(Player, TooltipFlag)}, which in turn is called from its respective GUIContainer.
|
||||
* This event is fired in {@link ItemStack#getTooltipLines(Item.TooltipContext, Player, TooltipFlag)}, which in turn is called from its respective GUIContainer.
|
||||
* Tooltips are also gathered with a null player during startup by {@link Minecraft#createSearchTrees()}.
|
||||
*/
|
||||
public ItemTooltipEvent(@NotNull ItemStack itemStack, @Nullable Player player, List<Component> list, TooltipFlag flags)
|
||||
@ApiStatus.Internal
|
||||
public ItemTooltipEvent(@NotNull ItemStack itemStack, @Nullable Player player, List<Component> list, TooltipFlag flags, Item.TooltipContext context, TooltipDisplay display)
|
||||
{
|
||||
this.player = player;
|
||||
this.itemStack = itemStack;
|
||||
this.toolTip = list;
|
||||
this.flags = flags;
|
||||
this.context = context;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link net.minecraft.world.item.Item.TooltipContext} for this tooltip.
|
||||
*/
|
||||
public Item.TooltipContext getContext()
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link net.minecraft.world.item.component.TooltipDisplay} for this tooltip.
|
||||
*/
|
||||
public TooltipDisplay getDisplay()
|
||||
{
|
||||
return display;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user