aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/IUIScene_HUD.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/Common/UI/IUIScene_HUD.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.Client/Common/UI/IUIScene_HUD.cpp')
-rw-r--r--Minecraft.Client/Common/UI/IUIScene_HUD.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp
index 03adbd2c..fd977966 100644
--- a/Minecraft.Client/Common/UI/IUIScene_HUD.cpp
+++ b/Minecraft.Client/Common/UI/IUIScene_HUD.cpp
@@ -7,6 +7,8 @@
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.monster.h"
#include "IUIScene_HUD.h"
+#include "UI.h"
+
IUIScene_HUD::IUIScene_HUD()
{
m_lastActiveSlot = -1;
@@ -79,7 +81,7 @@ void IUIScene_HUD::updateFrameTick()
{
//SetRidingHorse(false, 0);
shared_ptr<Entity> riding = pMinecraft->localplayers[iPad]->riding;
- if(riding == NULL)
+ if(riding == nullptr)
{
SetRidingHorse(false, false, 0);
}
@@ -146,8 +148,8 @@ void IUIScene_HUD::updateFrameTick()
{
if(uiOpacityTimer<10)
{
- float fStep=(80.0f-(float)ucAlpha)/10.0f;
- fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep));
+ float fStep=(80.0f-static_cast<float>(ucAlpha))/10.0f;
+ fVal=0.01f*(80.0f-((10.0f-static_cast<float>(uiOpacityTimer))*fStep));
}
else
{
@@ -156,7 +158,7 @@ void IUIScene_HUD::updateFrameTick()
}
else
{
- fVal=0.01f*(float)ucAlpha;
+ fVal=0.01f*static_cast<float>(ucAlpha);
}
}
else
@@ -166,12 +168,12 @@ void IUIScene_HUD::updateFrameTick()
{
ucAlpha=15;
}
- fVal=0.01f*(float)ucAlpha;
+ fVal=0.01f*static_cast<float>(ucAlpha);
}
SetOpacity(fVal);
bool bDisplayGui=app.GetGameStarted() && !ui.GetMenuDisplayed(iPad) && !(app.GetXuiAction(iPad)==eAppAction_AutosaveSaveGameCapturedThumbnail) && app.GetGameSettings(iPad,eGameSetting_DisplayHUD)!=0;
- if(bDisplayGui && pMinecraft->localplayers[iPad] != NULL)
+ if(bDisplayGui && pMinecraft->localplayers[iPad] != nullptr)
{
SetVisible(true);
}
@@ -198,7 +200,7 @@ void IUIScene_HUD::renderPlayerHealth()
bool bHasPoison = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::poison);
bool bHasWither = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::wither);
AttributeInstance *maxHealthAttribute = pMinecraft->localplayers[iPad]->getAttribute(SharedMonsterAttributes::MAX_HEALTH);
- float maxHealth = (float)maxHealthAttribute->getValue();
+ float maxHealth = static_cast<float>(maxHealthAttribute->getValue());
float totalAbsorption = pMinecraft->localplayers[iPad]->getAbsorptionAmount();
// Update armour
@@ -219,7 +221,7 @@ void IUIScene_HUD::renderPlayerHealth()
shared_ptr<Entity> riding = pMinecraft->localplayers[iPad]->riding;
- if(riding == NULL || riding && !riding->instanceof(eTYPE_LIVINGENTITY))
+ if(riding == nullptr || riding && !riding->instanceof(eTYPE_LIVINGENTITY))
{
SetRidingHorse(false, false, 0);
@@ -242,8 +244,8 @@ void IUIScene_HUD::renderPlayerHealth()
if (pMinecraft->localplayers[iPad]->isUnderLiquid(Material::water))
{
ShowAir(true);
- int count = (int) ceil((pMinecraft->localplayers[iPad]->getAirSupply() - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY);
- int extra = (int) ceil((pMinecraft->localplayers[iPad]->getAirSupply()) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count;
+ int count = static_cast<int>(ceil((pMinecraft->localplayers[iPad]->getAirSupply() - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY));
+ int extra = static_cast<int>(ceil((pMinecraft->localplayers[iPad]->getAirSupply()) * 10.0f / Player::TOTAL_AIR_SUPPLY)) - count;
SetAir(count, extra);
}
else
@@ -254,7 +256,7 @@ void IUIScene_HUD::renderPlayerHealth()
else if(riding->instanceof(eTYPE_LIVINGENTITY) )
{
shared_ptr<LivingEntity> living = dynamic_pointer_cast<LivingEntity>(riding);
- int riderCurrentHealth = (int) ceil(living->getHealth());
+ int riderCurrentHealth = static_cast<int>(ceil(living->getHealth()));
float maxRiderHealth = living->getMaxHealth();
SetRidingHorse(true, pMinecraft->localplayers[iPad]->isRidingJumpable(), maxRiderHealth);