1
0

Added cWorld:SpawnMob(PosX, PosY, PosZ, EntityType) to Lua API

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1014 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-10-28 14:57:35 +00:00
parent 1cd213fa60
commit 96f7246df1
6 changed files with 291 additions and 201 deletions

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 10/20/12 23:51:02.
** Generated automatically by tolua++-1.0.92 on 10/28/12 15:51:24.
*/
#ifndef __cplusplus
@ -388,7 +388,7 @@ static int tolua_AllToLua_cVine_DirectionToMetaData00(lua_State* tolua_S)
{
char a_Direction = ((char) tolua_tonumber(tolua_S,2,0));
{
char tolua_ret = (char) cVine::DirectionToMetaData(a_Direction);
unsigned char tolua_ret = (unsigned char) cVine::DirectionToMetaData(a_Direction);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@ -401,6 +401,36 @@ static int tolua_AllToLua_cVine_DirectionToMetaData00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* method: MetaDataToDirection of class cVine */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cVine_MetaDataToDirection00
static int tolua_AllToLua_cVine_MetaDataToDirection00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cVine",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
unsigned char a_MetaData = (( unsigned char) tolua_tonumber(tolua_S,2,0));
{
char tolua_ret = (char) cVine::MetaDataToDirection(a_MetaData);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: new of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_new00
static int tolua_AllToLua_cIniFile_new00(lua_State* tolua_S)
@ -12051,12 +12081,13 @@ static int tolua_AllToLua_cWorld_GetBlockTypeMeta00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockTypeMeta'", NULL);
#endif
{
self->GetBlockTypeMeta(a_BlockX,a_BlockY,a_BlockZ,a_BlockType,a_BlockMeta);
bool tolua_ret = (bool) self->GetBlockTypeMeta(a_BlockX,a_BlockY,a_BlockZ,a_BlockType,a_BlockMeta);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
tolua_pushnumber(tolua_S,(lua_Number)a_BlockType);
tolua_pushnumber(tolua_S,(lua_Number)a_BlockMeta);
}
}
return 2;
return 3;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetBlockTypeMeta'.",&tolua_err);
@ -12098,14 +12129,15 @@ static int tolua_AllToLua_cWorld_GetBlockInfo00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockInfo'", NULL);
#endif
{
self->GetBlockInfo(a_BlockX,a_BlockY,a_BlockZ,a_BlockType,a_Meta,a_SkyLight,a_BlockLight);
bool tolua_ret = (bool) self->GetBlockInfo(a_BlockX,a_BlockY,a_BlockZ,a_BlockType,a_Meta,a_SkyLight,a_BlockLight);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
tolua_pushnumber(tolua_S,(lua_Number)a_BlockType);
tolua_pushnumber(tolua_S,(lua_Number)a_Meta);
tolua_pushnumber(tolua_S,(lua_Number)a_SkyLight);
tolua_pushnumber(tolua_S,(lua_Number)a_BlockLight);
}
}
return 4;
return 5;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetBlockInfo'.",&tolua_err);
@ -13297,6 +13329,46 @@ static int tolua_AllToLua_cWorld_IsBlockDirectlyWatered00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* method: SpawnMob of class cWorld */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SpawnMob00
static int tolua_AllToLua_cWorld_SpawnMob00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
!tolua_isnumber(tolua_S,5,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,6,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
double a_PosX = ((double) tolua_tonumber(tolua_S,2,0));
double a_PosY = ((double) tolua_tonumber(tolua_S,3,0));
double a_PosZ = ((double) tolua_tonumber(tolua_S,4,0));
int a_EntityType = ((int) tolua_tonumber(tolua_S,5,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SpawnMob'", NULL);
#endif
{
int tolua_ret = (int) self->SpawnMob(a_PosX,a_PosY,a_PosZ,a_EntityType);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'SpawnMob'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: Clear of class cInventory */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_Clear00
static int tolua_AllToLua_cInventory_Clear00(lua_State* tolua_S)
@ -13362,6 +13434,40 @@ static int tolua_AllToLua_cInventory_AddItem00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* method: AddItemAnyAmount of class cInventory */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_AddItemAnyAmount00
static int tolua_AllToLua_cInventory_AddItemAnyAmount00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cItem",0,&tolua_err)) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
cItem* a_Item = ((cItem*) tolua_tousertype(tolua_S,2,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddItemAnyAmount'", NULL);
#endif
{
bool tolua_ret = (bool) self->AddItemAnyAmount(*a_Item);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'AddItemAnyAmount'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: RemoveItem of class cInventory */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_RemoveItem00
static int tolua_AllToLua_cInventory_RemoveItem00(lua_State* tolua_S)
@ -21860,6 +21966,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_cclass(tolua_S,"cVine","cVine","",NULL);
tolua_beginmodule(tolua_S,"cVine");
tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cVine_DirectionToMetaData00);
tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cVine_MetaDataToDirection00);
tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cIniFile","cIniFile","",tolua_collect_cIniFile);
@ -22460,6 +22567,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SKELETON",E_META_SPAWN_EGG_SKELETON);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SPIDER",E_META_SPAWN_EGG_SPIDER);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_ZOMBIE",E_META_SPAWN_EGG_ZOMBIE);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_GIANT",E_META_SPAWN_EGG_GIANT);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SLIME",E_META_SPAWN_EGG_SLIME);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_GHAST",E_META_SPAWN_EGG_GHAST);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_ZOMBIE_PIGMAN",E_META_SPAWN_EGG_ZOMBIE_PIGMAN);
@ -22468,7 +22576,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SILVERFISH",E_META_SPAWN_EGG_SILVERFISH);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_BLAZE",E_META_SPAWN_EGG_BLAZE);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_MAGMA_CUBE",E_META_SPAWN_EGG_MAGMA_CUBE);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_GIANT",E_META_SPAWN_EGG_GIANT);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_ENDER_DRAGON",E_META_SPAWN_EGG_ENDER_DRAGON);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_PIG",E_META_SPAWN_EGG_PIG);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SHEEP",E_META_SPAWN_EGG_SHEEP);
@ -22477,10 +22584,38 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SQUID",E_META_SPAWN_EGG_SQUID);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_WOLF",E_META_SPAWN_EGG_WOLF);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_MOOSHROOM",E_META_SPAWN_EGG_MOOSHROOM);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_OCELOT",E_META_SPAWN_EGG_OCELOT);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_VILLAGER",E_META_SPAWN_EGG_VILLAGER);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_SNOW_GOLEM",E_META_SPAWN_EGG_SNOW_GOLEM);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_OCELOT",E_META_SPAWN_EGG_OCELOT);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_IRON_GOLEM",E_META_SPAWN_EGG_IRON_GOLEM);
tolua_constant(tolua_S,"E_META_SPAWN_EGG_VILLAGER",E_META_SPAWN_EGG_VILLAGER);
tolua_constant(tolua_S,"E_ENTITY_TYPE_CREEPER",E_ENTITY_TYPE_CREEPER);
tolua_constant(tolua_S,"E_ENTITY_TYPE_SKELETON",E_ENTITY_TYPE_SKELETON);
tolua_constant(tolua_S,"E_ENTITY_TYPE_SPIDER",E_ENTITY_TYPE_SPIDER);
tolua_constant(tolua_S,"E_ENTITY_TYPE_GIANT",E_ENTITY_TYPE_GIANT);
tolua_constant(tolua_S,"E_ENTITY_TYPE_ZOMBIE",E_ENTITY_TYPE_ZOMBIE);
tolua_constant(tolua_S,"E_ENTITY_TYPE_SLIME",E_ENTITY_TYPE_SLIME);
tolua_constant(tolua_S,"E_ENTITY_TYPE_GHAST",E_ENTITY_TYPE_GHAST);
tolua_constant(tolua_S,"E_ENTITY_TYPE_ZOMBIE_PIGMAN",E_ENTITY_TYPE_ZOMBIE_PIGMAN);
tolua_constant(tolua_S,"E_ENTITY_TYPE_ENDERMAN",E_ENTITY_TYPE_ENDERMAN);
tolua_constant(tolua_S,"E_ENTITY_TYPE_CAVE_SPIDER",E_ENTITY_TYPE_CAVE_SPIDER);
tolua_constant(tolua_S,"E_ENTITY_TYPE_SILVERFISH",E_ENTITY_TYPE_SILVERFISH);
tolua_constant(tolua_S,"E_ENTITY_TYPE_BLAZE",E_ENTITY_TYPE_BLAZE);
tolua_constant(tolua_S,"E_ENTITY_TYPE_MAGMA_CUBE",E_ENTITY_TYPE_MAGMA_CUBE);
tolua_constant(tolua_S,"E_ENTITY_TYPE_ENDER_DRAGON",E_ENTITY_TYPE_ENDER_DRAGON);
tolua_constant(tolua_S,"E_ENTITY_TYPE_WITHER",E_ENTITY_TYPE_WITHER);
tolua_constant(tolua_S,"E_ENTITY_TYPE_BAT",E_ENTITY_TYPE_BAT);
tolua_constant(tolua_S,"E_ENTITY_TYPE_WITCH",E_ENTITY_TYPE_WITCH);
tolua_constant(tolua_S,"E_ENTITY_TYPE_PIG",E_ENTITY_TYPE_PIG);
tolua_constant(tolua_S,"E_ENTITY_TYPE_SHEEP",E_ENTITY_TYPE_SHEEP);
tolua_constant(tolua_S,"E_ENTITY_TYPE_COW",E_ENTITY_TYPE_COW);
tolua_constant(tolua_S,"E_ENTITY_TYPE_CHICKEN",E_ENTITY_TYPE_CHICKEN);
tolua_constant(tolua_S,"E_ENTITY_TYPE_SQUID",E_ENTITY_TYPE_SQUID);
tolua_constant(tolua_S,"E_ENTITY_TYPE_WOLF",E_ENTITY_TYPE_WOLF);
tolua_constant(tolua_S,"E_ENTITY_TYPE_MOOSHROOM",E_ENTITY_TYPE_MOOSHROOM);
tolua_constant(tolua_S,"E_ENTITY_TYPE_SNOW_GOLEM",E_ENTITY_TYPE_SNOW_GOLEM);
tolua_constant(tolua_S,"E_ENTITY_TYPE_OCELOT",E_ENTITY_TYPE_OCELOT);
tolua_constant(tolua_S,"E_ENTITY_TYPE_IRON_GOLEM",E_ENTITY_TYPE_IRON_GOLEM);
tolua_constant(tolua_S,"E_ENTITY_TYPE_VILLAGER",E_ENTITY_TYPE_VILLAGER);
tolua_function(tolua_S,"BlockStringToType",tolua_AllToLua_BlockStringToType00);
tolua_function(tolua_S,"StringToItem",tolua_AllToLua_StringToItem00);
tolua_function(tolua_S,"ItemToString",tolua_AllToLua_ItemToString00);
@ -22920,11 +23055,13 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetMaxSugarcaneHeight",tolua_AllToLua_cWorld_GetMaxSugarcaneHeight00);
tolua_function(tolua_S,"GetMaxCactusHeight",tolua_AllToLua_cWorld_GetMaxCactusHeight00);
tolua_function(tolua_S,"IsBlockDirectlyWatered",tolua_AllToLua_cWorld_IsBlockDirectlyWatered00);
tolua_function(tolua_S,"SpawnMob",tolua_AllToLua_cWorld_SpawnMob00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cInventory","cInventory","",NULL);
tolua_beginmodule(tolua_S,"cInventory");
tolua_function(tolua_S,"Clear",tolua_AllToLua_cInventory_Clear00);
tolua_function(tolua_S,"AddItem",tolua_AllToLua_cInventory_AddItem00);
tolua_function(tolua_S,"AddItemAnyAmount",tolua_AllToLua_cInventory_AddItemAnyAmount00);
tolua_function(tolua_S,"RemoveItem",tolua_AllToLua_cInventory_RemoveItem00);
tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cInventory_GetSlot00);
tolua_function(tolua_S,"GetFromHotBar",tolua_AllToLua_cInventory_GetFromHotBar00);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 10/20/12 23:51:03.
** Generated automatically by tolua++-1.0.92 on 10/28/12 15:51:25.
*/
/* Exported function */

