mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-17 20:10:23 +03:00
* Get rid of the survivalmode remnants in CreativeMode.
This commit is contained in:
@@ -9,31 +9,10 @@
|
||||
#include "CreativeMode.hpp"
|
||||
#include "Minecraft.hpp"
|
||||
|
||||
CreativeMode::CreativeMode(Minecraft* pMC) : GameMode(pMC),
|
||||
m_destroyingX(-1), m_destroyingY(-1), m_destroyingZ(-1),
|
||||
field_18(0.0f), field_1C(0.0f), field_20(0), field_24(0)
|
||||
CreativeMode::CreativeMode(Minecraft* pMC) : GameMode(pMC)
|
||||
{
|
||||
}
|
||||
|
||||
void CreativeMode::initPlayer(Player* p)
|
||||
{
|
||||
p->m_yaw = -180.0f;
|
||||
p->m_pInventory->prepareCreativeInventory();
|
||||
}
|
||||
|
||||
void CreativeMode::startDestroyBlock(int x, int y, int z, int i)
|
||||
{
|
||||
TileID tile = m_pMinecraft->m_pLevel->getTile(x, y, z);
|
||||
|
||||
if (tile <= 0)
|
||||
return;
|
||||
|
||||
if (m_pMinecraft->m_pLocalPlayer->canDestroy(Tile::tiles[tile]))
|
||||
destroyBlock(x, y, z, i);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool CreativeMode::destroyBlock(int x, int y, int z, int i)
|
||||
{
|
||||
m_pMinecraft->m_pParticleEngine->destroy(x, y, z);
|
||||
@@ -50,7 +29,7 @@ bool CreativeMode::destroyBlock(int x, int y, int z, int i)
|
||||
if (bCanDestroy)
|
||||
{
|
||||
Tile::tiles[tile]->playerDestroy(m_pMinecraft->m_pLevel, m_pMinecraft->m_pLocalPlayer, x, y, z, data);
|
||||
|
||||
|
||||
if (m_pMinecraft->isOnline())
|
||||
{
|
||||
m_pMinecraft->m_pRakNetInstance->send(new RemoveBlockPacket(m_pMinecraft->m_pLocalPlayer->m_EntityID, x, y, z));
|
||||
@@ -60,76 +39,10 @@ bool CreativeMode::destroyBlock(int x, int y, int z, int i)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreativeMode::continueDestroyBlock(int x, int y, int z, int i)
|
||||
void CreativeMode::initPlayer(Player* p)
|
||||
{
|
||||
if (field_24 > 0)
|
||||
{
|
||||
field_24--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_destroyingX != x || m_destroyingY != y || m_destroyingZ != z)
|
||||
{
|
||||
field_18 = 0.0f;
|
||||
field_1C = 0.0f;
|
||||
field_20 = 0;
|
||||
m_destroyingX = x;
|
||||
m_destroyingY = y;
|
||||
m_destroyingZ = z;
|
||||
return;
|
||||
}
|
||||
|
||||
TileID tile = m_pMinecraft->m_pLevel->getTile(m_destroyingX, m_destroyingY, m_destroyingZ);
|
||||
if (!tile)
|
||||
return;
|
||||
|
||||
Tile* pTile = Tile::tiles[tile];
|
||||
float destroyProgress = pTile->getDestroyProgress(m_pMinecraft->m_pLocalPlayer);
|
||||
|
||||
field_18 += 16.0f * destroyProgress;
|
||||
field_20++;
|
||||
|
||||
if ((field_20 & 3) == 1)
|
||||
{
|
||||
m_pMinecraft->m_pSoundEngine->play("step." + pTile->m_pSound->m_name,
|
||||
float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f,
|
||||
0.5f * (1.0f + pTile->m_pSound->field_18), 0.8f * pTile->m_pSound->field_1C);
|
||||
}
|
||||
|
||||
if (field_18 >= 1.0f)
|
||||
{
|
||||
destroyBlock(m_destroyingX, m_destroyingY, m_destroyingZ, i);
|
||||
field_20 = 0;
|
||||
field_24 = 5;
|
||||
field_18 = 0.0f;
|
||||
field_1C = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void CreativeMode::stopDestroyBlock()
|
||||
{
|
||||
field_18 = 0.0f;
|
||||
field_24 = 0;
|
||||
}
|
||||
|
||||
void CreativeMode::tick()
|
||||
{
|
||||
field_1C = field_18;
|
||||
}
|
||||
|
||||
void CreativeMode::render(float f)
|
||||
{
|
||||
if (field_18 <= 0.0f)
|
||||
{
|
||||
m_pMinecraft->m_gui.field_8 = 0.0f;
|
||||
m_pMinecraft->m_pLevelRenderer->field_10 = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float x = field_1C + (field_18 - field_1C) * f;
|
||||
m_pMinecraft->m_gui.field_8 = x;
|
||||
m_pMinecraft->m_pLevelRenderer->field_10 = x;
|
||||
}
|
||||
p->m_yaw = -180.0f;
|
||||
p->m_pInventory->prepareCreativeInventory();
|
||||
}
|
||||
|
||||
float CreativeMode::getPickRange()
|
||||
|
||||
@@ -14,25 +14,11 @@ class CreativeMode : public GameMode
|
||||
{
|
||||
public:
|
||||
CreativeMode(Minecraft*);
|
||||
bool destroyBlock(int, int, int, int);
|
||||
|
||||
void startDestroyBlock(int x, int y, int z, int i) override;
|
||||
bool destroyBlock(int x, int y, int z, int i);
|
||||
void continueDestroyBlock(int x, int y, int z, int i);
|
||||
void stopDestroyBlock() override;
|
||||
void tick() override;
|
||||
void render(float f) override;
|
||||
float getPickRange() override;
|
||||
bool isCreativeType() override;
|
||||
bool isSurvivalType() override;
|
||||
void initPlayer(Player*) override;
|
||||
|
||||
public:
|
||||
int m_destroyingX;
|
||||
int m_destroyingY;
|
||||
int m_destroyingZ;
|
||||
float field_18;
|
||||
float field_1C;
|
||||
int field_20;
|
||||
int field_24;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user