mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-11 20:11:18 +03:00
* Add LavaTexture.
This commit is contained in:
@@ -667,6 +667,7 @@ void Minecraft::init()
|
||||
m_pTextures = new Textures(&m_options, platform());
|
||||
m_pTextures->addDynamicTexture(new WaterTexture);
|
||||
m_pTextures->addDynamicTexture(new WaterSideTexture);
|
||||
m_pTextures->addDynamicTexture(new LavaTexture);
|
||||
m_pLevelRenderer = new LevelRenderer(this, m_pTextures);
|
||||
m_pGameRenderer = new GameRenderer(this);
|
||||
m_pParticleEngine = new ParticleEngine(m_pLevel, m_pTextures);
|
||||
|
||||
@@ -75,6 +75,19 @@ float Mth::sqrt(float a2)
|
||||
return sqrtf(a2);
|
||||
}
|
||||
|
||||
// ported from 0.6.1
|
||||
unsigned Mth::fastRandom()
|
||||
{
|
||||
int x0;
|
||||
static int x1, x2, x3, x4;
|
||||
|
||||
x0 = x1;
|
||||
x1 = x2;
|
||||
x2 = x3;
|
||||
x3 = x4;
|
||||
return(x4 = x4 ^ (unsigned(x4) >> 19) ^ x0 ^ (x0 << 11) ^ ((x0 ^ unsigned(x0 << 11)) >> 8));
|
||||
}
|
||||
|
||||
int Mth::floor(float f)
|
||||
{
|
||||
int result = int(f);
|
||||
|
||||
@@ -36,5 +36,6 @@ public:
|
||||
static float random(void);
|
||||
static float sin(float);
|
||||
static float sqrt(float);
|
||||
static unsigned fastRandom();
|
||||
};
|
||||
|
||||
|
||||
@@ -65,3 +65,20 @@ public:
|
||||
float* m_data3;
|
||||
float* m_data4;
|
||||
};
|
||||
|
||||
class LavaTexture : public DynamicTexture
|
||||
{
|
||||
public:
|
||||
LavaTexture();
|
||||
~LavaTexture();
|
||||
|
||||
void tick() override;
|
||||
|
||||
public:
|
||||
int field_14;
|
||||
int field_18;
|
||||
float* m_data1;
|
||||
float* m_data2;
|
||||
float* m_data3;
|
||||
float* m_data4;
|
||||
};
|
||||
|
||||
88
source/client/renderer/LavaTexture.cpp
Normal file
88
source/client/renderer/LavaTexture.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "DynamicTexture.hpp"
|
||||
#include "world/tile/Tile.hpp"
|
||||
|
||||
// Decompiled from MCPE v0.6.1.
|
||||
|
||||
LavaTexture::LavaTexture() : DynamicTexture(Tile::lava->m_TextureFrame)
|
||||
{
|
||||
field_14 = 0;
|
||||
field_18 = 0;
|
||||
|
||||
m_data1 = new float[0x400];
|
||||
m_data2 = new float[0x400];
|
||||
m_data3 = new float[0x400];
|
||||
m_data4 = new float[0x400];
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
m_data1[i] = 0.0f;
|
||||
m_data2[i] = 0.0f;
|
||||
m_data3[i] = 0.0f;
|
||||
m_data4[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
LavaTexture::~LavaTexture()
|
||||
{
|
||||
SAFE_DELETE(m_data1);
|
||||
SAFE_DELETE(m_data2);
|
||||
SAFE_DELETE(m_data3);
|
||||
SAFE_DELETE(m_data4);
|
||||
}
|
||||
|
||||
void LavaTexture::tick()
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
float f = 0.0F;
|
||||
int ax = int(Mth::sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f);
|
||||
int ay = int(Mth::sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f);
|
||||
|
||||
for (int bx = x - 1; bx <= x + 1; bx++)
|
||||
{
|
||||
for (int by = y - 1; by <= y + 1; by++)
|
||||
{
|
||||
int k2 = bx + ay & 0xf;
|
||||
int i3 = by + ax & 0xf;
|
||||
f += m_data1[k2 + i3 * 16];
|
||||
}
|
||||
}
|
||||
|
||||
m_data2[x + y * 16] = f / 10.0f + ((m_data3[(x & 0xf) + (y + 0 & 0xf) * 16] + m_data3[(x + 1 & 0xf) + (y & 0xf) * 16] + m_data3[(x + 1 & 0xf) + (y + 1 & 0xf) * 16] + m_data3[(x & 0xf) + (y + 1 & 0xf) * 16]) * 0.25f) * 0.8f;
|
||||
m_data3[x + y * 16] += m_data4[x + y * 16] * 0.01f;
|
||||
|
||||
if (m_data3[x + y * 16] < 0.0f)
|
||||
m_data3[x + y * 16] = 0.0f;
|
||||
|
||||
m_data4[x + y * 16] -= 0.06f;
|
||||
if (Mth::random() < 0.005f)
|
||||
m_data4[x + y * 16] = 1.5f;
|
||||
}
|
||||
}
|
||||
|
||||
std::swap(m_data1, m_data2);
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
float x1 = m_data1[i] * 2.0f;
|
||||
if (x1 > 1.0f)
|
||||
x1 = 1.0f;
|
||||
if (x1 < 0.0f)
|
||||
x1 = 0.0f;
|
||||
|
||||
m_pixels[i * 4 + 0] = int(155.0f + 100.0f * x1);
|
||||
m_pixels[i * 4 + 1] = int(255.0f * x1 * x1);
|
||||
m_pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1);
|
||||
m_pixels[i * 4 + 3] = 255;
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ void Inventory::prepareCreativeInventory()
|
||||
addCreativeItem(Tile::cloth->m_ID);
|
||||
addCreativeItem(Tile::mossStone->m_ID);
|
||||
addCreativeItem(Tile::bookshelf->m_ID);
|
||||
addCreativeItem(Tile::lapisBlock->m_ID);
|
||||
addCreativeItem(Tile::sponge->m_ID);
|
||||
addCreativeItem(Tile::sapling->m_ID);
|
||||
addCreativeItem(Tile::water->m_ID);
|
||||
|
||||
@@ -420,6 +420,7 @@
|
||||
<ClCompile Include="..\source\client\renderer\FrustumCuller.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\GameRenderer.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\ItemInHandRenderer.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\LavaTexture.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\LevelRenderer.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\LightLayer.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\LightUpdate.cpp" />
|
||||
|
||||
@@ -1958,6 +1958,9 @@
|
||||
<ClCompile Include="..\platforms\openal\SoundSystemAL.cpp">
|
||||
<Filter>source\platforms\openal</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\client\renderer\LavaTexture.cpp">
|
||||
<Filter>source\client\renderer</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\thirdparty\raknet\CMakeLists.txt">
|
||||
|
||||
Reference in New Issue
Block a user