summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-05 15:45:00 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-05 15:45:00 +0200
commitd397dd263f121340ef4633904e3c01419786856c (patch)
treeaddea805f20127475b5a632efdddf1d3adb3d2f1 /source
parentFixed personal crafting grid not being tossed on inventory close. (diff)
downloadcuberite-d397dd263f121340ef4633904e3c01419786856c.tar
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.gz
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.bz2
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.lz
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.xz
cuberite-d397dd263f121340ef4633904e3c01419786856c.tar.zst
cuberite-d397dd263f121340ef4633904e3c01419786856c.zip
Diffstat (limited to 'source')
-rw-r--r--source/BlockID.cpp8
-rw-r--r--source/Blocks/BlockCrops.h59
-rw-r--r--source/Blocks/BlockHandler.cpp2
-rw-r--r--source/Items/ItemHandler.cpp4
-rw-r--r--source/Items/ItemSeeds.h4
-rw-r--r--source/World.cpp34
-rw-r--r--source/World.h6
7 files changed, 106 insertions, 11 deletions
diff --git a/source/BlockID.cpp b/source/BlockID.cpp
index 87829951e..b62cd98b0 100644
--- a/source/BlockID.cpp
+++ b/source/BlockID.cpp
@@ -393,6 +393,7 @@ public:
// Transparent blocks
g_BlockTransparent[E_BLOCK_AIR] = true;
g_BlockTransparent[E_BLOCK_BROWN_MUSHROOM] = true;
+ g_BlockTransparent[E_BLOCK_CARROTS] = true;
g_BlockTransparent[E_BLOCK_CHEST] = true;
g_BlockTransparent[E_BLOCK_COBWEB] = true;
g_BlockTransparent[E_BLOCK_CROPS] = true;
@@ -406,8 +407,11 @@ public:
g_BlockTransparent[E_BLOCK_IRON_DOOR] = true;
g_BlockTransparent[E_BLOCK_LEAVES] = true;
g_BlockTransparent[E_BLOCK_LEVER] = true;
+ g_BlockTransparent[E_BLOCK_MELON_STEM] = true;
g_BlockTransparent[E_BLOCK_NETHER_BRICK_FENCE] = true;
+ g_BlockTransparent[E_BLOCK_POTATOES] = true;
g_BlockTransparent[E_BLOCK_POWERED_RAIL] = true;
+ g_BlockTransparent[E_BLOCK_PUMPKIN_STEM] = true;
g_BlockTransparent[E_BLOCK_RAIL] = true;
g_BlockTransparent[E_BLOCK_RED_MUSHROOM] = true;
g_BlockTransparent[E_BLOCK_RED_ROSE] = true;
@@ -426,10 +430,14 @@ public:
// One hit break blocks
g_BlockOneHitDig[E_BLOCK_BROWN_MUSHROOM] = true;
+ g_BlockOneHitDig[E_BLOCK_CARROTS] = true;
g_BlockOneHitDig[E_BLOCK_CROPS] = true;
g_BlockOneHitDig[E_BLOCK_FIRE] = true;
g_BlockOneHitDig[E_BLOCK_FLOWER_POT] = true;
g_BlockOneHitDig[E_BLOCK_LOCKED_CHEST] = true;
+ g_BlockOneHitDig[E_BLOCK_MELON_STEM] = true;
+ g_BlockOneHitDig[E_BLOCK_POTATOES] = true;
+ g_BlockOneHitDig[E_BLOCK_PUMPKIN_STEM] = true;
g_BlockOneHitDig[E_BLOCK_REDSTONE_REPEATER_OFF] = true;
g_BlockOneHitDig[E_BLOCK_REDSTONE_REPEATER_ON] = true;
g_BlockOneHitDig[E_BLOCK_REDSTONE_TORCH_OFF] = true;
diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h
index 6b33a400c..7658d2633 100644
--- a/source/Blocks/BlockCrops.h
+++ b/source/Blocks/BlockCrops.h
@@ -1,9 +1,17 @@
+
#pragma once
+
#include "BlockHandler.h"
#include "../MersenneTwister.h"
#include "../World.h"
-class cBlockCropsHandler : public cBlockHandler
+
+
+
+
+/// Common class that takes care of carrots, potatoes and wheat
+class cBlockCropsHandler :
+ public cBlockHandler
{
public:
cBlockCropsHandler(BLOCKTYPE a_BlockType)
@@ -22,11 +30,54 @@ public:
{
MTRand rand;
- if (a_Meta == 0x7) // Is fully grown
+ if (a_Meta == 0x7)
+ {
+ // Is fully grown, drop the entire produce:
+ switch (m_BlockType)
+ {
+ case E_BLOCK_CROPS:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
+ a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ break;
+ }
+ case E_BLOCK_CARROTS:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_CARROT, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ break;
+ }
+ case E_BLOCK_POTATOES:
+ {
+ a_Pickups.push_back(cItem(E_ITEM_POTATO, 1 + (int)(rand.randInt(2) + rand.randInt(2)) / 2, 0)); // [1 .. 3] with high preference of 2
+ if (rand.randInt(20) == 0)
+ {
+ // With a 5% chance, drop a poisonous potato as well
+ a_Pickups.push_back(cItem(E_ITEM_POISONOUS_POTATO, 1, 0));
+ }
+ break;
+ }
+ default:
+ {
+ ASSERT(!"Unhandled block type");
+ break;
+ }
+ } // switch (m_BlockType)
+ }
+ else
{
- a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
+ // Drop 1 item of whatever is growing
+ switch (m_BlockType)
+ {
+ case E_BLOCK_CROPS: a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0)); break;
+ case E_BLOCK_CARROTS: a_Pickups.push_back(cItem(E_ITEM_CARROT, 1, 0)); break;
+ case E_BLOCK_POTATOES: a_Pickups.push_back(cItem(E_ITEM_POTATO, 1, 0)); break;
+ default:
+ {
+ ASSERT(!"Unhandled block type");
+ break;
+ }
+ }
}
- a_Pickups.push_back(cItem(E_ITEM_SEEDS, (rand.randInt(3) == 0) ? 2 : 1, 0));
}
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp
index 991102aca..0a6334e15 100644
--- a/source/Blocks/BlockHandler.cpp
+++ b/source/Blocks/BlockHandler.cpp
@@ -98,6 +98,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType);
+ case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
@@ -142,6 +143,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_PLANKS: return new cBlockWoodHandler (a_BlockType);
case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType);
case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
+ case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType);
case E_BLOCK_DETECTOR_RAIL: return new cBlockRailHandler (a_BlockType);
case E_BLOCK_REDSTONE_ORE: return new cBlockOreHandler (a_BlockType);
diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp
index 8411ad688..df3257263 100644
--- a/source/Items/ItemHandler.cpp
+++ b/source/Items/ItemHandler.cpp
@@ -143,8 +143,10 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
return new cItemBucketHandler(a_ItemType);
}
- case E_ITEM_PUMPKIN_SEEDS:
+ case E_ITEM_CARROT:
case E_ITEM_MELON_SEEDS:
+ case E_ITEM_POTATO:
+ case E_ITEM_PUMPKIN_SEEDS:
case E_ITEM_SEEDS:
{
return new cItemSeedsHandler(a_ItemType);
diff --git a/source/Items/ItemSeeds.h b/source/Items/ItemSeeds.h
index d6df8bdd0..7a5f77b80 100644
--- a/source/Items/ItemSeeds.h
+++ b/source/Items/ItemSeeds.h
@@ -49,9 +49,11 @@ public:
a_BlockMeta = 0;
switch (m_ItemType)
{
- case E_ITEM_SEEDS: a_BlockType = E_BLOCK_CROPS; return true;
+ case E_ITEM_CARROT: a_BlockType = E_BLOCK_CARROTS; return true;
case E_ITEM_MELON_SEEDS: a_BlockType = E_BLOCK_MELON_STEM; return true;
+ case E_ITEM_POTATO: a_BlockType = E_BLOCK_POTATOES; return true;
case E_ITEM_PUMPKIN_SEEDS: a_BlockType = E_BLOCK_PUMPKIN_STEM; return true;
+ case E_ITEM_SEEDS: a_BlockType = E_BLOCK_CROPS; return true;
default: a_BlockType = E_BLOCK_AIR; return true;
}
return false;
diff --git a/source/World.cpp b/source/World.cpp
index bef797e06..adea59c24 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -224,15 +224,17 @@ cWorld::cWorld(const AString & a_WorldName) :
StorageSchema = IniFile.GetValueSet ("Storage", "Schema", StorageSchema);
m_MaxCactusHeight = IniFile.GetValueSetI("Plants", "MaxCactusHeight", 3);
m_MaxSugarcaneHeight = IniFile.GetValueSetI("Plants", "MaxSugarcaneHeight", 3);
+ m_IsCactusBonemealable = IniFile.GetValueSetB("Plants", "IsCactusBonemealable", false);
+ m_IsCarrotsBonemealable = IniFile.GetValueSetB("Plants", "IsCarrotsBonemealable", true);
m_IsCropsBonemealable = IniFile.GetValueSetB("Plants", "IsCropsBonemealable", true);
m_IsGrassBonemealable = IniFile.GetValueSetB("Plants", "IsGrassBonemealable", true);
- m_IsSaplingBonemealable = IniFile.GetValueSetB("Plants", "IsSaplingBonemealable", true);
m_IsMelonStemBonemealable = IniFile.GetValueSetB("Plants", "IsMelonStemBonemealable", true);
m_IsMelonBonemealable = IniFile.GetValueSetB("Plants", "IsMelonBonemealable", false);
+ m_IsPotatoesBonemealable = IniFile.GetValueSetB("Plants", "IsPotatoesBonemealable", true);
m_IsPumpkinStemBonemealable = IniFile.GetValueSetB("Plants", "IsPumpkinStemBonemealable", true);
m_IsPumpkinBonemealable = IniFile.GetValueSetB("Plants", "IsPumpkinBonemealable", false);
+ m_IsSaplingBonemealable = IniFile.GetValueSetB("Plants", "IsSaplingBonemealable", true);
m_IsSugarcaneBonemealable = IniFile.GetValueSetB("Plants", "IsSugarcaneBonemealable", false);
- m_IsCactusBonemealable = IniFile.GetValueSetB("Plants", "IsCactusBonemealable", false);
m_bEnabledPVP = IniFile.GetValueSetB("PVP", "Enabled", true);
m_IsDeepSnowEnabled = IniFile.GetValueSetB("Physics", "DeepSnow", false);
@@ -879,9 +881,22 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
switch (BlockType)
{
+ case E_BLOCK_CARROTS:
+ {
+ if (a_IsByBonemeal && !m_IsCarrotsBonemealable)
+ {
+ return false;
+ }
+ if (BlockMeta < 7)
+ {
+ FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7);
+ }
+ return true;
+ }
+
case E_BLOCK_CROPS:
{
- if (a_IsByBonemeal && !m_IsGrassBonemealable)
+ if (a_IsByBonemeal && !m_IsCropsBonemealable)
{
return false;
}
@@ -913,6 +928,19 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
return true;
}
+ case E_BLOCK_POTATOES:
+ {
+ if (a_IsByBonemeal && !m_IsPotatoesBonemealable)
+ {
+ return false;
+ }
+ if (BlockMeta < 7)
+ {
+ FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7);
+ }
+ return true;
+ }
+
case E_BLOCK_PUMPKIN_STEM:
{
if (BlockMeta < 7)
diff --git a/source/World.h b/source/World.h
index 5eab923b7..74dc3b9e8 100644
--- a/source/World.h
+++ b/source/World.h
@@ -524,15 +524,17 @@ private:
int m_MaxCactusHeight;
int m_MaxSugarcaneHeight;
+ bool m_IsCactusBonemealable;
+ bool m_IsCarrotsBonemealable;
bool m_IsCropsBonemealable;
bool m_IsGrassBonemealable;
- bool m_IsSaplingBonemealable;
bool m_IsMelonStemBonemealable;
bool m_IsMelonBonemealable;
+ bool m_IsPotatoesBonemealable;
bool m_IsPumpkinStemBonemealable;
bool m_IsPumpkinBonemealable;
+ bool m_IsSaplingBonemealable;
bool m_IsSugarcaneBonemealable;
- bool m_IsCactusBonemealable;
cEntityList m_RemoveEntityQueue;
cEntityList m_AllEntities;