From e2194e6e9083b54914deac3a5a6c2e3e4d262990 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 15:32:14 -0700 Subject: Added static const, initialized fields. --- src/BlockEntities/CommandBlockEntity.cpp | 3 ++- src/BlockEntities/MobHeadEntity.cpp | 2 ++ src/Entities/Entity.cpp | 2 ++ src/Mobs/AggressiveMonster.cpp | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 96ca0ac37..146ad915b 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -21,7 +21,8 @@ cCommandBlockEntity::cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World) : super(E_BLOCK_COMMAND_BLOCK, a_X, a_Y, a_Z, a_World), m_ShouldExecute(false), - m_IsPowered(false) + m_IsPowered(false), + m_Result(0) {} diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp index c0a1781f6..dc9c18d58 100644 --- a/src/BlockEntities/MobHeadEntity.cpp +++ b/src/BlockEntities/MobHeadEntity.cpp @@ -14,6 +14,8 @@ cMobHeadEntity::cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : super(E_BLOCK_HEAD, a_BlockX, a_BlockY, a_BlockZ, a_World), + m_Type(SKULL_TYPE_SKELETON), + m_Rotation(SKULL_ROTATION_NORTH), m_Owner("") { } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 7c8e18b51..827b88717 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -53,6 +53,8 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_TicksSinceLastVoidDamage(0) , m_IsSwimming(false) , m_IsSubmerged(false) + , m_AirLevel(0) + , m_AirTickTimer(0) , m_HeadYaw( 0.0 ) , m_Rot(0.0, 0.0, 0.0) , m_Pos(a_X, a_Y, a_Z) diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 3e5f72dbf..4997952be 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -108,7 +108,7 @@ void cAggressiveMonster::Attack(float a_Dt) bool cAggressiveMonster::IsMovingToTargetPosition() { - float epsilon = 0.000000000001; + static const float epsilon = 0.000000000001; // Difference between destination x and target x is negligible (to 10^-12 precision) if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < epsilon) { -- cgit v1.2.3 From 75bb36574b4bb78e8b5975bf905a97402fd8a4bb Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 10:01:50 -0700 Subject: Creative players cannot throw ender pearls. --- src/Items/ItemThrowable.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index c6a4e714e..f1ebb4508 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -89,6 +89,22 @@ public: super(E_ITEM_ENDER_PEARL, cProjectileEntity::pkEnderPearl, 30) { } + + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override + { + // Creative players cannot throw ender pearls. + if (a_Player->IsGameModeCreative()) + { + return false; + } + + a_Player->GetInventory().RemoveOneEquippedItem(); + Vector3d Pos = a_Player->GetThrowStartPos(); + Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff; + a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed); + + return true; + } } ; -- cgit v1.2.3 From cd38e792b7aac453549d1e9fea21ad94b8ea655a Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 10:24:39 -0700 Subject: Revert "Creative players cannot throw ender pearls." This reverts commit 75bb36574b4bb78e8b5975bf905a97402fd8a4bb. --- src/Items/ItemThrowable.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index f1ebb4508..c6a4e714e 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -89,22 +89,6 @@ public: super(E_ITEM_ENDER_PEARL, cProjectileEntity::pkEnderPearl, 30) { } - - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override - { - // Creative players cannot throw ender pearls. - if (a_Player->IsGameModeCreative()) - { - return false; - } - - a_Player->GetInventory().RemoveOneEquippedItem(); - Vector3d Pos = a_Player->GetThrowStartPos(); - Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff; - a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed); - - return true; - } } ; -- cgit v1.2.3