1140 Commits

Author SHA1 Message Date
Dylan K. Taylor
ad1cf38c21 LevelProviderManager: tighten up checks on registering 2018-07-17 12:02:08 +01:00
Dylan K. Taylor
5d769147ca LevelProviderManager: make addProvider() throw InvalidArgumentException instead of LevelException
LevelException is not useful because it's too generic.
2018-07-17 12:02:08 +01:00
Dylan K. Taylor
6f00a30ad7 Merge branch 'release/3.0' into release/3.1 2018-07-17 10:12:52 +01:00
Dylan K. Taylor
921f7e8f6a Level: remove useless check from populateChunk()
this is already checked at the top of the function.
2018-07-16 17:36:36 +01:00
Dylan K. Taylor
478a131aa5 Flat: separate logic of parsing preset and generating base chunk
now always generates the base chunk on init, because the generator won't be created unless there is generation to be done.
2018-07-14 11:51:49 +01:00
Dylan K. Taylor
53068caf3c Level: Only register generators when attempting to actually generate chunks
This saves a ton of memory on servers which don't generate any chunks during their runtime (which is most servers).
2018-07-14 11:34:55 +01:00
Dylan K. Taylor
1b7cd156aa Merge branch 'release/3.0' into release/3.1 2018-07-12 18:04:19 +01:00
Dylan K. Taylor
8aa8280a63
Level: Make spawn protection always active regardless of op count (#2290)
I don't care if this matches PC behaviour or not. bugs.mojang.com is full of bug reports about this. Just search for "minecraft spawn protection not working" and you'll see what I mean.

If you want to disable spawn protection, actually disable it. This behaviour is something that most users are not aware of and find astonishing when they discover it.

This behaviour was copied from Minecraft PC, and it's nearly as unexpected there as it is here.

This commit reverses the stupidity done in eb0525e892219508d0c0e4602e835d5ddbacaf45.
2018-07-12 17:25:05 +01:00
Dylan K. Taylor
066c990301 Merge branch 'release/3.0' into release/3.1 2018-07-11 10:21:16 +01:00
Dylan K. Taylor
06b80a9536 Level: Make getSafeSpawn() account for non-generated chunks
fixes #2295

There is still an issue in that the spawn point will not be offset if the chunk is not generated, but this is better than the spawn point being down at y=0. The other issue is a job for another time.
2018-07-11 10:17:59 +01:00
Dylan K. Taylor
28a72a93b4 Chunk: Use an SplFixedArray for heightmap
this goes on 3.1 because it changes the behaviour of chunk cloning, which might possibly break some plugins, and this isn't a bug fix.

This should see no change in behaviour other than a minor performance improvement and slight reduction in memory usage.
2018-07-05 11:58:20 +01:00
Dylan K. Taylor
dfc11abf2d Level: fixed sendBlocks() documentation 2018-07-02 16:53:48 +01:00
Dylan K. Taylor
17eef9f902 Level: stricten type checks on sendBlocks()
because people are morons
2018-07-02 16:53:00 +01:00
Dylan K. Taylor
57cfe9fd43 Level: fixed logic for sending changed blocks to players
If there is an empty list of blocks in the changedBlocks array for a chunk, that means that blocks changed the normal way and then were later set the direct way in the same tick. This means that no action needs to be taken on these chunks.
2018-06-29 11:10:31 +01:00
Dylan K. Taylor
d8824e7ee1 Level: discard changed blocks on chunk replace
this could cause issues when plugins replace chunks when blocks in the chunk have been changed on the same tick.
2018-06-29 11:06:33 +01:00
Dylan K. Taylor
3455d0f3b9 Level: cleaned up some nonsensical code in setChunk() 2018-06-29 10:58:31 +01:00
Dylan K. Taylor
76174f1920 Explosion: avoid leaving arrows stuck in nonexistent blocks 2018-06-23 13:03:46 +01:00
Dylan K. Taylor
f77a829a52 LevelDB: remove redundant check
Assume that entities on a chunk are not closed... none of the other providers check this
2018-06-16 18:00:26 +01:00
Dylan K. Taylor
f315aca4c3 Tile: make saveNBT() return a CompoundTag
I don't know why I made it take a parameter for this...
2018-06-16 17:59:41 +01:00
Dylan K. Taylor
ff2e99ecdc McRegion: nbtDeserialize() cannot return null 2018-06-11 15:05:38 +01:00
Dylan K. Taylor
07a156f5c4 BaseLevelProvider: remove leftover from b54197904d6c23c5babe2857d0107d9d0fc8bd68 2018-06-11 14:32:42 +01:00
Dylan K. Taylor
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
Dylan K. Taylor
3be6665e3d AsyncWorker IDs now start from 0 instead of 1
this now matches their IDs in the AsyncWorker pool, as used by submitTask().
2018-06-11 11:58:24 +01:00
Dylan K. Taylor
b9718f9e87 Remove redundant second parameters for BlockFactory::get() 2018-06-11 11:03:23 +01:00
Dylan K. Taylor
1d1e6966a2 Biome: remove useless abstract class 2018-06-11 11:00:33 +01:00
Dylan K. Taylor
610b7bd8b0 RiverBiome: don't generate grass underwater 2018-06-11 10:58:30 +01:00
Dylan K. Taylor
88d83e0fca AsyncPool: Lazy-start AsyncWorkers when they are needed only
This changes how the AsyncPool works so that it does not immediately always start all of the workers in the pool.
Instead, workers will be started only when an idle worker was not found.
This allows for significant memory footprint reductions while idle.

In effect the async-workers setting in pocketmine.yml now dictates a _maximum_ pool size, not a fixed pool size.
2018-06-11 10:23:46 +01:00
Dylan K. Taylor
4b221c0601 OceanBiome: don't inherit from GrassyBiome, change ground cover to gravel 2018-06-11 09:58:48 +01:00
Dylan K. Taylor
c4c6c58615 Added some missing typehints 2018-06-10 17:18:55 +01:00
Dylan K. Taylor
37b445f210 Updated Math dependency 2018-06-09 13:05:25 +01:00
Dylan K. Taylor
d04991feb6 Level: Avoid chunk sending bugs caused by duplicate chunks with wrong coordinates
If the same chunk is set into multiple different places in the world, the chunk's position is no longer able to be relied on, because it will have the position of the last place it was set. This results in chunks not getting sent correctly when the same chunk is set in multiple places.

This avoids the bug by using known valid coordinates (using chunk hashes) to establish the real coordinates, and also adds an assert to notify developers should they unintentionally set a duplicate chunk by mistake.
2018-06-09 11:25:45 +01:00
Dylan K. Taylor
af69418a55 PlainBiome: reduce maximum elevation 2018-06-08 13:04:45 +01:00
Dylan K. Taylor
8cd311bcb4 GroundCover: don't replace liquid with can-be-flowed-into blocks
fixes snow layers generating underwater
2018-06-08 11:15:19 +01:00
Dylan K. Taylor
78ec3937bf BiomeSelector: drastically simplified implementation and made more robust
- Doesn't need to be pre-populated with biomes prior to calculating the heatmap - now population of biomes is entirely dependent on the lookup function, improving consistency
- Uses an abstract class method for lookup instead of callback (use anonymous class instead)
- Faster because the heatmap is directly populated with biomes instead of biome IDs, removing an unnecessary lookup.
2018-06-08 10:19:08 +01:00
Dylan K. Taylor
4e3e807741 Biome: Added UnknownBiome class to avoid astonishing behaviour on unknown biomes 2018-06-08 10:19:08 +01:00
Dylan K. Taylor
8c6161a4f2 Biome: make biomes list use an SplFixedArray 2018-06-08 10:19:08 +01:00
Dylan K. Taylor
c8a87b14d5
PopulationTask: actually fix locks not getting released in generation errors 2018-06-07 23:53:59 +01:00
Dylan K. Taylor
8fca7cc68d Apply some typehints to generators 2018-06-07 20:22:35 +01:00
Dylan K. Taylor
45f940681a Make Normal->pickBiome() private 2018-06-07 20:21:26 +01:00
Dylan K. Taylor
e3c97d7d5e Flat: clean up more garbage 2018-06-07 20:18:04 +01:00
Dylan K. Taylor
172abef2a7 Flat: clean up generation of base chunk 2018-06-07 20:11:29 +01:00
Dylan K. Taylor
709abb02e6 Generator: remove more dead incomplete code
again, this can be added when and if it's actually implemented.
2018-06-07 19:54:51 +01:00
Dylan K. Taylor
428ca29e4b Remove dead bedrockDepth fields from generator
yes, this is not implemented yet. fields for this can be added when proper bedrock generation is implemented. For now, it's just dead code.
2018-06-07 19:52:56 +01:00
Dylan K. Taylor
f61ad20f6b Remove a whole bunch of dead copy-pasted code from Nether generator 2018-06-07 19:51:27 +01:00
Dylan K. Taylor
3c9af5cd6d Generator: small reduction of code duplication 2018-06-07 19:49:51 +01:00
Dylan K. Taylor
996935e9b2 Cleaned up level seed handling 2018-06-07 19:39:24 +01:00
Dylan K. Taylor
354b2dc5d1 and an extra note just in case 2018-06-07 15:20:51 +01:00
Dylan K. Taylor
0c70b83d81 LevelProvider: workaround bug fixed in b54197904d6c23c5babe2857d0107d9d0fc8bd68 for previously-affected worlds 2018-06-07 15:18:42 +01:00
Dylan K. Taylor
083a1e1ff6 GeneratorManager: Make addGenerator() throw exceptions instead of returning false 2018-06-07 14:34:26 +01:00
Dylan K. Taylor
17b58357fb GeneratorManager: add documentation for functions 2018-06-07 14:30:19 +01:00