diff options
Diffstat (limited to 'src/Blocks')
-rw-r--r-- | src/Blocks/BlockAnvil.h | 1 | ||||
-rw-r--r-- | src/Blocks/BlockDirt.h | 14 | ||||
-rw-r--r-- | src/Blocks/BlockEnchantmentTable.h | 2 | ||||
-rw-r--r-- | src/Blocks/BlockOre.h | 59 | ||||
-rw-r--r-- | src/Blocks/BlockWorkbench.h | 2 |
5 files changed, 75 insertions, 3 deletions
diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index 20514580e..abfa0f782 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -4,6 +4,7 @@ #include "BlockHandler.h" #include "../World.h" #include "../Entities/Player.h" +#include "../UI/AnvilWindow.h" diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index aae6719e2..12bca92dd 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -52,7 +52,19 @@ public: return; } } - + + // Make sure that there is enough light at the source block to spread + if (!a_Chunk.GetWorld()->IsChunkLighted(a_Chunk.GetPosX(), a_Chunk.GetPosZ())) + { + a_Chunk.GetWorld()->QueueLightChunk(a_Chunk.GetPosX(), a_Chunk.GetPosZ()); + return; + } + else if (std::max(a_Chunk.GetBlockLight(a_RelX, a_RelY + 1, a_RelZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelX, a_RelY + 1, a_RelZ))) < 9) + { + // Source block is not bright enough to spread + return; + } + // Grass spreads to adjacent dirt blocks: cFastRandom rand; for (int i = 0; i < 2; i++) // Pick two blocks to grow to diff --git a/src/Blocks/BlockEnchantmentTable.h b/src/Blocks/BlockEnchantmentTable.h index 81d2cb9a0..40001f356 100644 --- a/src/Blocks/BlockEnchantmentTable.h +++ b/src/Blocks/BlockEnchantmentTable.h @@ -2,7 +2,7 @@ #pragma once #include "BlockHandler.h" -#include "../UI/Window.h" +#include "../UI/EnchantingWindow.h" #include "../Entities/Player.h" diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h index f6ea3aa3c..08d79f435 100644 --- a/src/Blocks/BlockOre.h +++ b/src/Blocks/BlockOre.h @@ -11,6 +11,7 @@ class cBlockOreHandler : public cBlockHandler { + typedef cBlockHandler super; public: cBlockOreHandler(BLOCKTYPE a_BlockType) : cBlockHandler(a_BlockType) @@ -56,6 +57,64 @@ public: } } } + + virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override + { + super::OnDestroyedByPlayer(a_ChunkInterface, a_WorldInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); + + if (a_Player->IsGameModeCreative()) + { + // Don't drop XP when the player is in creative mode. + return; + } + + if (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) != 0) + { + // Don't drop XP when the ore is mined with the Silk Touch enchantment + return; + } + + cFastRandom Random; + int Reward = 0; + + switch (m_BlockType) + { + case E_BLOCK_NETHER_QUARTZ_ORE: + case E_BLOCK_LAPIS_ORE: + { + // Lapis and nether quartz get 2 - 5 experience + Reward = Random.NextInt(4) + 2; + break; + } + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + { + // Redstone gets 1 - 5 experience + Reward = Random.NextInt(5) + 1; + break; + } + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_EMERALD_ORE: + { + // Diamond and emerald get 3 - 7 experience + Reward = Random.NextInt(5) + 3; + break; + } + case E_BLOCK_COAL_ORE: + { + // Coal gets 0 - 2 experience + Reward = Random.NextInt(3); + break; + } + + default: break; + } + + if (Reward != 0) + { + a_WorldInterface.SpawnExperienceOrb(a_BlockX, a_BlockY, a_BlockZ, Reward); + } + } } ; diff --git a/src/Blocks/BlockWorkbench.h b/src/Blocks/BlockWorkbench.h index 699badaf2..e40e15606 100644 --- a/src/Blocks/BlockWorkbench.h +++ b/src/Blocks/BlockWorkbench.h @@ -2,7 +2,7 @@ #pragma once #include "BlockHandler.h" -#include "../UI/Window.h" +#include "../UI/CraftingWindow.h" #include "../Entities/Player.h" |