Commit Graph

102 Commits

Author SHA1 Message Date
34f54750c8 Added support for creation-time validation of generator options, closes #2717 2021-10-11 17:37:47 +01:00
7b6632941d GeneratorManager::getGenerator() now returns null for unknown generator aliases
instead of returning Normal::class (indistinguishable from successful match) or throwing an exception (pain in the ass to handle).
2021-10-11 16:04:36 +01:00
308d7c126a Fixed world data ::generate() functions putting level.dat in the wrong place if the world path didn't end with a / 2021-10-08 23:39:25 +01:00
8de30e8162 FastChunkSerializer no longer serializes light by default
the core doesn't use this anywhere.
serializeWithoutLight() has been renamed to serializeTerrain() to more accurately describe what it does.
2021-10-01 22:57:22 +01:00
5b818827db Chunk: stop exposing SplFixedArray<SubChunk> to the API
this fixes a large number of PHPStan errors, and also brings us a step closer to negative-build-height readiness.
2021-10-01 22:17:28 +01:00
42bf9578ce Remove unused constants 2021-10-01 22:05:03 +01:00
6cf181b579 LevelDB: Use arrow functions for better readability 2021-09-16 14:44:56 +01:00
4111d92b98 Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
11d2e1ef08 Require ext-chunkutils ^0.3.0 2021-09-07 22:53:50 +01:00
0289b45202 Chunk: Drop dirty flags for tiles and entities
instead, just ungate this and allow the provider to decide what to do.
Any chunk that contains entities or tiles is already always considered dirty, so the only thing the flags are good for is flagging chunks that previously had tiles and/or entities but no longer do.
In those cases, it's just removing keys from LevelDB anyway, so it's already very cheap.
Avoiding these redundant deletions is not worth the extra complexity and fragility of relying on flags to track this stuff.
2021-08-30 00:09:36 +01:00
994a2c9eb9 Clean up entity/tile data loading from world providers 2021-08-29 23:11:18 +01:00
91cb374220 LevelDB: fixed isPopulated state getting lost after chunk unload/reload 2021-08-08 16:01:45 +01:00
676bacbee1 Improve the flexibility of WorldProvider registration
WorldProviders now have the following requirements removed:
- __construct() is no longer required to have a specific signature
- static isValid() no longer needs to be implemented (you will still need it for registering, but it can be declared anywhere now)
- static generate() no longer needs to be implemented

This paves the way for more interesting types of world providers that use something other than local disk to store chunks (e.g. a mysql database).

WorldProviderManager no longer accepts class-string<WorldProvider>. Instead, WorldProviderManagerEntry is required, with 2 or 3 callbacks:
- ReadOnlyWorldProviderManager must provide a callback for isValid, and a callback for fromPath
- WritableWorldProviderManagerEntry must provide the same, and also a generate() callback

In practice, this requires zero changes to the WorldProviders themselves, since a WorldProviderManagerEntry can be created like this:
`new WritableWorldProviderManagerEntry(\Closure::fromCallable([LevelDB::class, 'isValid']), fn(string ) => new LevelDB(), \Closure::fromCallable([LevelDB::class, 'generate']))`

