Skip to content

Commit

Permalink
Exported cFallingBlock and cExpOrb (cuberite#3700)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seadragon91 authored and madmaxoft committed May 9, 2017
1 parent 3d5ee3e commit 7c4576a
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 6 deletions.
89 changes: 88 additions & 1 deletion Server/Plugins/APIDump/APIDesc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6004,6 +6004,10 @@ local Hash = cCryptoHash.sha1HexString("DataToHash")
},
Constants =
{
INVALID_ID =
{
Notes = "Special value of an entity ID, indicating a failure. Used primarily in functions that create entities when the entity cannot be created.",
},
etBoat =
{
Notes = "The entity is a {{cBoat}}",
Expand Down Expand Up @@ -10922,12 +10926,95 @@ a_Player:OpenWindow(Window);
},
Inherits = "cEntity",
},
cExpOrb =
{
Desc = [[
This class represents an experience orb. This entity can be spawned by using {{cWorld#SpawnExperienceOrb_1|cWorld:SpawnExperienceOrb}}.
It's also spawned when a monster is killed or a player is mining coal. The default lifetime of an experience orb is 5 mins.
]],
Functions =
{
GetAge =
{
Returns =
{
{
Type = "number"
},
},
Notes = "Returns the number of ticks that this experience orb has existed.",
},
SetAge =
{
Params =
{
{
Type = "number",
},
},
Notes = "Sets the experience orb's age, in ticks.",
},
GetReward =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the experience amount.",
},
SetReward =
{
Params =
{
{
Type = "number",
},
},
Notes = "Sets the experience amount.",
},
},
Inherits = "cEntity",
},
cFallingBlock =
{
Desc = [[
This class represents a falling block. This entity can be spawned by using {{cWorld#SpawnFallingBlock_1|cWorld:SpawnFallingBlock}}.
]],
Functions =
{
GetBlockType =
{
Returns =
{
{
Name = "BlockType",
Type = "number",
}
},
Notes = "Returns the block type of the falling block.",
},
GetBlockMeta =
{
Returns =
{
{
Name = "BlockMeta",
Type = "number",
}
},
Notes = "Returns the block meta of the falling block.",
},
},
Inherits = "cEntity",
},
cPickup =
{
Desc = [[
This class represents a pickup entity (an item that the player or mobs can pick up). It is also
commonly known as "drops". With this class you could create your own "drop" or modify those
created automatically.
created automatically. The default lifetime of a pickup is 5 mins.
]],
Functions =
{
Expand Down
2 changes: 2 additions & 0 deletions src/Bindings/AllToLua.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ $cfile "../Entities/ProjectileEntity.h"
$cfile "../Entities/ArrowEntity.h"
$cfile "../Entities/EntityEffect.h"
$cfile "../Entities/ExpBottleEntity.h"
$cfile "../Entities/ExpOrb.h"
$cfile "../Entities/FallingBlock.h"
$cfile "../Entities/FireChargeEntity.h"
$cfile "../Entities/FireworkEntity.h"
$cfile "../Entities/Floater.h"
Expand Down
2 changes: 2 additions & 0 deletions src/Bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ set(BINDING_DEPENDENCIES
../Enchantments.h
../Entities/ArrowEntity.h
../Entities/Entity.h
../Entities/ExpOrb.h
../Entities/EntityEffect.h
../Entities/ExpBottleEntity.h
../Entities/FallingBlock.h
../Entities/FireChargeEntity.h
../Entities/FireworkEntity.h
../Entities/Floater.h
Expand Down
12 changes: 8 additions & 4 deletions src/Entities/ExpOrb.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ class cExpOrb :
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void SpawnOn(cClientHandle & a_Client) override;

// tolua_begin

/** Returns the number of ticks that this entity has existed */
int GetAge(void) const { return std::chrono::duration_cast<cTickTime>(m_Timer).count(); } // tolua_export
int GetAge(void) const { return std::chrono::duration_cast<cTickTime>(m_Timer).count(); }

/** Set the number of ticks that this entity has existed */
void SetAge(int a_Age) { m_Timer = cTickTime(a_Age); } // tolua_export
void SetAge(int a_Age) { m_Timer = cTickTime(a_Age); }

/** Get the exp amount */
int GetReward(void) const { return m_Reward; } // tolua_export
int GetReward(void) const { return m_Reward; }

/** Set the exp amount */
void SetReward(int a_Reward) { m_Reward = a_Reward; } // tolua_export
void SetReward(int a_Reward) { m_Reward = a_Reward; }

// tolua_end

protected:
int m_Reward;
Expand Down
9 changes: 8 additions & 1 deletion src/Entities/FallingBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,28 @@ class cItem;



// tolua_begin

class cFallingBlock :
public cEntity
{
typedef cEntity super;

public:
// tolua_end

CLASS_PROTODEF(cFallingBlock)

/** Creates a new falling block. a_BlockPosition is expected in world coords */
cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);

// tolua_begin

BLOCKTYPE GetBlockType(void) const { return m_BlockType; }
NIBBLETYPE GetBlockMeta(void) const { return m_BlockMeta; }

// tolua_end

// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
Expand All @@ -36,7 +43,7 @@ class cFallingBlock :
BLOCKTYPE m_BlockType;
NIBBLETYPE m_BlockMeta;
Vector3i m_OriginalPosition; // Position where the falling block has started, in world coords
} ;
} ; // tolua_export



Expand Down

0 comments on commit 7c4576a

Please sign in to comment.