2011-10-03 14:41:19 -04:00
|
|
|
#pragma once
|
|
|
|
|
2011-12-22 11:30:40 -05:00
|
|
|
#include "BlockID.h"
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
//tolua_begin
|
|
|
|
// emissive blocks
|
|
|
|
extern char g_BlockLightValue[];
|
|
|
|
// whether blocks allow spreading
|
|
|
|
extern char g_BlockSpreadLightFalloff[];
|
|
|
|
// whether blocks are transparent (light can shine though)
|
|
|
|
extern bool g_BlockTransparent[];
|
|
|
|
// one hit break blocks
|
|
|
|
extern bool g_BlockOneHitDig[];
|
|
|
|
//tolua_end
|
|
|
|
|
|
|
|
//--DO NOT DELETE THIS COMMENT-- //tolua_export
|
|
|
|
|
|
|
|
inline bool IsValidBlock( int a_BlockID ) //tolua_export
|
|
|
|
{ //tolua_export
|
|
|
|
if( a_BlockID > -1 &&
|
2011-11-05 14:28:19 -04:00
|
|
|
a_BlockID <= 121 && //items to 109 are valid for 1.8.1.. 1.9.5 is up to 121
|
|
|
|
//a_BlockID != 29 && allow pistons
|
|
|
|
//a_BlockID != 33 && allow pistons
|
2011-10-03 14:41:19 -04:00
|
|
|
a_BlockID != 34 &&
|
|
|
|
a_BlockID != 36 )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} //tolua_export
|
|
|
|
|
2011-12-21 15:42:34 -05:00
|
|
|
// Was old :o
|
|
|
|
// Changed to fit the style ;)
|
|
|
|
inline bool IsValidItem( int a_ItemID ) //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
{ //tolua_export
|
2011-12-21 15:42:34 -05:00
|
|
|
if( (a_ItemID >= 256 && a_ItemID <= 383)
|
2011-10-03 14:41:19 -04:00
|
|
|
|| (a_ItemID == 2256 || a_ItemID == 2257) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( a_ItemID == 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return IsValidBlock( a_ItemID );
|
|
|
|
} //tolua_export
|
|
|
|
|
2011-12-22 16:36:24 -05:00
|
|
|
inline bool IsBlockWater(char a_BlockID)
|
2011-12-22 11:30:40 -05:00
|
|
|
{
|
|
|
|
return (a_BlockID == E_BLOCK_WATER || a_BlockID == E_BLOCK_STATIONARY_WATER);
|
|
|
|
}
|
|
|
|
|
2011-12-22 16:36:24 -05:00
|
|
|
inline bool IsBlockLava(char a_BlockID)
|
|
|
|
{
|
|
|
|
return (a_BlockID == E_BLOCK_LAVA || a_BlockID == E_BLOCK_STATIONARY_LAVA);
|
|
|
|
}
|
|
|
|
|
2012-03-04 08:54:33 -05:00
|
|
|
inline void AddDirection( int & a_X, int & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false )
|
|
|
|
{
|
2011-10-03 14:41:19 -04:00
|
|
|
if( !a_bInverse )
|
|
|
|
{
|
|
|
|
switch( a_Direction )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
a_Y--;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
a_Y++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
a_Z--;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
a_Z++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
a_X--;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
a_X++;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( a_Direction ) // other way around
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
a_Y++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
a_Y--;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
a_Z++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
a_Z--;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
a_X++;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
a_X--;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
2012-03-04 08:54:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void AddDirection( int & a_X, unsigned char & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false ) //tolua_export
|
|
|
|
{//tolua_export
|
|
|
|
int Y = a_Y;
|
|
|
|
AddDirection( a_X, Y, a_Z, a_Direction, a_bInverse );
|
|
|
|
if( Y < 0 ) a_Y = 0;
|
|
|
|
else if( Y > 255 ) a_Y = 255;
|
|
|
|
else a_Y = (unsigned char)Y;
|
2011-10-03 14:41:19 -04:00
|
|
|
}//tolua_export
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#define PI 3.14159265358979323846264338327950288419716939937510582097494459072381640628620899862803482534211706798f
|
|
|
|
#define MIN(a,b) (((a)>(b))?(b):(a))
|
|
|
|
#define MAX(a,b) (((a)>(b))?(a):(b))
|
|
|
|
inline void EulerToVector( float a_Pan, float a_Pitch, float & a_X, float & a_Y, float & a_Z )
|
|
|
|
{
|
2012-03-07 08:36:30 -05:00
|
|
|
// a_X = sinf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI );
|
|
|
|
// a_Y = -sinf ( a_Pitch / 180 * PI );
|
|
|
|
// a_Z = -cosf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI );
|
|
|
|
a_X = cos(a_Pan / 180 * PI)*cos(a_Pitch / 180 * PI);
|
|
|
|
a_Y = sin(a_Pan / 180 * PI)*cos(a_Pitch / 180 * PI);
|
|
|
|
a_Z = sin(a_Pitch / 180 * PI);
|
2011-10-03 14:41:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void VectorToEuler( float a_X, float a_Y, float a_Z, float & a_Pan, float & a_Pitch )
|
|
|
|
{
|
|
|
|
if( a_X != 0 )
|
|
|
|
a_Pan = atan2( a_Z, a_X ) * 180 / PI - 90;
|
|
|
|
else
|
|
|
|
a_Pan = 0;
|
|
|
|
a_Pitch = atan2(a_Y, sqrtf((a_X * a_X) + (a_Z * a_Z))) * 180 / PI;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float GetSignf( float a_Val )
|
|
|
|
{
|
|
|
|
return (a_Val < 0.f)?-1.f:1.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float GetSpecialSignf( float a_Val )
|
|
|
|
{
|
|
|
|
return (a_Val <= 0.f)?-1.f:1.f;
|
|
|
|
}
|
2011-12-25 12:47:01 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ItemCategory
|
|
|
|
{
|
|
|
|
inline bool IsPickaxe(ENUM_ITEM_ID a_ItemID)
|
|
|
|
{
|
|
|
|
return a_ItemID == E_ITEM_WOODEN_PICKAXE
|
|
|
|
|| a_ItemID == E_ITEM_STONE_PICKAXE
|
|
|
|
|| a_ItemID == E_ITEM_IRON_PICKAXE
|
|
|
|
|| a_ItemID == E_ITEM_GOLD_PICKAXE
|
|
|
|
|| a_ItemID == E_ITEM_DIAMOND_PICKAXE;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsAxe(ENUM_ITEM_ID a_ItemID)
|
|
|
|
{
|
|
|
|
return a_ItemID == E_ITEM_WOODEN_AXE
|
|
|
|
|| a_ItemID == E_ITEM_STONE_AXE
|
|
|
|
|| a_ItemID == E_ITEM_IRON_AXE
|
|
|
|
|| a_ItemID == E_ITEM_GOLD_AXE
|
|
|
|
|| a_ItemID == E_ITEM_DIAMOND_AXE;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsSword(ENUM_ITEM_ID a_ItemID)
|
|
|
|
{
|
|
|
|
return a_ItemID == E_ITEM_WOODEN_SWORD
|
|
|
|
|| a_ItemID == E_ITEM_STONE_SWORD
|
|
|
|
|| a_ItemID == E_ITEM_IRON_SWORD
|
|
|
|
|| a_ItemID == E_ITEM_GOLD_SWORD
|
|
|
|
|| a_ItemID == E_ITEM_DIAMOND_SWORD;
|
|
|
|
}
|
2012-03-07 08:36:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//tolua_begin
|
|
|
|
enum eGameMode
|
|
|
|
{
|
|
|
|
eGameMode_Survival = 0,
|
|
|
|
eGameMode_Creative = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum eWeather
|
|
|
|
{
|
|
|
|
eWeather_Sunny = 0,
|
|
|
|
eWeather_Rain = 1,
|
|
|
|
eWeather_ThunderStorm = 2,
|
|
|
|
|
|
|
|
};
|
|
|
|
//tolua_end
|