This provides identical functionality to before for the provider itself; only registration is changed.
2021-07-13 16:55:21 +01:00
32d7b1e6af Start using webmozart/pathutil for joining paths (#4287) 2021-06-29 19:40:43 +01:00
71a4ea2a95 FastChunkSerializer: remove useless variable initialization 2021-06-17 20:59:40 +01:00
43f71d0d63 FormatConverter: Copy worlds for backup if rename fails
this can fail if the backups directory points to a different drive than the original worlds location. In this case, we have to copy and delete the files instead, which is much slower, but works.
I REALLY advise against putting backups on a different mount point than worlds if you plan to convert large worlds.
2021-06-17 20:46:34 +01:00
61c59be299 Replace hardcoded block metadata shifts and masks with constants
we might want to make these bigger than 4 bits in the future.
2021-06-16 12:48:09 +01:00
5d83f4670a RegionLoader: Switch to using named constructors
this makes the code more self-descriptive, and also helps to detect potential bugs.
2021-04-15 21:57:23 +01:00
a0c3102b05 FormatConverter: add @phpstan-param for newProvider ctor parameter 2021-04-15 19:14:52 +01:00
8e3f5737a0 RegionWorldProvider: fix CS 2021-04-15 15:39:08 +01:00
32c4a165cf Removed RegionLoader::open()
this is nothing but a source of bugs.
2021-04-15 15:38:18 +01:00
edb590f681 missed one ... 2021-04-15 15:23:15 +01:00
08f0c9a244 Separate writable parts of RegionWorldProvider into WritableRegionWorldProvider 2021-04-15 15:20:57 +01:00
e6fb6b1f27 BaseLevelProvider: Remove obsolete proxy methods 2021-04-15 15:15:16 +01:00
7b21fc8e9d WorldCreationOptions are now mandatory during creation of worlds 2021-04-15 13:54:58 +01:00
c90ca37ea3 Fix CS 2021-04-13 21:10:18 +01:00
ab176264b4 ... 2021-04-13 21:06:37 +01:00
9c1b274499 WorldManager::createWorld() now accepts WorldCreationOptions instead of mixed[] 2021-04-13 21:03:25 +01:00
6ce15854af Clean up generator preset handling 2021-04-13 20:19:53 +01:00
eb9a68edee Further refactors to prepare for y=-64 lower limit 2021-03-18 00:08:16 +00:00
9a1cef0d4f Merge branch 'stable' 2021-02-11 22:35:33 +00:00
561fc62232 Merge remote-tracking branch 'origin/stable'
# Conflicts:
#	.github/workflows/main.yml
#	resources/vanilla
#	src/pocketmine/VersionInfo.php
#	src/world/format/io/region/RegionLoader.php
2021-02-03 17:32:47 +00:00
3e1ac66abf Merge branch 'stable' 2021-02-02 13:46:29 +00:00
69a829db91 Merge remote-tracking branch 'origin/stable' 2021-01-20 22:16:44 +00:00
487b5dd11d Merge branch 'stable' 2021-01-16 19:44:15 +00:00
5fa4e284bf Merge branch 'stable' 2020-12-27 19:35:27 +00:00
9228f006d4 Merge remote-tracking branch 'origin/stable'
# Conflicts:
#	composer.json
#	composer.lock
#	resources/vanilla
#	src/CrashDump.php
#	src/PocketMine.php
#	src/pocketmine/Server.php
#	src/pocketmine/item/Bucket.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/Chunk.php
#	src/pocketmine/level/format/io/leveldb/LevelDB.php
#	src/pocketmine/level/format/io/region/McRegion.php
#	src/pocketmine/network/mcpe/protocol/BatchPacket.php
#	src/pocketmine/tile/Furnace.php
#	src/pocketmine/utils/UUID.php
#	src/utils/ServerKiller.php
2020-12-20 20:54:13 +00:00
219cf2126b RegionWorldProvider: make loadRegion() return RegionLoader, fix 3 PHPStan null-reference errors 2020-12-07 19:04:52 +00:00
e810a68dd7 Merge branch 'stable'
# Conflicts:
#	build/php
#	composer.lock
#	resources/vanilla
#	src/pocketmine/VersionInfo.php
#	src/pocketmine/level/format/io/region/McRegion.php
2020-12-07 18:57:58 +00:00
b9cd633cee Chunks no longer exist in un-generated state
a non-generated chunk is now always represented by NULL. This forces the case of ungenerated chunks to be handled by all code, which is necessary because ungenerated chunks cannot be interacted with or modified in any meaningful way.
2020-12-03 22:28:43 +00:00
c808095978 Chunks no longer contain their own coordinates 2020-12-03 21:59:30 +00:00
1f5998d24c FastChunkSerializer no longer encodes chunk coordinates
in cases like PopulationTask it makes more sense to store the coordinates separately where they can be stored more efficiently (once instead of 9 times)
In addition, PopulationTask shouldn't need to serialize an empty chunk just to copy coordinates.

I've made changes like this in other areas already in preparation for the day when chunks no longer contain their coordinates, so this brings us one step closer to that goal.
2020-12-03 20:52:33 +00:00
0a7d81a2b0 FastChunkSerializer: retain emptyBlock on subchunks
I think we should probably get rid of this considering the potential for inconsistencies within a chunk, but not retaining this is a bug nonetheless, even though it doesn't have any effect in PM itself since we always use BlockLegacyIds << 4 as the empty block ID.

so, this is only really aiding (ab)use cases which weren't intended anyway ...
2020-11-27 13:41:35 +00:00
1d551af54a Merge remote-tracking branch 'origin/stable'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/level/Level.php
#	src/pocketmine/level/format/Chunk.php
#	tests/phpstan/configs/l7-baseline.neon
2020-11-01 15:58:16 +00:00
0cbc5c9a4a region: harden handling of ByteArrayTag
previously this would just explode if the wrong length of data was given.
2020-10-31 15:37:06 +00:00
8bab9cc108 RegionWorldProvider: use morton2d directly instead of abusing chunkHash()
while these currently do the same thing, it's very confusing and creates an unnecessary dependency on World.
2020-10-26 15:34:32 +00:00
d6ed542fcd Merge remote-tracking branch 'origin/stable' into master
# Conflicts:
#	composer.json
#	composer.lock
#	src/CrashDump.php
#	src/pocketmine/Server.php
#	src/pocketmine/level/format/io/region/McRegion.php
#	tests/phpstan/configs/check-explicit-mixed-baseline.neon
#	tests/phpstan/configs/l7-baseline.neon
#	tests/phpstan/configs/l8-baseline.neon
#	tests/travis/setup-php.yml
2020-10-26 16:18:53 +00:00
9191e75392 LevelDB: quick and dirty hack for air with bad metadata
this needs a proper solution, but this is a pressing issue that can't wait.
2020-10-03 16:41:26 +01:00
75e3a0aa0f Merge branch 'stable' into master
# Conflicts:
#	composer.lock
#	resources/vanilla
#	src/command/defaults/StatusCommand.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/level/format/SubChunk.php
2020-09-26 13:27:08 +01:00
89cce4c749 performance: only calculate light for chunks inside ticking areas
this produces a major performance improvement for large render distances, and reduces the impact of lighting calculation to zero on servers which have random blockupdates turned off.
2020-09-26 13:13:12 +01:00