View File

@ -597,11 +597,12 @@ enum
E_META_DYE_WHITE = 15,
// E_ITEM_SPAWN_EGG spawn EntityIDs:
// hostile:
// See also E_ENTITY_TYPE_XXX, since entity type and spawn egg meta are the same
E_META_SPAWN_EGG_CREEPER = 50,
E_META_SPAWN_EGG_SKELETON = 51,
E_META_SPAWN_EGG_SPIDER = 52,
E_META_SPAWN_EGG_ZOMBIE = 54,
E_META_SPAWN_EGG_GIANT = 53,
E_META_SPAWN_EGG_SLIME = 55,
E_META_SPAWN_EGG_GHAST = 56,
E_META_SPAWN_EGG_ZOMBIE_PIGMAN = 57,
@ -610,7 +611,6 @@ enum
E_META_SPAWN_EGG_SILVERFISH = 60,
E_META_SPAWN_EGG_BLAZE = 61,
E_META_SPAWN_EGG_MAGMA_CUBE = 62,
E_META_SPAWN_EGG_GIANT = 53,
E_META_SPAWN_EGG_ENDER_DRAGON = 63,
E_META_SPAWN_EGG_PIG = 90,
E_META_SPAWN_EGG_SHEEP = 91,
@ -619,10 +619,46 @@ enum
E_META_SPAWN_EGG_SQUID = 94,
E_META_SPAWN_EGG_WOLF = 95,
E_META_SPAWN_EGG_MOOSHROOM = 96,
E_META_SPAWN_EGG_OCELOT = 98,
E_META_SPAWN_EGG_VILLAGER = 120,
E_META_SPAWN_EGG_SNOW_GOLEM = 97,
E_META_SPAWN_EGG_IRON_GOLEM = 99
E_META_SPAWN_EGG_OCELOT = 98,
E_META_SPAWN_EGG_IRON_GOLEM = 99,
E_META_SPAWN_EGG_VILLAGER = 120,
} ;
enum
{
// See also E_META_SPAWN_EGG_XXX, since entity type and spawn egg meta are the same
E_ENTITY_TYPE_CREEPER = 50,
E_ENTITY_TYPE_SKELETON = 51,
E_ENTITY_TYPE_SPIDER = 52,
E_ENTITY_TYPE_GIANT = 53,
E_ENTITY_TYPE_ZOMBIE = 54,
E_ENTITY_TYPE_SLIME = 55,
E_ENTITY_TYPE_GHAST = 56,
E_ENTITY_TYPE_ZOMBIE_PIGMAN = 57,
E_ENTITY_TYPE_ENDERMAN = 58,
E_ENTITY_TYPE_CAVE_SPIDER = 59,
E_ENTITY_TYPE_SILVERFISH = 60,
E_ENTITY_TYPE_BLAZE = 61,
E_ENTITY_TYPE_MAGMA_CUBE = 62,
E_ENTITY_TYPE_ENDER_DRAGON = 63,
E_ENTITY_TYPE_WITHER = 64,
E_ENTITY_TYPE_BAT = 65,
E_ENTITY_TYPE_WITCH = 66,
E_ENTITY_TYPE_PIG = 90,
E_ENTITY_TYPE_SHEEP = 91,
E_ENTITY_TYPE_COW = 92,
E_ENTITY_TYPE_CHICKEN = 93,
E_ENTITY_TYPE_SQUID = 94,
E_ENTITY_TYPE_WOLF = 95,
E_ENTITY_TYPE_MOOSHROOM = 96,
E_ENTITY_TYPE_SNOW_GOLEM = 97,
E_ENTITY_TYPE_OCELOT = 98,
E_ENTITY_TYPE_IRON_GOLEM = 99,
E_ENTITY_TYPE_VILLAGER = 120,
} ;
//tolua_end

