From 4cd49d7eca5f8fd53eb98577a1f218a5086704bb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 5 Apr 2021 01:38:43 +0100 Subject: Fix sending incorrect date values on world change Yak shave: make more things use cTickTime. Fix a couple of incorrect modulo-on-millisecond-value by making them use WorldTickAge. --- src/Blocks/BlockBed.cpp | 4 ++-- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockPiston.cpp | 4 ++-- src/Blocks/WorldInterface.h | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 531f88345..4fe22dffd 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -75,7 +75,7 @@ bool cBlockBedHandler::OnUse( // Sleeping is allowed only during night and thunderstorms: if ( - !(((a_WorldInterface.GetTimeOfDay() > 12541) && (a_WorldInterface.GetTimeOfDay() < 23458)) || + !(((a_WorldInterface.GetTimeOfDay() > 12541_tick) && (a_WorldInterface.GetTimeOfDay() < 23458_tick)) || (a_Player.GetWorld()->GetWeather() == wThunderstorm)) ) // Source: https://minecraft.gamepedia.com/Bed#Sleeping { @@ -146,7 +146,7 @@ bool cBlockBedHandler::OnUse( return false; } ); - a_WorldInterface.SetTimeOfDay(0); + a_WorldInterface.SetTimeOfDay(0_tick); a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta & 0x0b); // Clear the "occupied" bit of the bed's block } return true; diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 985c1fff9..0c942cb49 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -193,7 +193,7 @@ private: The given block type is checked when the task is executed to ensure the position still contains a button. */ static void QueueButtonRelease(cWorld & a_ButtonWorld, const Vector3i a_Position, const BLOCKTYPE a_BlockType) { - const auto TickDelay = (a_BlockType == E_BLOCK_STONE_BUTTON) ? 20 : 30; + const auto TickDelay = (a_BlockType == E_BLOCK_STONE_BUTTON) ? 20_tick : 30_tick; a_ButtonWorld.ScheduleTask( TickDelay, [a_Position, a_BlockType](cWorld & a_World) diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index d9deedfc8..31f15a467 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -56,7 +56,7 @@ void cBlockPistonHandler::ExtendPiston(Vector3i a_BlockPos, cWorld & a_World) // However, we don't confuse animation with the underlying state of the world, so emulate by delaying 1 tick // (Probably why vanilla has so many dupe glitches with sand and pistons lolol) - a_World.ScheduleTask(1, [a_BlockPos](cWorld & World) + a_World.ScheduleTask(1_tick, [a_BlockPos](cWorld & World) { BLOCKTYPE pistonBlock; NIBBLETYPE pistonMeta; @@ -108,7 +108,7 @@ void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld & a_World) a_World.BroadcastBlockAction(a_BlockPos, PistonRetractAction, pistonMeta, pistonBlock); } - a_World.ScheduleTask(1, [a_BlockPos](cWorld & World) + a_World.ScheduleTask(1_tick, [a_BlockPos](cWorld & World) { BLOCKTYPE pistonBlock; NIBBLETYPE pistonMeta; diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index 4ae3f33c9..b610bd9ac 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -21,8 +21,8 @@ class cWorldInterface public: virtual ~cWorldInterface() {} - virtual int GetTimeOfDay(void) const = 0; - virtual Int64 GetWorldAge(void) const = 0; + virtual cTickTime GetTimeOfDay(void) const = 0; + virtual cTickTimeLong GetWorldAge(void) const = 0; virtual eDimension GetDimension(void) const = 0; @@ -70,7 +70,7 @@ public: If any chunk in the box is missing, ignores the entities in that chunk silently. */ virtual bool ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback a_Callback) = 0; - virtual void SetTimeOfDay(int a_TimeOfDay) = 0; + virtual void SetTimeOfDay(cTickTime a_TimeOfDay) = 0; /** Returns true if it is raining or storming at the specified location. This takes into account biomes. */ virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) = 0; -- cgit v1.2.3