From b083979cb20ef3726c59a4d4dc9048e848e7827f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 19 Dec 2013 15:57:15 +0000 Subject: Fixed repeaters not updating power --- src/Simulator/RedstoneSimulator.cpp | 52 +++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index eb26d0ca3..92aeda29a 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -186,8 +186,32 @@ void cRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, c } else { - ++itr; + itr++; + } + } + + for (RepeatersDelayList::iterator itr = m_RepeatersDelayList.begin(); itr != m_RepeatersDelayList.end();) + { + int RelX = itr->a_BlockPos.x - a_ChunkX * cChunkDef::Width; + int RelZ = itr->a_BlockPos.z - a_ChunkZ * cChunkDef::Width; + + BLOCKTYPE SourceBlockType; + if (!a_Chunk->UnboundedRelGetBlockType(RelX, itr->a_BlockPos.y, RelZ, SourceBlockType)) + { + continue; + } + + if ((SourceBlockType != E_BLOCK_REDSTONE_REPEATER_ON) && (SourceBlockType != E_BLOCK_REDSTONE_REPEATER_OFF)) + { + itr = m_RepeatersDelayList.erase(itr); + continue; + } + else if (itr->a_ElapsedTicks < itr->a_DelayTicks) + { + itr->a_ElapsedTicks++; } + + itr++; } for (cRedstoneSimulatorChunkData::iterator dataitr = ChunkData.begin(), end = ChunkData.end(); dataitr != end;) @@ -564,9 +588,8 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int { NIBBLETYPE a_Meta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - // We do this so that the repeater can continually update block power status (without being affected by it's own block type, which would happen if the block powering code was in an IF statement) - bool IsOn = ((a_MyState == E_BLOCK_REDSTONE_REPEATER_ON) ? true : false); - bool IsSelfPowered = IsRepeaterPowered(a_BlockX, a_BlockY, a_BlockZ, a_Meta & 0x3); + bool IsOn = ((a_MyState == E_BLOCK_REDSTONE_REPEATER_ON) ? true : false); // Cache if repeater is on + bool IsSelfPowered = IsRepeaterPowered(a_BlockX, a_BlockY, a_BlockZ, a_Meta & 0x3); // Cache if repeater is pwoered if (IsSelfPowered && !IsOn) // Queue a power change if I am receiving power but not on { @@ -618,21 +641,19 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int } } - m_RepeatersDelayList.erase(itr); + // Removal of the data entry will be handled in SimChunk - we still want to continue trying to power blocks, even if our delay time has reached + // Otherwise, the power state of blocks in front won't update after we have powered on return; } else { m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); - m_RepeatersDelayList.erase(itr); + m_RepeatersDelayList.erase(itr); // We can remove off repeaters which don't need further updating return; } } - else - { - itr->a_ElapsedTicks++; - return; - } + + // Tick incrementing handled in SimChunk } } @@ -1271,6 +1292,15 @@ void cRedstoneSimulator::QueueRepeaterPowerChange(int a_BlockX, int a_BlockY, in { if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { + if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry + { + return; + } + + // Already in here (normal to allow repeater to continue on powering and updating blocks in front) - just update info and quit + itr->a_DelayTicks = ((a_Meta & 0xC) >> 0x2) + 1; + itr->a_ElapsedTicks = 0; + itr->ShouldPowerOn = ShouldPowerOn; return; } } -- cgit v1.2.3 From 53ff372624e31028e61cdf72a82945fe935bb420 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 19 Dec 2013 15:57:35 +0000 Subject: Fixed dust from being placed on nonsolids --- src/Blocks/BlockRedstone.h | 2 +- src/Items/ItemRedstoneDust.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h index 57bd91b46..1bd9995f2 100644 --- a/src/Blocks/BlockRedstone.h +++ b/src/Blocks/BlockRedstone.h @@ -20,7 +20,7 @@ public: virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - return ((a_RelY > 0) && g_BlockIsSolid[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)]); + return ((a_RelY > 0) && g_BlockIsTorchPlaceable[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)]); } diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h index b7860b187..38bf00ba6 100644 --- a/src/Items/ItemRedstoneDust.h +++ b/src/Items/ItemRedstoneDust.h @@ -27,6 +27,11 @@ public: BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { + if (!g_BlockIsTorchPlaceable[a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ)]) // Some solid blocks, such as cocoa beans, are not suitable for dust + { + return false; + } + a_BlockType = E_BLOCK_REDSTONE_WIRE; a_BlockMeta = 0; return true; -- cgit v1.2.3 From 53e8c067eabb7eb024c84bf0e2af9c81d30f2acd Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 19 Dec 2013 16:03:43 +0000 Subject: Fixed 1.7 arm swing animation --- src/ClientHandle.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9565fc41f..de0a57a0a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1065,7 +1065,29 @@ void cClientHandle::HandleAnimation(char a_Animation) // Plugin disagrees, bail out return; } - + + // Because the animation ID sent to servers by clients are different to those sent back, we need this + switch (a_Animation) + { + case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1 + case 1: + case 2: + case 3: + { + a_Animation--; // Offset by -1 + break; + } + case 5: + case 6: + case 7: + { + a_Animation -= 2; // Offset by -2 + break; + } + default: // Anything else is the same + break; + } + m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, a_Animation, this); } -- cgit v1.2.3 From 86bfed735e28fe86ec40e89e59eb868c4a0a9b19 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 19 Dec 2013 17:32:06 +0100 Subject: Added cFloater class. --- src/Entities/Entity.h | 3 +++ src/Entities/Floater.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ src/Entities/Floater.h | 29 ++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 src/Entities/Floater.cpp create mode 100644 src/Entities/Floater.h diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 8d1692c98..7107a4a13 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -75,6 +75,7 @@ public: etTNT, etProjectile, etExpOrb, + etFloater, // Common variations etMob = etMonster, // DEPRECATED, use etMonster instead! @@ -129,6 +130,8 @@ public: bool IsBoat (void) const { return (m_EntityType == etBoat); } bool IsTNT (void) const { return (m_EntityType == etTNT); } bool IsProjectile (void) const { return (m_EntityType == etProjectile); } + bool IsExpOrb (void) const { return (m_EntityType == etExpOrb); } + bool IsFloater (void) const { return (m_EntityType == etFloater); } /// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) virtual bool IsA(const char * a_ClassName) const; diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp new file mode 100644 index 000000000..ebbf72b63 --- /dev/null +++ b/src/Entities/Floater.cpp @@ -0,0 +1,58 @@ +#include "Globals.h" + +#include "Floater.h" +#include "Player.h" +#include "../Clienthandle.h" + +cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID) : + cEntity(etFloater, a_X, a_Y, a_Z, 0.98, 0.98), + m_PlayerID(a_PlayerID), + m_CanPickupItem(false), + m_PickupCountDown(0) +{ + SetSpeed(a_Speed); +} + + + + + +void cFloater::SpawnOn(cClientHandle & a_Client) +{ + a_Client.SendSpawnObject(*this, 90, m_PlayerID, 0, 0); +} + + + + + +void cFloater::Tick(float a_Dt, cChunk & a_Chunk) +{ + HandlePhysics(a_Dt, a_Chunk); + if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()))) + { + if (m_World->GetTickRandomNumber(100) == 0) + { + SetSpeedY(-1); + m_CanPickupItem = true; + m_PickupCountDown = 20; + LOGD("Floater %i can be picked up", GetUniqueID()); + } + else + { + SetSpeedY(1); + } + } + SetSpeedX(GetSpeedX() * 0.95); + SetSpeedZ(GetSpeedZ() * 0.95); + if (CanPickup()) + { + m_PickupCountDown--; + if (m_PickupCountDown == 0) + { + m_CanPickupItem = false; + LOGD("The fish is gone. Floater %i can not pick an item up.", GetUniqueID()); + } + } + BroadcastMovementUpdate(); +} \ No newline at end of file diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h new file mode 100644 index 000000000..9bc5039f8 --- /dev/null +++ b/src/Entities/Floater.h @@ -0,0 +1,29 @@ + +#pragma once + +#include "Entity.h" + + + + + +class cFloater : + public cEntity +{ + typedef cFloater super; + +public: + + cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID); + + virtual void SpawnOn(cClientHandle & a_Client) override; + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + + bool CanPickup(void) const { return m_CanPickupItem; } + +protected: + Vector3d m_Speed; + int m_PickupCountDown; + int m_PlayerID; + bool m_CanPickupItem; +} ; \ No newline at end of file -- cgit v1.2.3 From 3d70d7198dbd2b9f71a9cf37bd0cf985495e6b00 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 19 Dec 2013 17:33:21 +0100 Subject: Implented IsFishing, SetIsFishing and GetFloaterID(). --- src/Entities/Player.cpp | 2 ++ src/Entities/Player.h | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7e7d77433..577a33ad9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -65,6 +65,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) , m_IsSubmerged(false) , m_IsFlying(false) , m_CanFly(false) + , m_IsFishing(false) + , m_FloaterID(-1) , m_EatingFinishTick(-1) , m_IsChargingBow(false) , m_BowCharge(0) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 59e941040..74da857e8 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -253,6 +253,14 @@ public: /// Returns true if the player is currently flying. bool IsFlying(void) const { return m_IsFlying; } + + /// returns true if the player has thrown out a floater. + bool IsFishing(void) const { return m_IsFishing; } + + void SetIsFishing(bool a_IsFishing, int a_FloaterID = -1) { m_IsFishing = a_IsFishing; m_FloaterID = a_FloaterID; } + + int GetFloaterID(void) const { return m_FloaterID; } + // tolua_end /// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet @@ -429,6 +437,7 @@ protected: bool m_IsFlying; bool m_IsSwimming; bool m_IsSubmerged; + bool m_IsFishing; bool m_CanFly; // If this is true the player can fly. Even if he is not in creative. @@ -445,6 +454,7 @@ protected: bool m_IsChargingBow; int m_BowCharge; + int m_FloaterID; virtual void Destroyed(void); -- cgit v1.2.3 From d9c8ae37cf332d4be93b7727f0c1899f40362aef Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 19 Dec 2013 17:34:03 +0100 Subject: Implented cItemFishingRodHandler. --- src/Items/ItemFishingRod.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++ src/Items/ItemHandler.cpp | 2 ++ 2 files changed, 65 insertions(+) create mode 100644 src/Items/ItemFishingRod.h diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h new file mode 100644 index 000000000..722c48c04 --- /dev/null +++ b/src/Items/ItemFishingRod.h @@ -0,0 +1,63 @@ + +// ItemFishingRod.h + +// Declares the various fishing rod ItemHandlers + + + + + +#pragma once + +#include "../Entities/Floater.h" +#include "../Entities/Entity.h" + + + + + +class cItemFishingRodHandler : + public cItemHandler +{ + typedef cItemHandler super; + +public: + cItemFishingRodHandler(int a_ItemType) : + super(a_ItemType) + { + } + + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + { + if (a_Player->IsFishing()) + { + class Callbacks : public cEntityCallback + { + public: + bool CanPickup; + virtual bool Item(cEntity * a_Entity) override + { + CanPickup = ((cFloater *)a_Entity)->CanPickup(); + a_Entity->Destroy(true); + return true; + } + Callbacks(void) : CanPickup(false) {} + } Callback; + a_World->DoWithEntityByID(a_Player->GetFloaterID(), Callback); + a_Player->SetIsFishing(false); + if (Callback.CanPickup) + { + a_Player->SendMessage("TODO: Spawn Items."); + // TODO: Pickups if fishing went correct. + } + + } + else + { + cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 5, a_Player->GetUniqueID()); + Floater->Initialize(a_World); + a_Player->SetIsFishing(true, Floater->GetUniqueID()); + } + return true; + } +} ; \ No newline at end of file diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 23b9a86d4..250e21dc4 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -17,6 +17,7 @@ #include "ItemComparator.h" #include "ItemDoor.h" #include "ItemDye.h" +#include "ItemFishingRod.h" #include "ItemFlowerPot.h" #include "ItemFood.h" #include "ItemHoe.h" @@ -100,6 +101,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_EGG: return new cItemEggHandler(); case E_ITEM_ENDER_PEARL: return new cItemEnderPearlHandler(); case E_ITEM_FIREWORK_ROCKET: return new cItemFireworkHandler(); + case E_ITEM_FISHING_ROD: return new cItemFishingRodHandler(a_ItemType); case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType); case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType); case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType); -- cgit v1.2.3 From 4a028986838948eeca0f61aefd281b6386c5dda5 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 19 Dec 2013 17:46:12 +0100 Subject: Added the Floater files to MCServer.vcproj --- VC2008/MCServer.vcproj | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 5b756f3b6..cb9867450 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -1358,6 +1358,14 @@ RelativePath="..\src\Entities\FallingBlock.h" > + + + + @@ -2566,6 +2574,10 @@ RelativePath="..\src\items\ItemDye.h" > + + -- cgit v1.2.3 From 78c59082379ff5ce09ad86b13b0bdb679fe08d71 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 19 Dec 2013 20:04:40 +0000 Subject: Test commit. --- COMPILING | 1 + 1 file changed, 1 insertion(+) diff --git a/COMPILING b/COMPILING index f8bdb298e..708e4413e 100644 --- a/COMPILING +++ b/COMPILING @@ -5,3 +5,4 @@ To compile MCServer on *nix, you need a GNUmake-compatible make that reads GNUma Run "make" to build a debug version (slow, but gives more info on crash) Run "make release=1" to build a release version (fast, less info on crash) Add addm32=1 to compile in 32-bit mode on 64-bit systems. +Add `-j 4` to use 4 threads and speed up compilation on multi-core devices. -- cgit v1.2.3 From 11e50df20901707d2b53186f454041ac1ca674f9 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 19 Dec 2013 20:07:58 +0000 Subject: Create .travis.yml --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..1233d55e9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: cpp +compiler: + - gcc + - clang +# Change this to your needs +script: make release=1 -- cgit v1.2.3 From 9f986a808c5d675d1b4622d8dc4c117dcf5c1dc3 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 19 Dec 2013 20:15:59 +0000 Subject: Update submodule URLs so people without SSH can get them. --- .gitmodules | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 088271457..028471319 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ [submodule "MCServer/Plugins/Core"] path = MCServer/Plugins/Core - url = git@github.com:mc-server/Core.git + url = git://github.com/mc-server/Core.git [submodule "MCServer/Plugins/ProtectionAreas"] path = MCServer/Plugins/ProtectionAreas - url = git@github.com:mc-server/ProtectionAreas.git + url = git://github.com/mc-server/ProtectionAreas.git [submodule "MCServer/Plugins/TransAPI"] path = MCServer/Plugins/TransAPI - url = git@github.com:bearbin/transapi.git + url = git://github.com/bearbin/transapi.git -- cgit v1.2.3 From 4df5bbb3f3ca820efdcd7f7f01917ae328ba834e Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 19 Dec 2013 20:35:45 +0000 Subject: update readme with travis info --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 255d9d467..467036950 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,5 @@ Other Stuff For other stuff, including plugins and discussion, check the [forums](http://forum.mc-server.org) and [wiki](http://mc-server.org/wiki/). Earn bitcoins for commits or donate to reward the MCServer developers: [![tip for next commit](http://tip4commit.com/projects/74.svg)](http://tip4commit.com/projects/74) + +Travis CI: [![Build Status](https://travis-ci.org/mc-server/MCServer.png?branch=master)](https://travis-ci.org/mc-server/MCServer) -- cgit v1.2.3 From 3f496db5a9f35065e178099c03e62718e44fd64e Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 19 Dec 2013 20:42:40 +0000 Subject: explicitly defined email notifications --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1233d55e9..7341232a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,11 @@ language: cpp compiler: - gcc - clang -# Change this to your needs +# Build MCServer script: make release=1 + +# Notification Settings +notifications: + email: + on_success: change + on_failure: always -- cgit v1.2.3 From 296a421e8a5820d4b63e74ba10c2c69571f16b20 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 19 Dec 2013 20:49:35 +0000 Subject: just a little change for travis ci test --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b0ad11d53..c65e6b8f6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,9 +11,11 @@ cloc.xsl *.user *.suo /EveryNight.cmd -*.sublime-* -# emacs stuff +# IDE Stuff +## Sublime Text +*.sublime-* +## emacs *.*~ # world inside source -- cgit v1.2.3 From 03a8dfc4a8daf2ef3ea63b1fdf161018acbe12ce Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 19 Dec 2013 20:53:47 +0000 Subject: Fixed PlayerAbilities and creative --- src/ClientHandle.cpp | 6 +++--- src/Entities/Player.cpp | 18 ++++++++++++++++++ src/Protocol/Protocol17x.cpp | 13 +++---------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index de0a57a0a..1e63e2ba1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -264,9 +264,6 @@ void cClientHandle::Authenticate(void) // Send experience m_Player->SendExperience(); - // Send gamemode (1.6.1 movementSpeed): - SendGameMode(m_Player->GetGameMode()); - m_Player->Initialize(World); m_State = csAuthenticated; @@ -489,6 +486,9 @@ void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_Hel void cClientHandle::HandlePlayerAbilities(bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed) { + UNUSED(FlyingSpeed); // Ignore the client values for these + UNUSED(WalkingSpeed); + m_Player->SetCanFly(a_CanFly); m_Player->SetFlying(a_IsFlying); } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7e7d77433..bb19bcce9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1500,6 +1500,24 @@ bool cPlayer::LoadFromDisk() //SetExperience(root.get("experience", 0).asInt()); m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt(); + + if (m_GameMode == eGameMode_Creative) + { + m_CanFly = true; + } + else if (m_GameMode == eGameMode_NotSet) + { + cWorld * World = cRoot::Get()->GetWorld(GetLoadedWorldName()); + if (World == NULL) + { + World = cRoot::Get()->GetDefaultWorld(); + } + + if (World->GetGameMode() == eGameMode_Creative) + { + m_CanFly = true; + } + } m_Inventory.LoadFromJson(root["inventory"]); diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index fff5311f6..161e81936 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -490,6 +490,7 @@ void cProtocol172::SendPlayerAbilities(void) if (m_Client->GetPlayer()->IsGameModeCreative()) { Flags |= 0x01; + Flags |= 0x08; // Godmode, used for creative } if (m_Client->GetPlayer()->IsFlying()) { @@ -499,7 +500,6 @@ void cProtocol172::SendPlayerAbilities(void) { Flags |= 0x04; } - // TODO: Other flags (god mode) Pkt.WriteByte(Flags); // TODO: Pkt.WriteFloat(m_Client->GetPlayer()->GetMaxFlyingSpeed()); Pkt.WriteFloat(0.05f); @@ -1291,23 +1291,16 @@ void cProtocol172::HandlePacketPlayerAbilities(cByteBuffer & a_ByteBuffer) HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, FlyingSpeed); HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, WalkingSpeed); - bool IsFlying, CanFly; + bool IsFlying = false, CanFly = false; if ((Flags & 2) != 0) { IsFlying = true; } - else - { - IsFlying = false; - } if ((Flags & 4) != 0) { CanFly = true; } - else - { - CanFly = false; - } + m_Client->HandlePlayerAbilities(CanFly, IsFlying, FlyingSpeed, WalkingSpeed); } -- cgit v1.2.3 From 5a97d831de3c11af704148a7e67be9994ae778eb Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 19 Dec 2013 20:56:07 +0000 Subject: take advantage of 1.5 cores given by travis with parallelization! --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7341232a7..229f55ebf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ compiler: - gcc - clang # Build MCServer -script: make release=1 +script: make release=1 -j 2 # Notification Settings notifications: -- cgit v1.2.3 From 018c65b4e3d1e5674e3134281ced640b0e85871f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 19 Dec 2013 22:16:15 +0100 Subject: You can get fish from fishing :D. Only one type of fish though. --- src/Items/ItemFishingRod.h | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 722c48c04..91c0e9638 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -11,7 +11,7 @@ #include "../Entities/Floater.h" #include "../Entities/Entity.h" - +#include "../Item.h" @@ -31,30 +31,45 @@ public: { if (a_Player->IsFishing()) { - class Callbacks : public cEntityCallback + class cFloaterCallback : + public cEntityCallback { public: - bool CanPickup; + cFloaterCallback(void) : + m_CanPickup(false) + { + } + + bool CanPickup(void) const { return m_CanPickup; } + Vector3d GetPos(void) const { return m_Pos; } + virtual bool Item(cEntity * a_Entity) override { - CanPickup = ((cFloater *)a_Entity)->CanPickup(); + m_CanPickup = ((cFloater *)a_Entity)->CanPickup(); + m_Pos = Vector3d(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ()); a_Entity->Destroy(true); return true; } - Callbacks(void) : CanPickup(false) {} - } Callback; - a_World->DoWithEntityByID(a_Player->GetFloaterID(), Callback); + protected: + bool m_CanPickup; + Vector3d m_Pos; + } Callbacks; + a_World->DoWithEntityByID(a_Player->GetFloaterID(), Callbacks); a_Player->SetIsFishing(false); - if (Callback.CanPickup) + + if (Callbacks.CanPickup()) { - a_Player->SendMessage("TODO: Spawn Items."); - // TODO: Pickups if fishing went correct. + cItems Drops; + Drops.Add(cItem(E_ITEM_RAW_FISH)); + Vector3d FloaterPos(Callbacks.GetPos()); + Vector3d FlyDirection(a_Player->GetPosition() - FloaterPos); + a_World->SpawnItemPickups(Drops, FloaterPos.x, FloaterPos.y, FloaterPos.z, FlyDirection.x, FlyDirection.y, FlyDirection.z); + // TODO: More types of pickups. } - } else { - cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 5, a_Player->GetUniqueID()); + cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 7, a_Player->GetUniqueID()); Floater->Initialize(a_World); a_Player->SetIsFishing(true, Floater->GetUniqueID()); } -- cgit v1.2.3 From 32d117a4988a55d8968fcc483d6d5614ef6c04dd Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 19 Dec 2013 22:18:05 +0100 Subject: The floater now actualy dives under water. --- src/Entities/Floater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index ebbf72b63..c467961c6 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -33,7 +33,7 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) { if (m_World->GetTickRandomNumber(100) == 0) { - SetSpeedY(-1); + SetPosY(GetPosY() - 1); m_CanPickupItem = true; m_PickupCountDown = 20; LOGD("Floater %i can be picked up", GetUniqueID()); -- cgit v1.2.3 From a1ce0a6d73f5d13e1c4391ecec87f6c814f4cf55 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 19 Dec 2013 22:44:10 +0100 Subject: Fixed #include in Floater.cpp. --- src/Entities/Floater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index c467961c6..1aa0413d9 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -2,7 +2,7 @@ #include "Floater.h" #include "Player.h" -#include "../Clienthandle.h" +#include "../ClientHandle.h" cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID) : cEntity(etFloater, a_X, a_Y, a_Z, 0.98, 0.98), -- cgit v1.2.3