From 7089c5e2671d2bf7781ab2eab7129bb5bd25b1a1 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 16 Mar 2014 14:01:22 +0100
Subject: [PATCH 01/10] Add new leaves to all classes.
---
src/Blocks/BlockLeaves.h | 2 +-
src/ChunkMap.cpp | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index a6d3373c1..954b993d6 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -87,7 +87,7 @@ public:
return;
}
- if ((Meta & 0x8) != 0)
+ if ((Meta & 0x8) == 0)
{
// These leaves have been checked for decay lately and nothing around them changed
return;
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index e695f0ab2..da5dd90e4 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1384,6 +1384,13 @@ void cChunkMap::ReplaceTreeBlocks(const sSetBlockVector & a_Blocks)
}
break;
}
+ case E_BLOCK_NEW_LEAVES:
+ {
+ if (itr->BlockType == E_BLOCK_NEW_LOG)
+ {
+ Chunk->SetBlock(itr->x, itr->y, itr->z, itr->BlockType, itr->BlockMeta);
+ }
+ }
}
} // for itr - a_Blocks[]
}
From c4a8336e847d2f4731dd9d899d6af200631f8aef Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 16 Mar 2014 14:38:41 +0100
Subject: [PATCH 02/10] Add HOOK_BLOCK_SPREAD
---
src/Bindings/Plugin.h | 1 +
src/Bindings/PluginLua.cpp | 21 +++++++++++++++++++++
src/Bindings/PluginLua.h | 1 +
src/Bindings/PluginManager.cpp | 21 +++++++++++++++++++++
src/Bindings/PluginManager.h | 2 ++
src/Simulator/FireSimulator.cpp | 14 +++++++++++---
6 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 949e4693a..4c6d5a938 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -46,6 +46,7 @@ public:
* On all these functions, return true if you want to override default behavior and not call other plugins on that callback.
* You can also return false, so default behavior is used.
**/
+ virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) = 0;
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index cccbc3c93..cefeb4996 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -195,6 +195,26 @@ void cPluginLua::Tick(float a_Dt)
+bool cPluginLua::OnBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_BLOCK_SPREAD];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), a_World, a_BlockX, a_BlockY, a_BlockZ, cLuaState::Return, res);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginLua::OnBlockToPickups(cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups)
{
cCSLock Lock(m_CriticalSection);
@@ -1430,6 +1450,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
{
switch (a_HookType)
{
+ case cPluginManager::HOOK_BLOCK_SPREAD: return "OnBlockSpread";
case cPluginManager::HOOK_BLOCK_TO_PICKUPS: return "OnBlockToPickups";
case cPluginManager::HOOK_CHAT: return "OnChat";
case cPluginManager::HOOK_CHUNK_AVAILABLE: return "OnChunkAvailable";
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index a177f5288..5c2c9e57f 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -69,6 +69,7 @@ public:
virtual void Tick(float a_Dt) override;
+ virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) override;
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) override;
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index b9cf160c4..142b4b5ad 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -205,6 +205,27 @@ void cPluginManager::Tick(float a_Dt)
+bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_SPREAD);
+ if (Plugins == m_Hooks.end())
+ {
+ return false;
+ }
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnBlockSpread(a_World, a_BlockX, a_BlockY, a_BlockZ))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginManager::CallHookBlockToPickups(
cWorld * a_World, cEntity * a_Digger,
int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 44bc5a8d7..18d34a50d 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -58,6 +58,7 @@ public: // tolua_export
// tolua_begin
enum PluginHook
{
+ HOOK_BLOCK_SPREAD,
HOOK_BLOCK_TO_PICKUPS,
HOOK_CHAT,
HOOK_CHUNK_AVAILABLE,
@@ -154,6 +155,7 @@ public: // tolua_export
unsigned int GetNumPlugins() const; // tolua_export
// Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
+ bool CallHookBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
bool CallHookBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups);
bool CallHookChat (cPlayer * a_Player, AString & a_Message);
bool CallHookChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 26712e6e6..871a1ec5c 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -6,6 +6,8 @@
#include "../BlockID.h"
#include "../Defines.h"
#include "../Chunk.h"
+#include "Root.h"
+#include "PluginManager.h"
@@ -315,9 +317,15 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int
*/
if (CanStartFireInBlock(a_Chunk, x, y, z))
{
- FLOG("FS: Starting new fire at {%d, %d, %d}.",
- x + a_Chunk->GetPosX() * cChunkDef::Width, y, z + a_Chunk->GetPosZ() * cChunkDef::Width
- );
+ int a_PosX = x + a_Chunk->GetPosX() * cChunkDef::Width;
+ int a_PosZ = z + a_Chunk->GetPosZ() * cChunkDef::Width;
+
+ if (cRoot::Get()->GetPluginManager()->CallHookBlockSpread(&m_World, a_PosX, y, a_PosZ))
+ {
+ return;
+ }
+
+ FLOG("FS: Starting new fire at {%d, %d, %d}.", a_PosX, y, a_PosZ);
a_Chunk->UnboundedRelSetBlock(x, y, z, E_BLOCK_FIRE, 0);
}
} // for y
From 3774b1be6445257a28677fbdce17bab58c168df9 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 16 Mar 2014 16:06:03 +0100
Subject: [PATCH 03/10] Add SpreadSource
---
src/Bindings/Plugin.h | 2 +-
src/Bindings/PluginLua.cpp | 4 ++--
src/Bindings/PluginLua.h | 2 +-
src/Bindings/PluginManager.cpp | 4 ++--
src/Bindings/PluginManager.h | 2 +-
src/BlockID.h | 13 +++++++++++++
src/Blocks/BlockDirt.h | 5 ++++-
src/Blocks/BlockMushroom.h | 3 +++
src/Blocks/BlockMycelium.h | 2 ++
src/Blocks/BlockVine.h | 5 ++++-
src/Simulator/FireSimulator.cpp | 2 +-
11 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 4c6d5a938..057fa0304 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -46,7 +46,7 @@ public:
* On all these functions, return true if you want to override default behavior and not call other plugins on that callback.
* You can also return false, so default behavior is used.
**/
- virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
+ virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0;
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) = 0;
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index cefeb4996..4f0e13f12 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -195,14 +195,14 @@ void cPluginLua::Tick(float a_Dt)
-bool cPluginLua::OnBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+bool cPluginLua::OnBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_BLOCK_SPREAD];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), a_World, a_BlockX, a_BlockY, a_BlockZ, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source, cLuaState::Return, res);
if (res)
{
return true;
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 5c2c9e57f..f51056186 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -69,7 +69,7 @@ public:
virtual void Tick(float a_Dt) override;
- virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+ virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) override;
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) override;
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) override;
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 142b4b5ad..7d346c522 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -205,7 +205,7 @@ void cPluginManager::Tick(float a_Dt)
-bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
{
HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_SPREAD);
if (Plugins == m_Hooks.end())
@@ -214,7 +214,7 @@ bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_B
}
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnBlockSpread(a_World, a_BlockX, a_BlockY, a_BlockZ))
+ if ((*itr)->OnBlockSpread(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source))
{
return true;
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 18d34a50d..03f19e831 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -155,7 +155,7 @@ public: // tolua_export
unsigned int GetNumPlugins() const; // tolua_export
// Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
- bool CallHookBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
+ bool CallHookBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source);
bool CallHookBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups);
bool CallHookChat (cPlayer * a_Player, AString & a_Message);
bool CallHookChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
diff --git a/src/BlockID.h b/src/BlockID.h
index 8adefcfba..a1a445da4 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -866,6 +866,19 @@ enum eShrapnelLevel
slAll
} ;
+
+
+
+
+enum eSpreadSource
+{
+ esFireSpread,
+ esGrassSpread,
+ esMushroomSpread,
+ esMycelSpread,
+ esVineSpread,
+} ;
+
// tolua_end
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h
index 544424a04..6240e5e3f 100644
--- a/src/Blocks/BlockDirt.h
+++ b/src/Blocks/BlockDirt.h
@@ -79,7 +79,10 @@ public:
Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta);
if ((cBlockInfo::IsOneHitDig(AboveDest) || cBlockInfo::IsTransparent(AboveDest)) && !IsBlockWater(AboveDest))
{
- Chunk->FastSetBlock(BlockX, BlockY, BlockZ, E_BLOCK_GRASS, 0);
+ if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, BlockX * cChunkDef::Width, BlockY, BlockZ * cChunkDef::Width, esGrassSpread))
+ {
+ Chunk->FastSetBlock(BlockX, BlockY, BlockZ, E_BLOCK_GRASS, 0);
+ }
}
} // for i - repeat twice
}
diff --git a/src/Blocks/BlockMushroom.h b/src/Blocks/BlockMushroom.h
index c30c1a401..135d418d7 100644
--- a/src/Blocks/BlockMushroom.h
+++ b/src/Blocks/BlockMushroom.h
@@ -17,6 +17,9 @@ public:
}
+ // TODO: Add Mushroom Spread
+
+
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to 0
diff --git a/src/Blocks/BlockMycelium.h b/src/Blocks/BlockMycelium.h
index 7f897c72a..2a8ef5fca 100644
--- a/src/Blocks/BlockMycelium.h
+++ b/src/Blocks/BlockMycelium.h
@@ -16,6 +16,8 @@ public:
{
}
+ // TODO: Add Mycel Spread
+
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0));
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h
index 8041d9359..9d84b720e 100644
--- a/src/Blocks/BlockVine.h
+++ b/src/Blocks/BlockVine.h
@@ -175,7 +175,10 @@ public:
a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY - 1, a_RelZ, Block);
if (Block == E_BLOCK_AIR)
{
- a_Chunk.UnboundedRelSetBlock(a_RelX, a_RelY - 1, a_RelZ, E_BLOCK_VINES, a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
+ if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, a_RelX * cChunkDef::Width, a_RelY - 1, a_RelZ * cChunkDef::Width, esVineSpread))
+ {
+ a_Chunk.UnboundedRelSetBlock(a_RelX, a_RelY - 1, a_RelZ, E_BLOCK_VINES, a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
+ }
}
}
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 871a1ec5c..932ccf6bd 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -320,7 +320,7 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int
int a_PosX = x + a_Chunk->GetPosX() * cChunkDef::Width;
int a_PosZ = z + a_Chunk->GetPosZ() * cChunkDef::Width;
- if (cRoot::Get()->GetPluginManager()->CallHookBlockSpread(&m_World, a_PosX, y, a_PosZ))
+ if (cRoot::Get()->GetPluginManager()->CallHookBlockSpread(&m_World, a_PosX, y, a_PosZ, esFireSpread))
{
return;
}
From 54d55b31ef9b17673212184ac523f6f2a964338d Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 16 Mar 2014 16:12:16 +0100
Subject: [PATCH 04/10] Add documentation for new Block spread
---
MCServer/Plugins/APIDump/APIDesc.lua | 9 +++++
.../Plugins/APIDump/Hooks/OnBlockSpread.lua | 40 +++++++++++++++++++
2 files changed, 49 insertions(+)
create mode 100644 MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 74e7bf860..92b57865f 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1826,6 +1826,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
},
Constants =
{
+ HOOK_BLOCK_SPREAD = { Notes = "Called when a block spreads based on world conditions" },
HOOK_BLOCK_TO_PICKUPS = { Notes = "Called when a block has been dug and is being converted to pickups. The server has provided the default pickups and the plugins may modify them." },
HOOK_CHAT = { Notes = "Called when a client sends a chat message that is not a command. The plugin may modify the chat message" },
HOOK_CHUNK_AVAILABLE = { Notes = "Called when a chunk is loaded or generated and becomes available in the {{cWorld|world}}." },
@@ -2767,6 +2768,14 @@ end
data provided with the explosions, such as the exploding {{cCreeper|creeper}} entity or the
{{Vector3i|coords}} of the exploding bed.
]],
+ },
+ SpreadSource =
+ {
+ Include = "^es.*",
+ TextBefore = [[
+ These constants are used to differentiate the various sources of spreads. They are used in
+ the {{OnBlockSpread|HOOK_BLOCK_SPREAD}} hook.
+ ]],
}
},
}, -- Globals
diff --git a/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua b/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
new file mode 100644
index 000000000..1dde55f36
--- /dev/null
+++ b/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
@@ -0,0 +1,40 @@
+return
+{
+ HOOK_BLOCK_SPREAD =
+ {
+ CalledWhen = "Called when a block spreads based on world conditions",
+ DefaultFnName = "OnBlockSpread", -- also used as pagename
+ Desc = [[
+ This hook is called when a block spreads.
+
+ The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT,
+ etc. It also carries the identification of the actual source. The exact type of the identification
+ depends on the source kind:
+
+ Source | Notes |
+ esFireSpread | Fire spreading |
+ esGrassSpread | Grass spreading |
+ esMushroomSpread | Mushroom spreading |
+ esMycelSpread | Mycel spreading |
+ esVineSpread | Vine spreading |
+
+ ]],
+ Params =
+ {
+ { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" },
+ { Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
+ { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
+ { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
+ { Name = "Source", Type = "eSpreadSource", Notes = "Source of the spread. See the table above." },
+ },
+ Returns = [[
+ If the function returns false or no value, the next plugin's callback is called, and finally
+ MCServer will process the spread. If the function
+ returns true, no other callback is called for this event and the spread will not occur.
+ ]],
+ }, -- HOOK_BLOCK_SPREAD
+}
+
+
+
+
From 09794e65bb8d752148250c40c710c08d0acf7ff8 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 16 Mar 2014 16:15:22 +0100
Subject: [PATCH 05/10] Wrong if in BlockLeaves
---
src/Blocks/BlockLeaves.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index 954b993d6..a6d3373c1 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -87,7 +87,7 @@ public:
return;
}
- if ((Meta & 0x8) == 0)
+ if ((Meta & 0x8) != 0)
{
// These leaves have been checked for decay lately and nothing around them changed
return;
From 9c461124866cd16d04206f49da6650a2219de50f Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 16 Mar 2014 22:28:12 +0100
Subject: [PATCH 06/10] Change SpreadSource prefix to ss
---
src/BlockID.h | 10 +++++-----
src/Blocks/BlockDirt.h | 2 +-
src/Blocks/BlockVine.h | 2 +-
src/Simulator/FireSimulator.cpp | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/BlockID.h b/src/BlockID.h
index a1a445da4..2fec512e2 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -872,11 +872,11 @@ enum eShrapnelLevel
enum eSpreadSource
{
- esFireSpread,
- esGrassSpread,
- esMushroomSpread,
- esMycelSpread,
- esVineSpread,
+ ssFireSpread,
+ ssGrassSpread,
+ ssMushroomSpread,
+ ssMycelSpread,
+ ssVineSpread,
} ;
// tolua_end
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h
index 6240e5e3f..a1ab74257 100644
--- a/src/Blocks/BlockDirt.h
+++ b/src/Blocks/BlockDirt.h
@@ -79,7 +79,7 @@ public:
Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta);
if ((cBlockInfo::IsOneHitDig(AboveDest) || cBlockInfo::IsTransparent(AboveDest)) && !IsBlockWater(AboveDest))
{
- if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, BlockX * cChunkDef::Width, BlockY, BlockZ * cChunkDef::Width, esGrassSpread))
+ if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, BlockX * cChunkDef::Width, BlockY, BlockZ * cChunkDef::Width, ssGrassSpread))
{
Chunk->FastSetBlock(BlockX, BlockY, BlockZ, E_BLOCK_GRASS, 0);
}
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h
index 9d84b720e..d096c81a8 100644
--- a/src/Blocks/BlockVine.h
+++ b/src/Blocks/BlockVine.h
@@ -175,7 +175,7 @@ public:
a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY - 1, a_RelZ, Block);
if (Block == E_BLOCK_AIR)
{
- if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, a_RelX * cChunkDef::Width, a_RelY - 1, a_RelZ * cChunkDef::Width, esVineSpread))
+ if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread((cWorld*) &a_WorldInterface, a_RelX * cChunkDef::Width, a_RelY - 1, a_RelZ * cChunkDef::Width, ssVineSpread))
{
a_Chunk.UnboundedRelSetBlock(a_RelX, a_RelY - 1, a_RelZ, E_BLOCK_VINES, a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
}
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 932ccf6bd..e4d4a540d 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -320,7 +320,7 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int
int a_PosX = x + a_Chunk->GetPosX() * cChunkDef::Width;
int a_PosZ = z + a_Chunk->GetPosZ() * cChunkDef::Width;
- if (cRoot::Get()->GetPluginManager()->CallHookBlockSpread(&m_World, a_PosX, y, a_PosZ, esFireSpread))
+ if (cRoot::Get()->GetPluginManager()->CallHookBlockSpread(&m_World, a_PosX, y, a_PosZ, ssFireSpread))
{
return;
}
From 9ac3e3405a92d458bf3d09d0ec0f60031d31823d Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 16 Mar 2014 22:28:53 +0100
Subject: [PATCH 07/10] Change SpreadSource documentation
---
MCServer/Plugins/APIDump/APIDesc.lua | 2 +-
MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 92b57865f..f8ad74226 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2771,7 +2771,7 @@ end
},
SpreadSource =
{
- Include = "^es.*",
+ Include = "^ss.*",
TextBefore = [[
These constants are used to differentiate the various sources of spreads. They are used in
the {{OnBlockSpread|HOOK_BLOCK_SPREAD}} hook.
diff --git a/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua b/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
index 1dde55f36..a2f7d7ef9 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
@@ -12,11 +12,11 @@ return
depends on the source kind:
Source | Notes |
- esFireSpread | Fire spreading |
- esGrassSpread | Grass spreading |
- esMushroomSpread | Mushroom spreading |
- esMycelSpread | Mycel spreading |
- esVineSpread | Vine spreading |
+ ssFireSpread | Fire spreading |
+ ssGrassSpread | Grass spreading |
+ ssMushroomSpread | Mushroom spreading |
+ ssMycelSpread | Mycel spreading |
+ ssVineSpread | Vine spreading |
]],
Params =
From 327b70e769bd3bb826320027a1b7d56f6e386a6b Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 24 Mar 2014 20:01:57 +0100
Subject: [PATCH 08/10] Change documentation text
---
MCServer/Plugins/APIDump/APIDesc.lua | 4 ++--
MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index f8ad74226..01f000182 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2773,8 +2773,8 @@ end
{
Include = "^ss.*",
TextBefore = [[
- These constants are used to differentiate the various sources of spreads. They are used in
- the {{OnBlockSpread|HOOK_BLOCK_SPREAD}} hook.
+ These constants are used to differentiate the various sources of spreads, such as grass growing.
+ They are used in the {{OnBlockSpread|HOOK_BLOCK_SPREAD}} hook.
]],
}
},
diff --git a/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua b/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
index a2f7d7ef9..ed0b5f46f 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnBlockSpread.lua
@@ -7,8 +7,8 @@ return
Desc = [[
This hook is called when a block spreads.
- The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT,
- etc. It also carries the identification of the actual source. The exact type of the identification
+ The spread carries with it the type of its source - whether it's a block spreads.
+ It also carries the identification of the actual source. The exact type of the identification
depends on the source kind:
Source | Notes |
From 8301f479bba4c12579d56c2274b85033a336057c Mon Sep 17 00:00:00 2001
From: Howaner
Date: Thu, 27 Mar 2014 23:21:04 +0100
Subject: [PATCH 09/10] Fix merge conflicts
---
src/ChunkMap.cpp | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index da5dd90e4..e695f0ab2 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1384,13 +1384,6 @@ void cChunkMap::ReplaceTreeBlocks(const sSetBlockVector & a_Blocks)
}
break;
}
- case E_BLOCK_NEW_LEAVES:
- {
- if (itr->BlockType == E_BLOCK_NEW_LOG)
- {
- Chunk->SetBlock(itr->x, itr->y, itr->z, itr->BlockType, itr->BlockMeta);
- }
- }
}
} // for itr - a_Blocks[]
}
From a2c4def518b0021a7575c9a9517f4f824369fe6d Mon Sep 17 00:00:00 2001
From: Howaner
Date: Fri, 28 Mar 2014 14:59:40 +0100
Subject: [PATCH 10/10] Add missing ChunkDesc import.
---
src/Generating/Prefab.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h
index ec95c909b..c80de21b2 100644
--- a/src/Generating/Prefab.h
+++ b/src/Generating/Prefab.h
@@ -16,7 +16,7 @@ declared in this file as well; the Gallery server exports areas in this format.
#include "PieceGenerator.h"
#include "../BlockArea.h"
-
+#include "ChunkDesc.h"