summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-09 14:44:02 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-09 14:44:02 +0200
commit2c241bb9a465bc69764c93785a770e37a513cc2d (patch)
treee4bb47195339829410d822fc186176d5496ba9ae /source
parentCacti grow by themselves and by bonemeal (diff)
downloadcuberite-2c241bb9a465bc69764c93785a770e37a513cc2d.tar
cuberite-2c241bb9a465bc69764c93785a770e37a513cc2d.tar.gz
cuberite-2c241bb9a465bc69764c93785a770e37a513cc2d.tar.bz2
cuberite-2c241bb9a465bc69764c93785a770e37a513cc2d.tar.lz
cuberite-2c241bb9a465bc69764c93785a770e37a513cc2d.tar.xz
cuberite-2c241bb9a465bc69764c93785a770e37a513cc2d.tar.zst
cuberite-2c241bb9a465bc69764c93785a770e37a513cc2d.zip
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp8
-rw-r--r--source/Bindings.h2
-rw-r--r--source/cClientHandle.cpp2
-rw-r--r--source/cWorld.cpp75
-rw-r--r--source/cWorld.h16
5 files changed, 88 insertions, 15 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 8f8da6936..1b6494237 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/09/12 14:03:09.
+** Generated automatically by tolua++-1.0.92 on 06/09/12 14:43:12.
*/
#ifndef __cplusplus
@@ -10262,7 +10262,8 @@ static int tolua_AllToLua_cWorld_GrowPlant00(lua_State* tolua_S)
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isboolean(tolua_S,5,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
)
goto tolua_lerror;
else
@@ -10272,11 +10273,12 @@ static int tolua_AllToLua_cWorld_GrowPlant00(lua_State* tolua_S)
int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ bool a_IsByBonemeal = ((bool) tolua_toboolean(tolua_S,5,false));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GrowPlant'", NULL);
#endif
{
- bool tolua_ret = (bool) self->GrowPlant(a_BlockX,a_BlockY,a_BlockZ);
+ bool tolua_ret = (bool) self->GrowPlant(a_BlockX,a_BlockY,a_BlockZ,a_IsByBonemeal);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
diff --git a/source/Bindings.h b/source/Bindings.h
index 8b68cd874..81db3d493 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/09/12 14:03:09.
+** Generated automatically by tolua++-1.0.92 on 06/09/12 14:43:13.
*/
/* Exported function */
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 5f918f121..f9d74a0de 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -1586,7 +1586,7 @@ bool cClientHandle::HandleDyes(cPacket_BlockPlace * a_Packet)
if (Equipped.m_ItemHealth == E_META_DYE_WHITE)
{
cWorld * World = m_Player->GetWorld();
- return World->GrowPlant(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ);
+ return World->GrowPlant(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, true);
}
return false;
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index b8e785dd5..664a25bdd 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -235,21 +235,32 @@ cWorld::cWorld( const AString & a_WorldName )
cMakeDir::MakeDir(m_WorldName.c_str());
MTRand r1;
- m_SpawnX = (double)((r1.randInt()%1000)-500);
+ m_SpawnX = (double)((r1.randInt() % 1000) - 500);
m_SpawnY = cChunkDef::Height;
- m_SpawnZ = (double)((r1.randInt()%1000)-500);
+ m_SpawnZ = (double)((r1.randInt() % 1000) - 500);
m_GameMode = eGameMode_Creative;
AString StorageSchema("Default");
cIniFile IniFile(m_IniFileName);
- if( IniFile.ReadFile() )
+ if (IniFile.ReadFile())
{
- m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX );
- m_SpawnY = IniFile.GetValueF("SpawnPosition", "Y", m_SpawnY );
- m_SpawnZ = IniFile.GetValueF("SpawnPosition", "Z", m_SpawnZ );
+ m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX);
+ m_SpawnY = IniFile.GetValueF("SpawnPosition", "Y", m_SpawnY);
+ m_SpawnZ = IniFile.GetValueF("SpawnPosition", "Z", m_SpawnZ);
m_GameMode = (eGameMode)IniFile.GetValueI("GameMode", "GameMode", m_GameMode );
StorageSchema = IniFile.GetValue("Storage", "Schema", StorageSchema);
+ m_MaxCactusHeight = IniFile.GetValueI("Plants", "MaxCactusHeight", 3);
+ m_MaxSugarcaneHeight = IniFile.GetValueI("Plants", "MaxSugarcaneHeight", 3);
+ m_IsCropsBonemealable = IniFile.GetValueB("Plants", "IsCropsBonemealable", true);
+ m_IsGrassBonemealable = IniFile.GetValueB("Plants", "IsGrassBonemealable", true);
+ m_IsSaplingBonemealable = IniFile.GetValueB("Plants", "IsSaplingBonemealable", true);
+ m_IsMelonStemBonemealable = IniFile.GetValueB("Plants", "IsMelonStemBonemealable", true);
+ m_IsMelonBonemealable = IniFile.GetValueB("Plants", "IsMelonBonemealable", false);
+ m_IsPumpkinStemBonemealable = IniFile.GetValueB("Plants", "IsPumpkinStemBonemealable", true);
+ m_IsPumpkinBonemealable = IniFile.GetValueB("Plants", "IsPumpkinBonemealable", false);
+ m_IsSugarcaneBonemealable = IniFile.GetValueB("Plants", "IsSugarcaneBonemealable", false);
+ m_IsCactusBonemealable = IniFile.GetValueB("Plants", "IsCactusBonemealable", false);
}
else
{
@@ -274,7 +285,7 @@ cWorld::cWorld( const AString & a_WorldName )
if( IniFile2.ReadFile() )
{
m_bAnimals = IniFile2.GetValueB("Monsters", "AnimalsOn", true );
- m_SpawnMonsterRate = (float)IniFile2.GetValueF("Monsters", "AnimalSpawnInterval", 10 );
+ m_SpawnMonsterRate = (float)IniFile2.GetValueF("Monsters", "AnimalSpawnInterval", 10);
SetMaxPlayers(IniFile2.GetValueI("Server", "MaxPlayers", 9001));
m_Description = IniFile2.GetValue("Server", "Description", "MCServer! - It's OVER 9000!").c_str();
}
@@ -844,7 +855,7 @@ void cWorld::GrowTreeImage(const sSetBlockVector & a_Blocks)
-bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
+bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal)
{
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
@@ -853,6 +864,10 @@ bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
{
case E_BLOCK_CROPS:
{
+ if (a_IsByBonemeal && !m_IsGrassBonemealable)
+ {
+ return false;
+ }
if (BlockMeta < 7)
{
FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7);
@@ -861,14 +876,42 @@ bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
}
case E_BLOCK_MELON_STEM:
+ {
+ if (BlockMeta < 7)
+ {
+ if (a_IsByBonemeal && !m_IsMelonStemBonemealable)
+ {
+ return false;
+ }
+ FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7);
+ }
+ else
+ {
+ if (a_IsByBonemeal && !m_IsMelonBonemealable)
+ {
+ return false;
+ }
+ GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, BlockType);
+ }
+ return true;
+ }
+
case E_BLOCK_PUMPKIN_STEM:
{
if (BlockMeta < 7)
{
+ if (a_IsByBonemeal && !m_IsPumpkinStemBonemealable)
+ {
+ return false;
+ }
FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, 7);
}
else
{
+ if (a_IsByBonemeal && !m_IsPumpkinBonemealable)
+ {
+ return false;
+ }
GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, BlockType);
}
return true;
@@ -876,12 +919,20 @@ bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
case E_BLOCK_SAPLING:
{
+ if (a_IsByBonemeal && !m_IsSaplingBonemealable)
+ {
+ return false;
+ }
GrowTreeFromSapling(a_BlockX, a_BlockY, a_BlockZ, BlockMeta);
return true;
}
case E_BLOCK_GRASS:
{
+ if (a_IsByBonemeal && !m_IsGrassBonemealable)
+ {
+ return false;
+ }
MTRand r1;
for (int i = 0; i < 60; i++)
{
@@ -918,12 +969,20 @@ bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ)
case E_BLOCK_SUGARCANE:
{
+ if (a_IsByBonemeal && !m_IsSugarcaneBonemealable)
+ {
+ return false;
+ }
m_ChunkMap->GrowSugarcane(a_BlockX, a_BlockY, a_BlockZ, 3);
return true;
}
case E_BLOCK_CACTUS:
{
+ if (a_IsByBonemeal && !m_IsCactusBonemealable)
+ {
+ return false;
+ }
m_ChunkMap->GrowCactus(a_BlockX, a_BlockY, a_BlockZ, 3);
return true;
}
diff --git a/source/cWorld.h b/source/cWorld.h
index 8f5cf63b0..79f904f54 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -244,8 +244,8 @@ public:
void GrowTreeImage(const sSetBlockVector & a_Blocks);
- /// Grows the plant at the specified block to its ripe stage (bonemeal used); returns false if the block is not growable.
- bool GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
+ /// Grows the plant at the specified block to its ripe stage (bonemeal used); returns false if the block is not growable. If a_IsBonemeal is true, block is not grown if not allowed in world.ini
+ bool GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal = false); // tolua_export
/// Grows a melon or a pumpkin next to the block specified (assumed to be the stem)
void GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockType); // tolua_export
@@ -361,6 +361,18 @@ private:
eWeather m_Weather;
+ int m_MaxCactusHeight;
+ int m_MaxSugarcaneHeight;
+ bool m_IsCropsBonemealable;
+ bool m_IsGrassBonemealable;
+ bool m_IsSaplingBonemealable;
+ bool m_IsMelonStemBonemealable;
+ bool m_IsMelonBonemealable;
+ bool m_IsPumpkinStemBonemealable;
+ bool m_IsPumpkinBonemealable;
+ bool m_IsSugarcaneBonemealable;
+ bool m_IsCactusBonemealable;
+
cEntityList m_RemoveEntityQueue;
cEntityList m_AllEntities;
cClientHandleList m_Clients;