aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/LocalPlayer.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-07 21:12:22 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-07 21:12:22 -0600
commit087b7e7abfe81dd7f0fdcdea36ac9f245950df1a (patch)
tree69454763e73ca764af4e682d3573080b13138a0e /Minecraft.Client/LocalPlayer.cpp
parenta9be52c41a02d207233199e98898fe7483d7e817 (diff)
Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore functionality of the nightly. All in-game menus do not work and generating a world crashes. This reverts commit a9be52c41a02d207233199e98898fe7483d7e817.
Diffstat (limited to 'Minecraft.Client/LocalPlayer.cpp')
-rw-r--r--Minecraft.Client/LocalPlayer.cpp106
1 files changed, 53 insertions, 53 deletions
diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp
index 7988416a..d743543e 100644
--- a/Minecraft.Client/LocalPlayer.cpp
+++ b/Minecraft.Client/LocalPlayer.cpp
@@ -56,7 +56,7 @@
#ifndef _DURANGO
#include "..\Minecraft.World\CommonStats.h"
#endif
-extern ConsoleUIController ui;
+
LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dimension) : Player(level, user->name)
@@ -79,11 +79,11 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim
this->minecraft = minecraft;
this->dimension = dimension;
- if (user != nullptr && user->name.length() > 0)
+ if (user != NULL && user->name.length() > 0)
{
customTextureUrl = L"http://s3.amazonaws.com/MinecraftSkins/" + user->name + L".png";
}
- if( user != nullptr )
+ if( user != NULL )
{
this->name = user->name;
//wprintf(L"Created LocalPlayer with name %ls\n", name.c_str() );
@@ -95,7 +95,7 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim
}
}
- input = nullptr;
+ input = NULL;
m_iPad = -1;
m_iScreenSection=C4JRender::VIEWPORT_TYPE_FULLSCREEN; // assume singleplayer default
m_bPlayerRespawned=false;
@@ -124,7 +124,7 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim
LocalPlayer::~LocalPlayer()
{
- if( this->input != nullptr )
+ if( this->input != NULL )
delete input;
}
@@ -188,9 +188,9 @@ void LocalPlayer::aiStep()
{
if (!level->isClientSide)
{
- if (riding != nullptr) this->ride(nullptr);
+ if (riding != NULL) this->ride(nullptr);
}
- if (minecraft->screen != nullptr) minecraft->setScreen(nullptr);
+ if (minecraft->screen != NULL) minecraft->setScreen(NULL);
if (portalTime == 0)
{
@@ -389,11 +389,11 @@ void LocalPlayer::aiStep()
jumpRidingTicks++;
if (jumpRidingTicks < 10)
{
- jumpRidingScale = static_cast<float>(jumpRidingTicks) * .1f;
+ jumpRidingScale = (float) jumpRidingTicks * .1f;
}
else
{
- jumpRidingScale = .8f + (2.f / static_cast<float>(jumpRidingTicks - 9)) * .1f;
+ jumpRidingScale = .8f + (2.f / ((float) (jumpRidingTicks - 9))) * .1f;
}
}
}
@@ -427,9 +427,9 @@ void LocalPlayer::aiStep()
#ifdef _DEBUG_MENUS_ENABLED
if(abilities.debugflying)
{
- flyX = static_cast<float>(viewVector->x) * input->ya;
- flyY = static_cast<float>(viewVector->y) * input->ya;
- flyZ = static_cast<float>(viewVector->z) * input->ya;
+ flyX = (float)viewVector->x * input->ya;
+ flyY = (float)viewVector->y * input->ya;
+ flyZ = (float)viewVector->z * input->ya;
}
else
#endif
@@ -437,11 +437,11 @@ void LocalPlayer::aiStep()
if( isSprinting() )
{
// Accelrate up to full speed if we are sprinting, moving in the direction of the view vector
- flyX = static_cast<float>(viewVector->x) * input->ya;
- flyY = static_cast<float>(viewVector->y) * input->ya;
- flyZ = static_cast<float>(viewVector->z) * input->ya;
+ flyX = (float)viewVector->x * input->ya;
+ flyY = (float)viewVector->y * input->ya;
+ flyZ = (float)viewVector->z * input->ya;
- float scale = static_cast<float>(SPRINT_DURATION - sprintTime)/10.0f;
+ float scale = ((float)(SPRINT_DURATION - sprintTime))/10.0f;
scale = scale * scale;
if ( scale > 1.0f ) scale = 1.0f;
flyX *= scale;
@@ -544,7 +544,7 @@ float LocalPlayer::getFieldOfViewModifier()
if (isUsingItem() && getUseItem()->id == Item::bow->id)
{
int ticksHeld = getTicksUsingItem();
- float scale = static_cast<float>(ticksHeld) / BowItem::MAX_DRAW_DURATION;
+ float scale = (float) ticksHeld / BowItem::MAX_DRAW_DURATION;
if (scale > 1)
{
scale = 1;
@@ -574,7 +574,7 @@ void LocalPlayer::readAdditionalSaveData(CompoundTag *entityTag)
void LocalPlayer::closeContainer()
{
Player::closeContainer();
- minecraft->setScreen(nullptr);
+ minecraft->setScreen(NULL);
// 4J - Close any xui here
// Fix for #9164 - CRASH: MP: Title crashes upon opening a chest and having another user destroy it.
@@ -705,21 +705,21 @@ bool LocalPlayer::openTrading(shared_ptr<Merchant> traderTarget, const wstring &
void LocalPlayer::crit(shared_ptr<Entity> e)
{
- shared_ptr<CritParticle> critParticle = std::make_shared<CritParticle>(reinterpret_cast<Level*>(minecraft->level), e);
+ shared_ptr<CritParticle> critParticle = shared_ptr<CritParticle>( new CritParticle((Level *)minecraft->level, e) );
critParticle->CritParticlePostConstructor();
minecraft->particleEngine->add(critParticle);
}
void LocalPlayer::magicCrit(shared_ptr<Entity> e)
{
- shared_ptr<CritParticle> critParticle = std::make_shared<CritParticle>(reinterpret_cast<Level*>(minecraft->level), e, eParticleType_magicCrit);
+ shared_ptr<CritParticle> critParticle = shared_ptr<CritParticle>( new CritParticle((Level *)minecraft->level, e, eParticleType_magicCrit) );
critParticle->CritParticlePostConstructor();
minecraft->particleEngine->add(critParticle);
}
void LocalPlayer::take(shared_ptr<Entity> e, int orgCount)
{
- minecraft->particleEngine->add(std::make_shared<TakeAnimationParticle>(reinterpret_cast<Level*>(minecraft->level), e, shared_from_this(), -0.5f));
+ minecraft->particleEngine->add( shared_ptr<TakeAnimationParticle>( new TakeAnimationParticle((Level *)minecraft->level, e, shared_from_this(), -0.5f) ) );
}
void LocalPlayer::chat(const wstring& message)
@@ -754,8 +754,8 @@ void LocalPlayer::hurtTo(float newHealth, ETelemetryChallenges damageSource)
if( this->getHealth() <= 0)
{
- int deathTime = static_cast<int>(level->getGameTime() % Level::TICKS_PER_DAY)/1000;
- int carriedId = inventory->getSelected() == nullptr ? 0 : inventory->getSelected()->id;
+ int deathTime = (int)(level->getGameTime() % Level::TICKS_PER_DAY)/1000;
+ int carriedId = inventory->getSelected() == NULL ? 0 : inventory->getSelected()->id;
TelemetryManager->RecordPlayerDiedOrFailed(GetXboxPad(), 0, y, 0, 0, carriedId, 0, damageSource);
// if there are any xuiscenes up for this player, close them
@@ -800,11 +800,11 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param)
delete [] param.data;
if (!app.CanRecordStatsAndAchievements()) return;
- if (stat == nullptr) return;
+ if (stat == NULL) return;
if (stat->isAchievement())
{
- Achievement *ach = static_cast<Achievement *>(stat);
+ Achievement *ach = (Achievement *) stat;
// 4J-PB - changed to attempt to award everytime - the award may need a storage device, so needs a primary player, and the player may not have been a primary player when they first 'got' the award
// so let the award manager figure it out
//if (!minecraft->stats[m_iPad]->hasTaken(ach))
@@ -830,7 +830,7 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param)
}
// 4J-JEV: To stop spamming trophies.
- unsigned long long achBit = static_cast<unsigned long long>(1) << ach->getAchievementID();
+ unsigned long long achBit = ((unsigned long long)1) << ach->getAchievementID();
if ( !(achBit & m_awardedThisSession) )
{
ProfileManager.Award(m_iPad, ach->getAchievementID());
@@ -1196,7 +1196,7 @@ void LocalPlayer::playSound(int soundId, float volume, float pitch)
bool LocalPlayer::isRidingJumpable()
{
- return riding != nullptr && riding->GetType() == eTYPE_HORSE;
+ return riding != NULL && riding->GetType() == eTYPE_HORSE;
}
float LocalPlayer::getJumpRidingScale()
@@ -1215,9 +1215,9 @@ bool LocalPlayer::hasPermission(EGameCommand command)
void LocalPlayer::onCrafted(shared_ptr<ItemInstance> item)
{
- if( minecraft->localgameModes[m_iPad] != nullptr )
+ if( minecraft->localgameModes[m_iPad] != NULL )
{
- TutorialMode *gameMode = static_cast<TutorialMode *>(minecraft->localgameModes[m_iPad]);
+ TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_iPad];
gameMode->getTutorial()->onCrafted(item);
}
}
@@ -1239,8 +1239,8 @@ void LocalPlayer::mapPlayerChunk(const unsigned int flagTileType)
int cx = this->xChunk;
int cz = this->zChunk;
- int pZ = static_cast<int>(floor(this->z)) %16;
- int pX = static_cast<int>(floor(this->x)) %16;
+ int pZ = ((int) floor(this->z)) %16;
+ int pX = ((int) floor(this->x)) %16;
cout<<"player in chunk ("<<cx<<","<<cz<<") at ("
<<this->x<<","<<this->y<<","<<this->z<<")\n";
@@ -1272,14 +1272,14 @@ void LocalPlayer::mapPlayerChunk(const unsigned int flagTileType)
void LocalPlayer::handleMouseDown(int button, bool down)
{
// 4J Stu - We should not accept any input while asleep, except the above to wake up
- if(isSleeping() && level != nullptr && level->isClientSide)
+ if(isSleeping() && level != NULL && level->isClientSide)
{
return;
}
if (!down) missTime = 0;
if (button == 0 && missTime > 0) return;
- if (down && minecraft->hitResult != nullptr && minecraft->hitResult->type == HitResult::TILE && button == 0)
+ if (down && minecraft->hitResult != NULL && minecraft->hitResult->type == HitResult::TILE && button == 0)
{
int x = minecraft->hitResult->x;
int y = minecraft->hitResult->y;
@@ -1328,9 +1328,9 @@ bool LocalPlayer::creativeModeHandleMouseClick(int button, bool buttonPressed)
}
// Get distance from last click point in each axis
- float dX = static_cast<float>(x) - lastClickX;
- float dY = static_cast<float>(y) - lastClickY;
- float dZ = static_cast<float>(z) - lastClickZ;
+ float dX = (float)x - lastClickX;
+ float dY = (float)y - lastClickY;
+ float dZ = (float)z - lastClickZ;
bool newClick = false;
float ddx = dX - lastClickdX;
@@ -1436,9 +1436,9 @@ bool LocalPlayer::creativeModeHandleMouseClick(int button, bool buttonPressed)
else
{
// First click - just record position & handle
- lastClickX = static_cast<float>(x);
- lastClickY = static_cast<float>(y);
- lastClickZ = static_cast<float>(z);
+ lastClickX = (float)x;
+ lastClickY = (float)y;
+ lastClickZ = (float)z;
// If we actually placed an item, then move into the init state as we are going to be doing the special creative mode auto repeat
bool itemPlaced = handleMouseClick(button);
// If we're sprinting or riding, don't auto-repeat at all. With auto repeat on, we can quickly place fires causing photosensitivity issues due to rapid flashing
@@ -1486,7 +1486,7 @@ bool LocalPlayer::handleMouseClick(int button)
// 4J-PB - Adding a special case in here for sleeping in a bed in a multiplayer game - we need to wake up, and we don't have the inbedchatscreen with a button
- if(button==1 && (isSleeping() && level != nullptr && level->isClientSide))
+ if(button==1 && (isSleeping() && level != NULL && level->isClientSide))
{
if(lastClickState == lastClick_oldRepeat) return false;
@@ -1497,14 +1497,14 @@ bool LocalPlayer::handleMouseClick(int button)
}
// 4J Stu - We should not accept any input while asleep, except the above to wake up
- if(isSleeping() && level != nullptr && level->isClientSide)
+ if(isSleeping() && level != NULL && level->isClientSide)
{
return false;
}
shared_ptr<ItemInstance> oldItem = inventory->getSelected();
- if (minecraft->hitResult == nullptr)
+ if (minecraft->hitResult == NULL)
{
if (button == 0 && minecraft->localgameModes[GetXboxPad()]->hasMissTime()) missTime = 10;
}
@@ -1555,7 +1555,7 @@ bool LocalPlayer::handleMouseClick(int button)
else
{
shared_ptr<ItemInstance> item = oldItem;
- int oldCount = item != nullptr ? item->count : 0;
+ int oldCount = item != NULL ? item->count : 0;
bool usedItem = false;
if (minecraft->gameMode->useItemOn(minecraft->localplayers[GetXboxPad()], level, item, x, y, z, face, minecraft->hitResult->pos, false, &usedItem))
{
@@ -1568,7 +1568,7 @@ bool LocalPlayer::handleMouseClick(int button)
//app.DebugPrintf("Player %d is swinging\n",GetXboxPad());
swing();
}
- if (item == nullptr)
+ if (item == NULL)
{
return false;
}
@@ -1587,7 +1587,7 @@ bool LocalPlayer::handleMouseClick(int button)
if (mayUse && button == 1)
{
shared_ptr<ItemInstance> item = inventory->getSelected();
- if (item != nullptr)
+ if (item != NULL)
{
if (minecraft->gameMode->useItem(minecraft->localplayers[GetXboxPad()], level, item))
{
@@ -1603,23 +1603,23 @@ void LocalPlayer::updateRichPresence()
if((m_iPad!=-1)/* && !ui.GetMenuDisplayed(m_iPad)*/ )
{
shared_ptr<ItemInstance> selectedItem = inventory->getSelected();
- if(selectedItem != nullptr && selectedItem->id == Item::fishingRod_Id)
+ if(selectedItem != NULL && selectedItem->id == Item::fishingRod_Id)
{
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FISHING);
}
- else if(selectedItem != nullptr && selectedItem->id == Item::map_Id)
+ else if(selectedItem != NULL && selectedItem->id == Item::map_Id)
{
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_MAP);
}
- else if ( (riding != nullptr) && riding->instanceof(eTYPE_MINECART) )
+ else if ( (riding != NULL) && riding->instanceof(eTYPE_MINECART) )
{
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_MINECART);
}
- else if ( (riding != nullptr) && riding->instanceof(eTYPE_BOAT) )
+ else if ( (riding != NULL) && riding->instanceof(eTYPE_BOAT) )
{
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BOATING);
}
- else if ( (riding != nullptr) && riding->instanceof(eTYPE_PIG) )
+ else if ( (riding != NULL) && riding->instanceof(eTYPE_PIG) )
{
app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_RIDING_PIG);
}
@@ -1660,13 +1660,13 @@ float LocalPlayer::getAndResetChangeDimensionTimer()
void LocalPlayer::handleCollectItem(shared_ptr<ItemInstance> item)
{
- if(item != nullptr)
+ if(item != NULL)
{
unsigned int itemCountAnyAux = 0;
unsigned int itemCountThisAux = 0;
for (unsigned int k = 0; k < inventory->items.length; ++k)
{
- if (inventory->items[k] != nullptr)
+ if (inventory->items[k] != NULL)
{
// do they have the item
if(inventory->items[k]->id == item->id)
@@ -1682,7 +1682,7 @@ void LocalPlayer::handleCollectItem(shared_ptr<ItemInstance> item)
}
}
}
- TutorialMode *gameMode = static_cast<TutorialMode *>(minecraft->localgameModes[m_iPad]);
+ TutorialMode *gameMode = (TutorialMode *)minecraft->localgameModes[m_iPad];
gameMode->getTutorial()->onTake(item, itemCountAnyAux, itemCountThisAux);
}