View File

@ -5,29 +5,6 @@
#include "../World.h"
#include "../Player.h"
// Mobs:
#include "../Mobs/Chicken.h"
#include "../Mobs/Spider.h"
#include "../Mobs/Cow.h"
#include "../Mobs/Squid.h"
#include "../Mobs/Wolf.h"
#include "../Mobs/Slime.h"
#include "../Mobs/Skeleton.h"
#include "../Mobs/Silverfish.h"
#include "../Mobs/Pig.h"
#include "../Mobs/Sheep.h"
#include "../Mobs/Zombie.h"
#include "../Mobs/Enderman.h"
#include "../Mobs/Creeper.h"
#include "../Mobs/Cavespider.h"
#include "../Mobs/Ghast.h"
#include "../Mobs/Zombiepigman.h"
#include "../Mobs/Villager.h"
#include "../Mobs/Ocelot.h"
#include "../Mobs/Mooshroom.h"
#include "../Mobs/Magmacube.h"
#include "../Mobs/Blaze.h"
@ -56,127 +33,15 @@ public:
a_BlockY--;
}
cMonster * Monster = NULL;
switch (a_Item->m_ItemDamage)
if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, a_Item->m_ItemDamage) >= 0)
{
case E_META_SPAWN_EGG_BLAZE:
{
Monster = new cBlaze();
break;
}
case E_META_SPAWN_EGG_CAVE_SPIDER:
{
Monster = new cCavespider();
break;
}
case E_META_SPAWN_EGG_CHICKEN:
{
Monster = new cChicken();
break;
}
case E_META_SPAWN_EGG_COW:
{
Monster = new cCow();
break;
}
case E_META_SPAWN_EGG_CREEPER:
{
Monster = new cCreeper();
break;
}
case E_META_SPAWN_EGG_ENDERMAN:
{
Monster = new cEnderman();
break;
}
case E_META_SPAWN_EGG_GHAST:
{
Monster = new cGhast();
break;
}
case E_META_SPAWN_EGG_MAGMA_CUBE:
{
Monster = new cMagmacube();
break;
}
case E_META_SPAWN_EGG_MOOSHROOM:
{
Monster = new cMooshroom();
break;
}
case E_META_SPAWN_EGG_OCELOT:
{
Monster = new cOcelot();
break;
}
case E_META_SPAWN_EGG_PIG:
{
Monster = new cPig();
break;
}
case E_META_SPAWN_EGG_SHEEP:
{
Monster = new cSheep();
break;
}
case E_META_SPAWN_EGG_SILVERFISH:
{
Monster = new cSilverfish();
break;
}
case E_META_SPAWN_EGG_SKELETON:
{
Monster = new cSkeleton();
break;
}
case E_META_SPAWN_EGG_SLIME:
{
Monster = new cSlime();
break;
}
case E_META_SPAWN_EGG_SPIDER:
{
Monster = new cSpider();
break;
}
case E_META_SPAWN_EGG_SQUID:
{
Monster = new cSquid();
break;
}
case E_META_SPAWN_EGG_VILLAGER:
{
Monster = new cVillager();
break;
}
case E_META_SPAWN_EGG_WOLF:
{
Monster = new cWolf();
break;
}
case E_META_SPAWN_EGG_ZOMBIE:
{
Monster = new cZombie();
break;
}
case E_META_SPAWN_EGG_ZOMBIE_PIGMAN:
{
Monster = new cZombiepigman();
break;
}
default:
{
return false;
}
}
Monster->Initialize(a_World);
Monster->TeleportTo(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5);
a_World->BroadcastSpawn(*Monster);
// The mob was spawned, "use" the item:
a_Player->UseEquippedItem();
return true;
}
return false;
}
} ;

