Merge branch 'master' into Fixes
This commit is contained in:
commit
af997a09ca
@ -129,6 +129,8 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPER
|
|||||||
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
|
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
|
||||||
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/LuaState_Call.inc PROPERTIES GENERATED TRUE)
|
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/LuaState_Call.inc PROPERTIES GENERATED TRUE)
|
||||||
|
|
||||||
|
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
add_library(Bindings ${SRCS} ${HDRS})
|
add_library(Bindings ${SRCS} ${HDRS})
|
||||||
|
|
||||||
|
@ -5,11 +5,6 @@
|
|||||||
#undef TOLUA_TEMPLATE_BIND
|
#undef TOLUA_TEMPLATE_BIND
|
||||||
#include "tolua++/include/tolua++.h"
|
#include "tolua++/include/tolua++.h"
|
||||||
|
|
||||||
#include "Plugin.h"
|
|
||||||
#include "PluginLua.h"
|
|
||||||
#include "PluginManager.h"
|
|
||||||
#include "LuaWindow.h"
|
|
||||||
#include "LuaChunkStay.h"
|
|
||||||
|
|
||||||
#include "../BlockInfo.h"
|
#include "../BlockInfo.h"
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "LuaChunkStay.h"
|
#include "LuaChunkStay.h"
|
||||||
#include "PluginLua.h"
|
#include "PluginLua.h"
|
||||||
#include "../World.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
// fwd:
|
// fwd:
|
||||||
class cPluginLua;
|
class cPluginLua;
|
||||||
|
class cChunkMap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ struct HTTPRequest;
|
|||||||
class cWebAdmin;
|
class cWebAdmin;
|
||||||
struct HTTPTemplateRequest;
|
struct HTTPTemplateRequest;
|
||||||
class cTNTEntity;
|
class cTNTEntity;
|
||||||
class cCreeper;
|
|
||||||
class cHopperEntity;
|
class cHopperEntity;
|
||||||
class cBlockEntity;
|
class cBlockEntity;
|
||||||
class cBoundingBox;
|
class cBoundingBox;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "LuaWindow.h"
|
#include "LuaWindow.h"
|
||||||
#include "../UI/SlotArea.h"
|
#include "../UI/SlotArea.h"
|
||||||
#include "PluginLua.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
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#undef TOLUA_TEMPLATE_BIND
|
#undef TOLUA_TEMPLATE_BIND
|
||||||
#include "tolua++/include/tolua++.h"
|
#include "tolua++/include/tolua++.h"
|
||||||
#include "polarssl/md5.h"
|
#include "polarssl/md5.h"
|
||||||
#include "Plugin.h"
|
|
||||||
#include "PluginLua.h"
|
#include "PluginLua.h"
|
||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
#include "LuaWindow.h"
|
#include "LuaWindow.h"
|
||||||
@ -27,7 +26,6 @@
|
|||||||
#include "../BlockEntities/MobHeadEntity.h"
|
#include "../BlockEntities/MobHeadEntity.h"
|
||||||
#include "../BlockEntities/FlowerPotEntity.h"
|
#include "../BlockEntities/FlowerPotEntity.h"
|
||||||
#include "../LineBlockTracer.h"
|
#include "../LineBlockTracer.h"
|
||||||
#include "../Protocol/Authenticator.h"
|
|
||||||
#include "../WorldStorage/SchematicFileSerializer.h"
|
#include "../WorldStorage/SchematicFileSerializer.h"
|
||||||
#include "../CompositeChat.h"
|
#include "../CompositeChat.h"
|
||||||
|
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "PluginManager.h"
|
#include "Defines.h"
|
||||||
|
|
||||||
|
class cCommandOutputCallback;
|
||||||
|
class cItems;
|
||||||
|
class cHopperEntity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cBlockEntityWithItems;
|
||||||
class cClientHandle;
|
class cClientHandle;
|
||||||
class cPlayer;
|
|
||||||
class cPickup;
|
class cPickup;
|
||||||
class cItem;
|
class cPlayer;
|
||||||
|
class cProjectileEntity;
|
||||||
class cEntity;
|
class cEntity;
|
||||||
|
class cMonster;
|
||||||
class cWorld;
|
class cWorld;
|
||||||
class cChunkDesc;
|
class cChunkDesc;
|
||||||
struct TakeDamageInfo;
|
struct TakeDamageInfo;
|
||||||
|
|
||||||
// fwd: cPlayer.h
|
|
||||||
class cPlayer;
|
|
||||||
|
|
||||||
// fwd: CraftingRecipes.h
|
// fwd: CraftingRecipes.h
|
||||||
class cCraftingGrid;
|
class cCraftingGrid;
|
||||||
|
@ -12,10 +12,12 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "PluginLua.h"
|
#include "PluginLua.h"
|
||||||
#include "../CommandOutput.h"
|
#include "../CommandOutput.h"
|
||||||
|
#include "PluginManager.h"
|
||||||
|
#include "../Item.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include "lua/src/lualib.h"
|
#include "lua/src/lauxlib.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef TOLUA_TEMPLATE_BIND
|
#undef TOLUA_TEMPLATE_BIND
|
||||||
|
@ -4,12 +4,10 @@
|
|||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
#include "Plugin.h"
|
#include "Plugin.h"
|
||||||
#include "PluginLua.h"
|
#include "PluginLua.h"
|
||||||
#include "../WebAdmin.h"
|
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../Server.h"
|
#include "../Server.h"
|
||||||
#include "../CommandOutput.h"
|
#include "../CommandOutput.h"
|
||||||
#include "../ChatColor.h"
|
|
||||||
|
|
||||||
#include "inifile/iniFile.h"
|
#include "inifile/iniFile.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Item.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "Defines.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ class cPickup;
|
|||||||
|
|
||||||
// fwd: Pawn.h
|
// fwd: Pawn.h
|
||||||
struct TakeDamageInfo;
|
struct TakeDamageInfo;
|
||||||
class cPawn;
|
|
||||||
|
|
||||||
// fwd: CommandOutput.h
|
// fwd: CommandOutput.h
|
||||||
class cCommandOutputCallback;
|
class cCommandOutputCallback;
|
||||||
@ -49,6 +47,8 @@ class cBlockEntityWithItems;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cItems;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "WebPlugin.h"
|
#include "WebPlugin.h"
|
||||||
#include "../WebAdmin.h"
|
#include "../WebAdmin.h"
|
||||||
#include "../Server.h"
|
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct lua_State;
|
|
||||||
struct HTTPRequest;
|
struct HTTPRequest;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../ClientHandle.h"
|
|
||||||
#include "../World.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -13,8 +11,9 @@ namespace Json
|
|||||||
class Value;
|
class Value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class cChunk;
|
||||||
class cPlayer;
|
class cPlayer;
|
||||||
class cPacket;
|
class cWorld;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "BlockEntity.h"
|
#include "BlockEntity.h"
|
||||||
#include "../ItemGrid.h"
|
#include "../ItemGrid.h"
|
||||||
#include "../UI/WindowOwner.h"
|
#include "../UI/WindowOwner.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/Window.h"
|
||||||
#include "json/json.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@ namespace Json
|
|||||||
};
|
};
|
||||||
|
|
||||||
class cClientHandle;
|
class cClientHandle;
|
||||||
class cServer;
|
|
||||||
class cNBTData;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,16 +4,14 @@
|
|||||||
// Implements the cCommandBlockEntity class representing a single command block in the world
|
// Implements the cCommandBlockEntity class representing a single command block in the world
|
||||||
|
|
||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
#include "json/json.h"
|
|
||||||
#include "CommandBlockEntity.h"
|
#include "CommandBlockEntity.h"
|
||||||
#include "../Entities/Player.h"
|
|
||||||
#include "../WorldStorage/FastNBT.h"
|
|
||||||
|
|
||||||
#include "../CommandOutput.h"
|
#include "../CommandOutput.h"
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../Server.h" // ExecuteConsoleCommand()
|
#include "../Server.h" // ExecuteConsoleCommand()
|
||||||
#include "../Chunk.h"
|
|
||||||
#include "../ChatColor.h"
|
#include "../ChatColor.h"
|
||||||
|
#include "../World.h"
|
||||||
|
#include "../ClientHandle.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntity.h"
|
#include "BlockEntity.h"
|
||||||
|
#include "RedstonePoweredEntity.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +27,8 @@ namespace Json
|
|||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
class cCommandBlockEntity :
|
class cCommandBlockEntity :
|
||||||
public cBlockEntity
|
public cBlockEntity,
|
||||||
|
public cRedstonePoweredEntity
|
||||||
{
|
{
|
||||||
typedef cBlockEntity super;
|
typedef cBlockEntity super;
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ public:
|
|||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
/// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
|
/// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
|
||||||
void SetRedstonePower(bool a_IsPowered);
|
virtual void SetRedstonePower(bool a_IsPowered) override;
|
||||||
|
|
||||||
/// Sets the command block to execute a command in the next tick
|
/// Sets the command block to execute a command in the next tick
|
||||||
void Activate(void);
|
void Activate(void);
|
||||||
|
@ -2,13 +2,10 @@
|
|||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
|
|
||||||
#include "DispenserEntity.h"
|
#include "DispenserEntity.h"
|
||||||
#include "../Entities/Player.h"
|
|
||||||
#include "../Simulator/FluidSimulator.h"
|
#include "../Simulator/FluidSimulator.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
|
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Entities/ArrowEntity.h"
|
|
||||||
#include "../Entities/FireChargeEntity.h"
|
|
||||||
#include "../Entities/ProjectileEntity.h"
|
#include "../Entities/ProjectileEntity.h"
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +106,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
|||||||
{
|
{
|
||||||
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
|
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
|
||||||
double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
|
double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
|
||||||
if (m_World->SpawnMob(MobX, DispY, MobZ, (cMonster::eType)m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
|
if (m_World->SpawnMob(MobX, DispY, MobZ, (eMonsterType)m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
|
||||||
{
|
{
|
||||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "DropSpenserEntity.h"
|
#include "DropSpenserEntity.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
#include "json/json.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ namespace Json
|
|||||||
}
|
}
|
||||||
|
|
||||||
class cClientHandle;
|
class cClientHandle;
|
||||||
class cServer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DropperEntity.h"
|
#include "DropperEntity.h"
|
||||||
#include "../Entities/Player.h"
|
|
||||||
#include "../Simulator/FluidSimulator.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/Window.h"
|
||||||
#include "json/json.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "BlockEntity.h"
|
#include "BlockEntity.h"
|
||||||
#include "UI/WindowOwner.h"
|
#include "UI/WindowOwner.h"
|
||||||
#include "json/json.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
// Implements the cFlowerPotEntity class representing a single flower pot in the world
|
// Implements the cFlowerPotEntity class representing a single flower pot in the world
|
||||||
|
|
||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
#include "json/json.h"
|
|
||||||
#include "FlowerPotEntity.h"
|
#include "FlowerPotEntity.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntity.h"
|
#include "BlockEntity.h"
|
||||||
|
#include "Item.h"
|
||||||
|
|
||||||
class cItem;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#include "../UI/Window.h"
|
#include "../UI/Window.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../Chunk.h"
|
|
||||||
#include "json/json.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ namespace Json
|
|||||||
}
|
}
|
||||||
|
|
||||||
class cClientHandle;
|
class cClientHandle;
|
||||||
class cServer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,10 +10,7 @@
|
|||||||
#include "../Entities/Pickup.h"
|
#include "../Entities/Pickup.h"
|
||||||
#include "../Bindings/PluginManager.h"
|
#include "../Bindings/PluginManager.h"
|
||||||
#include "ChestEntity.h"
|
#include "ChestEntity.h"
|
||||||
#include "DropSpenserEntity.h"
|
|
||||||
#include "FurnaceEntity.h"
|
#include "FurnaceEntity.h"
|
||||||
#include "../BoundingBox.h"
|
|
||||||
#include "json/json.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "JukeboxEntity.h"
|
#include "JukeboxEntity.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "json/json.h"
|
#include "json/value.h"
|
||||||
|
#include "Entities/Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntity.h"
|
#include "BlockEntity.h"
|
||||||
#include "../Entities/Player.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
// Implements the cMobHeadEntity class representing a single skull/head in the world
|
// Implements the cMobHeadEntity class representing a single skull/head in the world
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "json/json.h"
|
|
||||||
#include "MobHeadEntity.h"
|
#include "MobHeadEntity.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockEntity.h"
|
#include "BlockEntity.h"
|
||||||
|
#include "Defines.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "NoteEntity.h"
|
#include "NoteEntity.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "json/json.h"
|
#include "json/value.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
// Implements the cSignEntity class representing a single sign in the world
|
// Implements the cSignEntity class representing a single sign in the world
|
||||||
|
|
||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
#include "json/json.h"
|
#include "json/value.h"
|
||||||
#include "SignEntity.h"
|
#include "SignEntity.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../ClientHandle.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,34 +261,34 @@ int StringToMobType(const AString & a_MobString)
|
|||||||
const char * m_String;
|
const char * m_String;
|
||||||
} MobMap [] =
|
} MobMap [] =
|
||||||
{
|
{
|
||||||
{cMonster::mtCreeper, "Creeper"},
|
{mtCreeper, "Creeper"},
|
||||||
{cMonster::mtSkeleton, "Skeleton"},
|
{mtSkeleton, "Skeleton"},
|
||||||
{cMonster::mtSpider, "Spider"},
|
{mtSpider, "Spider"},
|
||||||
{cMonster::mtGiant, "Giant"},
|
{mtGiant, "Giant"},
|
||||||
{cMonster::mtZombie, "Zombie"},
|
{mtZombie, "Zombie"},
|
||||||
{cMonster::mtSlime, "Slime"},
|
{mtSlime, "Slime"},
|
||||||
{cMonster::mtGhast, "Ghast"},
|
{mtGhast, "Ghast"},
|
||||||
{cMonster::mtZombiePigman, "ZombiePigman"},
|
{mtZombiePigman, "ZombiePigman"},
|
||||||
{cMonster::mtEnderman, "Enderman"},
|
{mtEnderman, "Enderman"},
|
||||||
{cMonster::mtCaveSpider, "CaveSpider"},
|
{mtCaveSpider, "CaveSpider"},
|
||||||
{cMonster::mtSilverfish, "SilverFish"},
|
{mtSilverfish, "SilverFish"},
|
||||||
{cMonster::mtBlaze, "Blaze"},
|
{mtBlaze, "Blaze"},
|
||||||
{cMonster::mtMagmaCube, "MagmaCube"},
|
{mtMagmaCube, "MagmaCube"},
|
||||||
{cMonster::mtEnderDragon, "EnderDragon"},
|
{mtEnderDragon, "EnderDragon"},
|
||||||
{cMonster::mtWither, "Wither"},
|
{mtWither, "Wither"},
|
||||||
{cMonster::mtBat, "Bat"},
|
{mtBat, "Bat"},
|
||||||
{cMonster::mtWitch, "Witch"},
|
{mtWitch, "Witch"},
|
||||||
{cMonster::mtPig, "Pig"},
|
{mtPig, "Pig"},
|
||||||
{cMonster::mtSheep, "Sheep"},
|
{mtSheep, "Sheep"},
|
||||||
{cMonster::mtCow, "Cow"},
|
{mtCow, "Cow"},
|
||||||
{cMonster::mtChicken, "Chicken"},
|
{mtChicken, "Chicken"},
|
||||||
{cMonster::mtSquid, "Squid"},
|
{mtSquid, "Squid"},
|
||||||
{cMonster::mtWolf, "Wolf"},
|
{mtWolf, "Wolf"},
|
||||||
{cMonster::mtMooshroom, "Mooshroom"},
|
{mtMooshroom, "Mooshroom"},
|
||||||
{cMonster::mtSnowGolem, "SnowGolem"},
|
{mtSnowGolem, "SnowGolem"},
|
||||||
{cMonster::mtOcelot, "Ocelot"},
|
{mtOcelot, "Ocelot"},
|
||||||
{cMonster::mtIronGolem, "IronGolem"},
|
{mtIronGolem, "IronGolem"},
|
||||||
{cMonster::mtVillager, "Villager"},
|
{mtVillager, "Villager"},
|
||||||
};
|
};
|
||||||
for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++)
|
for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++)
|
||||||
{
|
{
|
||||||
|
@ -6,26 +6,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cBlockInfo::cBlockInfo()
|
|
||||||
: m_LightValue(0x00)
|
|
||||||
, m_SpreadLightFalloff(0x0f)
|
|
||||||
, m_Transparent(false)
|
|
||||||
, m_OneHitDig(false)
|
|
||||||
, m_PistonBreakable(false)
|
|
||||||
, m_IsSnowable(false)
|
|
||||||
, m_IsSolid(true)
|
|
||||||
, m_FullyOccupiesVoxel(false)
|
|
||||||
, m_CanBeTerraformed(false)
|
|
||||||
, m_PlaceSound("")
|
|
||||||
, m_Handler(NULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cBlockInfo::~cBlockInfo()
|
cBlockInfo::~cBlockInfo()
|
||||||
{
|
{
|
||||||
delete m_Handler;
|
delete m_Handler;
|
||||||
@ -33,28 +13,6 @@ cBlockInfo::~cBlockInfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
|
|
||||||
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
|
|
||||||
It works only if it is called for the first time before the app spawns other threads. */
|
|
||||||
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
|
|
||||||
{
|
|
||||||
static cBlockInfo ms_Info[256];
|
|
||||||
static bool IsBlockInfoInitialized = false;
|
|
||||||
if (!IsBlockInfoInitialized)
|
|
||||||
{
|
|
||||||
cBlockInfo::Initialize(ms_Info);
|
|
||||||
IsBlockInfoInitialized = true;
|
|
||||||
}
|
|
||||||
return ms_Info[a_Type];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
|
void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < 256; ++i)
|
for (unsigned int i = 0; i < 256; ++i)
|
||||||
|
@ -11,14 +11,27 @@ class cBlockHandler;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
class cBlockInfo
|
class cBlockInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Returns the associated BlockInfo structure for the specified block type. */
|
/** Returns the associated BlockInfo structure for the specified block type. */
|
||||||
static cBlockInfo & Get(BLOCKTYPE a_Type);
|
|
||||||
|
/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
|
||||||
|
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
|
||||||
|
It works only if it is called for the first time before the app spawns other threads. */
|
||||||
|
static cBlockInfo & Get(BLOCKTYPE a_Type)
|
||||||
|
{
|
||||||
|
static cBlockInfo ms_Info[256];
|
||||||
|
static bool IsBlockInfoInitialized = false;
|
||||||
|
if (!IsBlockInfoInitialized)
|
||||||
|
{
|
||||||
|
cBlockInfo::Initialize(ms_Info);
|
||||||
|
IsBlockInfoInitialized = true;
|
||||||
|
}
|
||||||
|
return ms_Info[a_Type];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** How much light do the blocks emit on their own? */
|
/** How much light do the blocks emit on their own? */
|
||||||
@ -78,7 +91,19 @@ protected:
|
|||||||
typedef cBlockInfo cBlockInfoArray[256];
|
typedef cBlockInfo cBlockInfoArray[256];
|
||||||
|
|
||||||
/** Creates a default BlockInfo structure, initializes all values to their defaults */
|
/** Creates a default BlockInfo structure, initializes all values to their defaults */
|
||||||
cBlockInfo();
|
cBlockInfo()
|
||||||
|
: m_LightValue(0x00)
|
||||||
|
, m_SpreadLightFalloff(0x0f)
|
||||||
|
, m_Transparent(false)
|
||||||
|
, m_OneHitDig(false)
|
||||||
|
, m_PistonBreakable(false)
|
||||||
|
, m_IsSnowable(false)
|
||||||
|
, m_IsSolid(true)
|
||||||
|
, m_FullyOccupiesVoxel(false)
|
||||||
|
, m_CanBeTerraformed(false)
|
||||||
|
, m_PlaceSound("")
|
||||||
|
, m_Handler(NULL)
|
||||||
|
{}
|
||||||
|
|
||||||
/** Cleans up the stored values */
|
/** Cleans up the stored values */
|
||||||
~cBlockInfo();
|
~cBlockInfo();
|
||||||
|
@ -4,6 +4,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "BroadcastInterface.h"
|
||||||
|
#include "ChunkInterface.h"
|
||||||
|
#include "Entities/../World.h"
|
||||||
|
#include "Entities/Player.h"
|
||||||
|
#include "WorldInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cBlockBedHandler::OnPlacedByPlayer(
|
void cBlockBedHandler::OnPlacedByPlayer(
|
||||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "ChunkInterface.h"
|
|
||||||
#include "WorldInterface.h"
|
|
||||||
#include "MetaRotator.h"
|
#include "MetaRotator.h"
|
||||||
#include "../Entities/Player.h"
|
#include "Item.h"
|
||||||
|
|
||||||
|
|
||||||
|
class cChunkInterface;
|
||||||
|
class cPlayer;
|
||||||
|
class cWorldInterface;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
|
#include "ChunkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "../FastRandom.h"
|
#include "../FastRandom.h"
|
||||||
|
#include "Root.h"
|
||||||
|
#include "Bindings/PluginManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "BlockDoor.h"
|
#include "BlockDoor.h"
|
||||||
#include "../Item.h"
|
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "Chunk.h"
|
#include "Chunk.h"
|
||||||
#include "MetaRotator.h"
|
#include "MetaRotator.h"
|
||||||
|
#include "ChunkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Root.h"
|
|
||||||
#include "../Bindings/PluginManager.h"
|
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
#include "BlockAnvil.h"
|
#include "BlockAnvil.h"
|
||||||
#include "BlockBed.h"
|
#include "BlockBed.h"
|
||||||
@ -84,6 +82,8 @@
|
|||||||
#include "BlockWorkbench.h"
|
#include "BlockWorkbench.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "BlockPluginInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Defines.h"
|
#include "../Defines.h"
|
||||||
#include "../Item.h"
|
|
||||||
#include "WorldInterface.h"
|
|
||||||
#include "ChunkInterface.h"
|
|
||||||
#include "BlockPluginInterface.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -14,6 +10,10 @@
|
|||||||
// fwd:
|
// fwd:
|
||||||
class cPlayer;
|
class cPlayer;
|
||||||
class cChunk;
|
class cChunk;
|
||||||
|
class cBlockPluginInterface;
|
||||||
|
class cChunkInterface;
|
||||||
|
class cWorldInterface;
|
||||||
|
class cItems;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ public:
|
|||||||
a_ChunkInterface.SetBlock(a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
a_ChunkInterface.SetBlock(a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
|
|
||||||
// Spawn the wither:
|
// Spawn the wither:
|
||||||
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
|
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtWither);
|
||||||
|
|
||||||
// Award Achievement
|
// Award Achievement
|
||||||
a_WorldInterface.ForEachPlayer(PlayerCallback);
|
a_WorldInterface.ForEachPlayer(PlayerCallback);
|
||||||
@ -181,7 +181,7 @@ public:
|
|||||||
a_ChunkInterface.SetBlock(a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0);
|
a_ChunkInterface.SetBlock(a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0);
|
||||||
|
|
||||||
// Spawn the wither:
|
// Spawn the wither:
|
||||||
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
|
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtWither);
|
||||||
|
|
||||||
// Award Achievement
|
// Award Achievement
|
||||||
a_WorldInterface.ForEachPlayer(PlayerCallback);
|
a_WorldInterface.ForEachPlayer(PlayerCallback);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "BlockInServerPluginInterface.h"
|
#include "BlockInServerPluginInterface.h"
|
||||||
|
#include "ChunkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
|
|
||||||
|
|
||||||
|
class cWorld;
|
||||||
|
|
||||||
|
|
||||||
class cBlockPistonHandler :
|
class cBlockPistonHandler :
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
int PosX = a_Chunk.GetPosX() * cChunkDef::Width + a_RelX;
|
int PosX = a_Chunk.GetPosX() * cChunkDef::Width + a_RelX;
|
||||||
int PosZ = a_Chunk.GetPosZ() * cChunkDef::Width + a_RelZ;
|
int PosZ = a_Chunk.GetPosZ() * cChunkDef::Width + a_RelZ;
|
||||||
|
|
||||||
a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, cMonster::mtZombiePigman);
|
a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, mtZombiePigman);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0);
|
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
|
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtSnowGolem);
|
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtSnowGolem);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
|
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
|
|
||||||
// Spawn the golem:
|
// 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, mtIronGolem);
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ + 1) == E_BLOCK_IRON_BLOCK) &&
|
(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ + 1) == E_BLOCK_IRON_BLOCK) &&
|
||||||
@ -76,7 +76,7 @@ public:
|
|||||||
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
|
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
|
|
||||||
// Spawn the golem:
|
// 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, mtIronGolem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "Chunk.h"
|
#include "Chunk.h"
|
||||||
#include "MetaRotator.h"
|
#include "MetaRotator.h"
|
||||||
|
#include "ChunkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "../Items/ItemHandler.h"
|
#include "../Items/ItemHandler.h"
|
||||||
#include "Root.h"
|
#include "Root.h"
|
||||||
|
#include "ChunkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "MetaRotator.h"
|
#include "MetaRotator.h"
|
||||||
|
#include "Bindings/PluginManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,139 @@
|
|||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
|
||||||
#include "ChunkInterface.h"
|
#include "ChunkInterface.h"
|
||||||
|
#include "ChunkMap.h"
|
||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
|
#include "WorldInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BLOCKTYPE cChunkInterface::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||||
|
{
|
||||||
|
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BLOCKTYPE cChunkInterface::GetBlock(const Vector3i & a_Pos)
|
||||||
|
{
|
||||||
|
return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NIBBLETYPE cChunkInterface::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||||
|
{
|
||||||
|
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cChunkInterface::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
|
||||||
|
{
|
||||||
|
return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Sets the block at the specified coords to the specified value.
|
||||||
|
Full processing, incl. updating neighbors, is performed.
|
||||||
|
*/
|
||||||
|
void cChunkInterface::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
||||||
|
{
|
||||||
|
m_ChunkMap->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunkInterface::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
|
||||||
|
{
|
||||||
|
m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunkInterface::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface)
|
||||||
|
{
|
||||||
|
m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Sets the block at the specified coords to the specified value.
|
||||||
|
The replacement doesn't trigger block updates.
|
||||||
|
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
|
||||||
|
*/
|
||||||
|
void cChunkInterface::FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
||||||
|
{
|
||||||
|
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunkInterface::FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
||||||
|
{
|
||||||
|
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunkInterface::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||||
|
{
|
||||||
|
m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback)
|
||||||
|
{
|
||||||
|
return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
|
||||||
|
{
|
||||||
|
return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z)
|
bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z)
|
||||||
{
|
{
|
||||||
@ -10,3 +142,4 @@ bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, int a_X, int
|
|||||||
Handler->OnDestroyed(*this, a_WorldInterface, a_X, a_Y, a_Z);
|
Handler->OnDestroyed(*this, a_WorldInterface, a_X, a_Y, a_Z);
|
||||||
return m_ChunkMap->DigBlock(a_X, a_Y, a_Z);
|
return m_ChunkMap->DigBlock(a_X, a_Y, a_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../ChunkMap.h"
|
|
||||||
#include "../ForEachChunkProvider.h"
|
#include "../ForEachChunkProvider.h"
|
||||||
#include "WorldInterface.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cChunkMap;
|
||||||
|
class cWorldInterface;
|
||||||
|
class cPlayer;
|
||||||
|
|
||||||
class cChunkInterface:
|
class cChunkInterface:
|
||||||
public cForEachChunkProvider
|
public cForEachChunkProvider
|
||||||
@ -16,70 +16,34 @@ public:
|
|||||||
|
|
||||||
cChunkInterface(cChunkMap * a_ChunkMap) : m_ChunkMap(a_ChunkMap) {}
|
cChunkInterface(cChunkMap * a_ChunkMap) : m_ChunkMap(a_ChunkMap) {}
|
||||||
|
|
||||||
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
|
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
{
|
BLOCKTYPE GetBlock(const Vector3i & a_Pos);
|
||||||
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int 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)
|
|
||||||
{
|
|
||||||
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
|
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
|
||||||
{
|
|
||||||
return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets the block at the specified coords to the specified value.
|
/** Sets the block at the specified coords to the specified value.
|
||||||
Full processing, incl. updating neighbors, is performed.
|
Full processing, incl. updating neighbors, is performed.
|
||||||
*/
|
*/
|
||||||
void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||||
{
|
|
||||||
m_ChunkMap->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
|
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData);
|
||||||
{
|
|
||||||
m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface)
|
void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface);
|
||||||
{
|
|
||||||
m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets the block at the specified coords to the specified value.
|
/** Sets the block at the specified coords to the specified value.
|
||||||
The replacement doesn't trigger block updates.
|
The replacement doesn't trigger block updates.
|
||||||
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
|
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
|
||||||
*/
|
*/
|
||||||
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||||
{
|
|
||||||
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||||
{
|
|
||||||
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
{
|
|
||||||
m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override
|
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override;
|
||||||
{
|
|
||||||
return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override
|
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override;
|
||||||
{
|
|
||||||
return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z);
|
bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z);
|
||||||
|
|
||||||
|
91
src/Blocks/GetHandlerCompileTimeTemplate.h
Normal file
91
src/Blocks/GetHandlerCompileTimeTemplate.h
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class cBlockTorchHandler;
|
||||||
|
class cBlockLeverHandler;
|
||||||
|
class cBlockButtonHandler;
|
||||||
|
class cBlockTripwireHookHandler;
|
||||||
|
class cBlockDoorHandler;
|
||||||
|
class cBlockPistonHandler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<BLOCKTYPE T>
|
||||||
|
class GetHandlerCompileTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class GetHandlerCompileTime<E_BLOCK_TORCH>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef cBlockTorchHandler type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class GetHandlerCompileTime<E_BLOCK_LEVER>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef cBlockLeverHandler type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class GetHandlerCompileTime<E_BLOCK_STONE_BUTTON>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef cBlockButtonHandler type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class GetHandlerCompileTime<E_BLOCK_TRIPWIRE_HOOK>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef cBlockTripwireHookHandler type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class GetHandlerCompileTime<E_BLOCK_WOODEN_DOOR>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef cBlockDoorHandler type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class GetHandlerCompileTime<E_BLOCK_PISTON>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef cBlockPistonHandler type;
|
||||||
|
};
|
||||||
|
|
@ -2,14 +2,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BroadcastInterface.h"
|
#include "BroadcastInterface.h"
|
||||||
#include "../Mobs/Monster.h"
|
#include "../Mobs/MonsterTypes.h"
|
||||||
|
|
||||||
class cItems;
|
class cItems;
|
||||||
|
|
||||||
typedef cItemCallback<cBlockEntity> cBlockEntityCallback;
|
typedef cItemCallback<cBlockEntity> cBlockEntityCallback;
|
||||||
|
|
||||||
|
|
||||||
|
class cMonster;
|
||||||
|
class cPlayer;
|
||||||
|
|
||||||
|
|
||||||
class cWorldInterface
|
class cWorldInterface
|
||||||
@ -33,7 +34,7 @@ public:
|
|||||||
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0;
|
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0;
|
||||||
|
|
||||||
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
|
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
|
||||||
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) = 0;
|
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) = 0;
|
||||||
|
|
||||||
/** Spawns an experience orb at the given location with the given reward. It returns the UniqueID of the spawned experience orb. */
|
/** Spawns an experience orb at the given location with the given reward. It returns the UniqueID of the spawned experience orb. */
|
||||||
virtual int SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) = 0;
|
virtual int SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) = 0;
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "BlockInServerPluginInterface.h"
|
#include "BlockInServerPluginInterface.h"
|
||||||
#include "SetChunkData.h"
|
#include "SetChunkData.h"
|
||||||
#include "BoundingBox.h"
|
#include "BoundingBox.h"
|
||||||
|
#include "Blocks/ChunkInterface.h"
|
||||||
|
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
|
|
||||||
@ -91,6 +92,7 @@ cChunk::cChunk(
|
|||||||
m_NeighborZP(a_NeighborZP),
|
m_NeighborZP(a_NeighborZP),
|
||||||
m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()),
|
m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()),
|
||||||
m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()),
|
m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()),
|
||||||
|
m_RedstoneSimulatorData(NULL),
|
||||||
m_AlwaysTicked(0)
|
m_AlwaysTicked(0)
|
||||||
{
|
{
|
||||||
if (a_NeighborXM != NULL)
|
if (a_NeighborXM != NULL)
|
||||||
@ -159,6 +161,8 @@ cChunk::~cChunk()
|
|||||||
m_WaterSimulatorData = NULL;
|
m_WaterSimulatorData = NULL;
|
||||||
delete m_LavaSimulatorData;
|
delete m_LavaSimulatorData;
|
||||||
m_LavaSimulatorData = NULL;
|
m_LavaSimulatorData = NULL;
|
||||||
|
delete m_RedstoneSimulatorData;
|
||||||
|
m_RedstoneSimulatorData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1366,9 +1370,9 @@ void cChunk::CreateBlockEntities(void)
|
|||||||
|
|
||||||
void cChunk::WakeUpSimulators(void)
|
void cChunk::WakeUpSimulators(void)
|
||||||
{
|
{
|
||||||
cSimulator * WaterSimulator = m_World->GetWaterSimulator();
|
cSimulator<cChunk, cWorld> * WaterSimulator = m_World->GetWaterSimulator();
|
||||||
cSimulator * LavaSimulator = m_World->GetLavaSimulator();
|
cSimulator<cChunk, cWorld> * LavaSimulator = m_World->GetLavaSimulator();
|
||||||
cSimulator * RedstoneSimulator = m_World->GetRedstoneSimulator();
|
cSimulator<cChunk, cWorld> * RedstoneSimulator = m_World->GetRedstoneSimulator();
|
||||||
int BaseX = m_PosX * cChunkDef::Width;
|
int BaseX = m_PosX * cChunkDef::Width;
|
||||||
int BaseZ = m_PosZ * cChunkDef::Width;
|
int BaseZ = m_PosZ * cChunkDef::Width;
|
||||||
for (int x = 0; x < Width; x++)
|
for (int x = 0; x < Width; x++)
|
||||||
|
21
src/Chunk.h
21
src/Chunk.h
@ -9,7 +9,9 @@
|
|||||||
#include "Simulator/SandSimulator.h"
|
#include "Simulator/SandSimulator.h"
|
||||||
#include "Simulator/IncrementalRedstoneSimulator.h"
|
#include "Simulator/IncrementalRedstoneSimulator.h"
|
||||||
|
|
||||||
|
#include "Blocks/GetHandlerCompileTimeTemplate.h"
|
||||||
|
|
||||||
|
#include "ChunkMap.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -29,7 +31,10 @@ class MTRand;
|
|||||||
class cPlayer;
|
class cPlayer;
|
||||||
class cChunkMap;
|
class cChunkMap;
|
||||||
class cBeaconEntity;
|
class cBeaconEntity;
|
||||||
|
class cBoundingBox;
|
||||||
class cChestEntity;
|
class cChestEntity;
|
||||||
|
class cCHunkDataCallback;
|
||||||
|
class cCommandBlockEntity;
|
||||||
class cDispenserEntity;
|
class cDispenserEntity;
|
||||||
class cFurnaceEntity;
|
class cFurnaceEntity;
|
||||||
class cNoteEntity;
|
class cNoteEntity;
|
||||||
@ -44,6 +49,7 @@ class cFluidSimulatorData;
|
|||||||
class cMobCensus;
|
class cMobCensus;
|
||||||
class cMobSpawner;
|
class cMobSpawner;
|
||||||
class cRedstonePoweredEntity;
|
class cRedstonePoweredEntity;
|
||||||
|
class cSetChunkData;
|
||||||
|
|
||||||
typedef std::list<cClientHandle *> cClientHandleList;
|
typedef std::list<cClientHandle *> cClientHandleList;
|
||||||
typedef cItemCallback<cEntity> cEntityCallback;
|
typedef cItemCallback<cEntity> cEntityCallback;
|
||||||
@ -414,12 +420,7 @@ public:
|
|||||||
cFluidSimulatorData * GetLavaSimulatorData (void) { return m_LavaSimulatorData; }
|
cFluidSimulatorData * GetLavaSimulatorData (void) { return m_LavaSimulatorData; }
|
||||||
cSandSimulatorChunkData & GetSandSimulatorData (void) { return m_SandSimulatorData; }
|
cSandSimulatorChunkData & GetSandSimulatorData (void) { return m_SandSimulatorData; }
|
||||||
|
|
||||||
cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return &m_RedstoneSimulatorData; }
|
cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return m_RedstoneSimulatorData; }
|
||||||
cRedstoneSimulatorChunkData * GetRedstoneSimulatorQueuedData(void) { return &m_RedstoneSimulatorQueuedData; }
|
|
||||||
cIncrementalRedstoneSimulator::PoweredBlocksList * GetRedstoneSimulatorPoweredBlocksList(void) { return &m_RedstoneSimulatorPoweredBlocksList; }
|
|
||||||
cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; }
|
|
||||||
cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; }
|
|
||||||
cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; }
|
|
||||||
bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; }
|
bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; }
|
||||||
void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; }
|
void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; }
|
||||||
|
|
||||||
@ -504,12 +505,8 @@ private:
|
|||||||
cFluidSimulatorData * m_LavaSimulatorData;
|
cFluidSimulatorData * m_LavaSimulatorData;
|
||||||
cSandSimulatorChunkData m_SandSimulatorData;
|
cSandSimulatorChunkData m_SandSimulatorData;
|
||||||
|
|
||||||
cRedstoneSimulatorChunkData m_RedstoneSimulatorData;
|
cRedstoneSimulatorChunkData * m_RedstoneSimulatorData;
|
||||||
cRedstoneSimulatorChunkData m_RedstoneSimulatorQueuedData;
|
|
||||||
cIncrementalRedstoneSimulator::PoweredBlocksList m_RedstoneSimulatorPoweredBlocksList;
|
|
||||||
cIncrementalRedstoneSimulator::LinkedBlocksList m_RedstoneSimulatorLinkedBlocksList;
|
|
||||||
cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList m_RedstoneSimulatorSimulatedPlayerToggleableList;
|
|
||||||
cIncrementalRedstoneSimulator::RepeatersDelayList m_RedstoneSimulatorRepeatersDelayList;
|
|
||||||
|
|
||||||
/** Indicates if simulate-once blocks should be updated by the redstone simulator */
|
/** Indicates if simulate-once blocks should be updated by the redstone simulator */
|
||||||
bool m_IsRedstoneDirty;
|
bool m_IsRedstoneDirty;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include "MobSpawner.h"
|
#include "MobSpawner.h"
|
||||||
#include "BoundingBox.h"
|
#include "BoundingBox.h"
|
||||||
#include "SetChunkData.h"
|
#include "SetChunkData.h"
|
||||||
|
#include "Blocks/ChunkInterface.h"
|
||||||
#include "Entities/Pickup.h"
|
#include "Entities/Pickup.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "BlockEntities/BlockEntity.h"
|
#include "BlockEntities/BlockEntity.h"
|
||||||
#include "Protocol/ChunkDataSerializer.h"
|
#include "Protocol/ChunkDataSerializer.h"
|
||||||
|
#include "ClientHandle.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ArrowEntity.h"
|
#include "ArrowEntity.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
#include "FastRandom.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "EnderCrystal.h"
|
#include "EnderCrystal.h"
|
||||||
#include "ClientHandle.h"
|
#include "ClientHandle.h"
|
||||||
#include "Player.h"
|
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
|
#include "../World.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Server.h"
|
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../Matrix4.h"
|
#include "../Matrix4.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
@ -334,10 +333,10 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
cMonster * Monster = (cMonster *)this;
|
cMonster * Monster = (cMonster *)this;
|
||||||
switch (Monster->GetMobType())
|
switch (Monster->GetMobType())
|
||||||
{
|
{
|
||||||
case cMonster::mtSkeleton:
|
case mtSkeleton:
|
||||||
case cMonster::mtZombie:
|
case mtZombie:
|
||||||
case cMonster::mtWither:
|
case mtWither:
|
||||||
case cMonster::mtZombiePigman:
|
case mtZombiePigman:
|
||||||
{
|
{
|
||||||
a_TDI.FinalDamage += (int)ceil(2.5 * SmiteLevel);
|
a_TDI.FinalDamage += (int)ceil(2.5 * SmiteLevel);
|
||||||
break;
|
break;
|
||||||
@ -353,9 +352,9 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
cMonster * Monster = (cMonster *)this;
|
cMonster * Monster = (cMonster *)this;
|
||||||
switch (Monster->GetMobType())
|
switch (Monster->GetMobType())
|
||||||
{
|
{
|
||||||
case cMonster::mtSpider:
|
case mtSpider:
|
||||||
case cMonster::mtCaveSpider:
|
case mtCaveSpider:
|
||||||
case cMonster::mtSilverfish:
|
case mtSilverfish:
|
||||||
{
|
{
|
||||||
a_TDI.RawDamage += (int)ceil(2.5 * BaneOfArthropodsLevel);
|
a_TDI.RawDamage += (int)ceil(2.5 * BaneOfArthropodsLevel);
|
||||||
// TODO: Add slowness effect
|
// TODO: Add slowness effect
|
||||||
@ -385,9 +384,9 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
|||||||
cMonster * Monster = (cMonster *)this;
|
cMonster * Monster = (cMonster *)this;
|
||||||
switch (Monster->GetMobType())
|
switch (Monster->GetMobType())
|
||||||
{
|
{
|
||||||
case cMonster::mtGhast:
|
case mtGhast:
|
||||||
case cMonster::mtZombiePigman:
|
case mtZombiePigman:
|
||||||
case cMonster::mtMagmaCube:
|
case mtMagmaCube:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
@ -436,8 +436,8 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
|
|||||||
// Doesn't effect undead mobs, spiders
|
// Doesn't effect undead mobs, spiders
|
||||||
if (
|
if (
|
||||||
Target.IsUndead() ||
|
Target.IsUndead() ||
|
||||||
(Target.GetMobType() == cMonster::mtSpider) ||
|
(Target.GetMobType() == mtSpider) ||
|
||||||
(Target.GetMobType() == cMonster::mtCaveSpider)
|
(Target.GetMobType() == mtCaveSpider)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -2061,8 +2061,8 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
|
|||||||
cMonster * Monster = (cMonster *)m_AttachedTo;
|
cMonster * Monster = (cMonster *)m_AttachedTo;
|
||||||
switch (Monster->GetMobType())
|
switch (Monster->GetMobType())
|
||||||
{
|
{
|
||||||
case cMonster::mtPig: m_Stats.AddValue(statDistPig, Value); break;
|
case mtPig: m_Stats.AddValue(statDistPig, Value); break;
|
||||||
case cMonster::mtHorse: m_Stats.AddValue(statDistHorse, Value); break;
|
case mtHorse: m_Stats.AddValue(statDistHorse, Value); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -48,13 +48,13 @@ void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
|
|||||||
{
|
{
|
||||||
if (m_World->GetTickRandomNumber(7) == 1)
|
if (m_World->GetTickRandomNumber(7) == 1)
|
||||||
{
|
{
|
||||||
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
|
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
|
||||||
}
|
}
|
||||||
else if (m_World->GetTickRandomNumber(32) == 1)
|
else if (m_World->GetTickRandomNumber(32) == 1)
|
||||||
{
|
{
|
||||||
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
|
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
|
||||||
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
|
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
|
||||||
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
|
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
|
||||||
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
|
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
|
|||||||
int TotalDamage = 0;
|
int TotalDamage = 0;
|
||||||
if (a_EntityHit.IsMob())
|
if (a_EntityHit.IsMob())
|
||||||
{
|
{
|
||||||
cMonster::eType MobType = ((cMonster &) a_EntityHit).GetMobType();
|
eMonsterType MobType = ((cMonster &) a_EntityHit).GetMobType();
|
||||||
if (MobType == cMonster::mtBlaze)
|
if (MobType == mtBlaze)
|
||||||
{
|
{
|
||||||
TotalDamage = 3;
|
TotalDamage = 3;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "../Simulator/FluidSimulator.h" // for cFluidSimulator::CanWashAway()
|
#include "../Simulator/FluidSimulator.h" // for cFluidSimulator::CanWashAway()
|
||||||
#include "../Simulator/FireSimulator.h"
|
#include "../Simulator/FireSimulator.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
|
#include "inifile/iniFile.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,6 +261,27 @@ void inline LOGERROR(const char* a_Format, ...)
|
|||||||
vprintf(a_Format, argList);
|
vprintf(a_Format, argList);
|
||||||
va_end(argList);
|
va_end(argList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void inline LOGWARNING(const char* a_Format, ...) FORMATSTRING(1, 2);
|
||||||
|
|
||||||
|
void inline LOGWARNING(const char* a_Format, ...)
|
||||||
|
{
|
||||||
|
va_list argList;
|
||||||
|
va_start(argList, a_Format);
|
||||||
|
vprintf(a_Format, argList);
|
||||||
|
va_end(argList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void inline LOGD(const char* a_Format, ...) FORMATSTRING(1, 2);
|
||||||
|
|
||||||
|
void inline LOGD(const char* a_Format, ...)
|
||||||
|
{
|
||||||
|
va_list argList;
|
||||||
|
va_start(argList, a_Format);
|
||||||
|
vprintf(a_Format, argList);
|
||||||
|
va_end(argList);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "../Blocks/BlockHandler.h"
|
#include "../Blocks/BlockHandler.h"
|
||||||
#include "../LineBlockTracer.h"
|
#include "../LineBlockTracer.h"
|
||||||
#include "../BlockInServerPluginInterface.h"
|
#include "../BlockInServerPluginInterface.h"
|
||||||
|
#include "../Blocks/ChunkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ public:
|
|||||||
a_BlockY--;
|
a_BlockY--;
|
||||||
}
|
}
|
||||||
|
|
||||||
cMonster::eType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
|
eMonsterType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
|
||||||
if (
|
if (
|
||||||
(MonsterType != cMonster::mtInvalidType) && // Valid monster type
|
(MonsterType != mtInvalidType) && // Valid monster type
|
||||||
(a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, MonsterType) >= 0)) // Spawning succeeded
|
(a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, MonsterType) >= 0)) // Spawning succeeded
|
||||||
{
|
{
|
||||||
if (!a_Player->IsGameModeCreative())
|
if (!a_Player->IsGameModeCreative())
|
||||||
@ -52,36 +52,36 @@ public:
|
|||||||
|
|
||||||
/** Converts the Spawn egg item damage to the monster type to spawn.
|
/** Converts the Spawn egg item damage to the monster type to spawn.
|
||||||
Returns mtInvalidType for invalid damage values. */
|
Returns mtInvalidType for invalid damage values. */
|
||||||
static cMonster::eType ItemDamageToMonsterType(short a_ItemDamage)
|
static eMonsterType ItemDamageToMonsterType(short a_ItemDamage)
|
||||||
{
|
{
|
||||||
switch (a_ItemDamage)
|
switch (a_ItemDamage)
|
||||||
{
|
{
|
||||||
case E_META_SPAWN_EGG_BAT: return cMonster::mtBat;
|
case E_META_SPAWN_EGG_BAT: return mtBat;
|
||||||
case E_META_SPAWN_EGG_BLAZE: return cMonster::mtBlaze;
|
case E_META_SPAWN_EGG_BLAZE: return mtBlaze;
|
||||||
case E_META_SPAWN_EGG_CAVE_SPIDER: return cMonster::mtCaveSpider;
|
case E_META_SPAWN_EGG_CAVE_SPIDER: return mtCaveSpider;
|
||||||
case E_META_SPAWN_EGG_CHICKEN: return cMonster::mtChicken;
|
case E_META_SPAWN_EGG_CHICKEN: return mtChicken;
|
||||||
case E_META_SPAWN_EGG_COW: return cMonster::mtCow;
|
case E_META_SPAWN_EGG_COW: return mtCow;
|
||||||
case E_META_SPAWN_EGG_CREEPER: return cMonster::mtCreeper;
|
case E_META_SPAWN_EGG_CREEPER: return mtCreeper;
|
||||||
case E_META_SPAWN_EGG_ENDERMAN: return cMonster::mtEnderman;
|
case E_META_SPAWN_EGG_ENDERMAN: return mtEnderman;
|
||||||
case E_META_SPAWN_EGG_GHAST: return cMonster::mtGhast;
|
case E_META_SPAWN_EGG_GHAST: return mtGhast;
|
||||||
case E_META_SPAWN_EGG_HORSE: return cMonster::mtHorse;
|
case E_META_SPAWN_EGG_HORSE: return mtHorse;
|
||||||
case E_META_SPAWN_EGG_MAGMA_CUBE: return cMonster::mtMagmaCube;
|
case E_META_SPAWN_EGG_MAGMA_CUBE: return mtMagmaCube;
|
||||||
case E_META_SPAWN_EGG_MOOSHROOM: return cMonster::mtMooshroom;
|
case E_META_SPAWN_EGG_MOOSHROOM: return mtMooshroom;
|
||||||
case E_META_SPAWN_EGG_OCELOT: return cMonster::mtOcelot;
|
case E_META_SPAWN_EGG_OCELOT: return mtOcelot;
|
||||||
case E_META_SPAWN_EGG_PIG: return cMonster::mtPig;
|
case E_META_SPAWN_EGG_PIG: return mtPig;
|
||||||
case E_META_SPAWN_EGG_SHEEP: return cMonster::mtSheep;
|
case E_META_SPAWN_EGG_SHEEP: return mtSheep;
|
||||||
case E_META_SPAWN_EGG_SILVERFISH: return cMonster::mtSilverfish;
|
case E_META_SPAWN_EGG_SILVERFISH: return mtSilverfish;
|
||||||
case E_META_SPAWN_EGG_SKELETON: return cMonster::mtSkeleton;
|
case E_META_SPAWN_EGG_SKELETON: return mtSkeleton;
|
||||||
case E_META_SPAWN_EGG_SLIME: return cMonster::mtSlime;
|
case E_META_SPAWN_EGG_SLIME: return mtSlime;
|
||||||
case E_META_SPAWN_EGG_SPIDER: return cMonster::mtSpider;
|
case E_META_SPAWN_EGG_SPIDER: return mtSpider;
|
||||||
case E_META_SPAWN_EGG_SQUID: return cMonster::mtSquid;
|
case E_META_SPAWN_EGG_SQUID: return mtSquid;
|
||||||
case E_META_SPAWN_EGG_VILLAGER: return cMonster::mtVillager;
|
case E_META_SPAWN_EGG_VILLAGER: return mtVillager;
|
||||||
case E_META_SPAWN_EGG_WITCH: return cMonster::mtWitch;
|
case E_META_SPAWN_EGG_WITCH: return mtWitch;
|
||||||
case E_META_SPAWN_EGG_WOLF: return cMonster::mtWolf;
|
case E_META_SPAWN_EGG_WOLF: return mtWolf;
|
||||||
case E_META_SPAWN_EGG_ZOMBIE: return cMonster::mtZombie;
|
case E_META_SPAWN_EGG_ZOMBIE: return mtZombie;
|
||||||
case E_META_SPAWN_EGG_ZOMBIE_PIGMAN: return cMonster::mtZombiePigman;
|
case E_META_SPAWN_EGG_ZOMBIE_PIGMAN: return mtZombiePigman;
|
||||||
}
|
}
|
||||||
return cMonster::mtInvalidType;
|
return mtInvalidType;
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set<cMonster::eType>& a_AllowedTypes) :
|
cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set<eMonsterType>& a_AllowedTypes) :
|
||||||
m_MonsterFamily(a_MonsterFamily),
|
m_MonsterFamily(a_MonsterFamily),
|
||||||
m_NewPack(true),
|
m_NewPack(true),
|
||||||
m_MobType(cMonster::mtInvalidType)
|
m_MobType(mtInvalidType)
|
||||||
{
|
{
|
||||||
for (std::set<cMonster::eType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); ++itr)
|
for (std::set<eMonsterType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (cMonster::FamilyFromType(*itr) == a_MonsterFamily)
|
if (cMonster::FamilyFromType(*itr) == a_MonsterFamily)
|
||||||
{
|
{
|
||||||
@ -44,9 +44,9 @@ bool cMobSpawner::CheckPackCenter(BLOCKTYPE a_BlockType)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cMobSpawner::addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType>& toAddIn)
|
void cMobSpawner::addIfAllowed(eMonsterType toAdd, std::set<eMonsterType>& toAddIn)
|
||||||
{
|
{
|
||||||
std::set<cMonster::eType>::iterator itr = m_AllowedTypes.find(toAdd);
|
std::set<eMonsterType>::iterator itr = m_AllowedTypes.find(toAdd);
|
||||||
if (itr != m_AllowedTypes.end())
|
if (itr != m_AllowedTypes.end())
|
||||||
{
|
{
|
||||||
toAddIn.insert(toAdd);
|
toAddIn.insert(toAdd);
|
||||||
@ -57,49 +57,49 @@ void cMobSpawner::addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType>&
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
||||||
{
|
{
|
||||||
std::set<cMonster::eType> allowedMobs;
|
std::set<eMonsterType> allowedMobs;
|
||||||
|
|
||||||
if (a_Biome == biMushroomIsland || a_Biome == biMushroomShore)
|
if (a_Biome == biMushroomIsland || a_Biome == biMushroomShore)
|
||||||
{
|
{
|
||||||
addIfAllowed(cMonster::mtMooshroom, allowedMobs);
|
addIfAllowed(mtMooshroom, allowedMobs);
|
||||||
}
|
}
|
||||||
else if (a_Biome == biNether)
|
else if (a_Biome == biNether)
|
||||||
{
|
{
|
||||||
addIfAllowed(cMonster::mtGhast, allowedMobs);
|
addIfAllowed(mtGhast, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtZombiePigman, allowedMobs);
|
addIfAllowed(mtZombiePigman, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtMagmaCube, allowedMobs);
|
addIfAllowed(mtMagmaCube, allowedMobs);
|
||||||
}
|
}
|
||||||
else if (a_Biome == biEnd)
|
else if (a_Biome == biEnd)
|
||||||
{
|
{
|
||||||
addIfAllowed(cMonster::mtEnderman, allowedMobs);
|
addIfAllowed(mtEnderman, allowedMobs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addIfAllowed(cMonster::mtBat, allowedMobs);
|
addIfAllowed(mtBat, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtSpider, allowedMobs);
|
addIfAllowed(mtSpider, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtZombie, allowedMobs);
|
addIfAllowed(mtZombie, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtSkeleton, allowedMobs);
|
addIfAllowed(mtSkeleton, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtCreeper, allowedMobs);
|
addIfAllowed(mtCreeper, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtSquid, allowedMobs);
|
addIfAllowed(mtSquid, allowedMobs);
|
||||||
|
|
||||||
if (a_Biome != biDesert && a_Biome != biBeach && a_Biome != biOcean)
|
if (a_Biome != biDesert && a_Biome != biBeach && a_Biome != biOcean)
|
||||||
{
|
{
|
||||||
addIfAllowed(cMonster::mtSheep, allowedMobs);
|
addIfAllowed(mtSheep, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtPig, allowedMobs);
|
addIfAllowed(mtPig, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtCow, allowedMobs);
|
addIfAllowed(mtCow, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtChicken, allowedMobs);
|
addIfAllowed(mtChicken, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtEnderman, allowedMobs);
|
addIfAllowed(mtEnderman, allowedMobs);
|
||||||
addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule
|
addIfAllowed(mtSlime, allowedMobs); // MG TODO : much more complicated rule
|
||||||
|
|
||||||
if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills)
|
if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills)
|
||||||
{
|
{
|
||||||
addIfAllowed(cMonster::mtWolf, allowedMobs);
|
addIfAllowed(mtWolf, allowedMobs);
|
||||||
}
|
}
|
||||||
else if (a_Biome == biJungle || a_Biome == biJungleHills)
|
else if (a_Biome == biJungle || a_Biome == biJungleHills)
|
||||||
{
|
{
|
||||||
addIfAllowed(cMonster::mtOcelot, allowedMobs);
|
addIfAllowed(mtOcelot, allowedMobs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
|||||||
size_t allowedMobsSize = allowedMobs.size();
|
size_t allowedMobsSize = allowedMobs.size();
|
||||||
if (allowedMobsSize > 0)
|
if (allowedMobsSize > 0)
|
||||||
{
|
{
|
||||||
std::set<cMonster::eType>::iterator itr = allowedMobs.begin();
|
std::set<eMonsterType>::iterator itr = allowedMobs.begin();
|
||||||
int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome);
|
int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome);
|
||||||
|
|
||||||
for (int i = 0; i < iRandom; i++)
|
for (int i = 0; i < iRandom; i++)
|
||||||
@ -117,14 +117,14 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
|||||||
|
|
||||||
return *itr;
|
return *itr;
|
||||||
}
|
}
|
||||||
return cMonster::mtInvalidType;
|
return mtInvalidType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome)
|
bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, eMonsterType a_MobType, EMCSBiome a_Biome)
|
||||||
{
|
{
|
||||||
BLOCKTYPE TargetBlock = E_BLOCK_AIR;
|
BLOCKTYPE TargetBlock = E_BLOCK_AIR;
|
||||||
if (m_AllowedTypes.find(a_MobType) != m_AllowedTypes.end() && a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock))
|
if (m_AllowedTypes.find(a_MobType) != m_AllowedTypes.end() && a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock))
|
||||||
@ -143,21 +143,21 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
|
|
||||||
switch (a_MobType)
|
switch (a_MobType)
|
||||||
{
|
{
|
||||||
case cMonster::mtSquid:
|
case mtSquid:
|
||||||
{
|
{
|
||||||
return IsBlockWater(TargetBlock) && (a_RelY >= 45) && (a_RelY <= 62);
|
return IsBlockWater(TargetBlock) && (a_RelY >= 45) && (a_RelY <= 62);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtBat:
|
case mtBat:
|
||||||
{
|
{
|
||||||
return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4) && (TargetBlock == E_BLOCK_AIR) && !cBlockInfo::IsTransparent(BlockAbove);
|
return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4) && (TargetBlock == E_BLOCK_AIR) && !cBlockInfo::IsTransparent(BlockAbove);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtChicken:
|
case mtChicken:
|
||||||
case cMonster::mtCow:
|
case mtCow:
|
||||||
case cMonster::mtPig:
|
case mtPig:
|
||||||
case cMonster::mtHorse:
|
case mtHorse:
|
||||||
case cMonster::mtSheep:
|
case mtSheep:
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
(TargetBlock == E_BLOCK_AIR) &&
|
(TargetBlock == E_BLOCK_AIR) &&
|
||||||
@ -168,7 +168,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtOcelot:
|
case mtOcelot:
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
(TargetBlock == E_BLOCK_AIR) &&
|
(TargetBlock == E_BLOCK_AIR) &&
|
||||||
@ -181,7 +181,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtEnderman:
|
case mtEnderman:
|
||||||
{
|
{
|
||||||
if (a_RelY < 250)
|
if (a_RelY < 250)
|
||||||
{
|
{
|
||||||
@ -202,7 +202,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtSpider:
|
case mtSpider:
|
||||||
{
|
{
|
||||||
bool CanSpawn = true;
|
bool CanSpawn = true;
|
||||||
bool HasFloor = false;
|
bool HasFloor = false;
|
||||||
@ -228,9 +228,9 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
return CanSpawn && HasFloor && (SkyLight <= 7) && (BlockLight <= 7);
|
return CanSpawn && HasFloor && (SkyLight <= 7) && (BlockLight <= 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtCreeper:
|
case mtCreeper:
|
||||||
case cMonster::mtSkeleton:
|
case mtSkeleton:
|
||||||
case cMonster::mtZombie:
|
case mtZombie:
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
(TargetBlock == E_BLOCK_AIR) &&
|
(TargetBlock == E_BLOCK_AIR) &&
|
||||||
@ -242,8 +242,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtMagmaCube:
|
case mtMagmaCube:
|
||||||
case cMonster::mtSlime:
|
case mtSlime:
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
(TargetBlock == E_BLOCK_AIR) &&
|
(TargetBlock == E_BLOCK_AIR) &&
|
||||||
@ -255,8 +255,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtGhast:
|
case mtGhast:
|
||||||
case cMonster::mtZombiePigman:
|
case mtZombiePigman:
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
(TargetBlock == E_BLOCK_AIR) &&
|
(TargetBlock == E_BLOCK_AIR) &&
|
||||||
@ -266,7 +266,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtWolf:
|
case mtWolf:
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
(TargetBlock == E_BLOCK_GRASS) &&
|
(TargetBlock == E_BLOCK_GRASS) &&
|
||||||
@ -305,15 +305,15 @@ cMonster* cMobSpawner::TryToSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY,
|
|||||||
if (m_NewPack)
|
if (m_NewPack)
|
||||||
{
|
{
|
||||||
m_MobType = ChooseMobType(a_Biome);
|
m_MobType = ChooseMobType(a_Biome);
|
||||||
if (m_MobType == cMonster::mtInvalidType)
|
if (m_MobType == mtInvalidType)
|
||||||
{
|
{
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
if (m_MobType == cMonster::mtWolf)
|
if (m_MobType == mtWolf)
|
||||||
{
|
{
|
||||||
a_MaxPackSize = 8;
|
a_MaxPackSize = 8;
|
||||||
}
|
}
|
||||||
else if (m_MobType == cMonster::mtGhast)
|
else if (m_MobType == mtGhast)
|
||||||
{
|
{
|
||||||
a_MaxPackSize = 1;
|
a_MaxPackSize = 1;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public :
|
|||||||
// a_AllowedTypes is the set of types allowed for mobs it will spawn. Empty set
|
// a_AllowedTypes is the set of types allowed for mobs it will spawn. Empty set
|
||||||
// would result in no spawn at all
|
// would result in no spawn at all
|
||||||
// Allowed mobs thah are not of the right Family will not be include (no warning)
|
// Allowed mobs thah are not of the right Family will not be include (no warning)
|
||||||
cMobSpawner(cMonster::eFamily MobFamily, const std::set<cMonster::eType> & a_AllowedTypes);
|
cMobSpawner(cMonster::eFamily MobFamily, const std::set<eMonsterType> & a_AllowedTypes);
|
||||||
|
|
||||||
/// Check if specified block can be a Pack center for this spawner
|
/// Check if specified block can be a Pack center for this spawner
|
||||||
bool CheckPackCenter(BLOCKTYPE a_BlockType);
|
bool CheckPackCenter(BLOCKTYPE a_BlockType);
|
||||||
@ -53,20 +53,20 @@ public :
|
|||||||
|
|
||||||
protected :
|
protected :
|
||||||
// return true if specified type of mob can spawn on specified block
|
// return true if specified type of mob can spawn on specified block
|
||||||
bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome);
|
bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, eMonsterType a_MobType, EMCSBiome a_Biome);
|
||||||
|
|
||||||
// return a random type that can spawn on specified biome.
|
// return a random type that can spawn on specified biome.
|
||||||
// returns E_ENTITY_TYPE_DONOTUSE if none is possible
|
// returns E_ENTITY_TYPE_DONOTUSE if none is possible
|
||||||
cMonster::eType ChooseMobType(EMCSBiome a_Biome);
|
eMonsterType ChooseMobType(EMCSBiome a_Biome);
|
||||||
|
|
||||||
// add toAdd inside toAddIn, if toAdd is in m_AllowedTypes
|
// add toAdd inside toAddIn, if toAdd is in m_AllowedTypes
|
||||||
void addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType> & toAddIn);
|
void addIfAllowed(eMonsterType toAdd, std::set<eMonsterType> & toAddIn);
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
cMonster::eFamily m_MonsterFamily;
|
cMonster::eFamily m_MonsterFamily;
|
||||||
std::set<cMonster::eType> m_AllowedTypes;
|
std::set<eMonsterType> m_AllowedTypes;
|
||||||
bool m_NewPack;
|
bool m_NewPack;
|
||||||
cMonster::eType m_MobType;
|
eMonsterType m_MobType;
|
||||||
std::set<cMonster*> m_Spawned;
|
std::set<cMonster*> m_Spawned;
|
||||||
cFastRandom m_Random;
|
cFastRandom m_Random;
|
||||||
} ;
|
} ;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
|
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
|
||||||
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
|
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
|
||||||
{
|
{
|
||||||
m_EMPersonality = AGGRESSIVE;
|
m_EMPersonality = AGGRESSIVE;
|
||||||
|
@ -14,7 +14,7 @@ class cAggressiveMonster :
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
||||||
|
|
||||||
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void InStateChasing(float a_Dt) override;
|
virtual void InStateChasing(float a_Dt) override;
|
||||||
|
@ -24,38 +24,38 @@ The strings need to be lowercase (for more efficient comparisons in StringToMobT
|
|||||||
*/
|
*/
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
cMonster::eType m_Type;
|
eMonsterType m_Type;
|
||||||
const char * m_lcName;
|
const char * m_lcName;
|
||||||
} g_MobTypeNames[] =
|
} g_MobTypeNames[] =
|
||||||
{
|
{
|
||||||
{cMonster::mtBat, "bat"},
|
{mtBat, "bat"},
|
||||||
{cMonster::mtBlaze, "blaze"},
|
{mtBlaze, "blaze"},
|
||||||
{cMonster::mtCaveSpider, "cavespider"},
|
{mtCaveSpider, "cavespider"},
|
||||||
{cMonster::mtChicken, "chicken"},
|
{mtChicken, "chicken"},
|
||||||
{cMonster::mtCow, "cow"},
|
{mtCow, "cow"},
|
||||||
{cMonster::mtCreeper, "creeper"},
|
{mtCreeper, "creeper"},
|
||||||
{cMonster::mtEnderman, "enderman"},
|
{mtEnderman, "enderman"},
|
||||||
{cMonster::mtEnderDragon, "enderdragon"},
|
{mtEnderDragon, "enderdragon"},
|
||||||
{cMonster::mtGhast, "ghast"},
|
{mtGhast, "ghast"},
|
||||||
{cMonster::mtHorse, "horse"},
|
{mtHorse, "horse"},
|
||||||
{cMonster::mtIronGolem, "irongolem"},
|
{mtIronGolem, "irongolem"},
|
||||||
{cMonster::mtMagmaCube, "magmacube"},
|
{mtMagmaCube, "magmacube"},
|
||||||
{cMonster::mtMooshroom, "mooshroom"},
|
{mtMooshroom, "mooshroom"},
|
||||||
{cMonster::mtOcelot, "ocelot"},
|
{mtOcelot, "ocelot"},
|
||||||
{cMonster::mtPig, "pig"},
|
{mtPig, "pig"},
|
||||||
{cMonster::mtSheep, "sheep"},
|
{mtSheep, "sheep"},
|
||||||
{cMonster::mtSilverfish, "silverfish"},
|
{mtSilverfish, "silverfish"},
|
||||||
{cMonster::mtSkeleton, "skeleton"},
|
{mtSkeleton, "skeleton"},
|
||||||
{cMonster::mtSlime, "slime"},
|
{mtSlime, "slime"},
|
||||||
{cMonster::mtSnowGolem, "snowgolem"},
|
{mtSnowGolem, "snowgolem"},
|
||||||
{cMonster::mtSpider, "spider"},
|
{mtSpider, "spider"},
|
||||||
{cMonster::mtSquid, "squid"},
|
{mtSquid, "squid"},
|
||||||
{cMonster::mtVillager, "villager"},
|
{mtVillager, "villager"},
|
||||||
{cMonster::mtWitch, "witch"},
|
{mtWitch, "witch"},
|
||||||
{cMonster::mtWither, "wither"},
|
{mtWither, "wither"},
|
||||||
{cMonster::mtWolf, "wolf"},
|
{mtWolf, "wolf"},
|
||||||
{cMonster::mtZombie, "zombie"},
|
{mtZombie, "zombie"},
|
||||||
{cMonster::mtZombiePigman, "zombiepigman"},
|
{mtZombiePigman, "zombiepigman"},
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ static const struct
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// cMonster:
|
// cMonster:
|
||||||
|
|
||||||
cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
|
cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
|
||||||
: super(etMonster, a_Width, a_Height)
|
: super(etMonster, a_Width, a_Height)
|
||||||
, m_EMState(IDLE)
|
, m_EMState(IDLE)
|
||||||
, m_EMPersonality(AGGRESSIVE)
|
, m_EMPersonality(AGGRESSIVE)
|
||||||
@ -491,50 +491,50 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
|
|||||||
switch (m_MobType)
|
switch (m_MobType)
|
||||||
{
|
{
|
||||||
// Animals
|
// Animals
|
||||||
case cMonster::mtChicken:
|
case mtChicken:
|
||||||
case cMonster::mtCow:
|
case mtCow:
|
||||||
case cMonster::mtHorse:
|
case mtHorse:
|
||||||
case cMonster::mtPig:
|
case mtPig:
|
||||||
case cMonster::mtSheep:
|
case mtSheep:
|
||||||
case cMonster::mtSquid:
|
case mtSquid:
|
||||||
case cMonster::mtMooshroom:
|
case mtMooshroom:
|
||||||
case cMonster::mtOcelot:
|
case mtOcelot:
|
||||||
case cMonster::mtWolf:
|
case mtWolf:
|
||||||
{
|
{
|
||||||
Reward = m_World->GetTickRandomNumber(2) + 1;
|
Reward = m_World->GetTickRandomNumber(2) + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monsters
|
// Monsters
|
||||||
case cMonster::mtCaveSpider:
|
case mtCaveSpider:
|
||||||
case cMonster::mtCreeper:
|
case mtCreeper:
|
||||||
case cMonster::mtEnderman:
|
case mtEnderman:
|
||||||
case cMonster::mtGhast:
|
case mtGhast:
|
||||||
case cMonster::mtSilverfish:
|
case mtSilverfish:
|
||||||
case cMonster::mtSkeleton:
|
case mtSkeleton:
|
||||||
case cMonster::mtSpider:
|
case mtSpider:
|
||||||
case cMonster::mtWitch:
|
case mtWitch:
|
||||||
case cMonster::mtZombie:
|
case mtZombie:
|
||||||
case cMonster::mtZombiePigman:
|
case mtZombiePigman:
|
||||||
case cMonster::mtSlime:
|
case mtSlime:
|
||||||
case cMonster::mtMagmaCube:
|
case mtMagmaCube:
|
||||||
{
|
{
|
||||||
Reward = 6 + (m_World->GetTickRandomNumber(2));
|
Reward = 6 + (m_World->GetTickRandomNumber(2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtBlaze:
|
case mtBlaze:
|
||||||
{
|
{
|
||||||
Reward = 10;
|
Reward = 10;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bosses
|
// Bosses
|
||||||
case cMonster::mtEnderDragon:
|
case mtEnderDragon:
|
||||||
{
|
{
|
||||||
Reward = 12000;
|
Reward = 12000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtWither:
|
case mtWither:
|
||||||
{
|
{
|
||||||
Reward = 50;
|
Reward = 50;
|
||||||
break;
|
break;
|
||||||
@ -755,7 +755,7 @@ bool cMonster::IsUndead(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
AString cMonster::MobTypeToString(cMonster::eType a_MobType)
|
AString cMonster::MobTypeToString(eMonsterType a_MobType)
|
||||||
{
|
{
|
||||||
// Mob types aren't sorted, so we need to search linearly:
|
// Mob types aren't sorted, so we need to search linearly:
|
||||||
for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++)
|
for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++)
|
||||||
@ -774,7 +774,7 @@ AString cMonster::MobTypeToString(cMonster::eType a_MobType)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cMonster::eType cMonster::StringToMobType(const AString & a_Name)
|
eMonsterType cMonster::StringToMobType(const AString & a_Name)
|
||||||
{
|
{
|
||||||
AString lcName = StrToLower(a_Name);
|
AString lcName = StrToLower(a_Name);
|
||||||
|
|
||||||
@ -815,7 +815,7 @@ cMonster::eType cMonster::StringToMobType(const AString & a_Name)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cMonster::eFamily cMonster::FamilyFromType(eType a_Type)
|
cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type)
|
||||||
{
|
{
|
||||||
// Passive-agressive mobs are counted in mob spawning code as passive
|
// Passive-agressive mobs are counted in mob spawning code as passive
|
||||||
|
|
||||||
@ -880,7 +880,7 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
|
cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
|
||||||
{
|
{
|
||||||
cFastRandom Random;
|
cFastRandom Random;
|
||||||
cMonster * toReturn = NULL;
|
cMonster * toReturn = NULL;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "../BlockID.h"
|
#include "../BlockID.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../Enchantments.h"
|
#include "../Enchantments.h"
|
||||||
|
#include "MonsterTypes.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -23,41 +24,9 @@ class cMonster :
|
|||||||
{
|
{
|
||||||
typedef cPawn super;
|
typedef cPawn super;
|
||||||
public:
|
public:
|
||||||
/// This identifies individual monster type, as well as their network type-ID
|
|
||||||
enum eType
|
//Depreciated
|
||||||
{
|
typedef eMonsterType eType;
|
||||||
mtInvalidType = -1,
|
|
||||||
|
|
||||||
mtBat = E_META_SPAWN_EGG_BAT,
|
|
||||||
mtBlaze = E_META_SPAWN_EGG_BLAZE,
|
|
||||||
mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER,
|
|
||||||
mtChicken = E_META_SPAWN_EGG_CHICKEN,
|
|
||||||
mtCow = E_META_SPAWN_EGG_COW,
|
|
||||||
mtCreeper = E_META_SPAWN_EGG_CREEPER,
|
|
||||||
mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON,
|
|
||||||
mtEnderman = E_META_SPAWN_EGG_ENDERMAN,
|
|
||||||
mtGhast = E_META_SPAWN_EGG_GHAST,
|
|
||||||
mtGiant = E_META_SPAWN_EGG_GIANT,
|
|
||||||
mtHorse = E_META_SPAWN_EGG_HORSE,
|
|
||||||
mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM,
|
|
||||||
mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE,
|
|
||||||
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM,
|
|
||||||
mtOcelot = E_META_SPAWN_EGG_OCELOT,
|
|
||||||
mtPig = E_META_SPAWN_EGG_PIG,
|
|
||||||
mtSheep = E_META_SPAWN_EGG_SHEEP,
|
|
||||||
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH,
|
|
||||||
mtSkeleton = E_META_SPAWN_EGG_SKELETON,
|
|
||||||
mtSlime = E_META_SPAWN_EGG_SLIME,
|
|
||||||
mtSnowGolem = E_META_SPAWN_EGG_SNOW_GOLEM,
|
|
||||||
mtSpider = E_META_SPAWN_EGG_SPIDER,
|
|
||||||
mtSquid = E_META_SPAWN_EGG_SQUID,
|
|
||||||
mtVillager = E_META_SPAWN_EGG_VILLAGER,
|
|
||||||
mtWitch = E_META_SPAWN_EGG_WITCH,
|
|
||||||
mtWither = E_META_SPAWN_EGG_WITHER,
|
|
||||||
mtWolf = E_META_SPAWN_EGG_WOLF,
|
|
||||||
mtZombie = E_META_SPAWN_EGG_ZOMBIE,
|
|
||||||
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
|
|
||||||
} ;
|
|
||||||
|
|
||||||
enum eFamily
|
enum eFamily
|
||||||
{
|
{
|
||||||
@ -80,7 +49,7 @@ public:
|
|||||||
a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22))
|
a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22))
|
||||||
a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively
|
a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively
|
||||||
*/
|
*/
|
||||||
cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
||||||
|
|
||||||
CLASS_PROTODEF(cMonster)
|
CLASS_PROTODEF(cMonster)
|
||||||
|
|
||||||
@ -98,7 +67,7 @@ public:
|
|||||||
virtual bool ReachedDestination(void);
|
virtual bool ReachedDestination(void);
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
eType GetMobType(void) const {return m_MobType; }
|
eMonsterType GetMobType(void) const {return m_MobType; }
|
||||||
eFamily GetMobFamily(void) const;
|
eFamily GetMobFamily(void) const;
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
@ -168,13 +137,13 @@ public:
|
|||||||
void SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible);
|
void SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible);
|
||||||
|
|
||||||
/// Translates MobType enum to a string, empty string if unknown
|
/// Translates MobType enum to a string, empty string if unknown
|
||||||
static AString MobTypeToString(eType a_MobType);
|
static AString MobTypeToString(eMonsterType a_MobType);
|
||||||
|
|
||||||
/// Translates MobType string to the enum, mtInvalidType if not recognized
|
/// Translates MobType string to the enum, mtInvalidType if not recognized
|
||||||
static eType StringToMobType(const AString & a_MobTypeName);
|
static eMonsterType StringToMobType(const AString & a_MobTypeName);
|
||||||
|
|
||||||
/// Returns the mob family based on the type
|
/// Returns the mob family based on the type
|
||||||
static eFamily FamilyFromType(eType a_MobType);
|
static eFamily FamilyFromType(eMonsterType a_MobType);
|
||||||
|
|
||||||
/// Returns the spawn delay (number of game ticks between spawn attempts) for the given mob family
|
/// Returns the spawn delay (number of game ticks between spawn attempts) for the given mob family
|
||||||
static int GetSpawnDelay(cMonster::eFamily a_MobFamily);
|
static int GetSpawnDelay(cMonster::eFamily a_MobFamily);
|
||||||
@ -185,7 +154,7 @@ public:
|
|||||||
a_MobType is the type of the mob to be created
|
a_MobType is the type of the mob to be created
|
||||||
Asserts and returns null if mob type is not specified
|
Asserts and returns null if mob type is not specified
|
||||||
*/
|
*/
|
||||||
static cMonster * NewMonsterFromType(eType a_MobType);
|
static cMonster * NewMonsterFromType(eMonsterType a_MobType);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -249,7 +218,7 @@ protected:
|
|||||||
float m_IdleInterval;
|
float m_IdleInterval;
|
||||||
float m_DestroyTimer;
|
float m_DestroyTimer;
|
||||||
|
|
||||||
eType m_MobType;
|
eMonsterType m_MobType;
|
||||||
AString m_CustomName;
|
AString m_CustomName;
|
||||||
bool m_CustomNameAlwaysVisible;
|
bool m_CustomNameAlwaysVisible;
|
||||||
|
|
||||||
|
41
src/Mobs/MonsterTypes.h
Normal file
41
src/Mobs/MonsterTypes.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// This identifies individual monster type, as well as their network type-ID
|
||||||
|
// tolua_begin
|
||||||
|
enum eMonsterType
|
||||||
|
{
|
||||||
|
mtInvalidType = -1,
|
||||||
|
|
||||||
|
mtBat = E_META_SPAWN_EGG_BAT,
|
||||||
|
mtBlaze = E_META_SPAWN_EGG_BLAZE,
|
||||||
|
mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER,
|
||||||
|
mtChicken = E_META_SPAWN_EGG_CHICKEN,
|
||||||
|
mtCow = E_META_SPAWN_EGG_COW,
|
||||||
|
mtCreeper = E_META_SPAWN_EGG_CREEPER,
|
||||||
|
mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON,
|
||||||
|
mtEnderman = E_META_SPAWN_EGG_ENDERMAN,
|
||||||
|
mtGhast = E_META_SPAWN_EGG_GHAST,
|
||||||
|
mtGiant = E_META_SPAWN_EGG_GIANT,
|
||||||
|
mtHorse = E_META_SPAWN_EGG_HORSE,
|
||||||
|
mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM,
|
||||||
|
mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE,
|
||||||
|
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM,
|
||||||
|
mtOcelot = E_META_SPAWN_EGG_OCELOT,
|
||||||
|
mtPig = E_META_SPAWN_EGG_PIG,
|
||||||
|
mtSheep = E_META_SPAWN_EGG_SHEEP,
|
||||||
|
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH,
|
||||||
|
mtSkeleton = E_META_SPAWN_EGG_SKELETON,
|
||||||
|
mtSlime = E_META_SPAWN_EGG_SLIME,
|
||||||
|
mtSnowGolem = E_META_SPAWN_EGG_SNOW_GOLEM,
|
||||||
|
mtSpider = E_META_SPAWN_EGG_SPIDER,
|
||||||
|
mtSquid = E_META_SPAWN_EGG_SQUID,
|
||||||
|
mtVillager = E_META_SPAWN_EGG_VILLAGER,
|
||||||
|
mtWitch = E_META_SPAWN_EGG_WITCH,
|
||||||
|
mtWither = E_META_SPAWN_EGG_WITHER,
|
||||||
|
mtWolf = E_META_SPAWN_EGG_WOLF,
|
||||||
|
mtZombie = E_META_SPAWN_EGG_ZOMBIE,
|
||||||
|
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
|
||||||
|
} ;
|
||||||
|
// tolua_end
|
||||||
|
|
@ -67,7 +67,7 @@ void cMooshroom::OnRightClicked(cPlayer & a_Player)
|
|||||||
cItems Drops;
|
cItems Drops;
|
||||||
Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0));
|
Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0));
|
||||||
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
|
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
|
||||||
m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), cMonster::mtCow);
|
m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtCow);
|
||||||
Destroy();
|
Destroy();
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
|
cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
|
||||||
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
|
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
|
||||||
{
|
{
|
||||||
m_EMPersonality = PASSIVE;
|
m_EMPersonality = PASSIVE;
|
||||||
|
@ -13,7 +13,7 @@ class cPassiveAggressiveMonster :
|
|||||||
typedef cAggressiveMonster super;
|
typedef cAggressiveMonster super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
||||||
|
|
||||||
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||||
} ;
|
} ;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
|
cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
|
||||||
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
|
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
|
||||||
{
|
{
|
||||||
m_EMPersonality = PASSIVE;
|
m_EMPersonality = PASSIVE;
|
||||||
|
@ -13,7 +13,7 @@ class cPassiveMonster :
|
|||||||
typedef cMonster super;
|
typedef cMonster super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "PassiveMonster.h"
|
#include "PassiveMonster.h"
|
||||||
|
#include "Blocks/ChunkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1990,7 +1990,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
{
|
{
|
||||||
switch (a_Mob.GetMobType())
|
switch (a_Mob.GetMobType())
|
||||||
{
|
{
|
||||||
case cMonster::mtCreeper:
|
case mtCreeper:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up?
|
WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up?
|
||||||
@ -1998,25 +1998,25 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged?
|
WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtBat:
|
case mtBat:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down?
|
WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtPig:
|
case mtPig:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled?
|
WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtVillager:
|
case mtVillager:
|
||||||
{
|
{
|
||||||
WriteByte(0x50);
|
WriteByte(0x50);
|
||||||
WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE?
|
WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtZombie:
|
case mtZombie:
|
||||||
{
|
{
|
||||||
WriteByte(0xC);
|
WriteByte(0xC);
|
||||||
WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Baby zombie?
|
WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Baby zombie?
|
||||||
@ -2026,13 +2026,13 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
|
WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtGhast:
|
case mtGhast:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to spit a flameball?
|
WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to spit a flameball?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtWolf:
|
case mtWolf:
|
||||||
{
|
{
|
||||||
Byte WolfStatus = 0;
|
Byte WolfStatus = 0;
|
||||||
if (((const cWolf &)a_Mob).IsSitting())
|
if (((const cWolf &)a_Mob).IsSitting())
|
||||||
@ -2056,7 +2056,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode?
|
WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtSheep:
|
case mtSheep:
|
||||||
{
|
{
|
||||||
// [1](1111)
|
// [1](1111)
|
||||||
// [] = Is sheared? () = Color, from 0 to 15
|
// [] = Is sheared? () = Color, from 0 to 15
|
||||||
@ -2072,7 +2072,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
WriteByte(SheepMetadata);
|
WriteByte(SheepMetadata);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtEnderman:
|
case mtEnderman:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house
|
WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house
|
||||||
@ -2082,19 +2082,19 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face?
|
WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtSkeleton:
|
case mtSkeleton:
|
||||||
{
|
{
|
||||||
WriteByte(0xD);
|
WriteByte(0xD);
|
||||||
WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not
|
WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtWitch:
|
case mtWitch:
|
||||||
{
|
{
|
||||||
WriteByte(0x15);
|
WriteByte(0x15);
|
||||||
WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
|
WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtWither:
|
case mtWither:
|
||||||
{
|
{
|
||||||
WriteByte(0x54); // Int at index 20
|
WriteByte(0x54); // Int at index 20
|
||||||
WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks());
|
WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks());
|
||||||
@ -2102,11 +2102,11 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
WriteFloat((float)(a_Mob.GetHealth()));
|
WriteFloat((float)(a_Mob.GetHealth()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtSlime:
|
case mtSlime:
|
||||||
case cMonster::mtMagmaCube:
|
case mtMagmaCube:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
if (a_Mob.GetMobType() == cMonster::mtSlime)
|
if (a_Mob.GetMobType() == mtSlime)
|
||||||
{
|
{
|
||||||
WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
|
WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
|
||||||
}
|
}
|
||||||
@ -2116,7 +2116,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtHorse:
|
case mtHorse:
|
||||||
{
|
{
|
||||||
int Flags = 0;
|
int Flags = 0;
|
||||||
if (((const cHorse &)a_Mob).IsTame())
|
if (((const cHorse &)a_Mob).IsTame())
|
||||||
|
@ -2740,7 +2740,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
{
|
{
|
||||||
switch (a_Mob.GetMobType())
|
switch (a_Mob.GetMobType())
|
||||||
{
|
{
|
||||||
case cMonster::mtCreeper:
|
case mtCreeper:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1);
|
WriteByte(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1);
|
||||||
@ -2749,28 +2749,28 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtBat:
|
case mtBat:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0);
|
WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtPig:
|
case mtPig:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0);
|
WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtVillager:
|
case mtVillager:
|
||||||
{
|
{
|
||||||
WriteByte(0x50);
|
WriteByte(0x50);
|
||||||
WriteInt(((const cVillager &)a_Mob).GetVilType());
|
WriteInt(((const cVillager &)a_Mob).GetVilType());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtZombie:
|
case mtZombie:
|
||||||
{
|
{
|
||||||
WriteByte(0x0c);
|
WriteByte(0x0c);
|
||||||
WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0);
|
WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0);
|
||||||
@ -2781,14 +2781,14 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtGhast:
|
case mtGhast:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cGhast &)a_Mob).IsCharging());
|
WriteByte(((const cGhast &)a_Mob).IsCharging());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtWolf:
|
case mtWolf:
|
||||||
{
|
{
|
||||||
const cWolf & Wolf = (const cWolf &)a_Mob;
|
const cWolf & Wolf = (const cWolf &)a_Mob;
|
||||||
Byte WolfStatus = 0;
|
Byte WolfStatus = 0;
|
||||||
@ -2816,7 +2816,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtSheep:
|
case mtSheep:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
Byte SheepMetadata = 0;
|
Byte SheepMetadata = 0;
|
||||||
@ -2829,7 +2829,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtEnderman:
|
case mtEnderman:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock()));
|
WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock()));
|
||||||
@ -2840,21 +2840,21 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtSkeleton:
|
case mtSkeleton:
|
||||||
{
|
{
|
||||||
WriteByte(0x0d);
|
WriteByte(0x0d);
|
||||||
WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0);
|
WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtWitch:
|
case mtWitch:
|
||||||
{
|
{
|
||||||
WriteByte(0x15);
|
WriteByte(0x15);
|
||||||
WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0);
|
WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtWither:
|
case mtWither:
|
||||||
{
|
{
|
||||||
WriteByte(0x54); // Int at index 20
|
WriteByte(0x54); // Int at index 20
|
||||||
WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
|
WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
|
||||||
@ -2863,21 +2863,21 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtSlime:
|
case mtSlime:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cSlime &)a_Mob).GetSize());
|
WriteByte(((const cSlime &)a_Mob).GetSize());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtMagmaCube:
|
case mtMagmaCube:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cMagmaCube &)a_Mob).GetSize());
|
WriteByte(((const cMagmaCube &)a_Mob).GetSize());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtHorse:
|
case mtHorse:
|
||||||
{
|
{
|
||||||
const cHorse & Horse = (const cHorse &)a_Mob;
|
const cHorse & Horse = (const cHorse &)a_Mob;
|
||||||
int Flags = 0;
|
int Flags = 0;
|
||||||
|
@ -3061,7 +3061,7 @@ void cProtocol180::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
{
|
{
|
||||||
switch (a_Mob.GetMobType())
|
switch (a_Mob.GetMobType())
|
||||||
{
|
{
|
||||||
case cMonster::mtCreeper:
|
case mtCreeper:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1);
|
WriteByte(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1);
|
||||||
@ -3070,28 +3070,28 @@ void cProtocol180::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtBat:
|
case mtBat:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0);
|
WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtPig:
|
case mtPig:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0);
|
WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtVillager:
|
case mtVillager:
|
||||||
{
|
{
|
||||||
WriteByte(0x50);
|
WriteByte(0x50);
|
||||||
WriteInt(((const cVillager &)a_Mob).GetVilType());
|
WriteInt(((const cVillager &)a_Mob).GetVilType());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtZombie:
|
case mtZombie:
|
||||||
{
|
{
|
||||||
WriteByte(0x0c);
|
WriteByte(0x0c);
|
||||||
WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0);
|
WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0);
|
||||||
@ -3102,14 +3102,14 @@ void cProtocol180::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtGhast:
|
case mtGhast:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cGhast &)a_Mob).IsCharging());
|
WriteByte(((const cGhast &)a_Mob).IsCharging());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtWolf:
|
case mtWolf:
|
||||||
{
|
{
|
||||||
const cWolf & Wolf = (const cWolf &)a_Mob;
|
const cWolf & Wolf = (const cWolf &)a_Mob;
|
||||||
Byte WolfStatus = 0;
|
Byte WolfStatus = 0;
|
||||||
@ -3137,7 +3137,7 @@ void cProtocol180::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtSheep:
|
case mtSheep:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
Byte SheepMetadata = 0;
|
Byte SheepMetadata = 0;
|
||||||
@ -3150,7 +3150,7 @@ void cProtocol180::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtEnderman:
|
case mtEnderman:
|
||||||
{
|
{
|
||||||
WriteByte(0x30);
|
WriteByte(0x30);
|
||||||
WriteShort((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock()));
|
WriteShort((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock()));
|
||||||
@ -3161,21 +3161,21 @@ void cProtocol180::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtSkeleton:
|
case mtSkeleton:
|
||||||
{
|
{
|
||||||
WriteByte(0x0d);
|
WriteByte(0x0d);
|
||||||
WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0);
|
WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtWitch:
|
case mtWitch:
|
||||||
{
|
{
|
||||||
WriteByte(0x15);
|
WriteByte(0x15);
|
||||||
WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0);
|
WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtWither:
|
case mtWither:
|
||||||
{
|
{
|
||||||
WriteByte(0x54); // Int at index 20
|
WriteByte(0x54); // Int at index 20
|
||||||
WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
|
WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
|
||||||
@ -3184,21 +3184,21 @@ void cProtocol180::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtSlime:
|
case mtSlime:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cSlime &)a_Mob).GetSize());
|
WriteByte(((const cSlime &)a_Mob).GetSize());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtMagmaCube:
|
case mtMagmaCube:
|
||||||
{
|
{
|
||||||
WriteByte(0x10);
|
WriteByte(0x10);
|
||||||
WriteByte(((const cMagmaCube &)a_Mob).GetSize());
|
WriteByte(((const cMagmaCube &)a_Mob).GetSize());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtHorse:
|
case mtHorse:
|
||||||
{
|
{
|
||||||
const cHorse & Horse = (const cHorse &)a_Mob;
|
const cHorse & Horse = (const cHorse &)a_Mob;
|
||||||
int Flags = 0;
|
int Flags = 0;
|
||||||
|
@ -10,7 +10,6 @@ SET (SRCS
|
|||||||
FloodyFluidSimulator.cpp
|
FloodyFluidSimulator.cpp
|
||||||
FluidSimulator.cpp
|
FluidSimulator.cpp
|
||||||
IncrementalRedstoneSimulator.cpp
|
IncrementalRedstoneSimulator.cpp
|
||||||
RedstoneSimulator.cpp
|
|
||||||
SandSimulator.cpp
|
SandSimulator.cpp
|
||||||
Simulator.cpp
|
Simulator.cpp
|
||||||
SimulatorManager.cpp
|
SimulatorManager.cpp
|
||||||
|
@ -16,7 +16,7 @@ it progresses to the next step (blockmeta++). This value is updated if a neighbo
|
|||||||
The simulator reads its parameters from the ini file given to the constructor.
|
The simulator reads its parameters from the ini file given to the constructor.
|
||||||
*/
|
*/
|
||||||
class cFireSimulator :
|
class cFireSimulator :
|
||||||
public cSimulator
|
public cSimulator<cChunk, cWorld>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cFireSimulator(cWorld & a_World, cIniFile & a_IniFile);
|
cFireSimulator(cWorld & a_World, cIniFile & a_IniFile);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../BlockArea.h"
|
#include "../BlockArea.h"
|
||||||
#include "../Blocks/BlockHandler.h"
|
#include "../Blocks/BlockHandler.h"
|
||||||
#include "../BlockInServerPluginInterface.h"
|
#include "../BlockInServerPluginInterface.h"
|
||||||
|
#include "../Blocks/ChunkInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
#include "Simulator.h"
|
#include "Simulator.h"
|
||||||
|
|
||||||
|
|
||||||
|
class cChunk;
|
||||||
|
class cWorld;
|
||||||
|
|
||||||
|
|
||||||
enum Direction
|
enum Direction
|
||||||
@ -36,9 +37,9 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
class cFluidSimulator :
|
class cFluidSimulator :
|
||||||
public cSimulator
|
public cSimulator<cChunk, cWorld>
|
||||||
{
|
{
|
||||||
typedef cSimulator super;
|
typedef cSimulator<cChunk, cWorld> super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
|
cFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,314 +3,7 @@
|
|||||||
|
|
||||||
#include "RedstoneSimulator.h"
|
#include "RedstoneSimulator.h"
|
||||||
|
|
||||||
/// Per-chunk data for the simulator, specified individual chunks to simulate
|
class cWorld;
|
||||||
typedef cCoordWithBlockAndBoolVector cRedstoneSimulatorChunkData;
|
class cChunk;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cIncrementalRedstoneSimulator :
|
|
||||||
public cRedstoneSimulator
|
|
||||||
{
|
|
||||||
typedef cRedstoneSimulator super;
|
|
||||||
public:
|
|
||||||
|
|
||||||
cIncrementalRedstoneSimulator(cWorld & a_World);
|
|
||||||
~cIncrementalRedstoneSimulator();
|
|
||||||
|
|
||||||
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
|
|
||||||
virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
|
|
||||||
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override { return IsRedstone(a_BlockType); }
|
|
||||||
virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
|
|
||||||
|
|
||||||
enum eRedstoneDirection
|
|
||||||
{
|
|
||||||
REDSTONE_NONE = 0,
|
|
||||||
REDSTONE_X_POS = 0x1,
|
|
||||||
REDSTONE_X_NEG = 0x2,
|
|
||||||
REDSTONE_Z_POS = 0x4,
|
|
||||||
REDSTONE_Z_NEG = 0x8,
|
|
||||||
};
|
|
||||||
eRedstoneDirection GetWireDirection(int a_BlockX, int a_BlockY, int a_BlockZ);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
#define MAX_POWER_LEVEL 15
|
|
||||||
|
|
||||||
struct sPoweredBlocks // Define structure of the directly powered blocks list
|
|
||||||
{
|
|
||||||
Vector3i a_BlockPos; // Position of powered block
|
|
||||||
Vector3i a_SourcePos; // Position of source powering the block at a_BlockPos
|
|
||||||
unsigned char a_PowerLevel;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sLinkedPoweredBlocks // Define structure of the indirectly powered blocks list (i.e. repeaters powering through a block to the block at the other side)
|
|
||||||
{
|
|
||||||
Vector3i a_BlockPos;
|
|
||||||
Vector3i a_MiddlePos; // Position of block that is betwixt a source and the destination
|
|
||||||
Vector3i a_SourcePos;
|
|
||||||
unsigned char a_PowerLevel;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sSimulatedPlayerToggleableList // Define structure of the list containing simulate-on-update blocks (such as trapdoors that respond once to a block update, and can be toggled by a player)
|
|
||||||
{
|
|
||||||
Vector3i a_RelBlockPos;
|
|
||||||
bool WasLastStatePowered; // Was the last state powered or not? Determines whether a source update has happened and if I should resimulate
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sRepeatersDelayList // Define structure of list containing repeaters' delay states
|
|
||||||
{
|
|
||||||
Vector3i a_RelBlockPos;
|
|
||||||
unsigned char a_DelayTicks; // For how many ticks should the repeater delay
|
|
||||||
unsigned char a_ElapsedTicks; // How much of the previous has been elapsed?
|
|
||||||
bool ShouldPowerOn; // What happens when the delay time is fulfilled?
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
typedef std::vector <sPoweredBlocks> PoweredBlocksList;
|
|
||||||
typedef std::vector <sLinkedPoweredBlocks> LinkedBlocksList;
|
|
||||||
typedef std::vector <sSimulatedPlayerToggleableList> SimulatedPlayerToggleableList;
|
|
||||||
typedef std::vector <sRepeatersDelayList> RepeatersDelayList;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
cRedstoneSimulatorChunkData * m_RedstoneSimulatorChunkData;
|
|
||||||
PoweredBlocksList * m_PoweredBlocks;
|
|
||||||
LinkedBlocksList * m_LinkedPoweredBlocks;
|
|
||||||
SimulatedPlayerToggleableList * m_SimulatedPlayerToggleableBlocks;
|
|
||||||
RepeatersDelayList * m_RepeatersDelayList;
|
|
||||||
|
|
||||||
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override { RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); }
|
|
||||||
void RedstoneAddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk, cChunk * a_OtherChunk = NULL);
|
|
||||||
cChunk * m_Chunk;
|
|
||||||
|
|
||||||
// We want a_MyState for devices needing a full FastSetBlock (as opposed to meta) because with our simulation model, we cannot keep setting the block if it is already set correctly
|
|
||||||
// In addition to being non-performant, it would stop the player from actually breaking said device
|
|
||||||
|
|
||||||
/* ====== SOURCES ====== */
|
|
||||||
/** Handles the redstone torch */
|
|
||||||
void HandleRedstoneTorch(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState);
|
|
||||||
/** Handles the redstone block */
|
|
||||||
void HandleRedstoneBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles levers */
|
|
||||||
void HandleRedstoneLever(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles buttons */
|
|
||||||
void HandleRedstoneButton(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles daylight sensors */
|
|
||||||
void HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles pressure plates */
|
|
||||||
void HandlePressurePlate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType);
|
|
||||||
/** Handles tripwire hooks
|
|
||||||
Performs correct meta and power setting for self by going in the direction it faces and looking for a continous line of tripwire bounded by another oppositely facing hook
|
|
||||||
If this line is complete, it verifies that at least on wire reports an entity is on top (via its meta), and performs its task
|
|
||||||
*/
|
|
||||||
void HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles trapped chests */
|
|
||||||
void HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/* ==================== */
|
|
||||||
|
|
||||||
/* ====== CARRIERS ====== */
|
|
||||||
/** Handles redstone wire */
|
|
||||||
void HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles repeaters */
|
|
||||||
void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState);
|
|
||||||
/* ====================== */
|
|
||||||
|
|
||||||
/* ====== DEVICES ====== */
|
|
||||||
/** Handles pistons */
|
|
||||||
void HandlePiston(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles dispensers and droppers */
|
|
||||||
void HandleDropSpenser(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles TNT (exploding) */
|
|
||||||
void HandleTNT(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles redstone lamps */
|
|
||||||
void HandleRedstoneLamp(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState);
|
|
||||||
/** Handles doords */
|
|
||||||
void HandleDoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles command blocks */
|
|
||||||
void HandleCommandBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles activator, detector, and powered rails */
|
|
||||||
void HandleRail(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType);
|
|
||||||
/** Handles trapdoors */
|
|
||||||
void HandleTrapdoor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles fence gates */
|
|
||||||
void HandleFenceGate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles noteblocks */
|
|
||||||
void HandleNoteBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Handles tripwires */
|
|
||||||
void HandleTripwire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/* ===================== */
|
|
||||||
|
|
||||||
/* ====== Helper functions ====== */
|
|
||||||
/** Marks a block as powered */
|
|
||||||
void SetBlockPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
|
|
||||||
/** Marks a block as being powered through another block */
|
|
||||||
void SetBlockLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelMiddleX, int a_RelMiddleY, int a_RelMiddleZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, BLOCKTYPE a_MiddeBlock, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
|
|
||||||
/** Marks a block as simulated, who should not be simulated further unless their power state changes, to accomodate a player manually toggling the block without triggering the simulator toggling it back */
|
|
||||||
void SetPlayerToggleableBlockAsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool WasLastStatePowered);
|
|
||||||
/** Marks the second block in a direction as linked powered */
|
|
||||||
void SetDirectionLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, char a_Direction, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
|
|
||||||
/** Marks all blocks immediately surrounding a coordinate as powered */
|
|
||||||
void SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
|
|
||||||
/** Queues a repeater to be powered or unpowered and returns if the m_RepeatersDelayList iterators were invalidated */
|
|
||||||
bool QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn);
|
|
||||||
/** Removes a block from the Powered and LinkedPowered lists
|
|
||||||
Used for variable sources such as tripwire hooks, daylight sensors, and trapped chests
|
|
||||||
*/
|
|
||||||
void SetSourceUnpowered(int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, cChunk * a_Chunk, bool a_IsFirstCall = true);
|
|
||||||
|
|
||||||
/** Returns if a coordinate is powered or linked powered */
|
|
||||||
bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); }
|
|
||||||
/** Returns if a coordinate is in the directly powered blocks list */
|
|
||||||
bool AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, cChunk * a_Chunk);
|
|
||||||
/** Returns if a coordinate is in the indirectly powered blocks list */
|
|
||||||
bool AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
|
|
||||||
/** Returns if a coordinate was marked as simulated (for blocks toggleable by players) */
|
|
||||||
bool AreCoordsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool IsCurrentStatePowered);
|
|
||||||
/** Returns if a repeater is powered by testing for power sources behind the repeater */
|
|
||||||
bool IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta);
|
|
||||||
/** Returns if a repeater is locked */
|
|
||||||
bool IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta);
|
|
||||||
/** Returns if a piston is powered */
|
|
||||||
bool IsPistonPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta);
|
|
||||||
/** Returns if a wire is powered
|
|
||||||
The only diffence between this and a normal AreCoordsPowered is that this function checks for a wire powering another wire */
|
|
||||||
bool IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel);
|
|
||||||
/** Handles delayed updates to repeaters **/
|
|
||||||
void HandleRedstoneRepeaterDelays(void);
|
|
||||||
|
|
||||||
/** Returns if lever metadata marks it as emitting power */
|
|
||||||
bool IsLeverOn(NIBBLETYPE a_BlockMeta);
|
|
||||||
/** Returns if button metadata marks it as emitting power */
|
|
||||||
bool IsButtonOn(NIBBLETYPE a_BlockMeta) { return IsLeverOn(a_BlockMeta); }
|
|
||||||
/* ============================== */
|
|
||||||
|
|
||||||
/* ====== Misc Functions ====== */
|
|
||||||
/** Returns if a block is viable to be the MiddleBlock of a SetLinkedPowered operation */
|
|
||||||
inline static bool IsViableMiddleBlock(BLOCKTYPE Block) { return cBlockInfo::FullyOccupiesVoxel(Block); }
|
|
||||||
|
|
||||||
/** Returns if a block is a mechanism (something that accepts power and does something)
|
|
||||||
Used by torches to determine if they power a block whilst not standing on the ground
|
|
||||||
*/
|
|
||||||
inline static bool IsMechanism(BLOCKTYPE Block)
|
|
||||||
{
|
|
||||||
switch (Block)
|
|
||||||
{
|
|
||||||
case E_BLOCK_ACTIVATOR_RAIL:
|
|
||||||
case E_BLOCK_COMMAND_BLOCK:
|
|
||||||
case E_BLOCK_PISTON:
|
|
||||||
case E_BLOCK_STICKY_PISTON:
|
|
||||||
case E_BLOCK_DISPENSER:
|
|
||||||
case E_BLOCK_DROPPER:
|
|
||||||
case E_BLOCK_FENCE_GATE:
|
|
||||||
case E_BLOCK_HOPPER:
|
|
||||||
case E_BLOCK_NOTE_BLOCK:
|
|
||||||
case E_BLOCK_TNT:
|
|
||||||
case E_BLOCK_TRAPDOOR:
|
|
||||||
case E_BLOCK_REDSTONE_LAMP_OFF:
|
|
||||||
case E_BLOCK_REDSTONE_LAMP_ON:
|
|
||||||
case E_BLOCK_WOODEN_DOOR:
|
|
||||||
case E_BLOCK_IRON_DOOR:
|
|
||||||
case E_BLOCK_REDSTONE_REPEATER_OFF:
|
|
||||||
case E_BLOCK_REDSTONE_REPEATER_ON:
|
|
||||||
case E_BLOCK_POWERED_RAIL:
|
|
||||||
case E_BLOCK_REDSTONE_WIRE:
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns if a block has the potential to output power */
|
|
||||||
inline static bool IsPotentialSource(BLOCKTYPE Block)
|
|
||||||
{
|
|
||||||
switch (Block)
|
|
||||||
{
|
|
||||||
case E_BLOCK_DETECTOR_RAIL:
|
|
||||||
case E_BLOCK_DAYLIGHT_SENSOR:
|
|
||||||
case E_BLOCK_WOODEN_BUTTON:
|
|
||||||
case E_BLOCK_STONE_BUTTON:
|
|
||||||
case E_BLOCK_REDSTONE_WIRE:
|
|
||||||
case E_BLOCK_REDSTONE_TORCH_ON:
|
|
||||||
case E_BLOCK_LEVER:
|
|
||||||
case E_BLOCK_REDSTONE_REPEATER_ON:
|
|
||||||
case E_BLOCK_BLOCK_OF_REDSTONE:
|
|
||||||
case E_BLOCK_ACTIVE_COMPARATOR:
|
|
||||||
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
|
|
||||||
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
|
|
||||||
case E_BLOCK_STONE_PRESSURE_PLATE:
|
|
||||||
case E_BLOCK_WOODEN_PRESSURE_PLATE:
|
|
||||||
case E_BLOCK_TRAPPED_CHEST:
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns if a block is any sort of redstone device */
|
|
||||||
inline static bool IsRedstone(BLOCKTYPE Block)
|
|
||||||
{
|
|
||||||
switch (Block)
|
|
||||||
{
|
|
||||||
// All redstone devices, please alpha sort
|
|
||||||
case E_BLOCK_ACTIVATOR_RAIL:
|
|
||||||
case E_BLOCK_ACTIVE_COMPARATOR:
|
|
||||||
case E_BLOCK_BLOCK_OF_REDSTONE:
|
|
||||||
case E_BLOCK_COMMAND_BLOCK:
|
|
||||||
case E_BLOCK_DETECTOR_RAIL:
|
|
||||||
case E_BLOCK_DISPENSER:
|
|
||||||
case E_BLOCK_DAYLIGHT_SENSOR:
|
|
||||||
case E_BLOCK_DROPPER:
|
|
||||||
case E_BLOCK_FENCE_GATE:
|
|
||||||
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
|
|
||||||
case E_BLOCK_HOPPER:
|
|
||||||
case E_BLOCK_INACTIVE_COMPARATOR:
|
|
||||||
case E_BLOCK_IRON_DOOR:
|
|
||||||
case E_BLOCK_LEVER:
|
|
||||||
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
|
|
||||||
case E_BLOCK_NOTE_BLOCK:
|
|
||||||
case E_BLOCK_POWERED_RAIL:
|
|
||||||
case E_BLOCK_REDSTONE_LAMP_OFF:
|
|
||||||
case E_BLOCK_REDSTONE_LAMP_ON:
|
|
||||||
case E_BLOCK_REDSTONE_REPEATER_OFF:
|
|
||||||
case E_BLOCK_REDSTONE_REPEATER_ON:
|
|
||||||
case E_BLOCK_REDSTONE_TORCH_OFF:
|
|
||||||
case E_BLOCK_REDSTONE_TORCH_ON:
|
|
||||||
case E_BLOCK_REDSTONE_WIRE:
|
|
||||||
case E_BLOCK_STICKY_PISTON:
|
|
||||||
case E_BLOCK_STONE_BUTTON:
|
|
||||||
case E_BLOCK_STONE_PRESSURE_PLATE:
|
|
||||||
case E_BLOCK_TNT:
|
|
||||||
case E_BLOCK_TRAPDOOR:
|
|
||||||
case E_BLOCK_TRAPPED_CHEST:
|
|
||||||
case E_BLOCK_TRIPWIRE_HOOK:
|
|
||||||
case E_BLOCK_TRIPWIRE:
|
|
||||||
case E_BLOCK_WOODEN_BUTTON:
|
|
||||||
case E_BLOCK_WOODEN_DOOR:
|
|
||||||
case E_BLOCK_WOODEN_PRESSURE_PLATE:
|
|
||||||
case E_BLOCK_PISTON:
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static bool AreCoordsOnChunkBoundary(int a_BlockX, int a_BlockY, int a_BlockZ)
|
|
||||||
{
|
|
||||||
return ( // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks
|
|
||||||
((a_BlockX % cChunkDef::Width) <= 1) ||
|
|
||||||
((a_BlockX % cChunkDef::Width) >= 14) ||
|
|
||||||
((a_BlockZ % cChunkDef::Width) <= 1) ||
|
|
||||||
((a_BlockZ % cChunkDef::Width) >= 14)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cRedstoneSimulator<cChunk, cWorld> * MakeIncrementalRedstoneSimulator(cWorld & a_World);
|
||||||
|
2546
src/Simulator/IncrementalRedstoneSimulator.inc
Normal file
2546
src/Simulator/IncrementalRedstoneSimulator.inc
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
|
|
||||||
class cRedstoneNoopSimulator :
|
class cRedstoneNoopSimulator :
|
||||||
public cRedstoneSimulator
|
public cRedstoneSimulator<cChunk, cWorld>
|
||||||
{
|
{
|
||||||
typedef cRedstoneSimulator super;
|
typedef cRedstoneSimulator<cChunk, cWorld> super;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
cRedstoneNoopSimulator(cWorld & a_World) :
|
cRedstoneNoopSimulator(cWorld & a_World) :
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
#include "Globals.h"
|
|
||||||
|
|
||||||
#include "RedstoneSimulator.h"
|
|
||||||
#include "../World.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cRedstoneSimulator::cRedstoneSimulator(cWorld & a_World) :
|
|
||||||
super(a_World)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -4,14 +4,25 @@
|
|||||||
#include "Simulator.h"
|
#include "Simulator.h"
|
||||||
|
|
||||||
|
|
||||||
|
class cRedstoneSimulatorChunkData
|
||||||
|
|
||||||
class cRedstoneSimulator :
|
|
||||||
public cSimulator
|
|
||||||
{
|
{
|
||||||
typedef cSimulator super;
|
public:
|
||||||
|
virtual ~cRedstoneSimulatorChunkData() = 0;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
inline cRedstoneSimulatorChunkData::~cRedstoneSimulatorChunkData() {}
|
||||||
|
|
||||||
|
template <class ChunkType, class WorldType>
|
||||||
|
class cRedstoneSimulator :
|
||||||
|
public cSimulator<ChunkType, WorldType>
|
||||||
|
{
|
||||||
|
typedef cSimulator<ChunkType, WorldType> super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cRedstoneSimulator(cWorld & a_World);
|
cRedstoneSimulator(WorldType & a_World) :
|
||||||
|
super(a_World)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user