2014-03-01 10:04:17 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-09-25 05:13:59 -04:00
|
|
|
#include "ChunkDef.h"
|
2014-03-01 10:04:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-02 03:50:24 -05:00
|
|
|
// tolua_begin
|
2014-03-01 14:34:19 -05:00
|
|
|
class cBlockInfo
|
2014-03-01 10:04:17 -05:00
|
|
|
{
|
|
|
|
public:
|
2018-02-20 05:43:28 -05:00
|
|
|
// tolua_end
|
2014-03-01 10:04:17 -05:00
|
|
|
|
2018-02-20 05:43:28 -05:00
|
|
|
/** The block type associated with this cBlockInfo. Needed for DeprecatedBindings.cpp */
|
|
|
|
BLOCKTYPE m_BlockType;
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2018-02-20 05:43:28 -05:00
|
|
|
/** Returns the associated BlockInfo structure for the specified block type.
|
|
|
|
This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
|
2017-07-03 12:34:27 -04:00
|
|
|
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable. */
|
2018-02-20 05:43:28 -05:00
|
|
|
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; }
|
2020-10-02 16:57:17 -04:00
|
|
|
/** 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) */
|
2018-02-20 05:43:28 -05:00
|
|
|
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));
|
|
|
|
}
|
2020-04-03 02:57:01 -04:00
|
|
|
static bool IsSnowable(BLOCKTYPE a_Type);
|
2018-02-20 05:43:28 -05:00
|
|
|
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
|
|
|
|
|
2020-09-12 14:57:44 -04:00
|
|
|
/** Returns how much of an explosion Destruction Lazor's (tm) intensity the given block attenuates.
|
|
|
|
See Physics\Explodinator.cpp for details of explosion block destruction. */
|
|
|
|
static float GetExplosionAbsorption(BLOCKTYPE Block);
|
|
|
|
|
2018-02-20 05:43:28 -05:00
|
|
|
/** Creates a default BlockInfo structure, initializes all values to their defaults */
|
2020-04-03 02:57:01 -04:00
|
|
|
cBlockInfo();
|
|
|
|
|
2018-02-20 05:43:28 -05:00
|
|
|
private:
|
2020-09-17 09:51:42 -04:00
|
|
|
|
2018-02-20 05:43:28 -05:00
|
|
|
/** Storage for all the BlockInfo structures. */
|
|
|
|
class cBlockInfoArray;
|
2014-03-01 14:34:19 -05:00
|
|
|
|
|
|
|
/** How much light do the blocks emit on their own? */
|
2014-03-01 10:04:17 -05:00
|
|
|
NIBBLETYPE m_LightValue;
|
2014-03-01 14:34:19 -05:00
|
|
|
|
|
|
|
/** How much light do the blocks consume? */
|
2014-03-01 10:04:17 -05:00
|
|
|
NIBBLETYPE m_SpreadLightFalloff;
|
|
|
|
|
2017-09-07 06:56:17 -04:00
|
|
|
/** Is a block transparent? (https://minecraft.gamepedia.com/Opacity) */
|
2014-03-01 10:04:17 -05:00
|
|
|
bool m_Transparent;
|
2014-03-01 14:34:19 -05:00
|
|
|
|
|
|
|
/** Is a block destroyed after a single hit? */
|
2014-03-01 10:04:17 -05:00
|
|
|
bool m_OneHitDig;
|
2014-03-01 14:34:19 -05:00
|
|
|
|
|
|
|
/** Can a piston break this block? */
|
2014-03-01 10:04:17 -05:00
|
|
|
bool m_PistonBreakable;
|
2014-03-01 14:34:19 -05:00
|
|
|
|
2017-12-26 16:25:57 -05:00
|
|
|
/** Does this block block the passage of rain? */
|
|
|
|
bool m_IsRainBlocker;
|
|
|
|
|
|
|
|
/** Does this block disperse sky light? (only relevant for transparent blocks) */
|
2017-09-07 06:56:17 -04:00
|
|
|
bool m_IsSkylightDispersant;
|
|
|
|
|
2014-03-01 14:34:19 -05:00
|
|
|
/** Is this block solid (player cannot walk through)? */
|
2014-03-01 10:04:17 -05:00
|
|
|
bool m_IsSolid;
|
2014-03-01 14:34:19 -05:00
|
|
|
|
2016-10-12 08:38:45 -04:00
|
|
|
/** Can a spectator interact with this block */
|
|
|
|
bool m_UseableBySpectator;
|
|
|
|
|
2014-03-02 03:50:24 -05:00
|
|
|
/** Does this block fully occupy its voxel - is it a 'full' block? */
|
2014-03-01 10:04:17 -05:00
|
|
|
bool m_FullyOccupiesVoxel;
|
|
|
|
|
2014-07-29 16:31:31 -04:00
|
|
|
/** Can a finisher change it? */
|
|
|
|
bool m_CanBeTerraformed;
|
|
|
|
|
2015-11-10 08:02:07 -05:00
|
|
|
/** Block height */
|
|
|
|
float m_BlockHeight;
|
|
|
|
|
2016-11-06 13:30:19 -05:00
|
|
|
/** Block's hardness. The greater the value the longer the player needs to break the block. */
|
|
|
|
float m_Hardness;
|
2014-07-17 13:13:23 -04:00
|
|
|
}; // tolua_export
|
2014-03-01 10:04:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-02 14:25:05 -05:00
|
|
|
|
2020-04-03 02:57:01 -04:00
|
|
|
bool IsBlockWater(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockIce(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockLava(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockLiquid(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockRail(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockFence(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockMaterialWood(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockMaterialPlants(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockMaterialVine(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockMaterialIron(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockMaterialLeaves(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockMaterialGourd(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
bool IsBlockMaterialRock(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-03 12:34:27 -04:00
|
|
|
class cBlockInfo::cBlockInfoArray:
|
|
|
|
public std::array<cBlockInfo, 256>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Initializes the contained BlockInfo structures with block-specific values. */
|
|
|
|
cBlockInfoArray();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-20 05:43:28 -05:00
|
|
|
inline const cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
|
2017-07-03 12:34:27 -04:00
|
|
|
{
|
2018-02-20 05:43:28 -05:00
|
|
|
static const cBlockInfoArray ms_Info;
|
2017-07-03 12:34:27 -04:00
|
|
|
return ms_Info[a_Type];
|
|
|
|
}
|