forked from WayofTime/BloodMagic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweaked the bars.png texture to make the red LP bar opaque. Added `NetworkHelper.canPlayerSeeSoulNetwork()`. Created ISoulNetworkViewer Interface. Made ItemSigilDivination implement it. Added ElementSoulNetwork to render the Soul Network HUD. Registered in Elements.
- Loading branch information
Showing
6 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/java/wayoftime/bloodmagic/api/compat/ISoulNetworkViewer.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,15 @@ | ||
package wayoftime.bloodmagic.api.compat; | ||
|
||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
|
||
/** | ||
* Interface for Items that allow players to see their Soul Network HUD. | ||
*/ | ||
public interface ISoulNetworkViewer | ||
{ | ||
boolean canSeeDemonSoulNetwork(Level level, ItemStack stack, Player player); | ||
|
||
int getSoulNetworkResolution(Level level, ItemStack stack, Player player); | ||
} |
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
54 changes: 54 additions & 0 deletions
54
src/main/java/wayoftime/bloodmagic/client/hud/element/ElementSoulNetwork.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,54 @@ | ||
package wayoftime.bloodmagic.client.hud.element; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Player; | ||
import wayoftime.bloodmagic.BloodMagic; | ||
import wayoftime.bloodmagic.core.data.SoulNetwork; | ||
import wayoftime.bloodmagic.util.Utils; | ||
import wayoftime.bloodmagic.util.helper.NetworkHelper; | ||
|
||
public class ElementSoulNetwork extends HUDElement | ||
{ | ||
|
||
private static final ResourceLocation BAR_LOCATION = new ResourceLocation(BloodMagic.MODID, "textures/hud/bars.png"); | ||
public ElementSoulNetwork() {super(36, 76);} | ||
|
||
@Override | ||
public void draw(GuiGraphics guiGraphics, float partialTicks, int drawX, int drawY) | ||
{ | ||
drawX += 4; // Offset X to account for wider HUD Box. | ||
|
||
Minecraft minecraft = Minecraft.getInstance(); | ||
Player player = minecraft.player; | ||
|
||
guiGraphics.blit(BAR_LOCATION, drawX, drawY, 0, 78, 28, 70); | ||
|
||
SoulNetwork soulNetwork = NetworkHelper.getSoulNetwork(player); | ||
int maxOrb = NetworkHelper.getCurrentMaxOrb(soulNetwork); | ||
int level = soulNetwork.getCurrentEssence(); | ||
int maxCapacity = NetworkHelper.getMaximumForTier(maxOrb); | ||
int fillHeight = 61 * level / maxCapacity; // 60 would have the bar full at exactly 100%. Set to 61 so the bar | ||
// is full slightly before the Soul Network is completely topped, so rituals don't flash the HUD. | ||
|
||
guiGraphics.blit(BAR_LOCATION, drawX + 8, drawY + 66 - fillHeight, 32, 86 + (58 - fillHeight), 12, fillHeight); | ||
|
||
if (player.isShiftKeyDown()) | ||
{ | ||
PoseStack poseStack = guiGraphics.pose(); | ||
poseStack.pushPose(); | ||
poseStack.translate(drawX + 14, drawY + 70, 0); | ||
poseStack.scale(0.5f, 0.5f, 1f); | ||
guiGraphics.drawCenteredString(minecraft.font, String.format("%,d LP", level), 0, 2, 0xffffffff); | ||
poseStack.popPose(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean shouldRender(Minecraft minecraft) | ||
{ | ||
return NetworkHelper.canPlayerSeeSoulNetwork(Minecraft.getInstance().player); | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.