summaryrefslogtreecommitdiffstats
path: root/source/Generating
diff options
context:
space:
mode:
Diffstat (limited to 'source/Generating')
-rw-r--r--source/Generating/ChunkDesc.cpp9
-rw-r--r--source/Generating/ChunkDesc.h1
-rw-r--r--source/Generating/MineShafts.cpp59
3 files changed, 49 insertions, 20 deletions
diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp
index f0927f294..68feb463d 100644
--- a/source/Generating/ChunkDesc.cpp
+++ b/source/Generating/ChunkDesc.cpp
@@ -526,6 +526,15 @@ void cChunkDesc::RandomFillRelCuboid(
+void cChunkDesc::AddBlockEntity(cBlockEntity * a_BlockEntity)
+{
+ m_BlockEntities.push_back(a_BlockEntity);
+}
+
+
+
+
+
void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
{
const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();
diff --git a/source/Generating/ChunkDesc.h b/source/Generating/ChunkDesc.h
index 5ec3759a9..a25d0a720 100644
--- a/source/Generating/ChunkDesc.h
+++ b/source/Generating/ChunkDesc.h
@@ -169,6 +169,7 @@ public:
// tolua_end
+ void AddBlockEntity(cBlockEntity * a_BlockEntity);
// Accessors used by cChunkGenerator::Generator descendants:
inline cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; }
diff --git a/source/Generating/MineShafts.cpp b/source/Generating/MineShafts.cpp
index 330a87576..b4c17aa27 100644
--- a/source/Generating/MineShafts.cpp
+++ b/source/Generating/MineShafts.cpp
@@ -19,6 +19,7 @@ in a depth-first processing. Each of the descendants will branch randomly, if no
#include "Globals.h"
#include "MineShafts.h"
#include "../Cuboid.h"
+#include "../ChestEntity.h"
@@ -747,6 +748,22 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc)
void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
{
+ static const cLootProbab LootProbab[] =
+ {
+ // Item, MinAmount, MaxAmount, Weight
+ { cItem(E_ITEM_IRON), 1, 5, 10 },
+ { cItem(E_ITEM_GOLD), 1, 3, 5 },
+ { cItem(E_ITEM_REDSTONE_DUST), 4, 9, 5 },
+ { cItem(E_ITEM_DIAMOND), 1, 2, 3 },
+ { cItem(E_ITEM_DYE, 1, 4), 4, 9, 5 }, // lapis lazuli dye
+ { cItem(E_ITEM_COAL), 3, 8, 10 },
+ { cItem(E_ITEM_BREAD), 1, 3, 15 },
+ { cItem(E_ITEM_IRON_PICKAXE), 1, 1, 1 },
+ { cItem(E_BLOCK_MINECART_TRACKS), 4, 8, 1 },
+ { cItem(E_ITEM_MELON_SEEDS), 2, 4, 10 },
+ { cItem(E_ITEM_PUMPKIN_SEEDS), 2, 4, 10 },
+ } ;
+
if (m_ChestPosition < 0)
{
return;
@@ -754,40 +771,42 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ int x, z;
+ NIBBLETYPE Meta = 0;
switch (m_Direction)
{
case dirXM:
case dirXP:
{
- int x = m_BoundingBox.p1.x + m_ChestPosition - BlockX;
- int z = m_BoundingBox.p1.z - BlockZ;
- if (
- (x >= 0) && (x < cChunkDef::Width) &&
- (z >= 0) && (z < cChunkDef::Width)
- )
- {
- a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, 0);
- // TODO: Fill the chest with loot
- }
+ x = m_BoundingBox.p1.x + m_ChestPosition - BlockX;
+ z = m_BoundingBox.p1.z - BlockZ;
+ Meta = E_META_CHEST_FACING_ZP;
break;
}
case dirZM:
case dirZP:
{
- int x = m_BoundingBox.p1.x - BlockX;
- int z = m_BoundingBox.p1.z + m_ChestPosition - BlockZ;
- if (
- (x >= 0) && (x < cChunkDef::Width) &&
- (z >= 0) && (z < cChunkDef::Width)
- )
- {
- a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, 0);
- // TODO: Fill the chest with loot
- }
+ x = m_BoundingBox.p1.x - BlockX;
+ z = m_BoundingBox.p1.z + m_ChestPosition - BlockZ;
+ Meta = E_META_CHEST_FACING_XP;
break;
}
} // switch (Dir)
+
+ if (
+ (x >= 0) && (x < cChunkDef::Width) &&
+ (z >= 0) && (z < cChunkDef::Width)
+ )
+ {
+ a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, Meta);
+ cChestEntity * ChestEntity = new cChestEntity(BlockX + x, m_BoundingBox.p1.y + 1, BlockZ + z);
+ cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
+ int NumSlots = 3 + ((Noise.IntNoise3DInt(x, m_BoundingBox.p1.y, z) / 11) % 4);
+ int Seed = Noise.IntNoise2DInt(x, z);
+ ChestEntity->GenerateRandomLootWithBooks(LootProbab, ARRAYCOUNT(LootProbab), NumSlots, Seed);
+ a_ChunkDesc.AddBlockEntity(ChestEntity);
+ }
}