Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
7.5 kB · 264 lines
C++
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264#include "stdafx.h"#include "..\..\Minecraft.h"#include "..\..\MultiPlayerLocalPlayer.h"#include "..\..\..\Minecraft.World\net.minecraft.world.effect.h"#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"#include "..\..\..\Minecraft.World\net.minecraft.world.entity.ai.attributes.h"#include "..\..\..\Minecraft.World\net.minecraft.world.entity.monster.h"#include "IUIScene_HUD.h"
IUIScene_HUD::IUIScene_HUD(){ m_lastActiveSlot = -1; m_iGuiScale = -1; m_bToolTipsVisible = true; m_lastExpProgress = 0.0f; m_lastExpLevel = 0; m_iCurrentHealth = 0; m_lastMaxHealth = 20; m_lastHealthBlink = false; m_lastHealthPoison = false; m_iCurrentFood = -1; m_lastFoodPoison = false; m_lastAir = 10; m_currentExtraAir = 0; m_lastArmour = 0; m_showHealth = true; m_showHorseHealth = true; m_showFood = true; m_showAir = true; m_showArmour = true; m_showExpBar = true; m_bRegenEffectEnabled = false; m_iFoodSaturation = 0; m_lastDragonHealth = 0.0f; m_showDragonHealth = false; m_ticksWithNoBoss = 0; m_uiSelectedItemOpacityCountDown = 0; m_displayName = L""; m_lastShowDisplayName = true; m_bRidingHorse = true; m_horseHealth = 1; m_lastHealthWither = true; m_iCurrentHealthAbsorb = -1; m_horseJumpProgress = 1.0f; m_iHeartOffsetIndex = -1; m_bHealthAbsorbActive = false; m_iHorseMaxHealth = -1; m_bIsJumpable = false;}
void IUIScene_HUD::updateFrameTick(){ int iPad = getPad(); Minecraft *pMinecraft = Minecraft::GetInstance();
int iGuiScale;
if(pMinecraft->localplayers[iPad]->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN) { iGuiScale=app.GetGameSettings(iPad,eGameSetting_UISize); } else { iGuiScale=app.GetGameSettings(iPad,eGameSetting_UISizeSplitscreen); } SetHudSize(iGuiScale);
SetDisplayName(ProfileManager.GetDisplayName(iPad));
SetTooltipsEnabled(((ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad())) || (app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_Tooltips) != 0)));
SetActiveSlot(pMinecraft->localplayers[iPad]->inventory->selected);
if (pMinecraft->localgameModes[iPad]->canHurtPlayer()) { renderPlayerHealth(); } else { //SetRidingHorse(false, 0); shared_ptr<Entity> riding = pMinecraft->localplayers[iPad]->riding; if(riding == NULL) { SetRidingHorse(false, false, 0); } else { SetRidingHorse(true, pMinecraft->localplayers[iPad]->isRidingJumpable(), 0); } ShowHorseHealth(false); m_horseHealth = 0; ShowHealth(false); ShowFood(false); ShowAir(false); ShowArmour(false); ShowExpBar(false); SetHealthAbsorb(0); }
if(pMinecraft->localplayers[iPad]->isRidingJumpable()) { SetHorseJumpBarProgress(pMinecraft->localplayers[iPad]->getJumpRidingScale()); } else if (pMinecraft->localgameModes[iPad]->hasExperience()) { // Update xp progress ShowExpBar(true);
SetExpBarProgress(pMinecraft->localplayers[iPad]->experienceProgress, pMinecraft->localplayers[iPad]->getXpNeededForNextLevel());
// Update xp level SetExpLevel(pMinecraft->localplayers[iPad]->experienceLevel); } else { ShowExpBar(false); SetExpLevel(0); }
if(m_uiSelectedItemOpacityCountDown>0) { --m_uiSelectedItemOpacityCountDown;
// 4J Stu - Timing here is kept the same as on Xbox360, even though we do it differently now and do the fade out in Flash rather than directly setting opacity if(m_uiSelectedItemOpacityCountDown < (SharedConstants::TICKS_PER_SECOND * 1) ) { HideSelectedLabel(); m_uiSelectedItemOpacityCountDown = 0; } }
unsigned char ucAlpha=app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_InterfaceOpacity); float fVal;
if(ucAlpha<80) { // if we are in a menu, set the minimum opacity for tooltips to 15% if(ui.GetMenuDisplayed(iPad) && (ucAlpha<15)) { ucAlpha=15; }
// check if we have the timer running for the opacity unsigned int uiOpacityTimer=app.GetOpacityTimer(iPad); if(uiOpacityTimer!=0) { if(uiOpacityTimer<10) { float fStep=(80.0f-(float)ucAlpha)/10.0f; fVal=0.01f*(80.0f-((10.0f-(float)uiOpacityTimer)*fStep)); } else { fVal=0.01f*80.0f; } } else { fVal=0.01f*(float)ucAlpha; } } else { // if we are in a menu, set the minimum opacity for tooltips to 15% if(ui.GetMenuDisplayed(iPad) && (ucAlpha<15)) { ucAlpha=15; } fVal=0.01f*(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) { SetVisible(true); } else { SetVisible(false); }}
void IUIScene_HUD::renderPlayerHealth(){ Minecraft *pMinecraft = Minecraft::GetInstance(); int iPad = getPad();
ShowHealth(true);
SetRegenerationEffect(pMinecraft->localplayers[iPad]->hasEffect(MobEffect::regeneration));
// Update health bool blink = pMinecraft->localplayers[iPad]->invulnerableTime / 3 % 2 == 1; if (pMinecraft->localplayers[iPad]->invulnerableTime < 10) blink = false; int currentHealth = pMinecraft->localplayers[iPad]->getHealth(); int oldHealth = pMinecraft->localplayers[iPad]->lastHealth; 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 totalAbsorption = pMinecraft->localplayers[iPad]->getAbsorptionAmount();
// Update armour int armor = pMinecraft->localplayers[iPad]->getArmorValue();
SetHealth(currentHealth, oldHealth, blink, bHasPoison || bHasWither, bHasWither); SetHealthAbsorb(totalAbsorption);
if(armor > 0) { ShowArmour(true); SetArmour(armor); } else { ShowArmour(false); }
shared_ptr<Entity> riding = pMinecraft->localplayers[iPad]->riding;
if(riding == NULL || riding && !riding->instanceof(eTYPE_LIVINGENTITY)) { SetRidingHorse(false, false, 0);
ShowFood(true); ShowHorseHealth(false); m_horseHealth = 0;
// Update food //bool foodBlink = false; FoodData *foodData = pMinecraft->localplayers[iPad]->getFoodData(); int food = foodData->getFoodLevel(); int oldFood = foodData->getLastFoodLevel(); bool hasHungerEffect = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::hunger); int saturationLevel = pMinecraft->localplayers[iPad]->getFoodData()->getSaturationLevel();
SetFood(food, oldFood, hasHungerEffect); SetFoodSaturationLevel(saturationLevel);
// Update air 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; SetAir(count, extra); } else { ShowAir(false); } } else if(riding->instanceof(eTYPE_LIVINGENTITY) ) { shared_ptr<LivingEntity> living = dynamic_pointer_cast<LivingEntity>(riding); int riderCurrentHealth = (int) ceil(living->getHealth()); float maxRiderHealth = living->getMaxHealth();
SetRidingHorse(true, pMinecraft->localplayers[iPad]->isRidingJumpable(), maxRiderHealth); SetHorseHealth(riderCurrentHealth); ShowHorseHealth(true); }}