Commit Graph

215 Commits

Author SHA1 Message Date
179fb9c7cb Fixed tree trunk generation bug introduced by ac87319aed
Blocks were being overwritten in the writebatch which hadn't yet been set, so reading them from the world yielded air blocks instead of trunk, allowing the generation to overwrite blocks which should have been logs.
2019-01-19 13:41:28 +00:00
5052b75565 Separate Level management functionality from Server, clean up a bunch of mess 2019-01-12 19:11:05 +00:00
d8d04aeb53 fixup some imports 2019-01-04 23:49:32 +00:00
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
e1064a9e36 Merge branch '3.5' 2019-01-04 00:37:48 +00:00
d71a543d10 Fixed a bunch of things PHPStan finds unpalatable
close #2614, fix a bunch of docs bugs, fix sendCreativeContents() crash on Human holders, move some inline variable declarations
2019-01-04 00:23:09 +00:00
ac87319aed Introduce a "block write-batch" concept (#2555)
Make use of writebatch to generate trees, doors and double plants safely

- Fixes #2441 
- Fixes #2548 
- Closes #2498
2018-12-29 12:00:14 +00:00
ab75e89d95 Fixed generation changes in recent builds compared to 3.x
this was caused by improper RNG sanitization and a recent cleanup refactor.
2018-12-27 17:36:41 -05:00
7d594ac6d8 Merge branch 'release/3.4' 2018-12-09 19:28:52 +00:00
f704061618 Tree: fixed being able to overwrite other trees
this was observable by planting a sapling underneath an existing tree and punching it with bone meal.

This change will also prevent trees generating too close together.
2018-12-09 19:26:48 +00:00
cd5b81bdb9 ChunkManager: Remove getBlockIdAt()/setBlockIdAt()/getBlockDataAt()/setBlockDataAt(), add getBlockAt() and setBlockAt() 2018-12-04 22:27:00 +00:00
98efd27543 Remove ability to set blockID and blockdata independently
This was the cause of many inconsistency and broken world bugs. In the future (once we switch to paletted chunks) this won't be possible anyway. For now, some temporary API is provided to allow modifying chunkdata directly, but it is required that **both** must be provided.
2018-11-22 16:53:22 +00:00
1e8b153662 Further cleanup to Simplex/Noise hierarchy 2018-10-28 16:30:18 +00:00
f4105fd91a Noise: remove a ton of dead code 2018-10-27 17:04:53 +01:00
ff28c982ac Kick out unnecessary Perlin class
the code in here isn't used anywhere except as a base for Simplex, so it makes more sense to flatten it and get rid of the crap.
2018-10-27 16:33:58 +01:00
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
70054de575 Clean up garbage in Tree populators 2018-10-15 19:42:16 +01:00
706082deb1 Fixed Flat generator using item ID/damage to build block layers 2018-10-07 12:01:43 +01:00
8a062f440d Chunk: remove column methods
these were (mostly) unused, and the places they were used breaks the interface definitions. It also exposes internals that are sensitive to change.
2018-10-03 18:35:39 +01:00
56d9943b0d Nuke Block->meta, split into variant and state properties, lots of cleanup
This is a major change to the way block metadata is handled within the PM core. This separates variant metadata (which really ought to be part of the ID) from state metadata, and in a couple of cases flattens separate states of blocks together.

The result of this is that invalid variants can be much more easily detected, and additionally state handling is much cleaner since meta is only needed at the serialize layer instead of throughout the code.
2018-09-21 19:28:10 +01:00
9b4d82630b BlockFactory: remove $solid
this is premature optimization and will run into problems once we enter the flattening.
2018-09-20 16:26:15 +01:00
f03ab76c83 Remove imports left over from 5ce2d5e072 2018-09-10 17:51:13 +01:00
d62e00cc74 AsyncPool: Remove Server dependency (API breaks included)
This brings two plugin-breaking changes: AsyncTask->onCompletion() and AsyncTask->onProgressUpdate() no longer accept Server parameters.

This now allows for the functionality of AsyncPool and AsyncTask to be tested outside of a Server.
2018-09-10 15:48:59 +01:00
5ce2d5e072 Clean up to Generator creation, remove getSeed() from ChunkManager interface
it's the generator's responsibility to know about the seed, not the chunkmanager's. This now reduces the complexity of implementing and using a chunkmanager.
2018-09-10 13:28:15 +01:00
92aeab0d00 Merge branch 'release/3.2' 2018-08-19 16:03:04 +01:00
2eda8cfad3 Merge branch 'release/3.1' into release/3.2 2018-08-19 16:01:47 +01:00
5df601c817 Add @see docs so PhpStorm can see dynamic constructor usages
PhpStorm can't see constructor usages when the class name is dynamic. This causes maintenance problems because cross-referencing constructors called like this doesn't show up dynamic calls.
2018-08-19 16:00:15 +01:00
20f3b82d52 Be less dependent on AsyncTask->onCompletion() Server parameter
this is going to get removed soon.
2018-08-04 15:56:14 +01:00
eb738d1d72 Apply more typehints to generator namespace 2018-07-26 19:31:18 +01:00
edb03e8a9b Remove more dead code from the generator
this stuff is useless broken crap that just makes noise in inspections for no good reason... bye
2018-07-26 19:21:38 +01:00
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
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
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
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
c4c6c58615 Added some missing typehints 2018-06-10 17:18:55 +01:00
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
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
c8a87b14d5 PopulationTask: actually fix locks not getting released in generation errors 2018-06-07 23:53:59 +01:00
8fca7cc68d Apply some typehints to generators 2018-06-07 20:22:35 +01:00
45f940681a Make Normal->pickBiome() private 2018-06-07 20:21:26 +01:00
e3c97d7d5e Flat: clean up more garbage 2018-06-07 20:18:04 +01:00
172abef2a7 Flat: clean up generation of base chunk 2018-06-07 20:11:29 +01:00
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
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
f61ad20f6b Remove a whole bunch of dead copy-pasted code from Nether generator 2018-06-07 19:51:27 +01:00
3c9af5cd6d Generator: small reduction of code duplication 2018-06-07 19:49:51 +01:00
996935e9b2 Cleaned up level seed handling 2018-06-07 19:39:24 +01:00
083a1e1ff6 GeneratorManager: Make addGenerator() throw exceptions instead of returning false 2018-06-07 14:34:26 +01:00
17b58357fb GeneratorManager: add documentation for functions 2018-06-07 14:30:19 +01:00