1
0

Added carrots and potatoes handling, bonemealing and proper lighting.

FS #166

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1359 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-04-05 13:45:00 +00:00
parent 4aed49a70f
commit d397dd263f
7 changed files with 106 additions and 11 deletions

View File

@ -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;

View File

@ -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)
{
a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
// 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
{
// 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));
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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;