* Work on survival mode.

This commit is contained in:
iProgramInCpp
2023-08-13 23:01:40 +03:00
parent e9f4ae6533
commit 1e7bedaa72
5 changed files with 25 additions and 2 deletions

View File

@@ -123,6 +123,9 @@ int LocalPlayer::move(float x, float y, float z)
int result = 0;
LocalPlayer* pLP = m_pMinecraft->m_pLocalPlayer;
if (!pLP)
return 1300; // TODO
if (Minecraft::DEADMAU5_CAMERA_CHEATS && pLP == this && m_pMinecraft->m_options.m_bFlyCheat)
{
//@HUH: Using m_pMinecraft->m_pLocalPlayer instead of this, even though they're the same
@@ -235,3 +238,15 @@ void LocalPlayer::updateAi()
field_B0C = m_pKeyboardInput->m_bJumpButton || m_nAutoJumpFrames > 0;
}
void LocalPlayer::beforeRemove()
{
#ifdef TEST_SURVIVAL_MODE
LogMsg("The localplayer was removed");
if (m_pMinecraft->m_pLocalPlayer == this)
m_pMinecraft->m_pLocalPlayer = nullptr;
if (m_pMinecraft->m_pMobPersp == this)
m_pMinecraft->m_pMobPersp = nullptr;
#endif
}

View File

@@ -27,6 +27,7 @@ public:
virtual int move(float x, float y, float z) override;
virtual void tick() override;
virtual void updateAi() override;
virtual void beforeRemove() override;
void calculateFlight(float, float, float);
void closeContainer(); //@HUH: oddly enough not a virtual/override

View File

@@ -364,7 +364,7 @@ void Mob::causeFallDamage(float level)
int x = int(ceilf(level - 3));
if (x > 0)
{
hurt(nullptr, 3);
hurt(nullptr, 3*42);
//@HUH: useless call to getTile? or could this be a return value of some sort
//Entity::causeFallDamage returns nothing though, so....
@@ -710,7 +710,9 @@ int Mob::getMaxSpawnClusterSize()
void Mob::actuallyHurt(int damage)
{
#ifdef TEST_SURVIVAL_MODE
m_health -= damage;
#endif
}
bool Mob::removeWhenFarAway()

View File

@@ -84,7 +84,11 @@ bool Player::isCreativeModeAllowed()
bool Player::hurt(Entity* pEnt, int damage)
{
//@HUH
#ifndef TEST_SURVIVAL_MODE
return false;
#endif
return Mob::hurt(pEnt, damage);
}
void Player::awardKillScore(Entity* pKilled, int score)

View File

@@ -92,6 +92,7 @@ void Inventory::prepareSurvivalInventory()
addTestItem(Item::wheat->m_itemID, 64);
addTestItem(Item::sugar->m_itemID, 64);
addTestItem(Item::camera->m_itemID, 64);
addTestItem(Tile::ladder->m_ID, 64);
for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++)
m_hotbar[i] = i;