diff options
author | Gargaj <gargaj@conspiracy.hu> | 2015-12-15 21:11:58 +0100 |
---|---|---|
committer | Gargaj <gargaj@conspiracy.hu> | 2015-12-15 21:14:27 +0100 |
commit | 68ff0edfde8d2c81e92e7b1334f8e9f19f4517d9 (patch) | |
tree | bd391b7fe84756a5290f0ee0a28ab318a3a47728 /src | |
parent | Merge pull request #2750 from cuberite/wrng (diff) | |
download | cuberite-68ff0edfde8d2c81e92e7b1334f8e9f19f4517d9.tar cuberite-68ff0edfde8d2c81e92e7b1334f8e9f19f4517d9.tar.gz cuberite-68ff0edfde8d2c81e92e7b1334f8e9f19f4517d9.tar.bz2 cuberite-68ff0edfde8d2c81e92e7b1334f8e9f19f4517d9.tar.lz cuberite-68ff0edfde8d2c81e92e7b1334f8e9f19f4517d9.tar.xz cuberite-68ff0edfde8d2c81e92e7b1334f8e9f19f4517d9.tar.zst cuberite-68ff0edfde8d2c81e92e7b1334f8e9f19f4517d9.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Mobs/Horse.cpp | 22 | ||||
-rw-r--r-- | src/Mobs/Horse.h | 3 | ||||
-rw-r--r-- | src/Protocol/Protocol18x.cpp | 6 |
3 files changed, 29 insertions, 2 deletions
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index a338f12bd..f133f9912 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -23,7 +23,8 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) : m_Armour(0), m_TimesToTame(TameTimes), m_TameAttemptTimes(0), - m_RearTickCount(0) + m_RearTickCount(0), + m_Speed(20.0) { } @@ -67,6 +68,7 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) } else { + // TODO: emit hearts here m_bIsTame = true; } } @@ -158,3 +160,21 @@ void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cHorse::InStateIdle(std::chrono::milliseconds a_Dt) +{ + // If horse is tame and someone is sitting on it, don't walk around + if ((!m_bIsTame) || (m_Attachee == nullptr)) + { + super::InStateIdle(a_Dt); + } +} + + + + + +void cHorse::HandleSpeedFromAttachee(float a_Forward, float a_Sideways) +{ + super::HandleSpeedFromAttachee(a_Forward * m_Speed, a_Sideways * m_Speed); +} diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h index 987ab71a9..c87d437c9 100644 --- a/src/Mobs/Horse.h +++ b/src/Mobs/Horse.h @@ -18,6 +18,8 @@ public: CLASS_PROTODEF(cHorse) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + virtual void InStateIdle(std::chrono::milliseconds a_Dt) override; + virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override; virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void OnRightClicked(cPlayer & a_Player) override; @@ -42,6 +44,7 @@ private: bool m_bHasChest, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame, m_bIsSaddled; int m_Type, m_Color, m_Style, m_Armour, m_TimesToTame, m_TameAttemptTimes, m_RearTickCount; + float m_Speed; } ; diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index 833746c00..ad2964bed 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -2486,8 +2486,8 @@ void cProtocol180::HandlePacketSlotSelect(cByteBuffer & a_ByteBuffer) void cProtocol180::HandlePacketSteerVehicle(cByteBuffer & a_ByteBuffer) { - HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Forward); HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Sideways); + HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Forward); HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Flags); if ((Flags & 0x2) != 0) @@ -2496,6 +2496,10 @@ void cProtocol180::HandlePacketSteerVehicle(cByteBuffer & a_ByteBuffer) } else if ((Flags & 0x1) != 0) { + // jump + } + else + { m_Client->HandleSteerVehicle(Forward, Sideways); } } |