summaryrefslogtreecommitdiffstats
path: root/source/Generating/MineShafts.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-06 23:21:57 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-06 23:21:57 +0200
commit502935c061ea913180f0a77a7406f5292e697c79 (patch)
treea74e562a772b89db12985d6f1744ae91ff4890d6 /source/Generating/MineShafts.cpp
parentAdded a tab in the serversettings where you can edit the world.ini of all your worlds. (diff)
downloadcuberite-502935c061ea913180f0a77a7406f5292e697c79.tar
cuberite-502935c061ea913180f0a77a7406f5292e697c79.tar.gz
cuberite-502935c061ea913180f0a77a7406f5292e697c79.tar.bz2
cuberite-502935c061ea913180f0a77a7406f5292e697c79.tar.lz
cuberite-502935c061ea913180f0a77a7406f5292e697c79.tar.xz
cuberite-502935c061ea913180f0a77a7406f5292e697c79.tar.zst
cuberite-502935c061ea913180f0a77a7406f5292e697c79.zip
Diffstat (limited to 'source/Generating/MineShafts.cpp')
-rw-r--r--source/Generating/MineShafts.cpp59
1 files changed, 39 insertions, 20 deletions
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);
+ }
}