summaryrefslogtreecommitdiffstats
path: root/src/Defines.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Defines.h')
-rw-r--r--src/Defines.h207
1 files changed, 172 insertions, 35 deletions
diff --git a/src/Defines.h b/src/Defines.h
index 7a86f499e..1a8b3fa4a 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -1,11 +1,12 @@
#pragma once
+#include "ChatColor.h"
+#include <limits>
-typedef unsigned char Byte;
/// List of slot numbers, used for inventory-painting
typedef std::vector<int> cSlotNums;
@@ -17,33 +18,6 @@ typedef std::vector<int> cSlotNums;
// tolua_begin
-/// How much light do the blocks emit on their own?
-extern unsigned char g_BlockLightValue[];
-
-/// How much light do the block consume?
-extern unsigned char g_BlockSpreadLightFalloff[];
-
-/// Is a block completely transparent? (light doesn't get decreased(?))
-extern bool g_BlockTransparent[];
-
-/// Is a block destroyed after a single hit?
-extern bool g_BlockOneHitDig[];
-
-/// Can a piston break this block?
-extern bool g_BlockPistonBreakable[256];
-
-/// Can this block hold snow atop?
-extern bool g_BlockIsSnowable[256];
-
-/// Does this block require a tool to drop?
-extern bool g_BlockRequiresSpecialTool[256];
-
-/// Is this block solid (player cannot walk through)?
-extern bool g_BlockIsSolid[256];
-
-/// Does this block fully occupy it's voxel - is it a 'full' block?
-extern bool g_BlockFullyOccupiesVoxel[256];
-
/// Experience Orb setup
enum
{
@@ -174,6 +148,43 @@ enum eWeather
+enum eMobHeadType
+{
+ SKULL_TYPE_SKELETON = 0,
+ SKULL_TYPE_WITHER = 1,
+ SKULL_TYPE_ZOMBIE = 2,
+ SKULL_TYPE_PLAYER = 3,
+ SKULL_TYPE_CREEPER = 4,
+} ;
+
+
+
+
+
+enum eMobHeadRotation
+{
+ 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,
+} ;
+
+
+
+
+
inline const char * ClickActionToString(eClickAction a_ClickAction)
{
switch (a_ClickAction)
@@ -216,6 +227,79 @@ inline const char * ClickActionToString(eClickAction a_ClickAction)
+/** 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;
+ default: return a_BlockFace;
+ }
+}
+
+
+
+
+
+/** 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;
+ default: return a_BlockFace;
+ }
+}
+
+
+
+
+
+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;
+ default: return a_BlockFace;
+ }
+}
+
+
+
+
+
+/** 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";
+ }
+ // clang optimisises this line away then warns that it has done so.
+ #if !defined(__clang__)
+ return Printf("Unknown BLOCK_FACE: %d", a_BlockFace);
+ #endif
+}
+
+
+
+
+
inline bool IsValidBlock(int a_BlockType)
{
if (
@@ -265,6 +349,15 @@ inline bool IsBlockWater(BLOCKTYPE a_BlockType)
+inline bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType)
+{
+ return (IsBlockWater(a_BlockType) || (a_BlockType == E_BLOCK_ICE));
+}
+
+
+
+
+
inline bool IsBlockLava(BLOCKTYPE a_BlockType)
{
return ((a_BlockType == E_BLOCK_LAVA) || (a_BlockType == E_BLOCK_STATIONARY_LAVA));
@@ -282,6 +375,24 @@ inline bool IsBlockLiquid(BLOCKTYPE a_BlockType)
+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;
+ }
+}
+
+
+
+
inline bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType)
{
@@ -300,7 +411,7 @@ inline bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType)
-inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, char a_BlockFace, bool a_bInverse = false) // tolua_export
+inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false) // tolua_export
{ // tolua_export
if (!a_bInverse)
{
@@ -344,7 +455,7 @@ inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cha
-inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_BlockZ, char a_BlockFace, bool a_bInverse = false)
+inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false)
{
int Y = a_BlockY;
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
@@ -364,8 +475,6 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
-
-
#define PI 3.14159265358979323846264338327950288419716939937510582097494459072381640628620899862803482534211706798f
inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z)
@@ -384,7 +493,7 @@ inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a
inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, double & a_Pitch)
{
- if (a_X != 0)
+ if (fabs(a_X) < std::numeric_limits<double>::epsilon())
{
a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
}
@@ -416,9 +525,37 @@ inline float GetSpecialSignf( float a_Val )
+
// tolua_begin
-/// Normalizes an angle in degrees to the [-180, +180) range:
+enum eMessageType
+{
+ // http://forum.mc-server.org/showthread.php?tid=1212
+ // MessageType...
+
+ 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
+
+ // Common aliases:
+ mtFail = mtFailure,
+ mtError = mtFailure,
+ mtInfo = mtInformation,
+ mtPM = mtPrivateMessage,
+};
+
+
+
+
+
+/** Normalizes an angle in degrees to the [-180, +180) range: */
inline double NormalizeAngleDegrees(const double a_Degrees)
{
double Norm = fmod(a_Degrees + 180, 360);
@@ -570,7 +707,7 @@ namespace ItemCategory
inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType)
{
if(!IsValidBlock(a_BlockType)) return false;
- return g_BlockRequiresSpecialTool[a_BlockType];
+ return cBlockInfo::RequiresSpecialTool(a_BlockType);
}