Added cSignEntity into API, added cChunkDesc:GetBlockEntity().
This fixes both #228 and #347.
This commit is contained in:
parent
79a98627a2
commit
082573771f
@ -2671,6 +2671,10 @@
|
||||
<Filter
|
||||
Name="BlockEntities"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\source\BlockEntities\BlockEntity.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\BlockEntities\BlockEntity.h"
|
||||
>
|
||||
|
@ -47,6 +47,7 @@ $cfile "BlockEntities/DispenserEntity.h"
|
||||
$cfile "BlockEntities/DropperEntity.h"
|
||||
$cfile "BlockEntities/FurnaceEntity.h"
|
||||
$cfile "BlockEntities/HopperEntity.h"
|
||||
$cfile "BlockEntities/SignEntity.h"
|
||||
$cfile "WebAdmin.h"
|
||||
$cfile "WebPlugin.h"
|
||||
$cfile "Root.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 11/14/13 16:18:41.
|
||||
** Generated automatically by tolua++-1.0.92 on 11/14/13 15:31:51.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
@ -46,6 +46,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
|
||||
#include "BlockEntities/DropperEntity.h"
|
||||
#include "BlockEntities/FurnaceEntity.h"
|
||||
#include "BlockEntities/HopperEntity.h"
|
||||
#include "BlockEntities/SignEntity.h"
|
||||
#include "WebAdmin.h"
|
||||
#include "WebPlugin.h"
|
||||
#include "Root.h"
|
||||
@ -74,9 +75,9 @@ static int tolua_collect_cItem (lua_State* tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_Vector3f (lua_State* tolua_S)
|
||||
static int tolua_collect_cFurnaceEntity (lua_State* tolua_S)
|
||||
{
|
||||
Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
|
||||
cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
@ -130,6 +131,13 @@ static int tolua_collect_cLuaWindow (lua_State* tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_cCraftingGrid (lua_State* tolua_S)
|
||||
{
|
||||
cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_cDropperEntity (lua_State* tolua_S)
|
||||
{
|
||||
cDropperEntity* self = (cDropperEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
@ -144,16 +152,9 @@ static int tolua_collect_cPickup (lua_State* tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_cItems (lua_State* tolua_S)
|
||||
static int tolua_collect_sWebAdminPage (lua_State* tolua_S)
|
||||
{
|
||||
cItems* self = (cItems*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_cCraftingGrid (lua_State* tolua_S)
|
||||
{
|
||||
cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
|
||||
sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
@ -172,16 +173,23 @@ static int tolua_collect_cBoundingBox (lua_State* tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_sWebAdminPage (lua_State* tolua_S)
|
||||
static int tolua_collect_cHopperEntity (lua_State* tolua_S)
|
||||
{
|
||||
sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
|
||||
cHopperEntity* self = (cHopperEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_cHopperEntity (lua_State* tolua_S)
|
||||
static int tolua_collect_Vector3f (lua_State* tolua_S)
|
||||
{
|
||||
cHopperEntity* self = (cHopperEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_cIniFile (lua_State* tolua_S)
|
||||
{
|
||||
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
@ -193,16 +201,16 @@ static int tolua_collect_Vector3i (lua_State* tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_cFurnaceEntity (lua_State* tolua_S)
|
||||
static int tolua_collect_cItems (lua_State* tolua_S)
|
||||
{
|
||||
cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
cItems* self = (cItems*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_collect_cIniFile (lua_State* tolua_S)
|
||||
static int tolua_collect_cSignEntity (lua_State* tolua_S)
|
||||
{
|
||||
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
|
||||
cSignEntity* self = (cSignEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
Mtolua_delete(self);
|
||||
return 0;
|
||||
}
|
||||
@ -254,21 +262,22 @@ static void tolua_reg_types (lua_State* tolua_S)
|
||||
tolua_usertype(tolua_S,"cHopperEntity");
|
||||
tolua_usertype(tolua_S,"std::vector<AString>");
|
||||
tolua_usertype(tolua_S,"cBlockEntityWithItems");
|
||||
tolua_usertype(tolua_S,"cWindow");
|
||||
tolua_usertype(tolua_S,"HTTPFormData");
|
||||
tolua_usertype(tolua_S,"cTracer");
|
||||
tolua_usertype(tolua_S,"cGroup");
|
||||
tolua_usertype(tolua_S,"cArrowEntity");
|
||||
tolua_usertype(tolua_S,"cDropSpenserEntity");
|
||||
tolua_usertype(tolua_S,"cWindow");
|
||||
tolua_usertype(tolua_S,"cBlockArea");
|
||||
tolua_usertype(tolua_S,"cCraftingGrid");
|
||||
tolua_usertype(tolua_S,"cPlayer");
|
||||
tolua_usertype(tolua_S,"cGroup");
|
||||
tolua_usertype(tolua_S,"HTTPRequest");
|
||||
tolua_usertype(tolua_S,"cBlockArea");
|
||||
tolua_usertype(tolua_S,"cTracer");
|
||||
tolua_usertype(tolua_S,"cBoundingBox");
|
||||
tolua_usertype(tolua_S,"cBlockEntity");
|
||||
tolua_usertype(tolua_S,"cCriticalSection");
|
||||
tolua_usertype(tolua_S,"HTTPTemplateRequest");
|
||||
tolua_usertype(tolua_S,"cServer");
|
||||
tolua_usertype(tolua_S,"cBoundingBox");
|
||||
tolua_usertype(tolua_S,"Vector3i");
|
||||
tolua_usertype(tolua_S,"cPlayer");
|
||||
tolua_usertype(tolua_S,"cFile");
|
||||
tolua_usertype(tolua_S,"cItems");
|
||||
tolua_usertype(tolua_S,"cClientHandle");
|
||||
@ -281,7 +290,7 @@ static void tolua_reg_types (lua_State* tolua_S)
|
||||
tolua_usertype(tolua_S,"cWebAdmin");
|
||||
tolua_usertype(tolua_S,"cItem");
|
||||
tolua_usertype(tolua_S,"cProjectileEntity");
|
||||
tolua_usertype(tolua_S,"HTTPRequest");
|
||||
tolua_usertype(tolua_S,"cSignEntity");
|
||||
tolua_usertype(tolua_S,"cItemGrid::cListener");
|
||||
tolua_usertype(tolua_S,"cDropperEntity");
|
||||
}
|
||||
@ -17607,6 +17616,46 @@ tolua_lerror:
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: CreateByBlockType of class cBlockEntity */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cBlockEntity_CreateByBlockType00
|
||||
static int tolua_AllToLua_cBlockEntity_CreateByBlockType00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"cBlockEntity",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_isnumber(tolua_S,6,0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,7,"cWorld",1,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,8,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,2,0));
|
||||
unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,3,0));
|
||||
int a_BlockX = ((int) tolua_tonumber(tolua_S,4,0));
|
||||
int a_BlockY = ((int) tolua_tonumber(tolua_S,5,0));
|
||||
int a_BlockZ = ((int) tolua_tonumber(tolua_S,6,0));
|
||||
cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,7,NULL));
|
||||
{
|
||||
cBlockEntity* tolua_ret = (cBlockEntity*) cBlockEntity::CreateByBlockType(a_BlockType,a_BlockMeta,a_BlockX,a_BlockY,a_BlockZ,a_World);
|
||||
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cBlockEntity");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'CreateByBlockType'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: GetPosX of class cBlockEntity */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cBlockEntity_GetPosX00
|
||||
static int tolua_AllToLua_cBlockEntity_GetPosX00(lua_State* tolua_S)
|
||||
@ -18841,6 +18890,192 @@ static int tolua_AllToLua_cHopperEntity_new00_local(lua_State* tolua_S)
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: new of class cSignEntity */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cSignEntity_new00
|
||||
static int tolua_AllToLua_cSignEntity_new00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"cSignEntity",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
|
||||
{
|
||||
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,2,0));
|
||||
int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0));
|
||||
int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0));
|
||||
int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0));
|
||||
{
|
||||
cSignEntity* tolua_ret = (cSignEntity*) Mtolua_new((cSignEntity)(a_BlockType,a_BlockX,a_BlockY,a_BlockZ));
|
||||
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cSignEntity");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: new_local of class cSignEntity */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cSignEntity_new00_local
|
||||
static int tolua_AllToLua_cSignEntity_new00_local(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertable(tolua_S,1,"cSignEntity",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
|
||||
{
|
||||
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,2,0));
|
||||
int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0));
|
||||
int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0));
|
||||
int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0));
|
||||
{
|
||||
cSignEntity* tolua_ret = (cSignEntity*) Mtolua_new((cSignEntity)(a_BlockType,a_BlockX,a_BlockY,a_BlockZ));
|
||||
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cSignEntity");
|
||||
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: SetLines of class cSignEntity */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cSignEntity_SetLines00
|
||||
static int tolua_AllToLua_cSignEntity_SetLines00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"cSignEntity",0,&tolua_err) ||
|
||||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
|
||||
!tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
|
||||
!tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,6,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cSignEntity* self = (cSignEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,2,0));
|
||||
const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,3,0));
|
||||
const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,4,0));
|
||||
const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,5,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLines'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->SetLines(a_Line1,a_Line2,a_Line3,a_Line4);
|
||||
tolua_pushcppstring(tolua_S,(const char*)a_Line1);
|
||||
tolua_pushcppstring(tolua_S,(const char*)a_Line2);
|
||||
tolua_pushcppstring(tolua_S,(const char*)a_Line3);
|
||||
tolua_pushcppstring(tolua_S,(const char*)a_Line4);
|
||||
}
|
||||
}
|
||||
return 4;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'SetLines'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: SetLine of class cSignEntity */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cSignEntity_SetLine00
|
||||
static int tolua_AllToLua_cSignEntity_SetLine00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"cSignEntity",0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,4,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cSignEntity* self = (cSignEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
int a_Index = ((int) tolua_tonumber(tolua_S,2,0));
|
||||
const AString a_Line = ((const AString) tolua_tocppstring(tolua_S,3,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLine'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->SetLine(a_Index,a_Line);
|
||||
tolua_pushcppstring(tolua_S,(const char*)a_Line);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'SetLine'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: GetLine of class cSignEntity */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cSignEntity_GetLine00
|
||||
static int tolua_AllToLua_cSignEntity_GetLine00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"const cSignEntity",0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const cSignEntity* self = (const cSignEntity*) tolua_tousertype(tolua_S,1,0);
|
||||
int a_Index = ((int) tolua_tonumber(tolua_S,2,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLine'", NULL);
|
||||
#endif
|
||||
{
|
||||
AString tolua_ret = (AString) self->GetLine(a_Index);
|
||||
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'GetLine'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* get function: Name of class HTTPFormData */
|
||||
#ifndef TOLUA_DISABLE_tolua_get_HTTPFormData_Name
|
||||
static int tolua_get_HTTPFormData_Name(lua_State* tolua_S)
|
||||
@ -27889,6 +28124,44 @@ tolua_lerror:
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: GetBlockEntity of class cChunkDesc */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_GetBlockEntity00
|
||||
static int tolua_AllToLua_cChunkDesc_GetBlockEntity00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"cChunkDesc",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_isnoobj(tolua_S,5,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cChunkDesc* self = (cChunkDesc*) tolua_tousertype(tolua_S,1,0);
|
||||
int a_RelX = ((int) tolua_tonumber(tolua_S,2,0));
|
||||
int a_RelY = ((int) tolua_tonumber(tolua_S,3,0));
|
||||
int a_RelZ = ((int) tolua_tonumber(tolua_S,4,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockEntity'", NULL);
|
||||
#endif
|
||||
{
|
||||
cBlockEntity* tolua_ret = (cBlockEntity*) self->GetBlockEntity(a_RelX,a_RelY,a_RelZ);
|
||||
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cBlockEntity");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'GetBlockEntity'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: new of class cCraftingGrid */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_new00
|
||||
static int tolua_AllToLua_cCraftingGrid_new00(lua_State* tolua_S)
|
||||
@ -30869,6 +31142,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
||||
tolua_cclass(tolua_S,"cBlockEntity","cBlockEntity","",NULL);
|
||||
#endif
|
||||
tolua_beginmodule(tolua_S,"cBlockEntity");
|
||||
tolua_function(tolua_S,"CreateByBlockType",tolua_AllToLua_cBlockEntity_CreateByBlockType00);
|
||||
tolua_function(tolua_S,"GetPosX",tolua_AllToLua_cBlockEntity_GetPosX00);
|
||||
tolua_function(tolua_S,"GetPosY",tolua_AllToLua_cBlockEntity_GetPosY00);
|
||||
tolua_function(tolua_S,"GetPosZ",tolua_AllToLua_cBlockEntity_GetPosZ00);
|
||||
@ -30965,6 +31239,19 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
||||
tolua_function(tolua_S,"new_local",tolua_AllToLua_cHopperEntity_new00_local);
|
||||
tolua_function(tolua_S,".call",tolua_AllToLua_cHopperEntity_new00_local);
|
||||
tolua_endmodule(tolua_S);
|
||||
#ifdef __cplusplus
|
||||
tolua_cclass(tolua_S,"cSignEntity","cSignEntity","cBlockEntity",tolua_collect_cSignEntity);
|
||||
#else
|
||||
tolua_cclass(tolua_S,"cSignEntity","cSignEntity","cBlockEntity",NULL);
|
||||
#endif
|
||||
tolua_beginmodule(tolua_S,"cSignEntity");
|
||||
tolua_function(tolua_S,"new",tolua_AllToLua_cSignEntity_new00);
|
||||
tolua_function(tolua_S,"new_local",tolua_AllToLua_cSignEntity_new00_local);
|
||||
tolua_function(tolua_S,".call",tolua_AllToLua_cSignEntity_new00_local);
|
||||
tolua_function(tolua_S,"SetLines",tolua_AllToLua_cSignEntity_SetLines00);
|
||||
tolua_function(tolua_S,"SetLine",tolua_AllToLua_cSignEntity_SetLine00);
|
||||
tolua_function(tolua_S,"GetLine",tolua_AllToLua_cSignEntity_GetLine00);
|
||||
tolua_endmodule(tolua_S);
|
||||
tolua_cclass(tolua_S,"HTTPFormData","HTTPFormData","",NULL);
|
||||
tolua_beginmodule(tolua_S,"HTTPFormData");
|
||||
tolua_variable(tolua_S,"Name",tolua_get_HTTPFormData_Name,tolua_set_HTTPFormData_Name);
|
||||
@ -31345,6 +31632,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
||||
tolua_function(tolua_S,"FloorRelCuboid",tolua_AllToLua_cChunkDesc_FloorRelCuboid01);
|
||||
tolua_function(tolua_S,"RandomFillRelCuboid",tolua_AllToLua_cChunkDesc_RandomFillRelCuboid00);
|
||||
tolua_function(tolua_S,"RandomFillRelCuboid",tolua_AllToLua_cChunkDesc_RandomFillRelCuboid01);
|
||||
tolua_function(tolua_S,"GetBlockEntity",tolua_AllToLua_cChunkDesc_GetBlockEntity00);
|
||||
tolua_endmodule(tolua_S);
|
||||
#ifdef __cplusplus
|
||||
tolua_cclass(tolua_S,"cCraftingGrid","cCraftingGrid","",tolua_collect_cCraftingGrid);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 11/14/13 16:18:41.
|
||||
** Generated automatically by tolua++-1.0.92 on 11/14/13 15:31:52.
|
||||
*/
|
||||
|
||||
/* Exported function */
|
||||
|
44
source/BlockEntities/BlockEntity.cpp
Normal file
44
source/BlockEntities/BlockEntity.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
// BlockEntity.cpp
|
||||
|
||||
// Implements the cBlockEntity class that is the common ancestor for all block entities
|
||||
|
||||
#include "Globals.h"
|
||||
#include "BlockEntity.h"
|
||||
#include "ChestEntity.h"
|
||||
#include "DispenserEntity.h"
|
||||
#include "DropperEntity.h"
|
||||
#include "FurnaceEntity.h"
|
||||
#include "HopperEntity.h"
|
||||
#include "JukeboxEntity.h"
|
||||
#include "NoteEntity.h"
|
||||
#include "SignEntity.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
|
||||
{
|
||||
switch (a_BlockType)
|
||||
{
|
||||
case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
|
||||
case E_BLOCK_DISPENSER: return new cDispenserEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
|
||||
case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
|
||||
case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
|
||||
case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
|
||||
case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
|
||||
case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
|
||||
case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
|
||||
case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
|
||||
case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
|
||||
}
|
||||
LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)",
|
||||
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
|
||||
);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -49,6 +49,11 @@ public:
|
||||
|
||||
// tolua_begin
|
||||
|
||||
/// Creates a new block entity for the specified block type
|
||||
/// If a_World is valid, then the entity is created bound to that world
|
||||
/// Returns NULL for unknown block types
|
||||
static cBlockEntity * CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World = NULL);
|
||||
|
||||
// Position, in absolute block coordinates:
|
||||
int GetPosX(void) const { return m_PosX; }
|
||||
int GetPosY(void) const { return m_PosY; }
|
||||
|
@ -9,9 +9,19 @@
|
||||
|
||||
|
||||
|
||||
cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
|
||||
: cBlockEntity(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, a_World)
|
||||
, m_Record( 0 )
|
||||
cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
||||
super(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, NULL),
|
||||
m_Record(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
|
||||
super(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, a_World),
|
||||
m_Record(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,12 @@ namespace Json
|
||||
class cJukeboxEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
public:
|
||||
|
||||
/// Creates a new jukebox entity that is not assigned to a world
|
||||
cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
virtual ~cJukeboxEntity();
|
||||
|
||||
|
@ -6,9 +6,12 @@
|
||||
#include <json/json.h>
|
||||
|
||||
|
||||
cNoteEntity::cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
|
||||
: cBlockEntity(E_BLOCK_NOTE_BLOCK, a_BlockX, a_BlockY, a_BlockZ, a_World)
|
||||
, m_Pitch( 0 )
|
||||
|
||||
|
||||
|
||||
cNoteEntity::cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
||||
super(E_BLOCK_NOTE_BLOCK, a_BlockX, a_BlockY, a_BlockZ, NULL),
|
||||
m_Pitch(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -16,7 +19,9 @@ cNoteEntity::cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_Wo
|
||||
|
||||
|
||||
|
||||
cNoteEntity::~cNoteEntity()
|
||||
cNoteEntity::cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
|
||||
super(E_BLOCK_NOTE_BLOCK, a_BlockX, a_BlockY, a_BlockZ, a_World),
|
||||
m_Pitch(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,13 @@ enum ENUM_NOTE_INSTRUMENTS
|
||||
class cNoteEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
public:
|
||||
|
||||
/// Creates a new note entity that is not assigned to a world
|
||||
cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
||||
virtual ~cNoteEntity();
|
||||
|
||||
bool LoadFromJson( const Json::Value& a_Value );
|
||||
virtual void SaveToJson( Json::Value& a_Value ) override;
|
||||
|
@ -1,21 +1,19 @@
|
||||
|
||||
// SignEntity.cpp
|
||||
|
||||
// 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 "SignEntity.h"
|
||||
|
||||
#include "../Entities/Player.h"
|
||||
// #include "ClientHandle.h"
|
||||
// #include "World.h"
|
||||
// #include "Root.h"
|
||||
|
||||
#include <json/json.h>
|
||||
#include "SignEntity.h"
|
||||
#include "../Entities/Player.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World)
|
||||
: cBlockEntity(a_BlockType, a_X, a_Y, a_Z, a_World)
|
||||
cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ) :
|
||||
super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -23,7 +21,8 @@ cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorl
|
||||
|
||||
|
||||
|
||||
cSignEntity::~cSignEntity()
|
||||
cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World) :
|
||||
super(a_BlockType, a_X, a_Y, a_Z, a_World)
|
||||
{
|
||||
}
|
||||
|
||||
@ -32,16 +31,16 @@ cSignEntity::~cSignEntity()
|
||||
|
||||
|
||||
// It don't do anything when 'used'
|
||||
void cSignEntity::UsedBy( cPlayer * a_Player )
|
||||
void cSignEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
(void)a_Player;
|
||||
UNUSED(a_Player);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cSignEntity::SetLines( const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4 )
|
||||
void cSignEntity::SetLines(const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
|
||||
{
|
||||
m_Line[0] = a_Line1;
|
||||
m_Line[1] = a_Line2;
|
||||
@ -53,25 +52,28 @@ void cSignEntity::SetLines( const AString & a_Line1, const AString & a_Line2, co
|
||||
|
||||
|
||||
|
||||
void cSignEntity::SetLine( int a_Index, const AString & a_Line )
|
||||
void cSignEntity::SetLine(int a_Index, const AString & a_Line)
|
||||
{
|
||||
if( a_Index < 4 && a_Index > -1 )
|
||||
if ((a_Index < 0) || (a_Index >= ARRAYCOUNT(m_Line)))
|
||||
{
|
||||
m_Line[a_Index] = a_Line;
|
||||
LOGWARNING("%s: setting a non-existent line %d (value \"%s\"", __FUNCTION__, a_Index, a_Line.c_str());
|
||||
return;
|
||||
}
|
||||
m_Line[a_Index] = a_Line;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AString cSignEntity::GetLine( int a_Index ) const
|
||||
AString cSignEntity::GetLine(int a_Index) const
|
||||
{
|
||||
if( a_Index < 4 && a_Index > -1 )
|
||||
if ((a_Index < 0) || (a_Index >= ARRAYCOUNT(m_Line)))
|
||||
{
|
||||
return m_Line[a_Index];
|
||||
LOGWARNING("%s: requesting a non-existent line %d", __FUNCTION__, a_Index);
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
return m_Line[a_Index];
|
||||
}
|
||||
|
||||
|
||||
@ -87,19 +89,7 @@ void cSignEntity::SendTo(cClientHandle & a_Client)
|
||||
|
||||
|
||||
|
||||
#define READ(File, Var) \
|
||||
if (File.Read(&Var, sizeof(Var)) != sizeof(Var)) \
|
||||
{ \
|
||||
LOGERROR("ERROR READING cSignEntity %s FROM FILE (line %d)", #Var, __LINE__); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cSignEntity::LoadFromJson( const Json::Value & a_Value )
|
||||
bool cSignEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
@ -113,7 +103,11 @@ bool cSignEntity::LoadFromJson( const Json::Value & a_Value )
|
||||
return true;
|
||||
}
|
||||
|
||||
void cSignEntity::SaveToJson( Json::Value & a_Value )
|
||||
|
||||
|
||||
|
||||
|
||||
void cSignEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
|
@ -1,4 +1,12 @@
|
||||
|
||||
// SignEntity.h
|
||||
|
||||
// Declares the cSignEntity class representing a single sign in the world
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BlockEntity.h"
|
||||
@ -13,28 +21,49 @@ namespace Json
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
|
||||
class cSignEntity :
|
||||
public cBlockEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
||||
public:
|
||||
|
||||
/// Creates a new empty sign entity at the specified block coords and block type (wall or standing)
|
||||
/// Used mainly by plugins while generating chunks
|
||||
cSignEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
// tolua_end
|
||||
|
||||
cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
|
||||
virtual ~cSignEntity();
|
||||
|
||||
bool LoadFromJson( const Json::Value& a_Value );
|
||||
virtual void SaveToJson(Json::Value& a_Value ) override;
|
||||
|
||||
void SetLines( const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4 );
|
||||
void SetLine( int a_Index, const AString & a_Line );
|
||||
// tolua_begin
|
||||
|
||||
AString GetLine( int a_Index ) const;
|
||||
/// Sets all the sign's lines
|
||||
void SetLines(const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
|
||||
|
||||
virtual void UsedBy( cPlayer * a_Player ) override;
|
||||
/// Sets individual line (zero-based index)
|
||||
void SetLine(int a_Index, const AString & a_Line);
|
||||
|
||||
/// Retrieves individual line (zero-based index)
|
||||
AString GetLine(int a_Index) const;
|
||||
|
||||
// tolua_end
|
||||
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
|
||||
private:
|
||||
|
||||
AString m_Line[4];
|
||||
};
|
||||
} ; // tolua_export
|
||||
|
||||
|
||||
|
||||
|
@ -1261,75 +1261,22 @@ void cChunk::CreateBlockEntities(void)
|
||||
switch (BlockType)
|
||||
{
|
||||
case E_BLOCK_CHEST:
|
||||
{
|
||||
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||
{
|
||||
m_BlockEntities.push_back(new cChestEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_DISPENSER:
|
||||
{
|
||||
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||
{
|
||||
m_BlockEntities.push_back(new cDispenserEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_DROPPER:
|
||||
{
|
||||
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||
{
|
||||
m_BlockEntities.push_back(new cDropperEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_LIT_FURNACE:
|
||||
case E_BLOCK_FURNACE:
|
||||
{
|
||||
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||
{
|
||||
NIBBLETYPE BlockMeta = cChunkDef::GetNibble(m_BlockMeta, x, y, z);
|
||||
m_BlockEntities.push_back(new cFurnaceEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, BlockType, BlockMeta, m_World));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_HOPPER:
|
||||
{
|
||||
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||
{
|
||||
m_BlockEntities.push_back(new cHopperEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
|
||||
}
|
||||
}
|
||||
|
||||
case E_BLOCK_SIGN_POST:
|
||||
case E_BLOCK_WALLSIGN:
|
||||
{
|
||||
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||
{
|
||||
m_BlockEntities.push_back( new cSignEntity(BlockType, x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_NOTE_BLOCK:
|
||||
{
|
||||
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||
{
|
||||
m_BlockEntities.push_back(new cNoteEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_JUKEBOX:
|
||||
{
|
||||
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||
{
|
||||
m_BlockEntities.push_back(new cJukeboxEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
|
||||
m_BlockEntities.push_back(cBlockEntity::CreateByBlockType(
|
||||
BlockType, GetMeta(x, y, z),
|
||||
x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1426,45 +1373,17 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType,
|
||||
switch (a_BlockType)
|
||||
{
|
||||
case E_BLOCK_CHEST:
|
||||
{
|
||||
AddBlockEntity(new cChestEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||
break;
|
||||
}
|
||||
case E_BLOCK_DISPENSER:
|
||||
{
|
||||
AddBlockEntity(new cDispenserEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||
break;
|
||||
}
|
||||
case E_BLOCK_DROPPER:
|
||||
{
|
||||
AddBlockEntity(new cDropperEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||
break;
|
||||
}
|
||||
case E_BLOCK_LIT_FURNACE:
|
||||
case E_BLOCK_FURNACE:
|
||||
{
|
||||
AddBlockEntity(new cFurnaceEntity(WorldPos.x, WorldPos.y, WorldPos.z, a_BlockType, a_BlockMeta, m_World));
|
||||
break;
|
||||
}
|
||||
case E_BLOCK_HOPPER:
|
||||
{
|
||||
AddBlockEntity(new cHopperEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||
break;
|
||||
}
|
||||
case E_BLOCK_SIGN_POST:
|
||||
case E_BLOCK_WALLSIGN:
|
||||
{
|
||||
AddBlockEntity(new cSignEntity(a_BlockType, WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||
break;
|
||||
}
|
||||
case E_BLOCK_NOTE_BLOCK:
|
||||
{
|
||||
AddBlockEntity(new cNoteEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||
break;
|
||||
}
|
||||
case E_BLOCK_JUKEBOX:
|
||||
{
|
||||
AddBlockEntity(new cJukeboxEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||
AddBlockEntity(cBlockEntity::CreateByBlockType(a_BlockType, a_BlockMeta, WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||
break;
|
||||
}
|
||||
} // switch (a_BlockType)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "../BlockArea.h"
|
||||
#include "../Cuboid.h"
|
||||
#include "../Noise.h"
|
||||
#include "../BlockEntities/BlockEntity.h"
|
||||
|
||||
|
||||
|
||||
@ -526,9 +527,28 @@ void cChunkDesc::RandomFillRelCuboid(
|
||||
|
||||
|
||||
|
||||
void cChunkDesc::AddBlockEntity(cBlockEntity * a_BlockEntity)
|
||||
cBlockEntity * cChunkDesc::GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ)
|
||||
{
|
||||
m_BlockEntities.push_back(a_BlockEntity);
|
||||
int AbsX = a_RelX + m_ChunkX * cChunkDef::Width;
|
||||
int AbsZ = a_RelZ + m_ChunkZ * cChunkDef::Width;
|
||||
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), end = m_BlockEntities.end(); itr != end; ++itr)
|
||||
{
|
||||
if (((*itr)->GetPosX() == AbsX) && ((*itr)->GetPosY() == a_RelY) && ((*itr)->GetPosZ() == AbsZ))
|
||||
{
|
||||
// Already in the list, return it:
|
||||
return *itr;
|
||||
}
|
||||
} // for itr - m_BlockEntities[]
|
||||
|
||||
// The block entity is not created yet, try to create it and add to list:
|
||||
cBlockEntity * be = cBlockEntity::CreateByBlockType(GetBlockType(a_RelX, a_RelY, a_RelZ), GetBlockMeta(a_RelX, a_RelY, a_RelZ), AbsX, a_RelY, AbsZ);
|
||||
if (be == NULL)
|
||||
{
|
||||
// No block entity for this block type
|
||||
return NULL;
|
||||
}
|
||||
m_BlockEntities.push_back(be);
|
||||
return be;
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,9 +170,12 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
// tolua_end
|
||||
/// Returns the block entity at the specified coords.
|
||||
/// If there is no block entity at those coords, tries to create one, based on the block type
|
||||
/// If the blocktype doesn't support a block entity, returns NULL.
|
||||
cBlockEntity * GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ);
|
||||
|
||||
void AddBlockEntity(cBlockEntity * a_BlockEntity);
|
||||
// tolua_end
|
||||
|
||||
// Accessors used by cChunkGenerator::Generator descendants:
|
||||
inline cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; }
|
||||
|
@ -794,12 +794,12 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
|
||||
)
|
||||
{
|
||||
a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, Meta);
|
||||
cChestEntity * ChestEntity = new cChestEntity(BlockX + x, m_BoundingBox.p1.y + 1, BlockZ + z);
|
||||
cChestEntity * ChestEntity = (cChestEntity *)a_ChunkDesc.GetBlockEntity(x, m_BoundingBox.p1.y + 1, z);
|
||||
ASSERT((ChestEntity != NULL) && (ChestEntity->GetBlockType() == E_BLOCK_CHEST));
|
||||
cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
|
||||
int NumSlots = 3 + ((Noise.IntNoise3DInt(x, m_BoundingBox.p1.y, z) / 11) % 4);
|
||||
int Seed = Noise.IntNoise2DInt(x, z);
|
||||
ChestEntity->GetContents().GenerateRandomLootWithBooks(LootProbab, ARRAYCOUNT(LootProbab), NumSlots, Seed);
|
||||
a_ChunkDesc.AddBlockEntity(ChestEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user