-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.21] Add GatherEffectScreenTooltipsEvent (#1240)
This new event allows changing the tooltip shown when hovering a potion effect in the player inventory.
- Loading branch information
1 parent
6bd9373
commit 901e469
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/net/neoforged/neoforge/client/event/GatherEffectScreenTooltipsEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.client.event; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.bus.api.Event; | ||
|
||
/** | ||
* This event is called when an {@link EffectRenderingInventoryScreen} draws the tooltip lines for a hovered {@link MobEffectInstance}. | ||
* It can be used to modify the tooltip. | ||
* <p> | ||
* This event is only fired on the {@linkplain Dist#CLIENT physical client}. | ||
*/ | ||
public class GatherEffectScreenTooltipsEvent extends Event { | ||
protected final EffectRenderingInventoryScreen<?> screen; | ||
protected final MobEffectInstance effectInst; | ||
protected final List<Component> tooltip; | ||
|
||
public GatherEffectScreenTooltipsEvent(EffectRenderingInventoryScreen<?> screen, MobEffectInstance effectInst, List<Component> tooltip) { | ||
this.screen = screen; | ||
this.effectInst = effectInst; | ||
this.tooltip = new ArrayList<>(tooltip); | ||
} | ||
|
||
/** | ||
* @return The screen which will be rendering the tooltip lines. | ||
*/ | ||
public EffectRenderingInventoryScreen<?> getScreen() { | ||
return this.screen; | ||
} | ||
|
||
/** | ||
* @return The effect whose tooltip is being drawn. | ||
*/ | ||
public MobEffectInstance getEffectInstance() { | ||
return this.effectInst; | ||
} | ||
|
||
/** | ||
* @return A mutable list of tooltip lines. | ||
*/ | ||
public List<Component> getTooltip() { | ||
return this.tooltip; | ||
} | ||
} |