Merge branch 'master' into awesometnt
Conflicts: src/ChunkMap.cpp
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "../World.h"
|
||||
#include "../Server.h"
|
||||
#include "../Root.h"
|
||||
#include "../Matrix4f.h"
|
||||
#include "../Matrix4.h"
|
||||
#include "../ClientHandle.h"
|
||||
#include "../Chunk.h"
|
||||
#include "../Simulator/FluidSimulator.h"
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Item.h"
|
||||
#include "../Vector3d.h"
|
||||
#include "../Vector3f.h"
|
||||
#include "../Vector3i.h"
|
||||
#include "../Vector3.h"
|
||||
|
||||
|
||||
|
||||
|
||||
+19
-7
@@ -5,20 +5,26 @@
|
||||
#include "../ClientHandle.h"
|
||||
|
||||
|
||||
cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward) :
|
||||
cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98),
|
||||
m_Reward(a_Reward)
|
||||
cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward)
|
||||
: cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98)
|
||||
, m_Reward(a_Reward)
|
||||
, m_Timer(0.f)
|
||||
{
|
||||
SetMaxHealth(5);
|
||||
SetHealth(5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward) :
|
||||
cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
|
||||
m_Reward(a_Reward)
|
||||
cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward)
|
||||
: cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98)
|
||||
, m_Reward(a_Reward)
|
||||
, m_Timer(0.f)
|
||||
{
|
||||
SetMaxHealth(5);
|
||||
SetHealth(5);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +58,7 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward);
|
||||
a_ClosestPlayer->DeltaExperience(m_Reward);
|
||||
|
||||
m_World->BroadcastSoundEffect("random.orb", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
||||
m_World->BroadcastSoundEffect("random.orb", (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
||||
|
||||
Destroy();
|
||||
}
|
||||
@@ -64,4 +70,10 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
BroadcastMovementUpdate();
|
||||
}
|
||||
HandlePhysics(a_Dt, a_Chunk);
|
||||
|
||||
m_Timer += a_Dt;
|
||||
if (m_Timer >= 1000 * 60 * 5) // 5 minutes
|
||||
{
|
||||
Destroy(true);
|
||||
}
|
||||
}
|
||||
|
||||
+19
-4
@@ -7,14 +7,17 @@
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
class cExpOrb :
|
||||
public cEntity
|
||||
{
|
||||
typedef cExpOrb super;
|
||||
|
||||
public:
|
||||
// tolua_end
|
||||
|
||||
CLASS_PROTODEF(cExpOrb);
|
||||
|
||||
|
||||
cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward);
|
||||
cExpOrb(const Vector3d & a_Pos, int a_Reward);
|
||||
|
||||
@@ -22,9 +25,21 @@ public:
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||
|
||||
// cExpOrb functions
|
||||
int GetReward(void) const { return m_Reward; }
|
||||
/** Returns the number of ticks that this entity has existed */
|
||||
int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export
|
||||
|
||||
/** Set the number of ticks that this entity has existed */
|
||||
void SetAge(int a_Age) { m_Timer = (float)(a_Age * 50); } // tolua_export
|
||||
|
||||
/** Get the exp amount */
|
||||
int GetReward(void) const { return m_Reward; } // tolua_export
|
||||
|
||||
/** Set the exp amount */
|
||||
void SetReward(int a_Reward) { m_Reward = a_Reward; } // tolua_export
|
||||
|
||||
protected:
|
||||
int m_Reward;
|
||||
} ;
|
||||
|
||||
/** The number of ticks that the entity has existed / timer between collect and destroy; in msec */
|
||||
float m_Timer;
|
||||
} ; // tolua_export
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "HangingEntity.h"
|
||||
#include "ClientHandle.h"
|
||||
#include "Player.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
|
||||
: cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8)
|
||||
, m_BlockFace(a_BlockFace)
|
||||
{
|
||||
SetMaxHealth(1);
|
||||
SetHealth(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
int Dir = 0;
|
||||
|
||||
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
|
||||
switch (m_BlockFace)
|
||||
{
|
||||
case BLOCK_FACE_ZP: break; // Initialised to zero
|
||||
case BLOCK_FACE_ZM: Dir = 2; break;
|
||||
case BLOCK_FACE_XM: Dir = 1; break;
|
||||
case BLOCK_FACE_XP: Dir = 3; break;
|
||||
default: ASSERT(!"Unhandled block face when trying to spawn item frame!"); return;
|
||||
}
|
||||
|
||||
if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180
|
||||
{
|
||||
SetYaw((Dir * 90) - 180);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetYaw(Dir * 90);
|
||||
}
|
||||
|
||||
a_ClientHandle.SendSpawnObject(*this, 71, Dir, (Byte)GetYaw(), (Byte)GetPitch());
|
||||
a_ClientHandle.SendEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Entity.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
class cHangingEntity :
|
||||
public cEntity
|
||||
{
|
||||
// tolua_end
|
||||
typedef cEntity super;
|
||||
|
||||
public:
|
||||
|
||||
CLASS_PROTODEF(cHangingEntity);
|
||||
|
||||
cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
|
||||
|
||||
/** Returns the orientation from the hanging entity */
|
||||
eBlockFace GetDirection() const { return m_BlockFace; } // tolua_export
|
||||
|
||||
/** Set the orientation from the hanging entity */
|
||||
void SetDirection(eBlockFace a_BlockFace) { m_BlockFace = a_BlockFace; } // tolua_export
|
||||
|
||||
/** Returns the X coord. */
|
||||
int GetTileX() const { return POSX_TOINT; } // tolua_export
|
||||
|
||||
/** Returns the Y coord. */
|
||||
int GetTileY() const { return POSY_TOINT; } // tolua_export
|
||||
|
||||
/** Returns the Z coord. */
|
||||
int GetTileZ() const { return POSZ_TOINT; } // tolua_export
|
||||
|
||||
private:
|
||||
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override {};
|
||||
|
||||
eBlockFace m_BlockFace;
|
||||
|
||||
}; // tolua_export
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,43 +10,10 @@
|
||||
|
||||
|
||||
cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
|
||||
: cEntity(etItemFrame, a_X, a_Y, a_Z, 0.8, 0.8),
|
||||
m_BlockFace(a_BlockFace),
|
||||
m_Item(E_BLOCK_AIR),
|
||||
m_Rotation(0)
|
||||
: cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z)
|
||||
, m_Item(E_BLOCK_AIR)
|
||||
, m_Rotation(0)
|
||||
{
|
||||
SetMaxHealth(1);
|
||||
SetHealth(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cItemFrame::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
int Dir = 0;
|
||||
|
||||
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
|
||||
switch (m_BlockFace)
|
||||
{
|
||||
case BLOCK_FACE_ZP: break; // Initialised to zero
|
||||
case BLOCK_FACE_ZM: Dir = 2; break;
|
||||
case BLOCK_FACE_XM: Dir = 1; break;
|
||||
case BLOCK_FACE_XP: Dir = 3; break;
|
||||
default: ASSERT(!"Unhandled block face when trying to spawn item frame!"); return;
|
||||
}
|
||||
|
||||
if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180
|
||||
{
|
||||
SetYaw((Dir * 90) - 180);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetYaw(Dir * 90);
|
||||
}
|
||||
|
||||
a_ClientHandle.SendSpawnObject(*this, 71, Dir, (Byte)GetYaw(), (Byte)GetPitch());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Entity.h"
|
||||
#include "HangingEntity.h"
|
||||
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
// tolua_begin
|
||||
class cItemFrame :
|
||||
public cEntity
|
||||
public cHangingEntity
|
||||
{
|
||||
// tolua_end
|
||||
typedef cEntity super;
|
||||
typedef cHangingEntity super;
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,18 +20,24 @@ public:
|
||||
|
||||
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
|
||||
|
||||
const cItem & GetItem(void) { return m_Item; }
|
||||
Byte GetRotation(void) const { return m_Rotation; }
|
||||
/** Returns the item in the frame */
|
||||
const cItem & GetItem(void) { return m_Item; } // tolua_export
|
||||
|
||||
/** Set the item in the frame */
|
||||
void SetItem(cItem & a_Item) { m_Item = a_Item; }; // tolua_export
|
||||
|
||||
/** Returns the rotation from the item in the frame */
|
||||
Byte GetRotation(void) const { return m_Rotation; } // tolua_export
|
||||
|
||||
/** Set the rotation from the item in the frame */
|
||||
void SetRotation(Byte a_Rotation) { m_Rotation = a_Rotation; } // tolua_export
|
||||
|
||||
private:
|
||||
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override {};
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
|
||||
|
||||
eBlockFace m_BlockFace;
|
||||
cItem m_Item;
|
||||
Byte m_Rotation;
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ cPickup::cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_It
|
||||
|
||||
void cPickup::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendPickupSpawn(*this);
|
||||
a_Client.SendPickupSpawn(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+13
-10
@@ -26,31 +26,34 @@ public:
|
||||
CLASS_PROTODEF(cPickup);
|
||||
|
||||
cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f);
|
||||
|
||||
|
||||
cItem & GetItem(void) {return m_Item; } // tolua_export
|
||||
const cItem & GetItem(void) const {return m_Item; }
|
||||
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
|
||||
|
||||
bool CollectedBy(cPlayer * a_Dest); // tolua_export
|
||||
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
|
||||
/// Returns the number of ticks that this entity has existed
|
||||
int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export
|
||||
|
||||
/// Returns true if the pickup has already been collected
|
||||
|
||||
/** Returns the number of ticks that this entity has existed */
|
||||
int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export
|
||||
|
||||
/** Set the number of ticks that this entity has existed */
|
||||
void SetAge(int a_Age) { m_Timer = (float)(a_Age * 50); } // tolua_export
|
||||
|
||||
/** Returns true if the pickup has already been collected */
|
||||
bool IsCollected(void) const { return m_bCollected; } // tolua_export
|
||||
|
||||
/// Returns true if created by player (i.e. vomiting), used for determining picking-up delay time
|
||||
/** Returns true if created by player (i.e. vomiting), used for determining picking-up delay time */
|
||||
bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export
|
||||
|
||||
|
||||
private:
|
||||
Vector3d m_ResultingSpeed; //Can be used to modify the resulting speed for the current tick ;)
|
||||
|
||||
Vector3d m_WaterSpeed;
|
||||
|
||||
/// The number of ticks that the entity has existed / timer between collect and destroy; in msec
|
||||
/** The number of ticks that the entity has existed / timer between collect and destroy; in msec */
|
||||
float m_Timer;
|
||||
|
||||
cItem m_Item;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "../OSSupport/Timer.h"
|
||||
#include "../Chunk.h"
|
||||
#include "../Items/ItemHandler.h"
|
||||
#include "../Vector3.h"
|
||||
|
||||
#include "inifile/iniFile.h"
|
||||
#include "json/json.h"
|
||||
|
||||
+14
-3
@@ -270,6 +270,9 @@ public:
|
||||
/// Returns true if the player is currently flying.
|
||||
bool IsFlying(void) const { return m_IsFlying; }
|
||||
|
||||
/** Returns if a player is sleeping in a bed */
|
||||
bool IsInBed(void) const { return m_bIsInBed; }
|
||||
|
||||
/// returns true if the player has thrown out a floater.
|
||||
bool IsFishing(void) const { return m_IsFishing; }
|
||||
|
||||
@@ -278,6 +281,9 @@ public:
|
||||
int GetFloaterID(void) const { return m_FloaterID; }
|
||||
|
||||
// tolua_end
|
||||
|
||||
/** Sets a player's in-bed state; we can't be sure plugins will keep this value updated, so no exporting */
|
||||
void SetIsInBed(bool a_Flag) { m_bIsInBed = a_Flag; }
|
||||
|
||||
/// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet
|
||||
void StartEating(void);
|
||||
@@ -371,8 +377,8 @@ protected:
|
||||
GroupList m_ResolvedGroups;
|
||||
GroupList m_Groups;
|
||||
|
||||
std::string m_PlayerName;
|
||||
std::string m_LoadedWorldName;
|
||||
AString m_PlayerName;
|
||||
AString m_LoadedWorldName;
|
||||
|
||||
/// Xp Level stuff
|
||||
enum
|
||||
@@ -456,7 +462,7 @@ protected:
|
||||
|
||||
int m_FloaterID;
|
||||
|
||||
cTeam* m_Team;
|
||||
cTeam * m_Team;
|
||||
|
||||
|
||||
|
||||
@@ -479,6 +485,11 @@ protected:
|
||||
|
||||
/// Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block)
|
||||
void ApplyFoodExhaustionFromMovement();
|
||||
|
||||
/** Flag representing whether the player is currently in a bed
|
||||
Set by a right click on unoccupied bed, unset by a time fast forward or teleport */
|
||||
bool m_bIsInBed;
|
||||
|
||||
} ; // tolua_export
|
||||
|
||||
|
||||
|
||||
@@ -663,8 +663,6 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do
|
||||
|
||||
void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
|
||||
{
|
||||
// TODO: Apply damage to certain mobs (blaze etc.) and anger all mobs
|
||||
|
||||
Destroy();
|
||||
}
|
||||
|
||||
@@ -672,6 +670,30 @@ void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFac
|
||||
|
||||
|
||||
|
||||
void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
||||
{
|
||||
int TotalDamage = 0;
|
||||
if (a_EntityHit.IsMob())
|
||||
{
|
||||
cMonster::eType MobType = ((cMonster &) a_EntityHit).GetMobType();
|
||||
if (MobType == cMonster::mtBlaze)
|
||||
{
|
||||
TotalDamage = 3;
|
||||
}
|
||||
else if (MobType == cMonster::mtEnderDragon)
|
||||
{
|
||||
TotalDamage = 1;
|
||||
}
|
||||
}
|
||||
a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
|
||||
|
||||
Destroy(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// cBottleOEnchantingEntity :
|
||||
|
||||
|
||||
@@ -259,6 +259,7 @@ protected:
|
||||
|
||||
// cProjectileEntity overrides:
|
||||
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
|
||||
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
|
||||
|
||||
// tolua_begin
|
||||
|
||||
|
||||
Reference in New Issue
Block a user