Merge branch 'master' into saplingsandleaves
Conflicts: src/Bindings/DeprecatedBindings.cpp src/Blocks/BlockSapling.h
This commit is contained in:
commit
d0e7b2f18b
@ -28,5 +28,6 @@ UltraCoderRU
|
||||
worktycho
|
||||
xoft
|
||||
Yeeeeezus (Donated AlchemistVillage prefabs)
|
||||
Howaner
|
||||
|
||||
Please add yourself to this list if you contribute to MCServer.
|
||||
|
@ -1155,6 +1155,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins,
|
||||
HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" },
|
||||
HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" },
|
||||
HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" },
|
||||
RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the inventory, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." },
|
||||
RemoveOneEquippedItem = { Params = "", Return = "", Notes = "Removes one item from the hotbar's currently selected slot" },
|
||||
SetArmorSlot = { Params = "ArmorSlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified armor slot contents" },
|
||||
SetEquippedSlotNum = { Params = "EquippedSlotNum", Return = "", Notes = "Sets the currently selected hotbar slot number" },
|
||||
@ -1384,6 +1385,7 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3");
|
||||
{ Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" },
|
||||
{ Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" },
|
||||
},
|
||||
RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the grid, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." },
|
||||
RemoveOneItem =
|
||||
{
|
||||
{ Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" },
|
||||
|
@ -2,7 +2,7 @@ return
|
||||
{
|
||||
HOOK_PLAYER_USED_BLOCK =
|
||||
{
|
||||
CalledWhen = "A player has just used a block (chest, furnace…). Notification only.",
|
||||
CalledWhen = "A player has just used a block (chest, furnace...). Notification only.",
|
||||
DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename
|
||||
Desc = [[
|
||||
This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a
|
||||
|
@ -60,9 +60,10 @@ function Initialize(Plugin)
|
||||
PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace");
|
||||
PM:BindCommand("/sched", "debuggers", HandleSched, "- Schedules a simple countdown using cWorld:ScheduleTask()");
|
||||
PM:BindCommand("/cs", "debuggers", HandleChunkStay, "- Tests the ChunkStay Lua integration for the specified chunk coords");
|
||||
PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings")
|
||||
PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one")
|
||||
PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z")
|
||||
PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings");
|
||||
PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one");
|
||||
PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z");
|
||||
PM:BindCommand("/rmitem", "debuggers", HandleRMItem, "- Remove the specified item from the inventory.");
|
||||
|
||||
Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers)
|
||||
Plugin:AddWebTab("StressTest", HandleRequest_StressTest)
|
||||
@ -533,7 +534,7 @@ function OnTakeDamage(Receiver, TDI)
|
||||
-- Receiver is cPawn
|
||||
-- TDI is TakeDamageInfo
|
||||
|
||||
LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)");
|
||||
-- LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)");
|
||||
return false;
|
||||
end
|
||||
|
||||
@ -1105,6 +1106,41 @@ end
|
||||
|
||||
|
||||
|
||||
function HandleRMItem(a_Split, a_Player)
|
||||
-- Check params:
|
||||
if (a_Split[2] == nil) then
|
||||
a_Player:SendMessage("Usage: /rmitem <Item> [Count]")
|
||||
return true
|
||||
end
|
||||
|
||||
-- Parse the item type:
|
||||
local Item = cItem()
|
||||
if (not StringToItem(a_Split[2], Item)) then
|
||||
a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item")
|
||||
return true
|
||||
end
|
||||
|
||||
-- Parse the optional item count
|
||||
if (a_Split[3] ~= nil) then
|
||||
local Count = tonumber(a_Split[3])
|
||||
if (Count == nil) then
|
||||
a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number")
|
||||
return true
|
||||
end
|
||||
|
||||
Item.m_ItemCount = Count
|
||||
end
|
||||
|
||||
-- Remove the item:
|
||||
local NumRemovedItems = a_Player:GetInventory():RemoveItem(Item)
|
||||
a_Player:SendMessageSuccess("Removed " .. NumRemovedItems .. " Items!")
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleRequest_Debuggers(a_Request)
|
||||
local FolderContents = cFile:GetFolderContents("./");
|
||||
return "<p>The following objects have been returned by cFile:GetFolderContents():<ul><li>" .. table.concat(FolderContents, "</li><li>") .. "</li></ul></p>";
|
||||
|
@ -5,7 +5,7 @@ MCServer is a Minecraft server that is written in C++ and designed to be efficie
|
||||
|
||||
MCServer can run on PCs, Macs, and *nix. This includes android phones and tablets as well as Raspberry Pis.
|
||||
|
||||
We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.7.9.
|
||||
We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.7.10.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 784b04ff9afd5faeaeb15c3fa159ff98adf55182
|
||||
Subproject commit 1ed82759c68f92c4acc7e3f33b850cf9f01c8aba
|
@ -61,7 +61,7 @@ class cListAllocationPool : public cAllocationPool<T>
|
||||
free (m_FreeList.front());
|
||||
m_FreeList.pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual T * Allocate() override
|
||||
{
|
||||
@ -90,7 +90,7 @@ class cListAllocationPool : public cAllocationPool<T>
|
||||
}
|
||||
virtual void Free(T * a_ptr) override
|
||||
{
|
||||
if (a_ptr == NULL)
|
||||
if (a_ptr == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -107,3 +107,7 @@ class cListAllocationPool : public cAllocationPool<T>
|
||||
std::list<void *> m_FreeList;
|
||||
std::auto_ptr<typename cAllocationPool<T>::cStarvationCallbacks> m_Callbacks;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
135
src/Bindings/CMakeLists.txt
Normal file
135
src/Bindings/CMakeLists.txt
Normal file
@ -0,0 +1,135 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
project (MCServer)
|
||||
|
||||
include_directories ("${PROJECT_SOURCE_DIR}/../")
|
||||
include_directories (".")
|
||||
|
||||
SET (SRCS
|
||||
Bindings.cpp
|
||||
DeprecatedBindings.cpp
|
||||
LuaChunkStay.cpp
|
||||
LuaState.cpp
|
||||
LuaWindow.cpp
|
||||
ManualBindings.cpp
|
||||
Plugin.cpp
|
||||
PluginLua.cpp
|
||||
PluginManager.cpp
|
||||
WebPlugin.cpp
|
||||
)
|
||||
|
||||
SET (HDRS
|
||||
Bindings.h
|
||||
DeprecatedBindings.h
|
||||
LuaChunkStay.h
|
||||
LuaFunctions.h
|
||||
LuaState.h
|
||||
LuaWindow.h
|
||||
ManualBindings.h
|
||||
Plugin.h
|
||||
PluginLua.h
|
||||
PluginManager.h
|
||||
WebPlugin.h
|
||||
tolua++.h
|
||||
)
|
||||
|
||||
# List all the files that are generated as part of the Bindings build process
|
||||
set (BINDING_OUTPUTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc
|
||||
)
|
||||
|
||||
set(BINDING_DEPENDECIES
|
||||
tolua
|
||||
../Bindings/virtual_method_hooks.lua
|
||||
../Bindings/AllToLua.pkg
|
||||
../Bindings/gen_LuaState_Call.lua
|
||||
../Bindings/LuaFunctions.h
|
||||
../Bindings/LuaState_Call.inc
|
||||
../Bindings/LuaWindow.h
|
||||
../Bindings/Plugin.h
|
||||
../Bindings/PluginLua.h
|
||||
../Bindings/PluginManager.h
|
||||
../Bindings/WebPlugin.h
|
||||
../BiomeDef.h
|
||||
../BlockArea.h
|
||||
../BlockEntities/BlockEntity.h
|
||||
../BlockEntities/BlockEntityWithItems.h
|
||||
../BlockEntities/ChestEntity.h
|
||||
../BlockEntities/DispenserEntity.h
|
||||
../BlockEntities/DropSpenserEntity.h
|
||||
../BlockEntities/DropperEntity.h
|
||||
../BlockEntities/FurnaceEntity.h
|
||||
../BlockEntities/HopperEntity.h
|
||||
../BlockEntities/JukeboxEntity.h
|
||||
../BlockEntities/NoteEntity.h
|
||||
../BlockEntities/SignEntity.h
|
||||
../BlockEntities/MobHeadEntity.h
|
||||
../BlockEntities/FlowerPotEntity.h
|
||||
../BlockID.h
|
||||
../BoundingBox.h
|
||||
../ChatColor.h
|
||||
../ChunkDef.h
|
||||
../ClientHandle.h
|
||||
../CraftingRecipes.h
|
||||
../Cuboid.h
|
||||
../Defines.h
|
||||
../Enchantments.h
|
||||
../Entities/EntityEffect.h
|
||||
../Entities/Entity.h
|
||||
../Entities/Floater.h
|
||||
../Entities/Pawn.h
|
||||
../Entities/Painting.h
|
||||
../Entities/Pickup.h
|
||||
../Entities/Player.h
|
||||
../Entities/ProjectileEntity.h
|
||||
../Entities/ArrowEntity.h
|
||||
../Entities/ThrownEggEntity.h
|
||||
../Entities/ThrownEnderPearlEntity.h
|
||||
../Entities/ExpBottleEntity.h
|
||||
../Entities/ThrownSnowballEntity.h
|
||||
../Entities/FireChargeEntity.h
|
||||
../Entities/FireworkEntity.h
|
||||
../Entities/GhastFireballEntity.h
|
||||
../Entities/TNTEntity.h
|
||||
../Entities/ExpOrb.h
|
||||
../Entities/HangingEntity.h
|
||||
../Entities/ItemFrame.h
|
||||
../Generating/ChunkDesc.h
|
||||
../Group.h
|
||||
../Inventory.h
|
||||
../Item.h
|
||||
../ItemGrid.h
|
||||
../Mobs/Monster.h
|
||||
../OSSupport/File.h
|
||||
../Root.h
|
||||
../Server.h
|
||||
../StringUtils.h
|
||||
../Tracer.h
|
||||
../UI/Window.h
|
||||
../Vector3.h
|
||||
../WebAdmin.h
|
||||
../World.h
|
||||
)
|
||||
|
||||
if (NOT MSVC)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
# add any new generated bindings here
|
||||
OUTPUT ${BINDING_OUTPUTS}
|
||||
|
||||
# Regenerate bindings:
|
||||
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
||||
# add any new generation dependencies here
|
||||
DEPENDS ${BINDING_DEPENDECIES}
|
||||
)
|
||||
endif ()
|
||||
set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
|
||||
|
||||
if(NOT MSVC)
|
||||
add_library(Bindings ${SRCS} ${HDRS})
|
||||
|
||||
target_link_libraries(Bindings lua sqlite tolualib polarssl)
|
||||
endif()
|
@ -25,9 +25,9 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
|
||||
#ifndef TOLUA_RELEASE
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -36,10 +36,10 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
}
|
||||
tolua_pushnumber(tolua_S,(lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
|
||||
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
#endif // #ifndef TOLUA_DISABLE
|
||||
|
||||
|
||||
|
||||
@ -53,8 +53,8 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
|
||||
#ifndef TOLUA_RELEASE
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@ -65,7 +65,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
|
||||
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
#endif // #ifndef TOLUA_DISABLE
|
||||
|
||||
|
||||
|
||||
@ -79,8 +79,8 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
|
||||
#ifndef TOLUA_RELEASE
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@ -91,7 +91,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
|
||||
tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
#endif // #ifndef TOLUA_DISABLE
|
||||
|
||||
|
||||
|
||||
@ -105,8 +105,8 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
|
||||
#ifndef TOLUA_RELEASE
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@ -117,7 +117,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
|
||||
tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
#endif // #ifndef TOLUA_DISABLE
|
||||
|
||||
|
||||
|
||||
@ -131,8 +131,8 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
|
||||
#ifndef TOLUA_RELEASE
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@ -143,7 +143,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
|
||||
tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
#endif // #ifndef TOLUA_DISABLE
|
||||
|
||||
|
||||
|
||||
@ -157,8 +157,8 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
|
||||
#ifndef TOLUA_RELEASE
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@ -169,7 +169,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
|
||||
tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
#endif // #ifndef TOLUA_DISABLE
|
||||
|
||||
|
||||
|
||||
@ -183,8 +183,8 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
|
||||
#ifndef TOLUA_RELEASE
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@ -195,7 +195,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
|
||||
tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
#endif // #ifndef TOLUA_DISABLE
|
||||
|
||||
|
||||
|
||||
@ -209,8 +209,8 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
|
||||
#ifndef TOLUA_RELEASE
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@ -221,7 +221,7 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
|
||||
tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
#endif // #ifndef TOLUA_DISABLE
|
||||
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
|
||||
|
||||
|
||||
|
||||
void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
|
||||
void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
|
||||
{
|
||||
// Check that the element has 2 coords:
|
||||
int NumCoords = luaL_getn(L, -1);
|
||||
|
@ -40,7 +40,7 @@ const cLuaState::cRet cLuaState::Return = {};
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cLuaState:
|
||||
|
||||
cLuaState::cLuaState(const AString & a_SubsystemName) :
|
||||
@ -1336,9 +1336,8 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
|
||||
{
|
||||
UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns
|
||||
|
||||
|
||||
// Format string consisting only of %s is used to appease the compiler
|
||||
LOGD("%s",(a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
|
||||
LOGD("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
|
||||
for (int i = lua_gettop(a_LuaState); i > 0; i--)
|
||||
{
|
||||
AString Value;
|
||||
@ -1371,7 +1370,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cLuaState::cRef:
|
||||
|
||||
cLuaState::cRef::cRef(void) :
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
|
||||
|
||||
/** Creates a new instance. The LuaState is not initialized.
|
||||
a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins,
|
||||
a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins,
|
||||
or "LuaScript" for the cLuaScript template
|
||||
*/
|
||||
cLuaState(const AString & a_SubsystemName);
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "../UI/SlotArea.h"
|
||||
#include "PluginLua.h"
|
||||
#include "../Entities/Player.h"
|
||||
#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL
|
||||
#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cLuaWindow:
|
||||
|
||||
cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) :
|
||||
|
@ -33,9 +33,7 @@
|
||||
|
||||
|
||||
|
||||
/****************************
|
||||
* Better error reporting for Lua
|
||||
**/
|
||||
// Better error reporting for Lua
|
||||
static int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaError)
|
||||
{
|
||||
// Retrieve current function name
|
||||
@ -81,10 +79,7 @@ static int lua_do_error(lua_State* L, const char * a_pFormat, ...)
|
||||
|
||||
|
||||
|
||||
/****************************
|
||||
* Lua bound functions with special return types
|
||||
**/
|
||||
|
||||
// Lua bound functions with special return types
|
||||
static int tolua_StringSplit(lua_State * tolua_S)
|
||||
{
|
||||
cLuaState LuaState(tolua_S);
|
||||
@ -557,10 +552,12 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
|
||||
|
||||
|
||||
|
||||
template< class Ty1,
|
||||
class Ty2,
|
||||
bool (Ty1::*Func1)(int, int, cItemCallback<Ty2> &) >
|
||||
static int tolua_ForEachInChunk(lua_State* tolua_S)
|
||||
template<
|
||||
class Ty1,
|
||||
class Ty2,
|
||||
bool (Ty1::*Func1)(int, int, cItemCallback<Ty2> &)
|
||||
>
|
||||
static int tolua_ForEachInChunk(lua_State * tolua_S)
|
||||
{
|
||||
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
|
||||
if ((NumArgs != 3) && (NumArgs != 4))
|
||||
@ -651,9 +648,11 @@ static int tolua_ForEachInChunk(lua_State* tolua_S)
|
||||
|
||||
|
||||
|
||||
template< class Ty1,
|
||||
class Ty2,
|
||||
bool (Ty1::*Func1)(cItemCallback<Ty2> &) >
|
||||
template<
|
||||
class Ty1,
|
||||
class Ty2,
|
||||
bool (Ty1::*Func1)(cItemCallback<Ty2> &)
|
||||
>
|
||||
static int tolua_ForEach(lua_State * tolua_S)
|
||||
{
|
||||
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
|
||||
@ -959,7 +958,7 @@ tolua_lerror:
|
||||
static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
|
||||
{
|
||||
// Exported manually, because tolua would require the out-only param a_Height to be used when calling
|
||||
// Takes (a_World,) a_BlockX, a_BlockZ
|
||||
// Takes a_World, a_BlockX, a_BlockZ
|
||||
// Returns Height, IsValid
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
@ -1927,12 +1926,12 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
|
||||
int Reference = LUA_REFNIL;
|
||||
|
||||
if (
|
||||
tolua_isstring(tolua_S, 2, 0, &tolua_err ) &&
|
||||
lua_isfunction(tolua_S, 3 )
|
||||
tolua_isstring(tolua_S, 2, 0, &tolua_err) &&
|
||||
lua_isfunction(tolua_S, 3)
|
||||
)
|
||||
{
|
||||
Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX);
|
||||
Title = ((std::string) tolua_tocppstring(tolua_S,2,0));
|
||||
Title = ((std::string)tolua_tocppstring(tolua_S, 2, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2065,7 +2064,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, it->first.c_str() );
|
||||
tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" );
|
||||
//lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data
|
||||
// lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data
|
||||
lua_settable(tolua_S, top);
|
||||
}
|
||||
|
||||
@ -2114,7 +2113,7 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
|
||||
{
|
||||
const AString & FancyName = iter->first;
|
||||
const AString & WebName = iter->second;
|
||||
tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key
|
||||
tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key
|
||||
tolua_pushstring( tolua_S, FancyName.c_str() );
|
||||
//
|
||||
lua_rawset(tolua_S, -3);
|
||||
@ -2592,7 +2591,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
|
||||
}
|
||||
|
||||
AString Filename = tolua_tostring(tolua_S, 2, 0);
|
||||
bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self,Filename);
|
||||
bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self, Filename);
|
||||
tolua_pushboolean(tolua_S, res);
|
||||
return 1;
|
||||
}
|
||||
@ -2652,7 +2651,7 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
|
||||
return 0;
|
||||
}
|
||||
AString Filename = tolua_tostring(tolua_S, 2, 0);
|
||||
bool res = cSchematicFileSerializer::SaveToSchematicFile(*self,Filename);
|
||||
bool res = cSchematicFileSerializer::SaveToSchematicFile(*self, Filename);
|
||||
tolua_pushboolean(tolua_S, res);
|
||||
return 1;
|
||||
}
|
||||
@ -3066,13 +3065,13 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
||||
tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab);
|
||||
tolua_endmodule(tolua_S);
|
||||
|
||||
tolua_cclass(tolua_S,"HTTPRequest","HTTPRequest","",NULL);
|
||||
tolua_beginmodule(tolua_S,"HTTPRequest");
|
||||
// tolua_variable(tolua_S,"Method",tolua_get_HTTPRequest_Method,tolua_set_HTTPRequest_Method);
|
||||
// tolua_variable(tolua_S,"Path",tolua_get_HTTPRequest_Path,tolua_set_HTTPRequest_Path);
|
||||
tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0);
|
||||
tolua_variable(tolua_S,"Params",tolua_get_HTTPRequest_Params,0);
|
||||
tolua_variable(tolua_S,"PostParams",tolua_get_HTTPRequest_PostParams,0);
|
||||
tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", NULL);
|
||||
tolua_beginmodule(tolua_S, "HTTPRequest");
|
||||
// tolua_variable(tolua_S, "Method", tolua_get_HTTPRequest_Method, tolua_set_HTTPRequest_Method);
|
||||
// tolua_variable(tolua_S, "Path", tolua_get_HTTPRequest_Path, tolua_set_HTTPRequest_Path);
|
||||
tolua_variable(tolua_S, "FormData", tolua_get_HTTPRequest_FormData, 0);
|
||||
tolua_variable(tolua_S, "Params", tolua_get_HTTPRequest_Params, 0);
|
||||
tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, 0);
|
||||
tolua_endmodule(tolua_S);
|
||||
|
||||
tolua_beginmodule(tolua_S, "cWebAdmin");
|
||||
|
@ -42,10 +42,7 @@ public:
|
||||
// Called each tick
|
||||
virtual void Tick(float a_Dt) = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
/** Calls the specified hook with the params given. Returns the bool that the hook callback returns.*/
|
||||
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;
|
||||
@ -152,7 +149,7 @@ private:
|
||||
int m_Version;
|
||||
|
||||
AString m_Directory;
|
||||
}; // tolua_export
|
||||
}; // tolua_export
|
||||
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ extern "C"
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cPluginLua:
|
||||
|
||||
cPluginLua::cPluginLua(const AString & a_PluginDirectory) :
|
||||
@ -78,7 +78,7 @@ bool cPluginLua::Initialize(void)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
if (!m_LuaState.IsValid())
|
||||
{
|
||||
{
|
||||
m_LuaState.Create();
|
||||
m_LuaState.RegisterAPILibs();
|
||||
|
||||
@ -1015,7 +1015,7 @@ bool cPluginLua::OnPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_Block
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
|
||||
bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
@ -1294,8 +1294,8 @@ bool cPluginLua::OnTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
|
||||
|
||||
|
||||
bool cPluginLua::OnUpdatedSign(
|
||||
cWorld * a_World,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ,
|
||||
cWorld * a_World,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ,
|
||||
const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4,
|
||||
cPlayer * a_Player
|
||||
)
|
||||
@ -1319,8 +1319,8 @@ bool cPluginLua::OnUpdatedSign(
|
||||
|
||||
|
||||
bool cPluginLua::OnUpdatingSign(
|
||||
cWorld * a_World,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ,
|
||||
cWorld * a_World,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ,
|
||||
AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4,
|
||||
cPlayer * a_Player
|
||||
)
|
||||
@ -1517,7 +1517,7 @@ bool cPluginLua::CanAddOldStyleHook(int a_HookType)
|
||||
return true;
|
||||
}
|
||||
|
||||
LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.",
|
||||
LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.",
|
||||
GetName().c_str(), a_HookType, FnName
|
||||
);
|
||||
m_LuaState.LogStackTrace();
|
||||
@ -1670,7 +1670,7 @@ AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request )
|
||||
sWebPluginTab * Tab = 0;
|
||||
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
|
||||
{
|
||||
if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr
|
||||
if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr
|
||||
{
|
||||
Tab = *itr;
|
||||
break;
|
||||
|
@ -145,7 +145,7 @@ public:
|
||||
|
||||
// cWebPlugin and WebAdmin stuff
|
||||
virtual AString HandleWebRequest(const HTTPRequest * a_Request ) override;
|
||||
bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS <<
|
||||
bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS <<
|
||||
|
||||
/** Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap. */
|
||||
void BindCommand(const AString & a_Command, int a_FnRef);
|
||||
|
@ -1486,7 +1486,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName)
|
||||
if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does?
|
||||
{
|
||||
m_DisablePluginList.push_back(itr->second);
|
||||
itr->second = NULL; // Get rid of this thing right away
|
||||
itr->second = NULL; // Get rid of this thing right away
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -51,10 +51,12 @@ class cBlockEntityWithItems;
|
||||
|
||||
|
||||
|
||||
class cPluginManager // tolua_export
|
||||
{ // tolua_export
|
||||
public: // tolua_export
|
||||
|
||||
// tolua_begin
|
||||
class cPluginManager
|
||||
{
|
||||
public:
|
||||
// tolua_end
|
||||
|
||||
// Called each tick
|
||||
virtual void Tick(float a_Dt);
|
||||
|
||||
@ -157,15 +159,17 @@ public: // tolua_export
|
||||
|
||||
|
||||
/** Returns the instance of the Plugin Manager (there is only ever one) */
|
||||
static cPluginManager * Get(void); // tolua_export
|
||||
static cPluginManager * Get(void); // tolua_export
|
||||
|
||||
typedef std::map< AString, cPlugin * > PluginMap;
|
||||
typedef std::list< cPlugin * > PluginList;
|
||||
cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export
|
||||
const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS <<
|
||||
cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export
|
||||
const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS <<
|
||||
|
||||
void FindPlugins(); // tolua_export
|
||||
void ReloadPlugins(); // tolua_export
|
||||
// tolua_begin
|
||||
void FindPlugins();
|
||||
void ReloadPlugins();
|
||||
// tolua_end
|
||||
|
||||
/** Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add */
|
||||
void AddHook(cPlugin * a_Plugin, int a_HookType);
|
||||
@ -335,8 +339,8 @@ private:
|
||||
bool AddPlugin(cPlugin * a_Plugin);
|
||||
|
||||
/** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */
|
||||
cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
|
||||
} ; // tolua_export
|
||||
cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
|
||||
} ; // tolua_export
|
||||
|
||||
|
||||
|
||||
|
@ -64,27 +64,27 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
|
||||
std::pair< AString, AString > Names;
|
||||
AStringVector Split = StringSplit(a_Request->Path, "/");
|
||||
|
||||
if( Split.size() > 1 )
|
||||
if (Split.size() > 1)
|
||||
{
|
||||
sWebPluginTab* Tab = 0;
|
||||
if( Split.size() > 2 ) // If we got the tab name, show that page
|
||||
sWebPluginTab * Tab = NULL;
|
||||
if (Split.size() > 2) // If we got the tab name, show that page
|
||||
{
|
||||
for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
|
||||
{
|
||||
if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr
|
||||
if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one!
|
||||
{
|
||||
Tab = *itr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Otherwise show the first tab
|
||||
else // Otherwise show the first tab
|
||||
{
|
||||
if( GetTabs().size() > 0 )
|
||||
Tab = *GetTabs().begin();
|
||||
}
|
||||
|
||||
if( Tab )
|
||||
if (Tab != NULL)
|
||||
{
|
||||
Names.first = Tab->Title;
|
||||
Names.second = Tab->SafeTitle;
|
||||
@ -97,13 +97,13 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
|
||||
|
||||
|
||||
|
||||
AString cWebPlugin::SafeString( const AString & a_String )
|
||||
AString cWebPlugin::SafeString(const AString & a_String)
|
||||
{
|
||||
AString RetVal;
|
||||
for( unsigned int i = 0; i < a_String.size(); ++i )
|
||||
{
|
||||
char c = a_String[i];
|
||||
if( c == ' ' )
|
||||
if( c == ' ' )
|
||||
{
|
||||
c = '_';
|
||||
}
|
||||
@ -111,3 +111,7 @@ AString cWebPlugin::SafeString( const AString & a_String )
|
||||
}
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
TabList & GetTabs() { return m_Tabs; }
|
||||
|
||||
typedef std::list< std::pair<AString, AString> > TabNameList;
|
||||
TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
|
||||
TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
|
||||
std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request );
|
||||
|
||||
private:
|
||||
|
@ -10,12 +10,13 @@
|
||||
|
||||
|
||||
// The "map" used for biome <-> string conversions:
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
EMCSBiome m_Biome;
|
||||
const char * m_String;
|
||||
} g_BiomeMap[] =
|
||||
{
|
||||
{biOcean, "Ocean"} ,
|
||||
{biOcean, "Ocean"},
|
||||
{biPlains, "Plains"},
|
||||
{biDesert, "Desert"},
|
||||
{biExtremeHills, "ExtremeHills"},
|
||||
|
@ -28,10 +28,10 @@ typedef void (CombinatorFunc)(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLE
|
||||
|
||||
// This wild construct allows us to pass a function argument and still have it inlined by the compiler :)
|
||||
/// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function
|
||||
template<bool MetasValid, CombinatorFunc Combinator>
|
||||
template<bool MetasValid, CombinatorFunc Combinator>
|
||||
void InternalMergeBlocks(
|
||||
BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes,
|
||||
NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas,
|
||||
NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas,
|
||||
int a_SizeX, int a_SizeY, int a_SizeZ,
|
||||
int a_SrcOffX, int a_SrcOffY, int a_SrcOffZ,
|
||||
int a_DstOffX, int a_DstOffY, int a_DstOffZ,
|
||||
@ -136,7 +136,7 @@ void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
|
||||
return;
|
||||
}
|
||||
|
||||
// Air is always hollowed out
|
||||
// Air is always hollowed out
|
||||
if (a_SrcType == E_BLOCK_AIR)
|
||||
{
|
||||
a_DstType = E_BLOCK_AIR;
|
||||
@ -269,7 +269,7 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cBlockArea:
|
||||
|
||||
cBlockArea::cBlockArea(void) :
|
||||
@ -781,7 +781,7 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block
|
||||
|
||||
|
||||
|
||||
void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
|
||||
void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
|
||||
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
|
||||
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
|
||||
)
|
||||
@ -1759,7 +1759,7 @@ NIBBLETYPE cBlockArea::GetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBL
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cBlockArea::cChunkReader:
|
||||
|
||||
cBlockArea::cChunkReader::cChunkReader(cBlockArea & a_Area) :
|
||||
@ -2226,7 +2226,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
|
||||
m_Size.x, m_Size.y, m_Size.z
|
||||
);
|
||||
return;
|
||||
} // case msDifference
|
||||
} // case msDifference
|
||||
|
||||
case cBlockArea::msMask:
|
||||
{
|
||||
|
@ -175,7 +175,7 @@ public:
|
||||
void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f);
|
||||
|
||||
/** Fills a cuboid inside the block area with the specified data */
|
||||
void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
|
||||
void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
|
||||
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
|
||||
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
|
||||
);
|
||||
@ -357,7 +357,7 @@ protected:
|
||||
|
||||
/** Sets the specified datatypes at the specified location. */
|
||||
void RelSetData(
|
||||
int a_RelX, int a_RelY, int a_RelZ,
|
||||
int a_RelX, int a_RelY, int a_RelZ,
|
||||
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
|
||||
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
|
||||
);
|
||||
|
@ -32,7 +32,7 @@ int cBeaconEntity::GetPyramidLevel(void)
|
||||
}
|
||||
|
||||
Area.Read(
|
||||
m_World,
|
||||
m_World,
|
||||
GetPosX() - 4, GetPosX() + 4,
|
||||
MinY, MaxY,
|
||||
GetPosZ() - 4, GetPosZ() + 4,
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
cItems Pickups;
|
||||
m_Contents.CopyToItems(Pickups);
|
||||
m_Contents.Clear();
|
||||
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
|
||||
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
|
||||
}
|
||||
|
||||
// tolua_begin
|
||||
|
@ -4,9 +4,41 @@ project (MCServer)
|
||||
|
||||
include_directories ("${PROJECT_SOURCE_DIR}/../")
|
||||
|
||||
file(GLOB SOURCE
|
||||
"*.cpp"
|
||||
"*.h"
|
||||
)
|
||||
SET (SRCS
|
||||
BeaconEntity.cpp
|
||||
BlockEntity.cpp
|
||||
ChestEntity.cpp
|
||||
CommandBlockEntity.cpp
|
||||
DispenserEntity.cpp
|
||||
DropSpenserEntity.cpp
|
||||
DropperEntity.cpp
|
||||
EnderChestEntity.cpp
|
||||
FlowerPotEntity.cpp
|
||||
FurnaceEntity.cpp
|
||||
HopperEntity.cpp
|
||||
JukeboxEntity.cpp
|
||||
MobHeadEntity.cpp
|
||||
NoteEntity.cpp
|
||||
SignEntity.cpp)
|
||||
|
||||
add_library(BlockEntities ${SOURCE})
|
||||
SET (HDRS
|
||||
BeaconEntity.h
|
||||
BlockEntity.h
|
||||
BlockEntityWithItems.h
|
||||
ChestEntity.h
|
||||
CommandBlockEntity.h
|
||||
DispenserEntity.h
|
||||
DropSpenserEntity.h
|
||||
DropperEntity.h
|
||||
EnderChestEntity.h
|
||||
FlowerPotEntity.h
|
||||
FurnaceEntity.h
|
||||
HopperEntity.h
|
||||
JukeboxEntity.h
|
||||
MobHeadEntity.h
|
||||
NoteEntity.h
|
||||
SignEntity.h)
|
||||
|
||||
if(NOT MSVC)
|
||||
add_library(BlockEntities ${SRCS} ${HDRS})
|
||||
endif()
|
||||
|
@ -169,15 +169,15 @@ void cChestEntity::OpenNewWindow(void)
|
||||
if (
|
||||
m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, OpenDbl) ||
|
||||
m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, OpenDbl) ||
|
||||
m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ - 1, OpenDbl) ||
|
||||
m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ + 1, OpenDbl)
|
||||
m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ - 1, OpenDbl) ||
|
||||
m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, OpenDbl)
|
||||
)
|
||||
{
|
||||
// The double-chest window has been opened in the callback
|
||||
return;
|
||||
}
|
||||
|
||||
// There is no chest neighbor, open a single-chest window:
|
||||
// There is no chest neighbor, open a single-chest window:
|
||||
OpenWindow(new cChestWindow(this));
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,8 @@ class cChestEntity :
|
||||
typedef cBlockEntityWithItems super;
|
||||
|
||||
public:
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ContentsHeight = 3,
|
||||
ContentsWidth = 9,
|
||||
} ;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "../CommandOutput.h"
|
||||
#include "../Root.h"
|
||||
#include "../Server.h" // ExecuteConsoleCommand()
|
||||
#include "../Server.h" // ExecuteConsoleCommand()
|
||||
#include "../Chunk.h"
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace Json
|
||||
|
||||
// tolua_begin
|
||||
|
||||
class cCommandBlockEntity :
|
||||
class cCommandBlockEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
@ -42,7 +42,7 @@ cDropSpenserEntity::~cDropSpenserEntity()
|
||||
|
||||
void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction)
|
||||
{
|
||||
switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't
|
||||
switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't
|
||||
{
|
||||
case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
|
||||
case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
|
||||
@ -90,7 +90,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
|
||||
int SmokeDir = 0;
|
||||
switch (Meta)
|
||||
{
|
||||
case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block)
|
||||
case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block)
|
||||
case E_META_DROPSPENSER_FACING_YM: SmokeDir = 4; break;
|
||||
case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break;
|
||||
case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break;
|
||||
@ -99,7 +99,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
|
||||
}
|
||||
m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir);
|
||||
m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -235,7 +235,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
||||
cItems Pickups;
|
||||
Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum));
|
||||
|
||||
const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6
|
||||
const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6
|
||||
int PickupSpeedX = 0, PickupSpeedY = 0, PickupSpeedZ = 0;
|
||||
switch (Meta)
|
||||
{
|
||||
@ -249,7 +249,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
||||
|
||||
double MicroX, MicroY, MicroZ;
|
||||
MicroX = DispX + 0.5;
|
||||
MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
|
||||
MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
|
||||
MicroZ = DispZ + 0.5;
|
||||
|
||||
|
||||
|
@ -35,7 +35,8 @@ class cDropSpenserEntity :
|
||||
typedef cBlockEntityWithItems super;
|
||||
|
||||
public:
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ContentsHeight = 3,
|
||||
ContentsWidth = 3,
|
||||
} ;
|
||||
|
@ -16,10 +16,10 @@ class cEnderChestEntity :
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
||||
public:
|
||||
public:
|
||||
// tolua_end
|
||||
|
||||
cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
virtual ~cEnderChestEntity();
|
||||
|
||||
static const char * GetClassStatic(void) { return "cEnderChestEntity"; }
|
||||
|
@ -27,7 +27,7 @@ namespace Json
|
||||
|
||||
// tolua_begin
|
||||
|
||||
class cFlowerPotEntity :
|
||||
class cFlowerPotEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
@ -219,7 +219,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
|
||||
}
|
||||
|
||||
Vector3f EntityPos = a_Entity->GetPosition();
|
||||
Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
|
||||
Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
|
||||
double Distance = (EntityPos - BlockPos).Length();
|
||||
|
||||
if (Distance < 0.5)
|
||||
@ -243,7 +243,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
|
||||
{
|
||||
m_bFoundPickupsAbove = true;
|
||||
m_Contents.SetSlot(i, Item);
|
||||
a_Pickup->Destroy(); // Kill pickup
|
||||
a_Pickup->Destroy(); // Kill pickup
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -253,11 +253,11 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
|
||||
|
||||
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
|
||||
|
||||
Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
|
||||
Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
|
||||
|
||||
if (Item.IsEmpty())
|
||||
{
|
||||
a_Pickup->Destroy(); // Kill pickup if all items were added
|
||||
a_Pickup->Destroy(); // Kill pickup if all items were added
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ class cHopperEntity :
|
||||
typedef cBlockEntityWithItems super;
|
||||
|
||||
public:
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ContentsHeight = 1,
|
||||
ContentsWidth = 5,
|
||||
TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper
|
||||
|
@ -19,7 +19,7 @@ namespace Json
|
||||
|
||||
// tolua_begin
|
||||
|
||||
class cJukeboxEntity :
|
||||
class cJukeboxEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
@ -25,7 +25,7 @@ namespace Json
|
||||
|
||||
// tolua_begin
|
||||
|
||||
class cMobHeadEntity :
|
||||
class cMobHeadEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
@ -28,7 +28,7 @@ enum ENUM_NOTE_INSTRUMENTS
|
||||
|
||||
// tolua_begin
|
||||
|
||||
class cNoteEntity :
|
||||
class cNoteEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
@ -25,7 +25,7 @@ namespace Json
|
||||
|
||||
// tolua_begin
|
||||
|
||||
class cSignEntity :
|
||||
class cSignEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
@ -255,7 +255,8 @@ AString ItemToFullString(const cItem & a_Item)
|
||||
|
||||
int StringToMobType(const AString & a_MobString)
|
||||
{
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
int m_MobType;
|
||||
const char * m_String;
|
||||
} MobMap [] =
|
||||
@ -286,7 +287,7 @@ int StringToMobType(const AString & a_MobString)
|
||||
{cMonster::mtMooshroom, "Mooshroom"},
|
||||
{cMonster::mtSnowGolem, "SnowGolem"},
|
||||
{cMonster::mtOcelot, "Ocelot"},
|
||||
{cMonster::mtIronGolem, "IronGolem"},
|
||||
{cMonster::mtIronGolem, "IronGolem"},
|
||||
{cMonster::mtVillager, "Villager"},
|
||||
};
|
||||
for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++)
|
||||
|
@ -171,12 +171,12 @@ enum ENUM_BLOCK_ID
|
||||
E_BLOCK_DROPPER = 158,
|
||||
E_BLOCK_STAINED_CLAY = 159,
|
||||
E_BLOCK_STAINED_GLASS_PANE = 160,
|
||||
E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x
|
||||
E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x
|
||||
E_BLOCK_NEW_LOG = 162,
|
||||
E_BLOCK_ACACIA_WOOD_STAIRS = 163,
|
||||
E_BLOCK_DARK_OAK_WOOD_STAIRS = 164,
|
||||
E_BLOCK_HAY_BALE = 170,
|
||||
E_BLOCK_CARPET = 171,
|
||||
E_BLOCK_CARPET = 171,
|
||||
E_BLOCK_HARDENED_CLAY = 172,
|
||||
E_BLOCK_BLOCK_OF_COAL = 173,
|
||||
E_BLOCK_PACKED_ICE = 174,
|
||||
@ -187,7 +187,7 @@ enum ENUM_BLOCK_ID
|
||||
E_BLOCK_NUMBER_OF_TYPES, ///< Number of individual (different) blocktypes
|
||||
E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used
|
||||
|
||||
// Synonym or ID compatibility
|
||||
// Synonym or ID compatibility
|
||||
E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION,
|
||||
E_BLOCK_RED_ROSE = E_BLOCK_FLOWER,
|
||||
E_BLOCK_LOCKED_CHEST = E_BLOCK_STAINED_GLASS,
|
||||
@ -399,7 +399,7 @@ enum
|
||||
// Please keep this list alpha-sorted by the blocktype / itemtype part
|
||||
// then number-sorted for the same block / item
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Block metas:
|
||||
|
||||
// E_BLOCK_BIG_FLOWER metas
|
||||
@ -678,7 +678,7 @@ enum
|
||||
E_META_WOOL_RED = 14,
|
||||
E_META_WOOL_BLACK = 15,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Item metas:
|
||||
|
||||
// E_ITEM_COAL metas:
|
||||
|
@ -450,9 +450,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
|
||||
a_Info[E_BLOCK_CROPS ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_FENCE ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_FIRE ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
|
||||
@ -484,7 +481,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
|
||||
a_Info[E_BLOCK_WATER ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
|
||||
a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false;
|
||||
|
||||
|
||||
// Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things:
|
||||
|
@ -77,7 +77,7 @@ protected:
|
||||
|
||||
/** Initializes the specified BlockInfo structures with block-specific values. */
|
||||
static void Initialize(cBlockInfoArray & a_BlockInfos);
|
||||
}; // tolua_export
|
||||
}; // tolua_export
|
||||
|
||||
|
||||
|
||||
|
@ -39,13 +39,13 @@ public:
|
||||
/** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded
|
||||
When this callback returns true, the tracing is aborted.
|
||||
*/
|
||||
virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace)
|
||||
{
|
||||
virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace)
|
||||
{
|
||||
UNUSED(a_BlockX);
|
||||
UNUSED(a_BlockY);
|
||||
UNUSED(a_BlockZ);
|
||||
UNUSED(a_EntryFace);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height)
|
||||
@ -54,8 +54,8 @@ public:
|
||||
Note that some paths can go out of the world and come back again (parabola),
|
||||
in such a case this callback is followed by OnIntoWorld() and further OnNextBlock() calls
|
||||
*/
|
||||
virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
|
||||
{
|
||||
virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
|
||||
{
|
||||
UNUSED(a_BlockX);
|
||||
UNUSED(a_BlockY);
|
||||
UNUSED(a_BlockZ);
|
||||
@ -68,12 +68,12 @@ public:
|
||||
Note that some paths can go out of the world and come back again (parabola),
|
||||
in such a case this callback is followed by further OnNextBlock() calls
|
||||
*/
|
||||
virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
|
||||
{
|
||||
virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
|
||||
{
|
||||
UNUSED(a_BlockX);
|
||||
UNUSED(a_BlockY);
|
||||
UNUSED(a_BlockZ);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Called when the path is sure not to hit any more blocks.
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -15,7 +15,7 @@ void cBlockBedHandler::OnPlacedByPlayer(
|
||||
if (a_BlockMeta < 8)
|
||||
{
|
||||
Vector3i Direction = MetaDataToDirection(a_BlockMeta);
|
||||
a_ChunkInterface.SetBlock(a_WorldInterface,a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8);
|
||||
a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,22 +116,22 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
|
||||
|
||||
if (Meta & 0x8)
|
||||
{
|
||||
// Is pillow
|
||||
// Is pillow
|
||||
a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is foot end
|
||||
VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken
|
||||
VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken
|
||||
|
||||
PillowDirection = MetaDataToDirection(Meta & 0x7);
|
||||
if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
|
||||
if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
|
||||
{
|
||||
a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z);
|
||||
}
|
||||
}
|
||||
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit
|
||||
a_Player->SetIsInBed(true);
|
||||
|
||||
cTimeFastForwardTester Tester;
|
||||
@ -140,9 +140,9 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
|
||||
cPlayerBedStateUnsetter Unsetter(Vector3i(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z), a_WorldInterface);
|
||||
a_WorldInterface.ForEachPlayer(Unsetter);
|
||||
a_WorldInterface.SetTimeOfDay(0);
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ class cBlockBedHandler :
|
||||
{
|
||||
public:
|
||||
cBlockBedHandler(BLOCKTYPE a_BlockType)
|
||||
: cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01,true>(a_BlockType)
|
||||
: cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ public:
|
||||
|
||||
|
||||
virtual void OnPlacedByPlayer(
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
|
||||
) override
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -74,7 +74,7 @@ public:
|
||||
default:
|
||||
{
|
||||
ASSERT(!"Unhandled block face!");
|
||||
return 0x0; // No idea, give a special meta (button in centre of block)
|
||||
return 0x0; // No idea, give a special meta (button in centre of block)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -68,7 +68,7 @@ public:
|
||||
|
||||
|
||||
virtual void OnPlacedByPlayer(
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
|
||||
Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
|
@ -152,7 +152,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
|
||||
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
|
||||
|
||||
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
|
||||
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
|
||||
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
|
||||
// so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself
|
||||
// needs extra datamembers.
|
||||
if (a_Meta & 0x08) return a_Meta;
|
||||
@ -179,7 +179,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
|
||||
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
|
||||
|
||||
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
|
||||
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
|
||||
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
|
||||
// so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself
|
||||
// needs extra datamembers.
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -43,8 +43,8 @@ public:
|
||||
// Mirrors defined by by a table. (Source, mincraft.gamepedia.com) 0x07 == 0111
|
||||
switch (a_Meta & 0x07)
|
||||
{
|
||||
case 0x00: return 0x01 + OtherMeta; // Down -> Up
|
||||
case 0x01: return 0x00 + OtherMeta; // Up -> Down
|
||||
case 0x00: return 0x01 + OtherMeta; // Down -> Up
|
||||
case 0x01: return 0x00 + OtherMeta; // Up -> Down
|
||||
}
|
||||
// Not Facing Up or Down; No change.
|
||||
return a_Meta;
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
//todo: Drop Ender Chest if using silk touch pickaxe
|
||||
// todo: Drop Ender Chest if using silk touch pickaxe
|
||||
a_Pickups.push_back(cItem(E_BLOCK_OBSIDIAN, 8, 0));
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public:
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta
|
||||
a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta
|
||||
}
|
||||
} ;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
/// Evaluates if coords have a valid border on top, based on MaxY
|
||||
bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
|
||||
{
|
||||
for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners
|
||||
for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners
|
||||
{
|
||||
if (a_ChunkInterface.GetBlock(X, checkBorder, Z) != E_BLOCK_OBSIDIAN)
|
||||
{
|
||||
@ -115,10 +115,10 @@ public:
|
||||
/// Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE)
|
||||
void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface)
|
||||
{
|
||||
int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
|
||||
int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above
|
||||
int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
|
||||
int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above
|
||||
|
||||
if (MaxY == 0) // Oh noes! Not a portal coordinate :(
|
||||
if (MaxY == 0) // Oh noes! Not a portal coordinate :(
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -127,11 +127,11 @@ public:
|
||||
{
|
||||
if (!FindPortalSliceZ(X, Y, Z1, Z2, MaxY, a_ChunkInterface))
|
||||
{
|
||||
return; // No eligible portal construct, abort abort abort!!
|
||||
return; // No eligible portal construct, abort abort abort!!
|
||||
}
|
||||
}
|
||||
|
||||
for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks
|
||||
for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks
|
||||
{
|
||||
for (int Width = XZM; Width <= XZP; Width++)
|
||||
{
|
||||
@ -153,23 +153,23 @@ public:
|
||||
/// Takes coordinates of base block and Y coord of target obsidian ceiling
|
||||
bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
|
||||
{
|
||||
Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
|
||||
Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction)
|
||||
bool FoundFrameXP = false, FoundFrameXM = false;
|
||||
for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
|
||||
for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners
|
||||
{
|
||||
int Value = FindObsidianCeiling(X1, Y, Z, a_ChunkInterface, MaxY);
|
||||
int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian
|
||||
if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find
|
||||
int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian
|
||||
if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find
|
||||
{
|
||||
FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further)
|
||||
FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further)
|
||||
break;
|
||||
}
|
||||
else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice'
|
||||
else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice'
|
||||
{
|
||||
return false; // Not valid slice, no portal can be formed
|
||||
return false; // Not valid slice, no portal can be formed
|
||||
}
|
||||
} XZP = X1 - 1; // Set boundary of frame interior
|
||||
for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
|
||||
} XZP = X1 - 1; // Set boundary of frame interior
|
||||
for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM)
|
||||
{
|
||||
int Value = FindObsidianCeiling(X2, Y, Z, a_ChunkInterface, MaxY);
|
||||
int ValueTwo = FindObsidianCeiling(X2, Y + 1, Z, a_ChunkInterface, MaxY);
|
||||
@ -182,7 +182,7 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} XZM = X2 + 1; // Set boundary, see previous
|
||||
} XZM = X2 + 1; // Set boundary, see previous
|
||||
return (FoundFrameXP && FoundFrameXM);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
|
@ -13,7 +13,7 @@ class cBlockFurnaceHandler :
|
||||
public cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
|
||||
{
|
||||
public:
|
||||
cBlockFurnaceHandler(BLOCKTYPE a_BlockType)
|
||||
cBlockFurnaceHandler(BLOCKTYPE a_BlockType)
|
||||
: cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
|
||||
{
|
||||
}
|
||||
@ -27,7 +27,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -70,7 +70,7 @@
|
||||
#include "BlockSand.h"
|
||||
#include "BlockSapling.h"
|
||||
#include "BlockSideways.h"
|
||||
#include "BlockSign.h"
|
||||
#include "BlockSignPost.h"
|
||||
#include "BlockSlab.h"
|
||||
#include "BlockSnow.h"
|
||||
#include "BlockStairs.h"
|
||||
@ -81,6 +81,7 @@
|
||||
#include "BlockTorch.h"
|
||||
#include "BlockTrapdoor.h"
|
||||
#include "BlockVine.h"
|
||||
#include "BlockWallSign.h"
|
||||
#include "BlockWorkbench.h"
|
||||
|
||||
|
||||
@ -176,7 +177,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
switch(a_BlockType)
|
||||
{
|
||||
// Block handlers, alphabetically sorted:
|
||||
// Block handlers, alphabetically sorted:
|
||||
case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
||||
case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType);
|
||||
case E_BLOCK_ANVIL: return new cBlockAnvilHandler (a_BlockType);
|
||||
@ -275,7 +276,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType);
|
||||
case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
||||
case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType);
|
||||
case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType);
|
||||
case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType);
|
||||
case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType);
|
||||
case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
||||
case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType);
|
||||
@ -297,7 +298,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType);
|
||||
case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType);
|
||||
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
|
||||
case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler
|
||||
case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType);
|
||||
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
|
||||
case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType);
|
||||
case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType);
|
||||
@ -327,7 +328,7 @@ cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
|
||||
|
||||
bool cBlockHandler::GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
)
|
||||
|
@ -30,14 +30,14 @@ public:
|
||||
/// Note that the coords are chunk-relative!
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
|
||||
|
||||
/** Called before a block is placed into a world.
|
||||
/** Called before a block is placed into a world.
|
||||
The handler should return true to allow placement, false to refuse.
|
||||
Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block.
|
||||
Called by cItemHandler::GetPlacementBlockTypeMeta() if the item is a block
|
||||
*/
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
);
|
||||
@ -47,8 +47,8 @@ public:
|
||||
|
||||
/// Called by cClientHandle::HandlePlaceBlock() after the player has placed a new block. Called after OnPlaced().
|
||||
virtual void OnPlacedByPlayer(
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
|
||||
);
|
||||
@ -93,7 +93,7 @@ public:
|
||||
virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta);
|
||||
|
||||
/** Checks if the block can be placed at this point.
|
||||
Default: CanBeAt(...)
|
||||
Default: CanBeAt(...)
|
||||
NOTE: This call doesn't actually place the block
|
||||
*/
|
||||
// virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir);
|
||||
@ -101,27 +101,27 @@ public:
|
||||
/// Called to check whether this block supports a rclk action. If it returns true, OnUse() is called
|
||||
virtual bool IsUseable(void);
|
||||
|
||||
/** Indicates whether the client will click through this block.
|
||||
/** Indicates whether the client will click through this block.
|
||||
For example digging a fire will hit the block below the fire so fire is clicked through
|
||||
*/
|
||||
virtual bool IsClickedThrough(void);
|
||||
|
||||
/** Checks if the player can build "inside" this block.
|
||||
/** Checks if the player can build "inside" this block.
|
||||
For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
|
||||
*/
|
||||
virtual bool DoesIgnoreBuildCollision(void);
|
||||
|
||||
/// <summary>Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow)</summary>
|
||||
virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta)
|
||||
{
|
||||
virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta)
|
||||
{
|
||||
UNUSED(a_Meta);
|
||||
return DoesIgnoreBuildCollision();
|
||||
return DoesIgnoreBuildCollision();
|
||||
}
|
||||
|
||||
/// <summary>Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true</summary>
|
||||
virtual bool DoesDropOnUnsuitable(void);
|
||||
|
||||
/** Called when one of the neighbors gets set; equivalent to MC block update.
|
||||
/** Called when one of the neighbors gets set; equivalent to MC block update.
|
||||
By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()),
|
||||
and wakes up all simulators on the block.
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
// TODO: Ice destroyed with air below it should turn into air instead of water
|
||||
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, 0);
|
||||
// This is called later than the real destroying of this ice block
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -12,17 +12,17 @@
|
||||
class cBlockLadderHandler :
|
||||
public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> >
|
||||
{
|
||||
typedef cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> > super;
|
||||
typedef cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> > super;
|
||||
public:
|
||||
cBlockLadderHandler(BLOCKTYPE a_BlockType)
|
||||
: super(a_BlockType)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -45,7 +45,7 @@ public:
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.Add(m_BlockType, 1, 0); // Reset meta
|
||||
a_Pickups.Add(m_BlockType, 1, 0); // Reset meta
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface,int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
// TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
|
||||
eBlockFace BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Leaves can be this many blocks that away (inclusive) from the log not to decay
|
||||
#define LEAVES_CHECK_DISTANCE 6
|
||||
|
||||
#define PROCESS_NEIGHBOR(x,y,z) \
|
||||
#define PROCESS_NEIGHBOR(x, y, z) \
|
||||
switch (a_Area.GetBlockType(x, y, z)) \
|
||||
{ \
|
||||
case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \
|
||||
@ -82,7 +82,7 @@ public:
|
||||
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
|
||||
}
|
||||
|
||||
|
||||
@ -106,10 +106,10 @@ public:
|
||||
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
|
||||
cBlockArea Area;
|
||||
if (!Area.Read(
|
||||
a_Chunk.GetWorld(),
|
||||
BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE,
|
||||
a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE,
|
||||
BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE,
|
||||
a_Chunk.GetWorld(),
|
||||
BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE,
|
||||
a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE,
|
||||
BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE,
|
||||
cBlockArea::baTypes)
|
||||
)
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -193,8 +193,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void OnPlacedByPlayer(
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
|
||||
) override
|
||||
|
@ -62,7 +62,7 @@ void cBlockPistonHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorld
|
||||
|
||||
bool cBlockPistonHandler::GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
)
|
||||
@ -235,7 +235,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cBlockPistonHeadHandler:
|
||||
|
||||
cBlockPistonHeadHandler::cBlockPistonHeadHandler(void) :
|
||||
@ -262,7 +262,7 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInter
|
||||
a_ChunkInterface.DigBlock(a_WorldInterface, newX, newY, newZ);
|
||||
if (a_Player->IsGameModeCreative())
|
||||
{
|
||||
return; // No pickups if creative
|
||||
return; // No pickups if creative
|
||||
}
|
||||
|
||||
cItems Pickups;
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override;
|
||||
@ -75,7 +75,7 @@ public:
|
||||
return BLOCK_FACE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
@ -132,7 +132,7 @@ private:
|
||||
{
|
||||
if (cBlockInfo::IsPistonBreakable(a_BlockType))
|
||||
{
|
||||
return false; // CanBreakPush returns true, but we need false to prevent pulling
|
||||
return false; // CanBreakPush returns true, but we need false to prevent pulling
|
||||
}
|
||||
|
||||
return CanPush(a_BlockType, a_BlockMeta);
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -36,7 +36,7 @@ public:
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
return; // No pickups
|
||||
return; // No pickups
|
||||
}
|
||||
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
@ -57,7 +57,7 @@ public:
|
||||
{
|
||||
if ((a_RelY - 1 < 0) || (a_RelY + 1 > cChunkDef::Height))
|
||||
{
|
||||
return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1
|
||||
return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1
|
||||
}
|
||||
|
||||
switch (a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ))
|
||||
@ -70,7 +70,7 @@ public:
|
||||
} PortalCheck[] =
|
||||
{
|
||||
{ 0, 1, 0},
|
||||
{ 0,-1, 0},
|
||||
{ 0, -1, 0},
|
||||
{ 1, 0, 0},
|
||||
{-1, 0, 0},
|
||||
} ;
|
||||
@ -95,7 +95,7 @@ public:
|
||||
} PortalCheck[] =
|
||||
{
|
||||
{ 0, 1, 0},
|
||||
{ 0,-1, 0},
|
||||
{ 0, -1, 0},
|
||||
{ 0, 0, -1},
|
||||
{ 0, 0, 1},
|
||||
} ;
|
||||
|
@ -76,14 +76,14 @@ public:
|
||||
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
|
||||
|
||||
// Spawn the golem:
|
||||
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem);
|
||||
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -18,14 +18,14 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
{
|
||||
a_BlockType = m_BlockType;
|
||||
NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage);
|
||||
if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block.
|
||||
if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block.
|
||||
{
|
||||
a_BlockMeta = Meta;
|
||||
return true;
|
||||
@ -42,25 +42,25 @@ public:
|
||||
case BLOCK_FACE_YM:
|
||||
case BLOCK_FACE_YP:
|
||||
{
|
||||
return a_QuartzMeta; // Top or bottom, just return original
|
||||
return a_QuartzMeta; // Top or bottom, just return original
|
||||
}
|
||||
|
||||
case BLOCK_FACE_ZP:
|
||||
case BLOCK_FACE_ZM:
|
||||
{
|
||||
return 0x4; // North or south
|
||||
return 0x4; // North or south
|
||||
}
|
||||
|
||||
case BLOCK_FACE_XP:
|
||||
case BLOCK_FACE_XM:
|
||||
{
|
||||
return 0x3; // East or west
|
||||
return 0x3; // East or west
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
ASSERT(!"Unhandled block face!");
|
||||
return a_QuartzMeta; // No idea, give a special meta (all sides the same)
|
||||
return a_QuartzMeta; // No idea, give a special meta (all sides the same)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -140,7 +140,7 @@ public:
|
||||
{
|
||||
NIBBLETYPE Meta = 0;
|
||||
char RailsCnt = 0;
|
||||
bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP
|
||||
bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP
|
||||
memset(Neighbors, 0, sizeof(Neighbors));
|
||||
Neighbors[0] = (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN));
|
||||
Neighbors[1] = (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN));
|
||||
@ -223,7 +223,7 @@ public:
|
||||
case E_META_RAIL_ZM_ZP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_DOWN)
|
||||
)
|
||||
{
|
||||
@ -235,7 +235,7 @@ public:
|
||||
case E_META_RAIL_XM_XP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN)
|
||||
)
|
||||
{
|
||||
@ -247,7 +247,7 @@ public:
|
||||
case E_META_RAIL_ASCEND_XP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
|
||||
)
|
||||
{
|
||||
@ -259,7 +259,7 @@ public:
|
||||
case E_META_RAIL_ASCEND_XM:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_WEST)
|
||||
)
|
||||
{
|
||||
@ -271,7 +271,7 @@ public:
|
||||
case E_META_RAIL_ASCEND_ZM:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH)
|
||||
)
|
||||
{
|
||||
@ -283,7 +283,7 @@ public:
|
||||
case E_META_RAIL_ASCEND_ZP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH)
|
||||
)
|
||||
{
|
||||
@ -295,7 +295,7 @@ public:
|
||||
case E_META_RAIL_CURVED_ZP_XP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST)
|
||||
)
|
||||
{
|
||||
@ -307,7 +307,7 @@ public:
|
||||
case E_META_RAIL_CURVED_ZP_XM:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
|
||||
)
|
||||
{
|
||||
@ -319,7 +319,7 @@ public:
|
||||
case E_META_RAIL_CURVED_ZM_XM:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST)
|
||||
)
|
||||
{
|
||||
@ -331,7 +331,7 @@ public:
|
||||
case E_META_RAIL_CURVED_ZM_XP:
|
||||
{
|
||||
if (
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) ||
|
||||
IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST)
|
||||
)
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
|
||||
inline static NIBBLETYPE RepeaterRotationToMetaData(double a_Rotation)
|
||||
{
|
||||
a_Rotation += 90 + 45; // So its not aligned with axis
|
||||
a_Rotation += 90 + 45; // So its not aligned with axis
|
||||
if (a_Rotation > 360)
|
||||
{
|
||||
a_Rotation -= 360;
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -32,7 +32,7 @@ public:
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta
|
||||
a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta
|
||||
}
|
||||
|
||||
|
||||
@ -43,25 +43,25 @@ public:
|
||||
case BLOCK_FACE_YM:
|
||||
case BLOCK_FACE_YP:
|
||||
{
|
||||
return a_Meta; // Top or bottom, just return original
|
||||
return a_Meta; // Top or bottom, just return original
|
||||
}
|
||||
|
||||
case BLOCK_FACE_ZP:
|
||||
case BLOCK_FACE_ZM:
|
||||
{
|
||||
return a_Meta | 0x8; // North or south
|
||||
return a_Meta | 0x8; // North or south
|
||||
}
|
||||
|
||||
case BLOCK_FACE_XP:
|
||||
case BLOCK_FACE_XM:
|
||||
{
|
||||
return a_Meta | 0x4; // East or west
|
||||
return a_Meta | 0x4; // East or west
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
ASSERT(!"Unhandled block face!");
|
||||
return a_Meta | 0xC; // No idea, give a special meta
|
||||
return a_Meta | 0xC; // No idea, give a special meta
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,21 +9,23 @@
|
||||
|
||||
|
||||
|
||||
class cBlockSignHandler :
|
||||
class cBlockSignPostHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
typedef cBlockHandler super;
|
||||
|
||||
public:
|
||||
cBlockSignHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
cBlockSignPostHandler(BLOCKTYPE a_BlockType) :
|
||||
super(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual const char * GetStepSound(void) override
|
||||
{
|
||||
@ -31,6 +33,17 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
if (a_RelY <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
|
||||
}
|
||||
|
||||
|
||||
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
||||
{
|
||||
a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
|
||||
@ -43,23 +56,6 @@ public:
|
||||
|
||||
return ((char)a_Rotation) % 16;
|
||||
}
|
||||
|
||||
|
||||
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
|
||||
{
|
||||
switch (a_Direction)
|
||||
{
|
||||
case 0x2: return 0x2;
|
||||
case 0x3: return 0x3;
|
||||
case 0x4: return 0x4;
|
||||
case 0x5: return 0x5;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0x2;
|
||||
}
|
||||
|
||||
|
||||
virtual void OnPlacedByPlayer(
|
||||
@ -84,22 +80,23 @@ public:
|
||||
return (a_Meta + 12) & 0x0f;
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Mirrors signs over the XY plane (North-South Mirroring)
|
||||
// Mirrors signs over the XY plane (North-South Mirroring)
|
||||
|
||||
// There are 16 meta values which correspond to different directions.
|
||||
// These values are equated to angles on a circle; 0x08 = 180 degrees.
|
||||
// There are 16 meta values which correspond to different directions.
|
||||
// These values are equated to angles on a circle; 0x08 = 180 degrees.
|
||||
return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta);
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Mirrors signs over the YZ plane (East-West Mirroring)
|
||||
// Mirrors signs over the YZ plane (East-West Mirroring)
|
||||
|
||||
// There are 16 meta values which correspond to different directions.
|
||||
// These values are equated to angles on a circle; 0x10 = 360 degrees.
|
||||
// There are 16 meta values which correspond to different directions.
|
||||
// These values are equated to angles on a circle; 0x10 = 360 degrees.
|
||||
return 0x10 - a_Meta;
|
||||
}
|
||||
} ;
|
@ -33,7 +33,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -33,8 +33,8 @@ public:
|
||||
if ((BlockBeforePlacement == E_BLOCK_SNOW) && (MetaBeforePlacement < 7))
|
||||
{
|
||||
// Only increment if:
|
||||
// A snow block was already there (not first time placement) AND
|
||||
// Height is smaller than 7, the maximum possible height
|
||||
// - A snow block was already there (not first time placement) AND
|
||||
// - Height is smaller than 7, the maximum possible height
|
||||
MetaBeforePlacement++;
|
||||
}
|
||||
|
||||
@ -47,12 +47,12 @@ public:
|
||||
{
|
||||
if ((a_Player->GetEquippedItem().m_ItemType == E_BLOCK_SNOW) && (a_Meta < 7))
|
||||
{
|
||||
return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored
|
||||
return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored
|
||||
}
|
||||
|
||||
if (a_Meta == 0)
|
||||
{
|
||||
return true; // If at normal snowfall height (lowest), we ignore collision
|
||||
return true; // If at normal snowfall height (lowest), we ignore collision
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -85,7 +85,7 @@ public:
|
||||
|
||||
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
||||
{
|
||||
a_Rotation += 90 + 45; // So its not aligned with axis
|
||||
a_Rotation += 90 + 45; // So its not aligned with axis
|
||||
if (a_Rotation > 360)
|
||||
{
|
||||
a_Rotation -= 360;
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
@ -28,7 +28,7 @@ public:
|
||||
|
||||
if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM))
|
||||
{
|
||||
a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face
|
||||
a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face
|
||||
if (a_BlockFace == BLOCK_FACE_NONE)
|
||||
{
|
||||
// Client wouldn't have sent anything anyway, but whatever
|
||||
@ -38,10 +38,10 @@ public:
|
||||
else
|
||||
{
|
||||
// Not top or bottom faces, try to preserve whatever face was clicked
|
||||
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); // Set to clicked block
|
||||
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); // Set to clicked block
|
||||
if (!CanBePlacedOn(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ), a_BlockFace))
|
||||
{
|
||||
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); // Reset to torch block
|
||||
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); // Reset to torch block
|
||||
// Torch couldn't be placed on whatever face was clicked, last ditch resort - find another face
|
||||
a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
|
||||
if (a_BlockFace == BLOCK_FACE_NONE)
|
||||
@ -113,13 +113,13 @@ public:
|
||||
/// Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure
|
||||
static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions
|
||||
for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions
|
||||
{
|
||||
eBlockFace Face = static_cast<eBlockFace>(i);
|
||||
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true);
|
||||
BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
if ( // If on a block that can only hold a torch if torch is standing on it, return that face
|
||||
if ( // If on a block that can only hold a torch if torch is standing on it, return that face
|
||||
((BlockInQuestion == E_BLOCK_GLASS) ||
|
||||
(BlockInQuestion == E_BLOCK_FENCE) ||
|
||||
(BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) ||
|
||||
@ -158,7 +158,7 @@ public:
|
||||
(BlockInQuestion == E_BLOCK_FENCE) ||
|
||||
(BlockInQuestion == E_BLOCK_SOULSAND) ||
|
||||
(BlockInQuestion == E_BLOCK_MOB_SPAWNER) ||
|
||||
(BlockInQuestion == E_BLOCK_END_PORTAL_FRAME) || // Actual vanilla behaviour
|
||||
(BlockInQuestion == E_BLOCK_END_PORTAL_FRAME) || // Actual vanilla behaviour
|
||||
(BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) ||
|
||||
(BlockInQuestion == E_BLOCK_COBBLESTONE_WALL)
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
|
89
src/Blocks/BlockWallSign.h
Normal file
89
src/Blocks/BlockWallSign.h
Normal file
@ -0,0 +1,89 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BlockHandler.h"
|
||||
#include "../Entities/Player.h"
|
||||
#include "Chunk.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockWallSignHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
typedef cBlockHandler super;
|
||||
|
||||
public:
|
||||
cBlockWallSignHandler(BLOCKTYPE a_BlockType) :
|
||||
super(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
virtual const char * GetStepSound(void) override
|
||||
{
|
||||
return "step.wood";
|
||||
}
|
||||
|
||||
|
||||
virtual void OnPlacedByPlayer(
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
|
||||
) override
|
||||
{
|
||||
a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX;
|
||||
int BlockZ = (a_Chunk.GetPosZ() * cChunkDef::Width) + a_RelZ;
|
||||
GetBlockCoordsBehindTheSign(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ), BlockX, BlockZ);
|
||||
|
||||
return (cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(BlockX, a_RelY, BlockZ)));
|
||||
}
|
||||
|
||||
|
||||
static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ)
|
||||
{
|
||||
switch (a_BlockMeta)
|
||||
{
|
||||
case 2: a_BlockZ++; break;
|
||||
case 3: a_BlockZ--; break;
|
||||
case 4: a_BlockX++; break;
|
||||
case 5: a_BlockX--; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
|
||||
{
|
||||
switch (a_Direction)
|
||||
{
|
||||
case 0x2: return 0x2;
|
||||
case 0x3: return 0x3;
|
||||
case 0x4: return 0x4;
|
||||
case 0x5: return 0x5;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0x2;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
class cBroadcastInterface
|
||||
class cBroadcastInterface
|
||||
{
|
||||
public:
|
||||
virtual ~cBroadcastInterface() {}
|
||||
|
@ -4,9 +4,99 @@ project (MCServer)
|
||||
|
||||
include_directories ("${PROJECT_SOURCE_DIR}/../")
|
||||
|
||||
file(GLOB SOURCE
|
||||
"*.cpp"
|
||||
"*.h"
|
||||
)
|
||||
SET (SRCS
|
||||
BlockBed.cpp
|
||||
BlockDoor.cpp
|
||||
BlockHandler.cpp
|
||||
BlockPiston.cpp
|
||||
ChunkInterface.cpp)
|
||||
|
||||
add_library(Blocks ${SOURCE})
|
||||
SET (HDRS
|
||||
BlockAnvil.h
|
||||
BlockBed.h
|
||||
BlockBigFlower.h
|
||||
BlockBrewingStand.h
|
||||
BlockButton.h
|
||||
BlockCactus.h
|
||||
BlockCake.h
|
||||
BlockCarpet.h
|
||||
BlockCauldron.h
|
||||
BlockChest.h
|
||||
BlockCloth.h
|
||||
BlockCobWeb.h
|
||||
BlockCommandBlock.h
|
||||
BlockComparator.h
|
||||
BlockCrops.h
|
||||
BlockDeadBush.h
|
||||
BlockDirt.h
|
||||
BlockDoor.h
|
||||
BlockDropSpenser.h
|
||||
BlockEnchantmentTable.h
|
||||
BlockEnderchest.h
|
||||
BlockEntity.h
|
||||
BlockFarmland.h
|
||||
BlockFenceGate.h
|
||||
BlockFire.h
|
||||
BlockFlower.h
|
||||
BlockFlowerPot.h
|
||||
BlockFluid.h
|
||||
BlockFurnace.h
|
||||
BlockGlass.h
|
||||
BlockGlowstone.h
|
||||
BlockGravel.h
|
||||
BlockHandler.h
|
||||
BlockHayBale.h
|
||||
BlockHopper.h
|
||||
BlockIce.h
|
||||
BlockLadder.h
|
||||
BlockLeaves.h
|
||||
BlockLever.h
|
||||
BlockLilypad.h
|
||||
BlockMelon.h
|
||||
BlockMobHead.h
|
||||
BlockMushroom.h
|
||||
BlockMycelium.h
|
||||
BlockNetherWart.h
|
||||
BlockNewLeaves.h
|
||||
BlockNote.h
|
||||
BlockOre.h
|
||||
BlockPiston.h
|
||||
BlockPlanks.h
|
||||
BlockPluginInterface.h
|
||||
BlockPortal.h
|
||||
BlockPressurePlate.h
|
||||
BlockPumpkin.h
|
||||
BlockQuartz.h
|
||||
BlockRail.h
|
||||
BlockRedstone.h
|
||||
BlockRedstoneLamp.h
|
||||
BlockRedstoneRepeater.h
|
||||
BlockRedstoneTorch.h
|
||||
BlockSand.h
|
||||
BlockSapling.h
|
||||
BlockSideways.h
|
||||
BlockSignPost.h
|
||||
BlockSlab.h
|
||||
BlockSnow.h
|
||||
BlockStairs.h
|
||||
BlockStems.h
|
||||
BlockStone.h
|
||||
BlockSugarcane.h
|
||||
BlockTNT.h
|
||||
BlockTallGrass.h
|
||||
BlockTorch.h
|
||||
BlockTrapdoor.h
|
||||
BlockTripwire.h
|
||||
BlockTripwireHook.h
|
||||
BlockVine.h
|
||||
BlockWallSign.h
|
||||
BlockWorkbench.h
|
||||
BroadcastInterface.h
|
||||
ChunkInterface.h
|
||||
ClearMetaOnDrop.h
|
||||
MetaRotator.h
|
||||
WorldInterface.h)
|
||||
|
||||
if(NOT MSVC)
|
||||
add_library(Blocks ${SRCS} ${HDRS})
|
||||
endif()
|
||||
|
@ -18,10 +18,10 @@ public:
|
||||
|
||||
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ);
|
||||
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
BLOCKTYPE GetBlock(const Vector3i & a_Pos)
|
||||
{
|
||||
{
|
||||
return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
|
||||
}
|
||||
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
|
@ -4,7 +4,7 @@
|
||||
// mixin for use to clear meta values when the block is converted to a pickup
|
||||
|
||||
// Usage: inherit from this class, passing the parent class as the parameter Base
|
||||
// For example to use in class Foo which should inherit Bar use
|
||||
// For example to use in class Foo which should inherit Bar use
|
||||
// class Foo : public cClearMetaOnDrop<Bar>;
|
||||
|
||||
template<class Base>
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
// MSVC generates warnings for the templated AssertIfNotMatched parameter conditions, so disable it:
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4127) // Conditional expression is constant
|
||||
#pragma warning(disable: 4127) // Conditional expression is constant
|
||||
#endif
|
||||
|
||||
|
||||
@ -47,8 +47,8 @@ NIBBLETYPE cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatc
|
||||
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
|
||||
switch (a_Meta & BitMask)
|
||||
{
|
||||
case South: return West | OtherMeta;
|
||||
case West: return North | OtherMeta;
|
||||
case South: return West | OtherMeta;
|
||||
case West: return North | OtherMeta;
|
||||
case North: return East | OtherMeta;
|
||||
case East: return South | OtherMeta;
|
||||
}
|
||||
@ -69,7 +69,7 @@ NIBBLETYPE cMetaRotator<Base, BitMask, North, East, South, West, AssertIfNotMatc
|
||||
NIBBLETYPE OtherMeta = a_Meta & (~BitMask);
|
||||
switch (a_Meta & BitMask)
|
||||
{
|
||||
case South: return East | OtherMeta;
|
||||
case South: return East | OtherMeta;
|
||||
case East: return North | OtherMeta;
|
||||
case North: return West | OtherMeta;
|
||||
case West: return South | OtherMeta;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
virtual cBroadcastInterface & GetBroadcastManager() = 0;
|
||||
|
||||
virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) = 0;
|
||||
virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) = 0;
|
||||
|
||||
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
|
||||
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) = 0;
|
||||
|
@ -191,7 +191,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Point)
|
||||
|
||||
|
||||
|
||||
bool cBoundingBox::IsInside(double a_X, double a_Y,double a_Z)
|
||||
bool cBoundingBox::IsInside(double a_X, double a_Y, double a_Z)
|
||||
{
|
||||
return IsInside(m_Min, m_Max, a_X, a_Y, a_Z);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
bool IsInside(const Vector3d & a_Point);
|
||||
|
||||
/// Returns true if the point is inside the bounding box
|
||||
bool IsInside(double a_X, double a_Y,double a_Z);
|
||||
bool IsInside(double a_X, double a_Y, double a_Z);
|
||||
|
||||
/// Returns true if a_Other is inside this bounding box
|
||||
bool IsInside(cBoundingBox & a_Other);
|
||||
|
@ -140,7 +140,7 @@ protected:
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cByteBuffer:
|
||||
|
||||
cByteBuffer::cByteBuffer(size_t a_BufferSize) :
|
||||
|
@ -5,144 +5,148 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/")
|
||||
include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include")
|
||||
include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
|
||||
|
||||
set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++)
|
||||
set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs)
|
||||
set(FOLDERS
|
||||
OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ Bindings
|
||||
WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs
|
||||
)
|
||||
|
||||
set(BINDING_DEPENDECIES
|
||||
tolua
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg
|
||||
Bindings/gen_LuaState_Call.lua
|
||||
Bindings/LuaFunctions.h
|
||||
Bindings/LuaWindow.h
|
||||
Bindings/Plugin.h
|
||||
Bindings/PluginLua.h
|
||||
Bindings/PluginManager.h
|
||||
Bindings/WebPlugin.h
|
||||
SET (SRCS
|
||||
BiomeDef.cpp
|
||||
BlockArea.cpp
|
||||
BlockID.cpp
|
||||
BlockInfo.cpp
|
||||
BoundingBox.cpp
|
||||
ByteBuffer.cpp
|
||||
ChatColor.cpp
|
||||
Chunk.cpp
|
||||
ChunkData.cpp
|
||||
ChunkMap.cpp
|
||||
ChunkSender.cpp
|
||||
ChunkStay.cpp
|
||||
ClientHandle.cpp
|
||||
CommandOutput.cpp
|
||||
CompositeChat.cpp
|
||||
CraftingRecipes.cpp
|
||||
Cuboid.cpp
|
||||
DeadlockDetect.cpp
|
||||
Enchantments.cpp
|
||||
FastRandom.cpp
|
||||
FurnaceRecipe.cpp
|
||||
Globals.cpp
|
||||
Group.cpp
|
||||
GroupManager.cpp
|
||||
Inventory.cpp
|
||||
Item.cpp
|
||||
ItemGrid.cpp
|
||||
LightingThread.cpp
|
||||
LineBlockTracer.cpp
|
||||
LinearInterpolation.cpp
|
||||
Log.cpp
|
||||
MCLogger.cpp
|
||||
Map.cpp
|
||||
MapManager.cpp
|
||||
MobCensus.cpp
|
||||
MobFamilyCollecter.cpp
|
||||
MobProximityCounter.cpp
|
||||
MobSpawner.cpp
|
||||
MonsterConfig.cpp
|
||||
Noise.cpp
|
||||
ProbabDistrib.cpp
|
||||
RCONServer.cpp
|
||||
Root.cpp
|
||||
Scoreboard.cpp
|
||||
Server.cpp
|
||||
Statistics.cpp
|
||||
StringCompression.cpp
|
||||
StringUtils.cpp
|
||||
Tracer.cpp
|
||||
VoronoiMap.cpp
|
||||
WebAdmin.cpp
|
||||
World.cpp
|
||||
main.cpp)
|
||||
|
||||
SET (HDRS
|
||||
AllocationPool.h
|
||||
BiomeDef.h
|
||||
BlockArea.h
|
||||
BlockEntities/BlockEntity.h
|
||||
BlockEntities/BlockEntityWithItems.h
|
||||
BlockEntities/ChestEntity.h
|
||||
BlockEntities/DispenserEntity.h
|
||||
BlockEntities/DropSpenserEntity.h
|
||||
BlockEntities/DropperEntity.h
|
||||
BlockEntities/FurnaceEntity.h
|
||||
BlockEntities/HopperEntity.h
|
||||
BlockEntities/JukeboxEntity.h
|
||||
BlockEntities/NoteEntity.h
|
||||
BlockEntities/SignEntity.h
|
||||
BlockEntities/MobHeadEntity.h
|
||||
BlockEntities/FlowerPotEntity.h
|
||||
BlockID.h
|
||||
BlockInServerPluginInterface.h
|
||||
BlockInfo.h
|
||||
BlockTracer.h
|
||||
BoundingBox.h
|
||||
ByteBuffer.h
|
||||
ChatColor.h
|
||||
Chunk.h
|
||||
ChunkData.h
|
||||
ChunkDataCallback.h
|
||||
ChunkDef.h
|
||||
ChunkMap.h
|
||||
ChunkSender.h
|
||||
ChunkStay.h
|
||||
ClientHandle.h
|
||||
CommandOutput.h
|
||||
CompositeChat.h
|
||||
CraftingRecipes.h
|
||||
Cuboid.h
|
||||
DeadlockDetect.h
|
||||
Defines.h
|
||||
Enchantments.h
|
||||
Entities/EntityEffect.h
|
||||
Entities/Entity.h
|
||||
Entities/Floater.h
|
||||
Entities/Pawn.h
|
||||
Entities/Painting.h
|
||||
Entities/Pickup.h
|
||||
Entities/Player.h
|
||||
Entities/ProjectileEntity.h
|
||||
Entities/ArrowEntity.h
|
||||
Entities/ThrownEggEntity.h
|
||||
Entities/ThrownEnderPearlEntity.h
|
||||
Entities/ExpBottleEntity.h
|
||||
Entities/ThrownSnowballEntity.h
|
||||
Entities/FireChargeEntity.h
|
||||
Entities/FireworkEntity.h
|
||||
Entities/GhastFireballEntity.h
|
||||
Entities/TNTEntity.h
|
||||
Entities/ExpOrb.h
|
||||
Entities/HangingEntity.h
|
||||
Entities/ItemFrame.h
|
||||
Generating/ChunkDesc.h
|
||||
Endianness.h
|
||||
FastRandom.h
|
||||
ForEachChunkProvider.h
|
||||
FurnaceRecipe.h
|
||||
Globals.h
|
||||
Group.h
|
||||
GroupManager.h
|
||||
Inventory.h
|
||||
Item.h
|
||||
ItemGrid.h
|
||||
Mobs/Monster.h
|
||||
OSSupport/File.h
|
||||
LeakFinder.h
|
||||
LightingThread.h
|
||||
LineBlockTracer.h
|
||||
LinearInterpolation.h
|
||||
LinearUpscale.h
|
||||
Log.h
|
||||
MCLogger.h
|
||||
Map.h
|
||||
MapManager.h
|
||||
Matrix4.h
|
||||
MemoryLeak.h
|
||||
MersenneTwister.h
|
||||
MobCensus.h
|
||||
MobFamilyCollecter.h
|
||||
MobProximityCounter.h
|
||||
MobSpawner.h
|
||||
MonsterConfig.h
|
||||
Noise.h
|
||||
ProbabDistrib.h
|
||||
RCONServer.h
|
||||
Root.h
|
||||
Scoreboard.h
|
||||
Server.h
|
||||
StackWalker.h
|
||||
Statistics.h
|
||||
StringCompression.h
|
||||
StringUtils.h
|
||||
Tracer.h
|
||||
UI/Window.h
|
||||
Vector3.h
|
||||
VoronoiMap.h
|
||||
WebAdmin.h
|
||||
World.h
|
||||
)
|
||||
XMLParser.h)
|
||||
|
||||
# List all the files that are generated as part of the Bindings build process
|
||||
set (BINDING_OUTPUTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/LuaState_Call.inc
|
||||
)
|
||||
|
||||
include_directories(Bindings)
|
||||
include_directories(.)
|
||||
|
||||
if (WIN32)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${BINDING_OUTPUTS}
|
||||
|
||||
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll
|
||||
|
||||
# Regenerate bindings:
|
||||
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
|
||||
|
||||
# add any new generation dependencies here
|
||||
DEPENDS ${BINDING_DEPENDECIES}
|
||||
)
|
||||
else ()
|
||||
ADD_CUSTOM_COMMAND(
|
||||
# add any new generated bindings here
|
||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
|
||||
|
||||
# Regenerate bindings:
|
||||
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
|
||||
|
||||
# add any new generation dependencies here
|
||||
DEPENDS ${BINDING_DEPENDECIES}
|
||||
)
|
||||
endif ()
|
||||
set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
|
||||
include_directories(".")
|
||||
|
||||
if (NOT MSVC)
|
||||
|
||||
# Bindings need to reference other folders, so they are done here instead
|
||||
|
||||
# lib dependencies are not included
|
||||
|
||||
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
|
||||
|
||||
#add cpp files here
|
||||
add_library(Bindings
|
||||
Bindings/Bindings
|
||||
Bindings/DeprecatedBindings
|
||||
Bindings/LuaChunkStay
|
||||
Bindings/LuaState
|
||||
Bindings/LuaWindow
|
||||
Bindings/ManualBindings
|
||||
Bindings/Plugin
|
||||
Bindings/PluginLua
|
||||
Bindings/PluginManager
|
||||
Bindings/WebPlugin
|
||||
)
|
||||
foreach(folder ${FOLDERS})
|
||||
add_subdirectory(${folder})
|
||||
endforeach(folder)
|
||||
|
||||
target_link_libraries(Bindings lua sqlite tolualib polarssl)
|
||||
get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
|
||||
|
||||
#clear file
|
||||
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt)
|
||||
@ -153,43 +157,19 @@ if (NOT MSVC)
|
||||
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h")
|
||||
|
||||
foreach(folder ${FOLDERS})
|
||||
add_subdirectory(${folder})
|
||||
endforeach(folder)
|
||||
|
||||
file(GLOB SOURCE
|
||||
"*.cpp"
|
||||
"*.h"
|
||||
)
|
||||
|
||||
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/StackWalker.cpp" "${PROJECT_SOURCE_DIR}/LeakFinder.cpp")
|
||||
list(APPEND SOURCE "${SRCS}")
|
||||
list(APPEND SOURCE "${HDRS}")
|
||||
|
||||
# If building a windows version, but not using MSVC, add the resources directly to the makefile:
|
||||
if (WIN32)
|
||||
FILE(GLOB ResourceFiles
|
||||
"Resources/*.rc"
|
||||
)
|
||||
list(APPEND SOURCE "${ResourceFiles}")
|
||||
list(APPEND SOURCE "Resources/MCServer.rc")
|
||||
endif()
|
||||
|
||||
|
||||
else ()
|
||||
# MSVC-specific handling: Put all files into one project, separate by the folders:
|
||||
|
||||
# Get all files in this folder:
|
||||
file(GLOB_RECURSE SOURCE
|
||||
"*.cpp"
|
||||
"*.h"
|
||||
"*.pkg"
|
||||
)
|
||||
source_group("" FILES ${SOURCE})
|
||||
|
||||
LIST(APPEND SOURCE "Bindings/Bindings.cpp" "Bindings/Bindings.h")
|
||||
source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h")
|
||||
|
||||
# Add all subfolders as solution-folders:
|
||||
list(APPEND FOLDERS "Resources")
|
||||
list(APPEND FOLDERS "Bindings")
|
||||
function(includefolder PATH)
|
||||
FILE(GLOB FOLDER_FILES
|
||||
"${PATH}/*.cpp"
|
||||
@ -202,9 +182,29 @@ else ()
|
||||
endfunction(includefolder)
|
||||
|
||||
foreach(folder ${FOLDERS})
|
||||
add_subdirectory(${folder})
|
||||
includefolder(${folder})
|
||||
|
||||
# Get all source files in this folder:
|
||||
get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
|
||||
foreach (src ${FOLDER_SRCS})
|
||||
list(APPEND SOURCE "${folder}/${src}")
|
||||
endforeach(src)
|
||||
|
||||
# Get all headers in this folder:
|
||||
get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
|
||||
foreach (hdr ${FOLDER_HDRS})
|
||||
list(APPEND SOURCE "${folder}/${hdr}")
|
||||
endforeach(hdr)
|
||||
endforeach(folder)
|
||||
|
||||
list(APPEND SOURCE "${SRCS}")
|
||||
list(APPEND SOURCE "${HDRS}")
|
||||
list(APPEND SOURCE "Bindings/AllToLua.pkg")
|
||||
|
||||
includefolder("Resources")
|
||||
source_group("" FILES ${SOURCE})
|
||||
|
||||
include_directories("${PROJECT_SOURCE_DIR}")
|
||||
|
||||
# Precompiled headers (1st part)
|
||||
@ -230,6 +230,25 @@ endif()
|
||||
|
||||
set(EXECUTABLE MCServer)
|
||||
|
||||
if (MSVC)
|
||||
get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS)
|
||||
get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${BINDING_OUTPUTS}
|
||||
|
||||
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/MCServer/lua51.dll ./lua51.dll
|
||||
|
||||
# Regenerate bindings:
|
||||
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
|
||||
|
||||
# add any new generation dependencies here
|
||||
DEPENDS ${BINDING_DEPENDECIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(${EXECUTABLE} ${SOURCE})
|
||||
|
||||
|
||||
@ -261,9 +280,11 @@ endif ()
|
||||
|
||||
|
||||
if (NOT MSVC)
|
||||
target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks)
|
||||
target_link_libraries(${EXECUTABLE} Protocol Generating Generating_Prefabs WorldStorage)
|
||||
target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities PolarSSL++)
|
||||
target_link_libraries(${EXECUTABLE}
|
||||
OSSupport HTTPServer Bindings Items Blocks
|
||||
Protocol Generating Generating_Prefabs WorldStorage
|
||||
Mobs Entities Simulator UI BlockEntities PolarSSL++
|
||||
)
|
||||
endif ()
|
||||
if (WIN32)
|
||||
target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib)
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
static const std::string Rose;
|
||||
static const std::string LightPurple;
|
||||
static const std::string Yellow;
|
||||
static const std::string White;
|
||||
static const std::string White;
|
||||
|
||||
// Styles ( source: http://wiki.vg/Chat )
|
||||
static const std::string Random;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user