summaryrefslogtreecommitdiffstats
path: root/src/BlockInfo.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockInfo.h')
-rw-r--r--src/BlockInfo.h111
1 files changed, 29 insertions, 82 deletions
diff --git a/src/BlockInfo.h b/src/BlockInfo.h
index 8962f6328..7a25e6760 100644
--- a/src/BlockInfo.h
+++ b/src/BlockInfo.h
@@ -6,42 +6,11 @@
+
// tolua_begin
class cBlockInfo
{
public:
- // tolua_end
-
- /** The block type associated with this cBlockInfo. Needed for DeprecatedBindings.cpp */
- BLOCKTYPE m_BlockType;
-
- /** Returns the associated BlockInfo structure for the specified block 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. */
- inline static const cBlockInfo & Get(BLOCKTYPE a_Type);
-
- // tolua_begin
-
- inline static NIBBLETYPE GetLightValue (BLOCKTYPE a_Type) { return Get(a_Type).m_LightValue; }
- inline static NIBBLETYPE GetSpreadLightFalloff(BLOCKTYPE a_Type) { return Get(a_Type).m_SpreadLightFalloff; }
- inline static bool IsTransparent (BLOCKTYPE a_Type) { return Get(a_Type).m_Transparent; }
- /** Warning: IsOneHitDig does not take into account enchantments / status effects / swim state / floating state
- and therefore may be incorrect. Only use to check if hardness is 0
- If you want to check if a player would instantly mine a_Block use cPlayer::CanInstantlyMine(a_Block) */
- inline static bool IsOneHitDig (BLOCKTYPE a_Type) { return Get(a_Type).m_OneHitDig; }
- inline static bool IsPistonBreakable (BLOCKTYPE a_Type) { return Get(a_Type).m_PistonBreakable; }
- inline static bool IsRainBlocker (BLOCKTYPE a_Type) { return Get(a_Type).m_IsRainBlocker; }
- inline static bool IsSkylightDispersant (BLOCKTYPE a_Type)
- {
- return ((Get(a_Type).m_IsSkylightDispersant) || (Get(a_Type).m_SpreadLightFalloff > 1));
- }
- static bool IsSnowable(BLOCKTYPE a_Type);
- inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; }
- inline static bool IsUseableBySpectator (BLOCKTYPE a_Type) { return Get(a_Type).m_UseableBySpectator; }
- inline static bool FullyOccupiesVoxel (BLOCKTYPE a_Type) { return Get(a_Type).m_FullyOccupiesVoxel; }
- inline static bool CanBeTerraformed (BLOCKTYPE a_Type) { return Get(a_Type).m_CanBeTerraformed; }
- inline static float GetBlockHeight (BLOCKTYPE a_Type) { return Get(a_Type).m_BlockHeight; }
- inline static float GetHardness (BLOCKTYPE a_Type) { return Get(a_Type).m_Hardness; }
// tolua_end
@@ -49,53 +18,53 @@ public:
See Physics\Explodinator.cpp for details of explosion block destruction. */
static float GetExplosionAbsorption(BLOCKTYPE Block);
- /** Creates a default BlockInfo structure, initializes all values to their defaults */
- cBlockInfo();
-
-private:
-
- /** Storage for all the BlockInfo structures. */
- class cBlockInfoArray;
+ // tolua_begin
/** How much light do the blocks emit on their own? */
- NIBBLETYPE m_LightValue;
+ static NIBBLETYPE GetLightValue(BLOCKTYPE Block);
/** How much light do the blocks consume? */
- NIBBLETYPE m_SpreadLightFalloff;
+ static NIBBLETYPE GetSpreadLightFalloff(BLOCKTYPE Block);
- /** Is a block transparent? (https://minecraft.gamepedia.com/Opacity) */
- bool m_Transparent;
+ /** Can a finisher change it? */
+ static bool CanBeTerraformed(BLOCKTYPE Block);
- /** Is a block destroyed after a single hit? */
- bool m_OneHitDig;
+ /** Does this block fully occupy its voxel - is it a 'full' block? */
+ static bool FullyOccupiesVoxel(BLOCKTYPE Block);
+
+ /** Is a block destroyed after a single hit?
+ Warning: IsOneHitDig does not take into account enchantments / status effects / swim state / floating state
+ and therefore may be incorrect. Only use to check if hardness is 0.
+ If you want to check if a player would instantly mine a_Block use cPlayer::CanInstantlyMine(a_Block) */
+ static bool IsOneHitDig(BLOCKTYPE Block);
/** Can a piston break this block? */
- bool m_PistonBreakable;
+ static bool IsPistonBreakable(BLOCKTYPE Block);
/** Does this block block the passage of rain? */
- bool m_IsRainBlocker;
+ static bool IsRainBlocker(BLOCKTYPE Block);
/** Does this block disperse sky light? (only relevant for transparent blocks) */
- bool m_IsSkylightDispersant;
+ static bool IsSkylightDispersant(BLOCKTYPE Block);
- /** Is this block solid (player cannot walk through)? */
- bool m_IsSolid;
+ static bool IsSnowable(BLOCKTYPE Block);
- /** Can a spectator interact with this block */
- bool m_UseableBySpectator;
+ /** Is this block solid (player cannot walk through)? */
+ static bool IsSolid(BLOCKTYPE Block);
- /** Does this block fully occupy its voxel - is it a 'full' block? */
- bool m_FullyOccupiesVoxel;
+ /** Is a block transparent? (https://minecraft.gamepedia.com/Opacity) */
+ static bool IsTransparent(BLOCKTYPE Block);
- /** Can a finisher change it? */
- bool m_CanBeTerraformed;
+ /** Can a spectator interact with this block? */
+ static bool IsUseableBySpectator(BLOCKTYPE Block);
- /** Block height */
- float m_BlockHeight;
+ /** Block's height. */
+ static float GetBlockHeight(BLOCKTYPE Block);
/** Block's hardness. The greater the value the longer the player needs to break the block. */
- float m_Hardness;
-}; // tolua_export
+ static float GetHardness(BLOCKTYPE Block);
+};
+// tolua_end
@@ -130,25 +99,3 @@ bool IsBlockMaterialLeaves(BLOCKTYPE a_BlockType);
bool IsBlockMaterialGourd(BLOCKTYPE a_BlockType);
bool IsBlockMaterialRock(BLOCKTYPE a_BlockType);
-
-
-
-
-
-class cBlockInfo::cBlockInfoArray:
- public std::array<cBlockInfo, 256>
-{
-public:
- /** Initializes the contained BlockInfo structures with block-specific values. */
- cBlockInfoArray();
-};
-
-
-
-
-
-inline const cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
-{
- static const cBlockInfoArray ms_Info;
- return ms_Info[a_Type];
-}