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.
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.
* 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
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.
take fences as an example: say you have fence1 and fence2 next to each other, like this:
|==|
and they are joined together
then delete the fence on the right
the left fence will then look like this
|
but the server would still think its collision boxes were like this:
|=
so you wouldn't be able to shoot arrows through that space.
This commit clears pre-computed bounding boxes when a block is set using Level->setBlock() (in case the block was previously already set and has pre-calculated outdated AABB). However, because of weird blocks like fences, glass and walls, they must also be cleared on neighbour block update (since connection state isn't shown in the block data).
the footprint of compressed chunk batches is so small now that it doesn't make sense to disable it out of the box. The performance gains from caching chunks are more than worth it.
As of 1.2, the average footprint of these caches is usually ~2% or less of the size of the actual chunk itself. Moving around a lot will frequently cause the same chunks to get sent several times as it passes in and out of your render distance, and the chunk isn't even changing in that time, so the chunk is getting needlessly re-serialized over and over again. So even if your world is not static (for example a creative server) chunk caching will still offer benefits, and the memory expense is so small it's a no-brainer.