Commit Graph

957 Commits

Author SHA1 Message Date
c16c9efdf3 Chunk: Rename unload() to onUnload()
this more accurately describes what the function does.
2018-01-02 10:50:22 +00:00
c3cc6f9880 Chunk: Clean up unnecessary checks in unload() 2018-01-02 10:48:01 +00:00
bde0ba1100 Level: Set chunk coordinates in setChunk()
The level provider used to do this in LevelProvider->setChunk(), but it does not anymore.
2018-01-01 13:13:47 +00:00
f580f27ec7 LevelProvider: Updated documentation 2018-01-01 11:59:22 +00:00
a46029c0f6 LevelProvider: Nuked the complicated mess out of level providers
Level providers are now cut back to just an interface to a world's data. They don't keep their own chunk registries or any stupid shit like that because the Level already does that.

This furthers the goal of being able to move level I/O off the main thread, and also drastically decreases the complication of implementing level providers.
2018-01-01 11:21:46 +00:00
1a615591e2 LevelProvider: Remove cyclic dependency between Level and LevelProvider
This will now allow LevelProviders to be constructed on threads.
2018-01-01 10:50:13 +00:00
d19683b7dd LevelProvider: Remove some dead methods 2017-12-31 18:35:23 +00:00
f17b3b2a3b LevelProvider: Refactor providers to drop lots of duplicated code 2017-12-31 18:35:23 +00:00
a0a2ea01bc LevelDB: Check for LEVELDB_ZLIB_RAW_COMPRESSION when checking for the extension's presence
We always want to validate that the leveldb provided supports the world format.
2017-12-31 17:49:02 +00:00
5132ab6cd9 LevelDB: Remove redundant folder creation in generate()
This is pointless because the call below - which is _also_ recursively creating directories - will create this directory anyway.
2017-12-31 17:46:07 +00:00
256bdf2581 McRegion: Use MainLogger::getLogger()
another one bites the dust
2017-12-31 16:06:08 +00:00
8a3f8b4706 LevelProvider: Remove redundant method requestChunkTask()
This removes one more dependency that LevelProvider has on Level.
2017-12-31 16:05:58 +00:00
7264ce43ae McRegion: Added method pathToRegion() 2017-12-31 14:25:17 +00:00
66e475cbb8 Region: Remove RegionLoader/McRegion cyclic dependency 2017-12-30 19:59:35 +00:00
1e896efff9 McRegion: Added an assert 2017-12-30 19:49:44 +00:00
4db7a7e57f Region: Change chunk offset calculation in regions to use bitmasks
I don't know why it wasn't done like this to start with. However this has not been tested yet, so this goes on a different branch for now to test.
2017-12-30 19:41:58 +00:00
54b23968e7 McRegion: Refactor some ambiguous variable names 2017-12-30 18:59:01 +00:00
bcb080e2b9 Level: Make sleepTicks private, don't write directly 2017-12-30 18:41:13 +00:00
965c19375f NBT: Split up concerns of endianness and varint NBT into their own classes, separate stream handling from NBT class
The remaining methods, constants and fields in the NBT class now pertain to generic NBT functionality (except for the matchList()/matchTree() methods, but that's a job for another time). All NBT I/O specific logic has now been moved to NBTStream and its descendents.
2017-12-30 14:55:45 +00:00
c64b9ad63a MovingObjectPosition: Use asVector3() instead of creating a new vector the hard way 2017-12-26 15:37:00 +00:00
4f8e4f0522 Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00
3853938ef3 Level: Manage block cache appropriately when loading/unloading/replacing chunks, close #1813 (#1823)
This changes the block cache to be a 2-dimensional hashmap of [chunkHash][blockHash]. This is needed to more effectively dispose of chunk-specific block caches when chunks are modified.

This now destroys the cache for specific chunk indexes in the following circumstances:
- When a chunk is unloaded (the cache isn't needed anymore)
- When a chunk is set into the world (for example, from the generator)
- When a chunk is loaded (probably unnecessary)

This resolves the ghost blocks bug many have been complaining about.
2017-12-16 09:49:48 +00:00
4ec8416f9a Level: Fix minor code duplication in setChunk() 2017-12-15 16:47:59 +00:00
dc064dfa2e Level: Fixed some unnecessary double uses of Level::blockHash() 2017-12-13 11:25:36 +00:00
131a6a4d19 Cache fix related to #1813: Don't cache blocks for chunks that don't exist 2017-12-13 10:47:12 +00:00
e58db75396 Level: Remove redundant null checks from useBreakOn()
These checks are not needed as of 3eae7a1875.
2017-12-11 16:31:43 +00:00
51cec525ee Added methods for calculating sun angle and sky light level reduction by day time
Use real sky light level in Level->getFullLightAt()

close #1471
2017-12-06 12:40:52 +00:00
a5f4dda918 Added documentation for Level->addChunkPacket()
this method is confusingly named
2017-12-06 11:15:17 +00:00
d03fdd5f72 Liquids refactor, bug fixes and performance improvements (#1753)
* Added Liquid->getLiquidLevelDecreasePerBlock()

* Fixed lava turning into cobblestone when flowing over water

* Cache liquid flow vectors for faster entity movement

* Removed a condition that made lava impossible to get rid of
In the PC code, the equivalent code makes the delay between scheduled ticks 4 times longer. Here, it just breaks the code. I don't know what the 4x stuff is about, but this code does not produce the expected behaviour and lava works fine regardless.

* Fixed strange behaviour with liquids trying to flow into other liquids
Liquids should consider other liquids as a path of least resistance. However, they should not actually flow into them. This fixes a variety of CPU leak issues with falling water in large water bodies such as oceans.
This also fixes the plus-shape effect that liquid is supposed to produce when a source is placed above ground.

* Removed a bad optimization making liquids flowing down slopes behave undesirably

* Optimize performance of slope searching by limiting recursion depth based on previous path lengths
If we already found a step down on a previous run after 2 blocks, it doesn't make sense to continue allowing checking 4 blocks because the results will just be ignored. This allows limiting the number of recursion steps, which significantly improves the performance when flowing down slopes.
However, this will still be just as bad for performance on flat terrain as it was to start with.

* Make some Liquid methods only accept Blocks as parameters
these are only ever passed blocks anyway, doesn't make sense to allow vectors.

* Moved some things to local variables
these are each only used in one function, so it doesn't make sense for them to be class members.

* Fixed water flow down slopes going everywhere, but degraded performance again

* Lava should only search 2 blocks for a slope

* Stop wasting CPU calculating optimal flow directions for liquids with too-high decay
It calculates the flow directions and THEN doesn't use them when it
realizes the flow decay is too high. This is completely pointless.

* Use a less hacky method to handle lava flowing into water

* Doubled flow performance on flat terrain
Since calculateFlowCost() usually ends up visiting the same blocks about 6 times when on flat terrain, it makes sense to cache some stuff for when blocks get revisited so expensive dumb checks don't need to keep on being done. On my machine this produces a 50-60% performance improvement when flowing on flat terrain.

* Fixed missing return values in Liquid->onUpdate()
these return values aren't used anywhere, but we should be consistent

* Don't allow flowing back in the same direction we just came from
This reduces the recursions by about 30%, providing about the same percentage performance improvement.

* Remove Liquid's temporalVector (it's not used anymore)
primitive types for the win!

* Move liquid collide to its own method

* add sound for lava/water mix
2017-12-04 10:09:35 +00:00
af68125872 Make Level->getName() less volatile
this resolves problems with crashes when getName() is called on an unloaded level. This obviously doesn't solve the root cause of the issue (level being accessed after unload) but since many things use the level name without checking if it's unloaded first, it's a bad idea for it to be volatile.

This resolves the server crash issue noted in #1527, where an exception is raised due to level unload during a tick, which subsequently causes a crash when trying to log the exception.
2017-12-04 09:57:53 +00:00
88318d740a Use standard subchunk iterator code in Explosion
this causes a slight performance loss (<10%), but in a sane language this would be inlined anyway
2017-11-28 11:20:22 +00:00
d3e5733ea0 Significantly improved light population performance using subchunk
direct accessing

These changes produce upwards of 2x better performance (YMMV, also
depends on the circumstances).
2017-11-28 11:20:22 +00:00
4703715063 Added a SubChunkIteratorManager class for faster subchunk handling 2017-11-28 11:20:14 +00:00
523a7f0999 Fix a very rare light propagation bug
This could occur when light sources were placed near each other and one of them is removed, the other's light would not be propagated far enough because the node wasn't queued for updating although it was marked as if it was.
2017-11-27 19:43:56 +00:00
256527c953 Chunk: Fixed possible bug with Chunk->setBlockData()
to be honest this would probably never affect anything, but let's be consistent.
2017-11-27 19:26:20 +00:00
b93691a177 Chunk: Remove redundant assignment 2017-11-27 18:58:08 +00:00
48c5db4296 Chunk: Add some PhpDoc 2017-11-27 17:51:42 +00:00
c564655f9b Chunk: Remove unnecessary default values
these are assigned in the constructor anyway.
2017-11-27 17:49:08 +00:00
49301b0d74 Chunk: Use an SplFixedArray for subchunks 2017-11-27 17:46:48 +00:00
8bc733514b LevelDB: Fixed nonsensical array access in iterator loop 2017-11-27 17:21:26 +00:00
c1a6711514 Fix for explosions modifying the wrong subchunks under some circumstances 2017-11-27 17:11:52 +00:00
ed195e1167 phpdoc 2017-11-23 17:27:41 +00:00
667a54fd00 Store world height in the Level for faster access
this might look like a micro optimization, but it shows up big-time on profiler snapshots.
2017-11-23 17:24:37 +00:00
74b074753f Bulk addition of constant visibilities
thanks PhpStorm inspections plugin for annoying the shit out of me until
I did this.
2017-11-21 14:44:10 +00:00
00a9ae6c95 make use of getSavableEntities() in Level->unloadChunk()
why couldn't I have thought of this before I changed this the first time >.>
2017-11-19 18:08:42 +00:00
a9df383346 generalized conditions for saving entities with chunks 2017-11-19 18:06:38 +00:00
19dc22d6b3 Chunk save: skip entities which won't be saved anyway
don't just hardcode this to players
2017-11-19 17:57:54 +00:00
2fd61163bf cleanup some chunks leftovers from 1.0 2017-11-19 17:52:36 +00:00
5640bcb0b8 add some new leveldb keys 2017-11-19 17:43:54 +00:00
ea3c7383fb Added support for handling MCPE 1.2 leveldb worlds
requires php-leveldb version >=0.2.1 and the latest version of
pmmp/leveldb-mcpe
2017-11-19 17:31:09 +00:00