View File

@ -23,21 +23,26 @@
#include "Simulator/RedstoneSimulator.h"
// Mobs:
#include "Mobs/Blaze.h"
#include "Mobs/Cavespider.h"
#include "Mobs/Chicken.h"
#include "Mobs/Spider.h"
#include "Mobs/Cow.h"
#include "Mobs/Squid.h"
#include "Mobs/Wolf.h"
#include "Mobs/Slime.h"
#include "Mobs/Skeleton.h"
#include "Mobs/Silverfish.h"
#include "Mobs/Creeper.h"
#include "Mobs/Enderman.h"
#include "Mobs/Ghast.h"
#include "Mobs/Magmacube.h"
#include "Mobs/Mooshroom.h"
#include "Mobs/Ocelot.h"
#include "Mobs/Pig.h"
#include "Mobs/Sheep.h"
#include "Mobs/Silverfish.h"
#include "Mobs/Skeleton.h"
#include "Mobs/Slime.h"
#include "Mobs/Spider.h"
#include "Mobs/Squid.h"
#include "Mobs/Villager.h"
#include "Mobs/Wolf.h"
#include "Mobs/Zombie.h"
#include "Mobs/Enderman.h"
#include "Mobs/Creeper.h"
#include "Mobs/Cavespider.h"
#include "Mobs/Ghast.h"
#include "Mobs/Zombiepigman.h"
#include "OSSupport/MakeDir.h"
@ -2185,6 +2190,50 @@ bool cWorld::IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ)
int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, int a_EntityType)
{
cMonster * Monster = NULL;
switch (a_EntityType)
{
case E_ENTITY_TYPE_BLAZE: Monster = new cBlaze(); break;
case E_ENTITY_TYPE_CAVE_SPIDER: Monster = new cCavespider(); break;
case E_ENTITY_TYPE_CHICKEN: Monster = new cChicken(); break;
case E_ENTITY_TYPE_COW: Monster = new cCow(); break;
case E_ENTITY_TYPE_CREEPER: Monster = new cCreeper(); break;
case E_ENTITY_TYPE_ENDERMAN: Monster = new cEnderman(); break;
case E_ENTITY_TYPE_GHAST: Monster = new cGhast(); break;
case E_ENTITY_TYPE_MAGMA_CUBE: Monster = new cMagmacube(); break;
case E_ENTITY_TYPE_MOOSHROOM: Monster = new cMooshroom(); break;
case E_ENTITY_TYPE_OCELOT: Monster = new cOcelot(); break;
case E_ENTITY_TYPE_PIG: Monster = new cPig(); break;
case E_ENTITY_TYPE_SHEEP: Monster = new cSheep(); break;
case E_ENTITY_TYPE_SILVERFISH: Monster = new cSilverfish(); break;
case E_ENTITY_TYPE_SKELETON: Monster = new cSkeleton(); break;
case E_ENTITY_TYPE_SLIME: Monster = new cSlime(); break;
case E_ENTITY_TYPE_SPIDER: Monster = new cSpider(); break;
case E_ENTITY_TYPE_SQUID: Monster = new cSquid(); break;
case E_ENTITY_TYPE_VILLAGER: Monster = new cVillager(); break;
case E_ENTITY_TYPE_WOLF: Monster = new cWolf(); break;
case E_ENTITY_TYPE_ZOMBIE: Monster = new cZombie(); break;
case E_ENTITY_TYPE_ZOMBIE_PIGMAN: Monster = new cZombiepigman(); break;
default:
{
LOGWARNING(__FUNCTION__ ": Unhandled entity type: %d. Not spawning.", a_EntityType);
return -1;
}
}
Monster->Initialize(this);
Monster->TeleportTo(a_PosX, a_PosY, a_PosZ);
BroadcastSpawn(*Monster);
return Monster->GetUniqueID();
}
cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const char * a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock)
{
AString SimulatorNameKey;

View File

@ -408,6 +408,9 @@ public:
bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
/// Spawns a mob of the specified entity type. Returns the mob's EntityID if recognized and spawned, <0 otherwise
int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, int a_EntityType); // tolua_export
private:
friend class cRoot;