diff --git a/source/Minecraft.cpp b/source/Minecraft.cpp
index 67cc574..8fbdafd 100644
--- a/source/Minecraft.cpp
+++ b/source/Minecraft.cpp
@@ -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);
diff --git a/source/client/common/Mth.cpp b/source/client/common/Mth.cpp
index 25c1100..4bc566d 100644
--- a/source/client/common/Mth.cpp
+++ b/source/client/common/Mth.cpp
@@ -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);
diff --git a/source/client/common/Mth.hpp b/source/client/common/Mth.hpp
index e68f744..182b19b 100644
--- a/source/client/common/Mth.hpp
+++ b/source/client/common/Mth.hpp
@@ -36,5 +36,6 @@ public:
static float random(void);
static float sin(float);
static float sqrt(float);
+ static unsigned fastRandom();
};
diff --git a/source/client/renderer/DynamicTexture.hpp b/source/client/renderer/DynamicTexture.hpp
index c35a626..fea117b 100644
--- a/source/client/renderer/DynamicTexture.hpp
+++ b/source/client/renderer/DynamicTexture.hpp
@@ -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;
+};
diff --git a/source/client/renderer/LavaTexture.cpp b/source/client/renderer/LavaTexture.cpp
new file mode 100644
index 0000000..d44cad7
--- /dev/null
+++ b/source/client/renderer/LavaTexture.cpp
@@ -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;
+ }
+}
diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp
index 66933c1..f6c5b40 100644
--- a/source/world/item/Inventory.cpp
+++ b/source/world/item/Inventory.cpp
@@ -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);
diff --git a/windows_vs/minecraftcpp.vcxproj b/windows_vs/minecraftcpp.vcxproj
index 734d8ad..d912a01 100644
--- a/windows_vs/minecraftcpp.vcxproj
+++ b/windows_vs/minecraftcpp.vcxproj
@@ -420,6 +420,7 @@
+
diff --git a/windows_vs/minecraftcpp.vcxproj.filters b/windows_vs/minecraftcpp.vcxproj.filters
index 9215283..701e005 100644
--- a/windows_vs/minecraftcpp.vcxproj.filters
+++ b/windows_vs/minecraftcpp.vcxproj.filters
@@ -1958,6 +1958,9 @@
source\platforms\openal
+
+ source\client\renderer
+