-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make heart types an extensible enum and add an event to modify them (#…
…999)
- Loading branch information
1 parent
4a7d634
commit b13c445
Showing
4 changed files
with
99 additions
and
7 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
50 changes: 50 additions & 0 deletions
50
src/main/java/net/neoforged/neoforge/event/entity/player/PlayerHeartTypeEvent.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,50 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.event.entity.player; | ||
|
||
import net.minecraft.client.gui.Gui; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
/** | ||
* Fired by {@link Gui.HeartType#forPlayer} to allow mods to change the heart sprite which is displayed in the player's | ||
* health bar. | ||
* | ||
* <p> | ||
* This event is fired only on the client. | ||
*/ | ||
public class PlayerHeartTypeEvent extends PlayerEvent { | ||
private final Gui.HeartType originalType; | ||
private Gui.HeartType type; | ||
|
||
public PlayerHeartTypeEvent(Player player, Gui.HeartType type) { | ||
super(player); | ||
this.type = type; | ||
this.originalType = type; | ||
} | ||
|
||
/** | ||
* @return The original heart type which would be displayed by vanilla. | ||
*/ | ||
public Gui.HeartType getOriginalType() { | ||
return originalType; | ||
} | ||
|
||
/** | ||
* @return The heart type which will be displayed on the health bar. | ||
*/ | ||
public Gui.HeartType getType() { | ||
return type; | ||
} | ||
|
||
/** | ||
* Set the heart sprite which will be displayed on the {@link Player}'s health bar. | ||
* | ||
* @param type The {@link Gui.HeartType} to display | ||
*/ | ||
public void setType(Gui.HeartType type) { | ||
this.type = type; | ||
} | ||
} |
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