From cea3a8e7e8cbf45f709ec63a096cf07b92c87073 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 16:58:40 +0100 Subject: Cauldrons fill --- src/Blocks/BlockCauldron.h | 14 ++++++++++++++ src/Blocks/WorldInterface.h | 3 +++ 2 files changed, 17 insertions(+) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 41b79b6c3..8b5cd9ccb 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -58,6 +58,20 @@ public: { return true; } + + virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override + { + if (!a_WorldInterface.IsWeatherWet()) + { + return; + } + + NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); + if (Meta < 3) + { + a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, Meta + 1); + } + } } ; diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index bfbb053d9..08600d502 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -37,4 +37,7 @@ public: virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0; + /** Returns true if the current weather has any precipitation - rain or storm */ + virtual bool IsWeatherWet(void) const = 0; + }; -- cgit v1.2.3 From 60a37c1370dc766c55a344090d8d26bc2e1c1c99 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 May 2014 16:58:55 +0100 Subject: Very minor code changes --- src/Blocks/BlockBed.cpp | 2 +- src/Blocks/BlockPortal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 6a3c6a55b..07ef997dd 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -108,7 +108,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (Meta & 0x4) { - a_Player->SendMessageFailure("This bed is occupied."); + a_Player->SendMessageFailure("This bed is occupied"); } else { diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 3b8030028..e718d9a70 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -55,7 +55,7 @@ public: virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - if ((a_RelY - 1 < 0) || (a_RelY + 1 > cChunkDef::Height)) + if ((a_RelY == 0) || (a_RelY == cChunkDef::Height)) // Y can't be < 0 or > Height; (Fast)SetBlock won't allow it { return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1 } -- cgit v1.2.3 From 576f89c1d5bdb067c0ca06237440f754d80bd13c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 1 Jun 2014 18:46:59 +0100 Subject: Implemented bed homes + Implemented bed home positions * Fixed some inventory and health server/client mismatches after world change --- src/Blocks/BlockBed.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 07ef997dd..5525f0d0c 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -133,6 +133,8 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit a_Player->SetIsInBed(true); + a_Player->SetBedPos(Vector3i(a_BlockX, a_BlockY, a_BlockZ)); + a_Player->SendMessageSuccess("Home position set successfully"); cTimeFastForwardTester Tester; if (a_WorldInterface.ForEachPlayer(Tester)) -- cgit v1.2.3 From 01f38d883602045e84fdf98bf3395e97608d9aad Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 13:22:50 +0100 Subject: Added checks for no downfall biomes --- src/Blocks/BlockCauldron.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 8b5cd9ccb..5ec776df6 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -61,7 +61,7 @@ public: virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override { - if (!a_WorldInterface.IsWeatherWet()) + if (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(a_RelX, a_RelZ)) || !a_WorldInterface.IsWeatherWet()) { return; } -- cgit v1.2.3 From 156c9851b8a099656fa86ea52d989e35e5b7ebf1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 5 Jun 2014 17:58:29 +0100 Subject: Suggestions --- src/Blocks/WorldInterface.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index 08600d502..7df82197e 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -37,7 +37,9 @@ public: virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0; - /** Returns true if the current weather has any precipitation - rain or storm */ + /** Returns true if the current weather has any precipitation - rain or storm + Does not check if biome has no downfall, use cChunk::GetBiomeAt(RelX, RelZ) for that + */ virtual bool IsWeatherWet(void) const = 0; }; -- cgit v1.2.3 From a70b8298b6ada8abead9ef2b292531407225c2d1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Jun 2014 10:14:04 +0100 Subject: Cauldrons check the heightmap --- src/Blocks/BlockCauldron.h | 6 +++++- src/Blocks/WorldInterface.h | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 5ec776df6..e0f86f4cb 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -61,8 +61,12 @@ public: virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override { - if (IsBiomeNoDownfall(a_Chunk.GetBiomeAt(a_RelX, a_RelZ)) || !a_WorldInterface.IsWeatherWet()) + int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; + int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; + if (!a_WorldInterface.IsWeatherWetAt(BlockX, BlockZ) || (a_RelY != a_WorldInterface.GetHeight(BlockX, BlockZ))) { + // It's not raining at our current location or we do not have a direct view of the sky + // We cannot eat the rain :( return; } diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index 7df82197e..e5638c16e 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -37,9 +37,9 @@ public: virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0; - /** Returns true if the current weather has any precipitation - rain or storm - Does not check if biome has no downfall, use cChunk::GetBiomeAt(RelX, RelZ) for that - */ - virtual bool IsWeatherWet(void) const = 0; + /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */ + virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) = 0; + /** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */ + virtual int GetHeight(int a_BlockX, int a_BlockZ) = 0; }; -- cgit v1.2.3 From 0a15e1f420402e797397ea447b1df96f6ea2106f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 22 Jul 2014 10:33:16 +0100 Subject: Suggestion and failed merge fix --- src/Blocks/BlockPortal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 6f41f96df..fc74e89d0 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -55,7 +55,7 @@ public: virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - if ((a_RelY == 0) || (a_RelY == cChunkDef::Height)) // Y can't be < 0 or > Height; (Fast)SetBlock won't allow it + if ((a_RelY - 1 < 0) || (a_RelY + 1 > cChunkDef::Height)) { return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1 } -- cgit v1.2.3