2012-12-24 17:09:01 -05:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
#pragma once
|
|
|
|
|
2014-03-09 14:47:22 -04:00
|
|
|
#include <limits>
|
2014-05-09 17:43:00 -04:00
|
|
|
#include <cmath>
|
2014-02-03 17:46:56 -05:00
|
|
|
|
2013-05-30 04:40:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-05-30 04:40:13 -04:00
|
|
|
/// List of slot numbers, used for inventory-painting
|
|
|
|
typedef std::vector<int> cSlotNums;
|
|
|
|
|
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
// tolua_begin
|
|
|
|
|
2013-11-13 12:25:47 -05:00
|
|
|
/// Experience Orb setup
|
|
|
|
enum
|
|
|
|
{
|
2014-07-17 13:13:23 -04:00
|
|
|
// Open to suggestion on naming convention here :)
|
2013-11-13 12:25:47 -05:00
|
|
|
MAX_EXPERIENCE_ORB_SIZE = 2000
|
|
|
|
} ;
|
2013-11-13 08:50:47 -05:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-01 13:05:58 -04:00
|
|
|
/// Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc
|
|
|
|
enum eBlockFace
|
2012-08-10 16:42:59 -04:00
|
|
|
{
|
2013-09-01 13:05:58 -04:00
|
|
|
BLOCK_FACE_NONE = -1, // Interacting with no block face - swinging the item in the air
|
2013-11-16 15:58:17 -05:00
|
|
|
BLOCK_FACE_XM = 4, // Interacting with the X- face of the block
|
|
|
|
BLOCK_FACE_XP = 5, // Interacting with the X+ face of the block
|
2013-09-01 13:05:58 -04:00
|
|
|
BLOCK_FACE_YM = 0, // Interacting with the Y- face of the block
|
|
|
|
BLOCK_FACE_YP = 1, // Interacting with the Y+ face of the block
|
2013-11-16 15:58:17 -05:00
|
|
|
BLOCK_FACE_ZM = 2, // Interacting with the Z- face of the block
|
|
|
|
BLOCK_FACE_ZP = 3, // Interacting with the Z+ face of the block
|
2014-10-11 22:39:55 -04:00
|
|
|
|
2013-09-01 13:05:58 -04:00
|
|
|
// Synonyms using the (deprecated) world directions:
|
|
|
|
BLOCK_FACE_BOTTOM = BLOCK_FACE_YM, // Interacting with the bottom face of the block
|
|
|
|
BLOCK_FACE_TOP = BLOCK_FACE_YP, // Interacting with the top face of the block
|
2013-11-16 15:58:17 -05:00
|
|
|
BLOCK_FACE_NORTH = BLOCK_FACE_ZM, // Interacting with the northern face of the block
|
|
|
|
BLOCK_FACE_SOUTH = BLOCK_FACE_ZP, // Interacting with the southern face of the block
|
|
|
|
BLOCK_FACE_WEST = BLOCK_FACE_XM, // Interacting with the western face of the block
|
|
|
|
BLOCK_FACE_EAST = BLOCK_FACE_XP, // Interacting with the eastern face of the block
|
2012-08-18 05:56:28 -04:00
|
|
|
} ;
|
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// PlayerDigging status constants
|
2012-08-18 05:56:28 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DIG_STATUS_STARTED = 0,
|
2013-01-13 07:59:48 -05:00
|
|
|
DIG_STATUS_CANCELLED = 1,
|
2012-08-18 05:56:28 -04:00
|
|
|
DIG_STATUS_FINISHED = 2,
|
2014-01-15 17:36:19 -05:00
|
|
|
DIG_STATUS_DROP_STACK= 3,
|
2012-08-18 05:56:28 -04:00
|
|
|
DIG_STATUS_DROP_HELD = 4,
|
|
|
|
DIG_STATUS_SHOOT_EAT = 5,
|
2012-08-10 16:42:59 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
/// Individual actions sent in the WindowClick packet
|
|
|
|
enum eClickAction
|
|
|
|
{
|
|
|
|
// Sorted by occurrence in the 1.5 protocol
|
|
|
|
caLeftClick,
|
|
|
|
caRightClick,
|
|
|
|
caShiftLeftClick,
|
|
|
|
caShiftRightClick,
|
|
|
|
caNumber1,
|
|
|
|
caNumber2,
|
|
|
|
caNumber3,
|
|
|
|
caNumber4,
|
|
|
|
caNumber5,
|
|
|
|
caNumber6,
|
|
|
|
caNumber7,
|
|
|
|
caNumber8,
|
|
|
|
caNumber9,
|
|
|
|
caMiddleClick,
|
|
|
|
caDropKey,
|
|
|
|
caCtrlDropKey,
|
|
|
|
caLeftClickOutside,
|
|
|
|
caRightClickOutside,
|
|
|
|
caLeftClickOutsideHoldNothing,
|
|
|
|
caRightClickOutsideHoldNothing,
|
|
|
|
caLeftPaintBegin,
|
|
|
|
caRightPaintBegin,
|
|
|
|
caLeftPaintProgress,
|
|
|
|
caRightPaintProgress,
|
|
|
|
caLeftPaintEnd,
|
|
|
|
caRightPaintEnd,
|
|
|
|
caDblClick,
|
|
|
|
// Add new actions here
|
|
|
|
caUnknown = 255,
|
2014-10-11 22:39:55 -04:00
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
// Keep this list in sync with ClickActionToString() function below!
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum eGameMode
|
|
|
|
{
|
|
|
|
eGameMode_NotSet = -1,
|
|
|
|
eGameMode_Survival = 0,
|
|
|
|
eGameMode_Creative = 1,
|
|
|
|
eGameMode_Adventure = 2,
|
2014-09-16 14:01:04 -04:00
|
|
|
eGameMode_Spectator = 3,
|
2014-10-11 22:39:55 -04:00
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
// Easier-to-use synonyms:
|
|
|
|
gmNotSet = eGameMode_NotSet,
|
|
|
|
gmSurvival = eGameMode_Survival,
|
|
|
|
gmCreative = eGameMode_Creative,
|
|
|
|
gmAdventure = eGameMode_Adventure,
|
2014-09-16 14:01:04 -04:00
|
|
|
gmSpectator = eGameMode_Spectator,
|
2014-10-11 22:39:55 -04:00
|
|
|
|
2013-07-28 16:55:09 -04:00
|
|
|
// These two are used to check GameMode for validity when converting from integers.
|
|
|
|
gmMax, // Gets automatically assigned
|
|
|
|
gmMin = 0,
|
2013-05-08 05:45:07 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum eWeather
|
|
|
|
{
|
|
|
|
eWeather_Sunny = 0,
|
|
|
|
eWeather_Rain = 1,
|
|
|
|
eWeather_ThunderStorm = 2,
|
2014-10-11 22:39:55 -04:00
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
// Easier-to-use synonyms:
|
|
|
|
wSunny = eWeather_Sunny,
|
|
|
|
wRain = eWeather_Rain,
|
|
|
|
wThunderstorm = eWeather_ThunderStorm,
|
|
|
|
wStorm = wThunderstorm,
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-19 08:45:09 -05:00
|
|
|
enum eMobHeadType
|
2014-02-17 14:14:08 -05:00
|
|
|
{
|
|
|
|
SKULL_TYPE_SKELETON = 0,
|
|
|
|
SKULL_TYPE_WITHER = 1,
|
|
|
|
SKULL_TYPE_ZOMBIE = 2,
|
|
|
|
SKULL_TYPE_PLAYER = 3,
|
|
|
|
SKULL_TYPE_CREEPER = 4,
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-19 08:45:09 -05:00
|
|
|
enum eMobHeadRotation
|
2014-02-17 14:14:08 -05:00
|
|
|
{
|
|
|
|
SKULL_ROTATION_NORTH = 0,
|
|
|
|
SKULL_ROTATION_NORTH_NORTH_EAST = 1,
|
|
|
|
SKULL_ROTATION_NORTH_EAST = 2,
|
|
|
|
SKULL_ROTATION_EAST_NORTH_EAST = 3,
|
|
|
|
SKULL_ROTATION_EAST = 4,
|
|
|
|
SKULL_ROTATION_EAST_SOUTH_EAST = 5,
|
|
|
|
SKULL_ROTATION_SOUTH_EAST = 6,
|
|
|
|
SKULL_ROTATION_SOUTH_SOUTH_EAST = 7,
|
|
|
|
SKULL_ROTATION_SOUTH = 8,
|
|
|
|
SKULL_ROTATION_SOUTH_SOUTH_WEST = 9,
|
|
|
|
SKULL_ROTATION_SOUTH_WEST = 10,
|
|
|
|
SKULL_ROTATION_WEST_SOUTH_WEST = 11,
|
|
|
|
SKULL_ROTATION_WEST = 12,
|
|
|
|
SKULL_ROTATION_WEST_NORTH_WEST = 13,
|
|
|
|
SKULL_ROTATION_NORTH_WEST = 14,
|
|
|
|
SKULL_ROTATION_NORTH_NORTH_WEST = 15,
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
inline const char * ClickActionToString(eClickAction a_ClickAction)
|
|
|
|
{
|
|
|
|
switch (a_ClickAction)
|
|
|
|
{
|
|
|
|
case caLeftClick: return "caLeftClick";
|
|
|
|
case caRightClick: return "caRightClick";
|
|
|
|
case caShiftLeftClick: return "caShiftLeftClick";
|
|
|
|
case caShiftRightClick: return "caShiftRightClick";
|
|
|
|
case caNumber1: return "caNumber1";
|
|
|
|
case caNumber2: return "caNumber2";
|
|
|
|
case caNumber3: return "caNumber3";
|
|
|
|
case caNumber4: return "caNumber4";
|
|
|
|
case caNumber5: return "caNumber5";
|
|
|
|
case caNumber6: return "caNumber6";
|
|
|
|
case caNumber7: return "caNumber7";
|
|
|
|
case caNumber8: return "caNumber8";
|
|
|
|
case caNumber9: return "caNumber9";
|
|
|
|
case caMiddleClick: return "caMiddleClick";
|
|
|
|
case caDropKey: return "caDropKey";
|
|
|
|
case caCtrlDropKey: return "caCtrlDropKey";
|
|
|
|
case caLeftClickOutside: return "caLeftClickOutside";
|
|
|
|
case caRightClickOutside: return "caRightClickOutside";
|
|
|
|
case caLeftClickOutsideHoldNothing: return "caLeftClickOutsideHoldNothing";
|
|
|
|
case caRightClickOutsideHoldNothing: return "caRightClickOutsideHoldNothing";
|
|
|
|
case caLeftPaintBegin: return "caLeftPaintBegin";
|
|
|
|
case caRightPaintBegin: return "caRightPaintBegin";
|
|
|
|
case caLeftPaintProgress: return "caLeftPaintProgress";
|
|
|
|
case caRightPaintProgress: return "caRightPaintProgress";
|
|
|
|
case caLeftPaintEnd: return "caLeftPaintEnd";
|
|
|
|
case caRightPaintEnd: return "caRightPaintEnd";
|
|
|
|
case caDblClick: return "caDblClick";
|
2014-10-11 22:39:55 -04:00
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
case caUnknown: return "caUnknown";
|
|
|
|
}
|
|
|
|
ASSERT(!"Unknown click action");
|
|
|
|
return "caUnknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-02 10:05:39 -05:00
|
|
|
/** Returns a blockface mirrored around the Y axis (doesn't change up/down). */
|
|
|
|
inline eBlockFace MirrorBlockFaceY(eBlockFace a_BlockFace)
|
|
|
|
{
|
|
|
|
switch (a_BlockFace)
|
|
|
|
{
|
|
|
|
case BLOCK_FACE_XM: return BLOCK_FACE_XP;
|
|
|
|
case BLOCK_FACE_XP: return BLOCK_FACE_XM;
|
|
|
|
case BLOCK_FACE_ZM: return BLOCK_FACE_ZP;
|
|
|
|
case BLOCK_FACE_ZP: return BLOCK_FACE_ZM;
|
2014-03-04 16:25:31 -05:00
|
|
|
default: return a_BlockFace;
|
2014-03-02 10:05:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Returns a blockface rotated around the Y axis counter-clockwise. */
|
|
|
|
inline eBlockFace RotateBlockFaceCCW(eBlockFace a_BlockFace)
|
|
|
|
{
|
|
|
|
switch (a_BlockFace)
|
|
|
|
{
|
|
|
|
case BLOCK_FACE_XM: return BLOCK_FACE_ZP;
|
|
|
|
case BLOCK_FACE_XP: return BLOCK_FACE_ZM;
|
|
|
|
case BLOCK_FACE_ZM: return BLOCK_FACE_XM;
|
|
|
|
case BLOCK_FACE_ZP: return BLOCK_FACE_XP;
|
2014-03-04 16:25:31 -05:00
|
|
|
default: return a_BlockFace;
|
2014-03-02 10:05:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace)
|
|
|
|
{
|
|
|
|
switch (a_BlockFace)
|
|
|
|
{
|
|
|
|
case BLOCK_FACE_XM: return BLOCK_FACE_ZM;
|
|
|
|
case BLOCK_FACE_XP: return BLOCK_FACE_ZP;
|
|
|
|
case BLOCK_FACE_ZM: return BLOCK_FACE_XP;
|
|
|
|
case BLOCK_FACE_ZP: return BLOCK_FACE_XM;
|
2014-03-04 16:25:31 -05:00
|
|
|
default: return a_BlockFace;
|
2014-03-02 10:05:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-16 12:55:58 -04:00
|
|
|
inline eBlockFace ReverseBlockFace(eBlockFace a_BlockFace)
|
|
|
|
{
|
|
|
|
switch (a_BlockFace)
|
|
|
|
{
|
|
|
|
case BLOCK_FACE_YP: return BLOCK_FACE_YM;
|
|
|
|
case BLOCK_FACE_XP: return BLOCK_FACE_XM;
|
|
|
|
case BLOCK_FACE_ZP: return BLOCK_FACE_ZM;
|
|
|
|
case BLOCK_FACE_YM: return BLOCK_FACE_YP;
|
|
|
|
case BLOCK_FACE_XM: return BLOCK_FACE_XP;
|
|
|
|
case BLOCK_FACE_ZM: return BLOCK_FACE_ZP;
|
|
|
|
default: return a_BlockFace;
|
|
|
|
}
|
|
|
|
}
|
2014-03-02 10:05:39 -05:00
|
|
|
|
|
|
|
|
2014-03-09 05:05:30 -04:00
|
|
|
/** Returns the textual representation of the BlockFace constant. */
|
|
|
|
inline AString BlockFaceToString(eBlockFace a_BlockFace)
|
|
|
|
{
|
|
|
|
switch (a_BlockFace)
|
|
|
|
{
|
|
|
|
case BLOCK_FACE_XM: return "BLOCK_FACE_XM";
|
|
|
|
case BLOCK_FACE_XP: return "BLOCK_FACE_XP";
|
|
|
|
case BLOCK_FACE_YM: return "BLOCK_FACE_YM";
|
|
|
|
case BLOCK_FACE_YP: return "BLOCK_FACE_YP";
|
|
|
|
case BLOCK_FACE_ZM: return "BLOCK_FACE_ZM";
|
|
|
|
case BLOCK_FACE_ZP: return "BLOCK_FACE_ZP";
|
|
|
|
case BLOCK_FACE_NONE: return "BLOCK_FACE_NONE";
|
|
|
|
}
|
2014-03-19 15:06:12 -04:00
|
|
|
// clang optimisises this line away then warns that it has done so.
|
|
|
|
#if !defined(__clang__)
|
|
|
|
return Printf("Unknown BLOCK_FACE: %d", a_BlockFace);
|
|
|
|
#endif
|
2014-03-09 05:05:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
inline bool IsValidBlock(int a_BlockType)
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
if (
|
|
|
|
(a_BlockType > -1) &&
|
2013-08-16 06:23:24 -04:00
|
|
|
(a_BlockType <= E_BLOCK_MAX_TYPE_ID)
|
2013-01-11 23:46:01 -05:00
|
|
|
)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2013-05-08 05:45:07 -04:00
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-08 05:45:07 -04:00
|
|
|
inline bool IsValidItem(int a_ItemType)
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
if (
|
|
|
|
((a_ItemType >= E_ITEM_FIRST) && (a_ItemType <= E_ITEM_MAX_CONSECUTIVE_TYPE_ID)) || // Basic items range
|
|
|
|
((a_ItemType >= E_ITEM_FIRST_DISC) && (a_ItemType <= E_ITEM_LAST_DISC)) // Music discs' special range
|
|
|
|
)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
if (a_ItemType == 0)
|
|
|
|
{
|
2012-06-14 09:06:06 -04:00
|
|
|
return false;
|
2013-01-11 23:46:01 -05:00
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
return IsValidBlock(a_ItemType);
|
2013-05-08 05:45:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// tolua_end
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-02 16:48:21 -05:00
|
|
|
inline bool IsBlockWater(BLOCKTYPE a_BlockType)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-02-02 16:48:21 -05:00
|
|
|
return ((a_BlockType == E_BLOCK_WATER) || (a_BlockType == E_BLOCK_STATIONARY_WATER));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType)
|
|
|
|
{
|
|
|
|
return (IsBlockWater(a_BlockType) || (a_BlockType == E_BLOCK_ICE));
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
inline bool IsBlockLava(BLOCKTYPE a_BlockType)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
return ((a_BlockType == E_BLOCK_LAVA) || (a_BlockType == E_BLOCK_STATIONARY_LAVA));
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
inline bool IsBlockLiquid(BLOCKTYPE a_BlockType)
|
2012-07-12 13:26:00 -04:00
|
|
|
{
|
2012-10-03 04:52:11 -04:00
|
|
|
return IsBlockWater(a_BlockType) || IsBlockLava(a_BlockType);
|
2012-07-12 13:26:00 -04:00
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-19 09:52:45 -05:00
|
|
|
inline bool IsBlockRail(BLOCKTYPE a_BlockType)
|
|
|
|
{
|
|
|
|
switch (a_BlockType)
|
|
|
|
{
|
|
|
|
case E_BLOCK_RAIL:
|
|
|
|
case E_BLOCK_ACTIVATOR_RAIL:
|
|
|
|
case E_BLOCK_DETECTOR_RAIL:
|
|
|
|
case E_BLOCK_POWERED_RAIL:
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
inline bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-03 04:52:11 -04:00
|
|
|
switch (a_BlockType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
case E_BLOCK_DIRT:
|
|
|
|
case E_BLOCK_GRASS:
|
|
|
|
case E_BLOCK_FARMLAND:
|
2013-01-11 23:46:01 -05:00
|
|
|
{
|
2012-07-15 16:36:34 -04:00
|
|
|
return true;
|
2013-01-11 23:46:01 -05:00
|
|
|
}
|
2012-07-15 16:36:34 -04:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-12 13:26:00 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-04 13:59:05 -05:00
|
|
|
inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false) // tolua_export
|
2013-01-11 23:46:01 -05:00
|
|
|
{ // tolua_export
|
2012-08-10 16:42:59 -04:00
|
|
|
if (!a_bInverse)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
switch (a_BlockFace)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-11-16 15:58:17 -05:00
|
|
|
case BLOCK_FACE_YP: a_BlockY++; break;
|
|
|
|
case BLOCK_FACE_YM: a_BlockY--; break;
|
|
|
|
case BLOCK_FACE_ZM: a_BlockZ--; break;
|
|
|
|
case BLOCK_FACE_ZP: a_BlockZ++; break;
|
|
|
|
case BLOCK_FACE_XP: a_BlockX++; break;
|
|
|
|
case BLOCK_FACE_XM: a_BlockX--; break;
|
2012-08-10 16:42:59 -04:00
|
|
|
default:
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
LOGWARNING("%s: Unknown face: %d", __FUNCTION__, a_BlockFace);
|
|
|
|
ASSERT(!"AddFaceDirection(): Unknown face");
|
2012-08-10 16:42:59 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
switch (a_BlockFace)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-11-16 15:58:17 -05:00
|
|
|
case BLOCK_FACE_YP: a_BlockY--; break;
|
|
|
|
case BLOCK_FACE_YM: a_BlockY++; break;
|
|
|
|
case BLOCK_FACE_ZM: a_BlockZ++; break;
|
|
|
|
case BLOCK_FACE_ZP: a_BlockZ--; break;
|
|
|
|
case BLOCK_FACE_XP: a_BlockX--; break;
|
|
|
|
case BLOCK_FACE_XM: a_BlockX++; break;
|
2012-08-10 16:42:59 -04:00
|
|
|
default:
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
LOGWARNING("%s: Unknown inv face: %d", __FUNCTION__, a_BlockFace);
|
|
|
|
ASSERT(!"AddFaceDirection(): Unknown face");
|
2012-08-10 16:42:59 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2013-01-11 23:46:01 -05:00
|
|
|
} // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-04 13:59:05 -05:00
|
|
|
inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false)
|
2013-01-11 23:46:01 -05:00
|
|
|
{
|
|
|
|
int Y = a_BlockY;
|
|
|
|
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
|
2014-10-11 22:39:55 -04:00
|
|
|
a_BlockY = Clamp<unsigned char>(static_cast<unsigned char>(Y), 0, 255);
|
2013-01-11 23:46:01 -05:00
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-04 16:02:04 -04:00
|
|
|
#define PI 3.14159265358979323846264338327950288419716939937510582097494459072381640628620899862803482534211706798f
|
2013-05-08 05:45:07 -04:00
|
|
|
|
2013-03-09 09:35:43 -05:00
|
|
|
inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-07-21 09:19:48 -04: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);
|
2013-03-09 09:35:43 -05:00
|
|
|
a_X = cos(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI);
|
|
|
|
a_Y = sin(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI);
|
2012-06-14 09:06:06 -04:00
|
|
|
a_Z = sin(a_Pitch / 180 * PI);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-09 09:35:43 -05:00
|
|
|
inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, double & a_Pitch)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-04-17 01:35:26 -04:00
|
|
|
double r = sqrt((a_X * a_X) + (a_Z * a_Z));
|
|
|
|
if (r < std::numeric_limits<double>::epsilon())
|
2013-03-09 09:35:43 -05:00
|
|
|
{
|
2014-04-17 01:35:26 -04:00
|
|
|
a_Pan = 0;
|
2013-03-09 09:35:43 -05:00
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
else
|
2013-03-09 09:35:43 -05:00
|
|
|
{
|
2014-07-17 10:33:09 -04:00
|
|
|
a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
|
2013-03-09 09:35:43 -05:00
|
|
|
}
|
2014-04-17 01:35:26 -04:00
|
|
|
|
|
|
|
a_Pitch = atan2(a_Y, r) * 180 / PI;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-09 09:35:43 -05:00
|
|
|
inline float GetSignf(float a_Val)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-03-09 09:35:43 -05:00
|
|
|
return (a_Val < 0.f) ? -1.f : 1.f;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-21 09:19:48 -04:00
|
|
|
inline float GetSpecialSignf( float a_Val)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-03-09 09:35:43 -05:00
|
|
|
return (a_Val <= 0.f) ? -1.f : 1.f;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-15 17:16:44 -05:00
|
|
|
|
2014-08-28 09:58:48 -04:00
|
|
|
template <class T> inline T Diff(T a_Val1, T a_Val2)
|
2014-05-09 17:43:00 -04:00
|
|
|
{
|
|
|
|
return std::abs(a_Val1 - a_Val2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-15 17:16:44 -05:00
|
|
|
// tolua_begin
|
|
|
|
|
|
|
|
enum eMessageType
|
2014-02-03 17:46:56 -05:00
|
|
|
{
|
|
|
|
// http://forum.mc-server.org/showthread.php?tid=1212
|
|
|
|
// MessageType...
|
|
|
|
|
2014-03-16 13:44:23 -04:00
|
|
|
mtCustom, // Send raw data without any processing
|
|
|
|
mtFailure, // Something could not be done (i.e. command not executed due to insufficient privilege)
|
|
|
|
mtInformation, // Informational message (i.e. command usage)
|
|
|
|
mtSuccess, // Something executed successfully
|
|
|
|
mtWarning, // Something concerning (i.e. reload) is about to happen
|
|
|
|
mtFatal, // Something catastrophic occured (i.e. plugin crash)
|
|
|
|
mtDeath, // Denotes death of player
|
|
|
|
mtPrivateMessage, // Player to player messaging identifier
|
|
|
|
mtJoin, // A player has joined the server
|
|
|
|
mtLeave, // A player has left the server
|
2014-10-11 22:39:55 -04:00
|
|
|
|
2014-03-16 13:44:23 -04:00
|
|
|
// Common aliases:
|
|
|
|
mtFail = mtFailure,
|
|
|
|
mtError = mtFailure,
|
|
|
|
mtInfo = mtInformation,
|
|
|
|
mtPM = mtPrivateMessage,
|
2014-02-03 17:46:56 -05:00
|
|
|
};
|
|
|
|
|
2014-02-15 17:16:44 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-08 07:08:56 -05:00
|
|
|
|
2014-02-07 13:58:52 -05:00
|
|
|
/** Normalizes an angle in degrees to the [-180, +180) range: */
|
2013-12-08 07:08:56 -05:00
|
|
|
inline double NormalizeAngleDegrees(const double a_Degrees)
|
|
|
|
{
|
|
|
|
double Norm = fmod(a_Degrees + 180, 360);
|
|
|
|
if (Norm < 0)
|
|
|
|
{
|
|
|
|
Norm += 360;
|
|
|
|
}
|
|
|
|
return Norm - 180;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
namespace ItemCategory
|
|
|
|
{
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsPickaxe(short a_ItemID)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsAxe(short a_ItemID)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsSword(short a_ItemID)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
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-08-19 07:51:17 -04:00
|
|
|
inline bool IsHoe(short a_ItemID)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
return (a_ItemID == E_ITEM_WOODEN_HOE)
|
|
|
|
|| (a_ItemID == E_ITEM_STONE_HOE)
|
|
|
|
|| (a_ItemID == E_ITEM_IRON_HOE)
|
|
|
|
|| (a_ItemID == E_ITEM_GOLD_HOE)
|
|
|
|
|| (a_ItemID == E_ITEM_DIAMOND_HOE);
|
|
|
|
}
|
2014-10-11 22:39:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsShovel(short a_ItemID)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
return (a_ItemID == E_ITEM_WOODEN_SHOVEL)
|
|
|
|
|| (a_ItemID == E_ITEM_STONE_SHOVEL)
|
|
|
|
|| (a_ItemID == E_ITEM_IRON_SHOVEL)
|
|
|
|
|| (a_ItemID == E_ITEM_GOLD_SHOVEL)
|
|
|
|
|| (a_ItemID == E_ITEM_DIAMOND_SHOVEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsTool(short a_ItemID)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-07-21 09:19:48 -04:00
|
|
|
return IsPickaxe( a_ItemID)
|
|
|
|
|| IsAxe ( a_ItemID)
|
|
|
|
|| IsSword ( a_ItemID)
|
|
|
|
|| IsHoe ( a_ItemID)
|
|
|
|
|| IsShovel ( a_ItemID);
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2014-10-11 22:39:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsHelmet(short a_ItemType)
|
2012-08-11 15:43:28 -04:00
|
|
|
{
|
|
|
|
return (
|
|
|
|
(a_ItemType == E_ITEM_LEATHER_CAP) ||
|
|
|
|
(a_ItemType == E_ITEM_GOLD_HELMET) ||
|
|
|
|
(a_ItemType == E_ITEM_CHAIN_HELMET) ||
|
|
|
|
(a_ItemType == E_ITEM_IRON_HELMET) ||
|
|
|
|
(a_ItemType == E_ITEM_DIAMOND_HELMET)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsChestPlate(short a_ItemType)
|
2012-08-11 15:43:28 -04:00
|
|
|
{
|
|
|
|
return (
|
|
|
|
(a_ItemType == E_ITEM_LEATHER_TUNIC) ||
|
|
|
|
(a_ItemType == E_ITEM_GOLD_CHESTPLATE) ||
|
|
|
|
(a_ItemType == E_ITEM_CHAIN_CHESTPLATE) ||
|
|
|
|
(a_ItemType == E_ITEM_IRON_CHESTPLATE) ||
|
|
|
|
(a_ItemType == E_ITEM_DIAMOND_CHESTPLATE)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsLeggings(short a_ItemType)
|
2012-08-11 15:43:28 -04:00
|
|
|
{
|
|
|
|
return (
|
|
|
|
(a_ItemType == E_ITEM_LEATHER_PANTS) ||
|
|
|
|
(a_ItemType == E_ITEM_GOLD_LEGGINGS) ||
|
|
|
|
(a_ItemType == E_ITEM_CHAIN_LEGGINGS) ||
|
|
|
|
(a_ItemType == E_ITEM_IRON_LEGGINGS) ||
|
|
|
|
(a_ItemType == E_ITEM_DIAMOND_LEGGINGS)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-19 07:51:17 -04:00
|
|
|
inline bool IsBoots(short a_ItemType)
|
2012-08-11 15:43:28 -04:00
|
|
|
{
|
|
|
|
return (
|
|
|
|
(a_ItemType == E_ITEM_LEATHER_BOOTS) ||
|
|
|
|
(a_ItemType == E_ITEM_GOLD_BOOTS) ||
|
|
|
|
(a_ItemType == E_ITEM_CHAIN_BOOTS) ||
|
|
|
|
(a_ItemType == E_ITEM_IRON_BOOTS) ||
|
|
|
|
(a_ItemType == E_ITEM_DIAMOND_BOOTS)
|
|
|
|
);
|
|
|
|
}
|
2014-10-11 22:39:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-24 03:20:16 -04:00
|
|
|
inline bool IsArmor(short a_ItemType)
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
IsHelmet(a_ItemType) ||
|
|
|
|
IsChestPlate(a_ItemType) ||
|
|
|
|
IsLeggings(a_ItemType) ||
|
|
|
|
IsBoots(a_ItemType)
|
|
|
|
);
|
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2013-11-30 09:57:56 -05:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
// tolua_end
|