From ed88d68fd70b6fb1204f7d584c092bc2b8d46630 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 11 Apr 2023 23:20:58 +0100 Subject: [PATCH] Remove stuff deprecated in 4.19.0 --- src/entity/object/ExperienceOrb.php | 10 ++-- src/player/PlayerChunkLoader.php | 47 ------------------ src/timings/Timings.php | 6 --- src/world/TickingChunkLoader.php | 40 --------------- src/world/World.php | 76 +---------------------------- 5 files changed, 4 insertions(+), 175 deletions(-) delete mode 100644 src/player/PlayerChunkLoader.php delete mode 100644 src/world/TickingChunkLoader.php diff --git a/src/entity/object/ExperienceOrb.php b/src/entity/object/ExperienceOrb.php index 0d3af7e6c..5120da3e1 100644 --- a/src/entity/object/ExperienceOrb.php +++ b/src/entity/object/ExperienceOrb.php @@ -84,9 +84,6 @@ class ExperienceOrb extends Entity{ return $result; } - /** @deprecated */ - protected int $age = 0; - /** Ticker used for determining interval in which to look for new target players. */ protected int $lookForTargetTime = 0; @@ -111,11 +108,11 @@ class ExperienceOrb extends Entity{ protected function initEntity(CompoundTag $nbt) : void{ parent::initEntity($nbt); - $this->age = $nbt->getShort(self::TAG_AGE, 0); - if($this->age === -32768){ + $age = $nbt->getShort(self::TAG_AGE, 0); + if($age === -32768){ $this->despawnDelay = self::NEVER_DESPAWN; }else{ - $this->despawnDelay = max(0, self::DEFAULT_DESPAWN_DELAY - $this->age); + $this->despawnDelay = max(0, self::DEFAULT_DESPAWN_DELAY - $age); } } @@ -180,7 +177,6 @@ class ExperienceOrb extends Entity{ protected function entityBaseTick(int $tickDiff = 1) : bool{ $hasUpdate = parent::entityBaseTick($tickDiff); - $this->age += $tickDiff; $this->despawnDelay -= $tickDiff; if($this->despawnDelay <= 0){ $this->flagForDespawn(); diff --git a/src/player/PlayerChunkLoader.php b/src/player/PlayerChunkLoader.php deleted file mode 100644 index 175f242d3..000000000 --- a/src/player/PlayerChunkLoader.php +++ /dev/null @@ -1,47 +0,0 @@ -currentLocation = $currentLocation; - } - - public function getX() : float{ - return $this->currentLocation->getFloorX(); - } - - public function getZ() : float{ - return $this->currentLocation->getFloorZ(); - } -} diff --git a/src/timings/Timings.php b/src/timings/Timings.php index 9f011e3ed..a4d2a6967 100644 --- a/src/timings/Timings.php +++ b/src/timings/Timings.php @@ -34,12 +34,6 @@ use function get_class; use function str_starts_with; abstract class Timings{ - /** - * @deprecated This was used by the old timings viewer to make a timer appear in the Breakdown section of a timings - * report. Provide a group to your timer's constructor instead. - * @see Timings::GROUP_BREAKDOWN - */ - public const INCLUDED_BY_OTHER_TIMINGS_PREFIX = "** "; public const GROUP_BREAKDOWN = "Minecraft - Breakdown"; private static bool $initialized = false; diff --git a/src/world/TickingChunkLoader.php b/src/world/TickingChunkLoader.php deleted file mode 100644 index a44173c33..000000000 --- a/src/world/TickingChunkLoader.php +++ /dev/null @@ -1,40 +0,0 @@ - TickingChunkLoader - * @phpstan-var array - * - * @deprecated - */ - private array $tickingLoaders = []; - /** - * @var int[] spl_object_id => number of chunks - * @phpstan-var array - * - * @deprecated - */ - private array $tickingLoaderCounter = []; - /** * @var TickingChunkEntry[] chunkHash => TickingChunkEntry * @phpstan-var array @@ -799,15 +783,6 @@ class World implements ChunkManager{ $this->chunkLoaders[$chunkHash][$loaderId] = $loader; - if($loader instanceof TickingChunkLoader){ - if(!isset($this->tickingLoaders[$loaderId])){ - $this->tickingLoaderCounter[$loaderId] = 1; - $this->tickingLoaders[$loaderId] = $loader; - }else{ - ++$this->tickingLoaderCounter[$loaderId]; - } - } - $this->cancelUnloadChunkRequest($chunkX, $chunkZ); if($autoLoad){ @@ -828,11 +803,6 @@ class World implements ChunkManager{ unset($this->chunkPopulationRequestMap[$chunkHash]); } } - - if(isset($this->tickingLoaderCounter[$loaderId]) && --$this->tickingLoaderCounter[$loaderId] === 0){ - unset($this->tickingLoaderCounter[$loaderId]); - unset($this->tickingLoaders[$loaderId]); - } } } @@ -1206,46 +1176,8 @@ class World implements ChunkManager{ } } - /** - * @deprecated - * - * @param true[] $chunkTickList - * @param bool[] $chunkTickableCache - * - * @phpstan-param array $chunkTickList - * @phpstan-param array $chunkTickableCache - * @phpstan-param-out array $chunkTickList - * @phpstan-param-out array $chunkTickableCache - */ - private function selectTickableChunksLegacy(array &$chunkTickList, array &$chunkTickableCache) : void{ - $centerChunks = []; - - $selector = new ChunkSelector(); - foreach($this->tickingLoaders as $loader){ - $centerChunkX = (int) floor($loader->getX()) >> Chunk::COORD_BIT_SIZE; - $centerChunkZ = (int) floor($loader->getZ()) >> Chunk::COORD_BIT_SIZE; - $centerChunkPosHash = World::chunkHash($centerChunkX, $centerChunkZ); - if(isset($centerChunks[$centerChunkPosHash])){ - //we already queued chunks in this radius because of a previous loader on the same chunk - continue; - } - $centerChunks[$centerChunkPosHash] = true; - - foreach($selector->selectChunks( - $this->chunkTickRadius, - $centerChunkX, - $centerChunkZ - ) as $hash){ - World::getXZ($hash, $chunkX, $chunkZ); - if(!isset($chunkTickList[$hash]) && isset($this->chunks[$hash]) && $this->isChunkTickable($chunkX, $chunkZ, $chunkTickableCache)){ - $chunkTickList[$hash] = true; - } - } - } - } - private function tickChunks() : void{ - if($this->chunkTickRadius <= 0 || (count($this->tickingChunks) === 0 && count($this->tickingLoaders) === 0)){ + if($this->chunkTickRadius <= 0 || count($this->tickingChunks) === 0){ return; } @@ -1269,12 +1201,6 @@ class World implements ChunkManager{ $chunkTickList[$hash] = true; } - //TODO: REMOVE THIS - //backwards compatibility for TickingChunkLoader, although I'm not sure this is really necessary in practice - if(count($this->tickingLoaders) !== 0){ - $this->selectTickableChunksLegacy($chunkTickList, $chunkTickableCache); - } - $this->timings->randomChunkUpdatesChunkSelection->stopTiming(); foreach($chunkTickList as $index => $_){