summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-11-14 16:05:55 +0100
committermadmaxoft <github@xoft.cz>2013-11-14 16:05:55 +0100
commitefb6f598bca3b5dc024c7dc9c707f7efed71ef7d (patch)
tree8306fff44b178e00bd6e95f049c6663f91dcfc89 /source
parentAdded cSignEntity into API, added cChunkDesc:GetBlockEntity(). (diff)
downloadcuberite-efb6f598bca3b5dc024c7dc9c707f7efed71ef7d.tar
cuberite-efb6f598bca3b5dc024c7dc9c707f7efed71ef7d.tar.gz
cuberite-efb6f598bca3b5dc024c7dc9c707f7efed71ef7d.tar.bz2
cuberite-efb6f598bca3b5dc024c7dc9c707f7efed71ef7d.tar.lz
cuberite-efb6f598bca3b5dc024c7dc9c707f7efed71ef7d.tar.xz
cuberite-efb6f598bca3b5dc024c7dc9c707f7efed71ef7d.tar.zst
cuberite-efb6f598bca3b5dc024c7dc9c707f7efed71ef7d.zip
Diffstat (limited to 'source')
-rw-r--r--source/AllToLua.pkg2
-rw-r--r--source/Bindings.cpp151
-rw-r--r--source/Bindings.h2
-rw-r--r--source/BlockEntities/JukeboxEntity.cpp38
-rw-r--r--source/BlockEntities/JukeboxEntity.h28
5 files changed, 180 insertions, 41 deletions
diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg
index f41ce8de3..ee594be1a 100644
--- a/source/AllToLua.pkg
+++ b/source/AllToLua.pkg
@@ -47,6 +47,8 @@ $cfile "BlockEntities/DispenserEntity.h"
$cfile "BlockEntities/DropperEntity.h"
$cfile "BlockEntities/FurnaceEntity.h"
$cfile "BlockEntities/HopperEntity.h"
+$cfile "BlockEntities/JukeboxEntity.h"
+$cfile "BlockEntities/NoteEntity.h"
$cfile "BlockEntities/SignEntity.h"
$cfile "WebAdmin.h"
$cfile "WebPlugin.h"
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 6ae121f19..fb84061b6 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 11/14/13 15:31:51.
+** Generated automatically by tolua++-1.0.92 on 11/14/13 15:39:43.
*/
#ifndef __cplusplus
@@ -46,6 +46,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
#include "BlockEntities/DropperEntity.h"
#include "BlockEntities/FurnaceEntity.h"
#include "BlockEntities/HopperEntity.h"
+#include "BlockEntities/JukeboxEntity.h"
+#include "BlockEntities/NoteEntity.h"
#include "BlockEntities/SignEntity.h"
#include "WebAdmin.h"
#include "WebPlugin.h"
@@ -245,6 +247,7 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cPluginManager");
tolua_usertype(tolua_S,"Vector3f");
tolua_usertype(tolua_S,"cCraftingRecipes");
+ tolua_usertype(tolua_S,"cJukeboxEntity");
tolua_usertype(tolua_S,"cChestEntity");
tolua_usertype(tolua_S,"cDispenserEntity");
tolua_usertype(tolua_S,"cGhastFireballEntity");
@@ -263,21 +266,21 @@ static void tolua_reg_types (lua_State* tolua_S)
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,"cGroup");
+ tolua_usertype(tolua_S,"cItem");
+ tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cArrowEntity");
tolua_usertype(tolua_S,"cDropSpenserEntity");
tolua_usertype(tolua_S,"cCraftingGrid");
- tolua_usertype(tolua_S,"HTTPRequest");
tolua_usertype(tolua_S,"cBlockArea");
- tolua_usertype(tolua_S,"cTracer");
+ tolua_usertype(tolua_S,"cGroup");
tolua_usertype(tolua_S,"cBoundingBox");
+ tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cCriticalSection");
tolua_usertype(tolua_S,"HTTPTemplateRequest");
tolua_usertype(tolua_S,"cServer");
- tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"cPlayer");
+ tolua_usertype(tolua_S,"HTTPFormData");
tolua_usertype(tolua_S,"cFile");
tolua_usertype(tolua_S,"cItems");
tolua_usertype(tolua_S,"cClientHandle");
@@ -288,7 +291,7 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cThrownEggEntity");
tolua_usertype(tolua_S,"cGroupManager");
tolua_usertype(tolua_S,"cWebAdmin");
- tolua_usertype(tolua_S,"cItem");
+ tolua_usertype(tolua_S,"HTTPRequest");
tolua_usertype(tolua_S,"cProjectileEntity");
tolua_usertype(tolua_S,"cSignEntity");
tolua_usertype(tolua_S,"cItemGrid::cListener");
@@ -18890,6 +18893,133 @@ static int tolua_AllToLua_cHopperEntity_new00_local(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetRecord of class cJukeboxEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cJukeboxEntity_GetRecord00
+static int tolua_AllToLua_cJukeboxEntity_GetRecord00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cJukeboxEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cJukeboxEntity* self = (cJukeboxEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRecord'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetRecord();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetRecord'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetRecord of class cJukeboxEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cJukeboxEntity_SetRecord00
+static int tolua_AllToLua_cJukeboxEntity_SetRecord00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cJukeboxEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cJukeboxEntity* self = (cJukeboxEntity*) tolua_tousertype(tolua_S,1,0);
+ int a_Record = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetRecord'", NULL);
+#endif
+ {
+ self->SetRecord(a_Record);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetRecord'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: PlayRecord of class cJukeboxEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cJukeboxEntity_PlayRecord00
+static int tolua_AllToLua_cJukeboxEntity_PlayRecord00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cJukeboxEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cJukeboxEntity* self = (cJukeboxEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'PlayRecord'", NULL);
+#endif
+ {
+ self->PlayRecord();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'PlayRecord'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: EjectRecord of class cJukeboxEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cJukeboxEntity_EjectRecord00
+static int tolua_AllToLua_cJukeboxEntity_EjectRecord00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cJukeboxEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cJukeboxEntity* self = (cJukeboxEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'EjectRecord'", NULL);
+#endif
+ {
+ self->EjectRecord();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'EjectRecord'.",&tolua_err);
+ return 0;
+#endif
+}
+#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)
@@ -31239,6 +31369,13 @@ 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);
+ tolua_cclass(tolua_S,"cJukeboxEntity","cJukeboxEntity","cBlockEntity",NULL);
+ tolua_beginmodule(tolua_S,"cJukeboxEntity");
+ tolua_function(tolua_S,"GetRecord",tolua_AllToLua_cJukeboxEntity_GetRecord00);
+ tolua_function(tolua_S,"SetRecord",tolua_AllToLua_cJukeboxEntity_SetRecord00);
+ tolua_function(tolua_S,"PlayRecord",tolua_AllToLua_cJukeboxEntity_PlayRecord00);
+ tolua_function(tolua_S,"EjectRecord",tolua_AllToLua_cJukeboxEntity_EjectRecord00);
+ tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cSignEntity","cSignEntity","cBlockEntity",tolua_collect_cSignEntity);
#else
diff --git a/source/Bindings.h b/source/Bindings.h
index 81a70a4a3..3fa84e215 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 11/14/13 15:31:52.
+** Generated automatically by tolua++-1.0.92 on 11/14/13 15:39:43.
*/
/* Exported function */
diff --git a/source/BlockEntities/JukeboxEntity.cpp b/source/BlockEntities/JukeboxEntity.cpp
index adf0f6af4..aca376dd3 100644
--- a/source/BlockEntities/JukeboxEntity.cpp
+++ b/source/BlockEntities/JukeboxEntity.cpp
@@ -9,16 +9,6 @@
-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)
@@ -31,11 +21,7 @@ cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld
cJukeboxEntity::~cJukeboxEntity()
{
- if (m_Record >= 2256 && m_Record <= 2267)
- {
- EjectRecord();
- m_Record = 0;
- }
+ EjectRecord();
}
@@ -54,10 +40,9 @@ void cJukeboxEntity::UsedBy(cPlayer * a_Player)
PlayRecord();
}
}
- else if (m_Record >= 2256 && m_Record <= 2267)
+ else
{
EjectRecord();
- m_Record = 0;
}
}
@@ -65,7 +50,7 @@ void cJukeboxEntity::UsedBy(cPlayer * a_Player)
-void cJukeboxEntity::PlayRecord( void )
+void cJukeboxEntity::PlayRecord(void)
{
m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, m_Record);
}
@@ -74,19 +59,26 @@ void cJukeboxEntity::PlayRecord( void )
-void cJukeboxEntity::EjectRecord( void )
+void cJukeboxEntity::EjectRecord(void)
{
+ if ((m_Record < E_ITEM_FIRST_DISC) || (m_Record > E_ITEM_LAST_DISC))
+ {
+ // There's no record here
+ return;
+ }
+
cItems Drops;
Drops.push_back(cItem(m_Record, 1, 0));
m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 8);
m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, 0);
+ m_Record = 0;
}
-int cJukeboxEntity::GetRecord( void )
+int cJukeboxEntity::GetRecord(void)
{
return m_Record;
}
@@ -95,7 +87,7 @@ int cJukeboxEntity::GetRecord( void )
-void cJukeboxEntity::SetRecord( int a_Record )
+void cJukeboxEntity::SetRecord(int a_Record)
{
m_Record = a_Record;
}
@@ -104,7 +96,7 @@ void cJukeboxEntity::SetRecord( int a_Record )
-bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value )
+bool cJukeboxEntity::LoadFromJson(const Json::Value & a_Value)
{
m_PosX = a_Value.get("x", 0).asInt();
m_PosY = a_Value.get("y", 0).asInt();
@@ -119,7 +111,7 @@ bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value )
-void cJukeboxEntity::SaveToJson( Json::Value & a_Value )
+void cJukeboxEntity::SaveToJson(Json::Value & a_Value)
{
a_Value["x"] = m_PosX;
a_Value["y"] = m_PosY;
diff --git a/source/BlockEntities/JukeboxEntity.h b/source/BlockEntities/JukeboxEntity.h
index 2dd61a403..fcafdc479 100644
--- a/source/BlockEntities/JukeboxEntity.h
+++ b/source/BlockEntities/JukeboxEntity.h
@@ -17,31 +17,39 @@ namespace Json
+// tolua_begin
+
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);
+ // tolua_end
cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cJukeboxEntity();
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson( Json::Value& a_Value ) override;
+ bool LoadFromJson(const Json::Value & a_Value);
+ virtual void SaveToJson(Json::Value & a_Value) override;
- int GetRecord( void );
- void SetRecord( int a_Record );
- void PlayRecord( void );
- void EjectRecord( void );
- virtual void UsedBy( cPlayer * a_Player ) override;
+ // tolua_begin
+
+ int GetRecord(void);
+ void SetRecord(int a_Record);
+ void PlayRecord(void);
+
+ /// Ejects the currently held record as a pickup. Does nothing when no record inserted.
+ void EjectRecord(void);
+
+ // tolua_end
+
+ virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override { };
private:
int m_Record;
-};
+} ; // tolua_end