531 Commits

Author SHA1 Message Date
Dylan K. Taylor
b727972c76 World: remove useless isLightPopulated() check
chunks are never light populated when loaded from disk now.
2020-09-26 12:52:28 +01:00
Dylan K. Taylor
ae9e931849 LightPopulationTask: Simplify check for chunk loading in onCompletion()
we have no business loading chunks here either, although the isChunkLoaded() check should prevent that from happening.
2020-09-20 13:44:02 +01:00
Dylan K. Taylor
b252c18d34 World: Loading chunks to sync block updates is a bug
again, this should never happen, because chunk unloading cleans this stuff out. But if it did happen, loading chunks is not the way to take care of it.
2020-09-20 13:42:27 +01:00
Dylan K. Taylor
5096741b29 World::getChunk() behaviour now matches that of a regular ChunkManager
Various bugs existed for a while with stuff using chunk managers instead of worlds when interacting with terrain due to a behavioural inconsistency between World::getChunk() (return from cache or load from disk), and SimpleChunkManager::getChunk() (return from cache only). This change brings the two in line.
World::getOrLoadChunk() has been added as a replacement, which has the same behaviour as the old getChunk() and also makes it more obvious that there is an issue with code using it during refactoring.
2020-09-20 13:29:09 +01:00
Dylan K. Taylor
c9d2edcb4d Rename SubChunkIteratorManager -> SubChunkExplorer 2020-09-20 12:47:44 +01:00
Dylan K. Taylor
4879df626d Reduced LightUpdate dependency on ChunkManager to indirect
this opens the gateway for alternative SubChunkIteratorManager implementations which don't use ChunkManager at all.
2020-09-20 12:41:53 +01:00
Dylan K. Taylor
5661d0496f RuntimeBlockMapping::toRuntimeId() now accepts a single integer instead of id/meta
the expectation is that eventually this will receive arbitrary internal runtime IDs instead of static id/meta, and RuntimeBlockMapping doesn't really care about this crap anyway.
2020-09-20 12:16:11 +01:00
Dylan K. Taylor
c20ac82fe6 LightUpdate: Move propagation-specific state to a separate unit
this solves multiple architectural issues:
- improves reusability by avoiding having old state info stick around to fuck stuff up
- prevents access to propagation state from outside of propagation

this also reduces the latent memory usage of light-updates after they have been used.

TODO: we could probably change LightPropagationContext to LightPropagator and move all the propagation-specific code into it if we can solve the subchunk-iterator and effective light problems.
2020-09-09 01:06:09 +01:00
Dylan K. Taylor
bde24d9279 LightUpdate: remove unused field 2020-09-08 23:14:10 +01:00
Dylan K. Taylor
03de2bcc67 Chunk: simplify heightmap calculation 2020-09-08 23:03:52 +01:00
Dylan K. Taylor
c7070788f9 Rename and repurpose Block->diffusesSkyLight to blocksDirectSkyLight
this new form allows skipping some useless checks during sky light calculation and also allows getting rid of the last hard dependency on core Block classes.
We're getting real close to native light now.
2020-09-08 22:40:05 +01:00
Dylan K. Taylor
ec6ac59b9c BlockLightUpdate: actually use lightEmitters
I accidentally added this during a separation of my local changes, but it's useful anyway, so we should use it.
This removes BlockLightUpdate's implicit dependency on Block, which is a
step towards native light.
2020-09-08 18:21:03 +01:00
Dylan K. Taylor
205617f29e Untether LightUpdate and children from BlockFactory 2020-09-08 18:14:35 +01:00
Dylan K. Taylor
0fd3d91038 LightArray: hide constants ZERO and FIFTEEN from the API
this makes it easier to implement this in C++ with the same API. Since the C++ version doesn't use strings, these constants aren't needed anyway.
2020-09-08 15:13:58 +01:00
Dylan K. Taylor
01f8116cdd Fix some of the implicit immutability issues of EmptySubChunk
it's useful to have an immutable stub around for the sake of feeding back dummy read values, but for write values it has to barf instead of being quiet.
There's still some issues with LightArray which I don't currently have a solution for, but I'm thinking about separating light storage from chunks anyway.
2020-09-07 14:43:26 +01:00
Dylan K. Taylor
5fbc842f7a LightArray: do not accept NULL in the constructor
it makes more sense to pass LightArray::ZERO or just use LightArray::fill(0) if a zeroed light array is desired.
2020-09-06 16:18:47 +01:00
Dylan K. Taylor
94d8f59484 LightUpdate::execute() now returns the number of visits made to blocks in total
this is useful for performance profiling.
2020-09-05 22:25:42 +01:00
Dylan K. Taylor
15299735e9 Do not create chunks during light propagation/removal
this used to be necessary to trigger subchunk creation so that light arrays would be available for use. With 02ff8d671b93ec5911576643e9b03f2049f31c81, this is no longer necessary.
2020-09-05 22:22:19 +01:00
Dylan K. Taylor
6b6f77f8af Chunk: improved heightmap calculation performance
recalculateHeightMapColumn is stateless, so it can't make any assumptions about which subchunks to check for blocks. However, in most the average case (6 allocated subchunks), this causes 2500+ useless SubChunk->getHighestBlockAt() calls (10 per column). Since we're calculating in bulk, we can figure out which subchunks are empty one time and ignore them for all 256 columns.
In the average case, this produced a 50-60% performance improvement for heightmap calculation (~1.1 ms -> 0.5 ms).
In extreme cases where the height is extremely varied, this produces no observable performance benefit, but for most cases with flattish terrain, it's an improvement.
It can likely be further improved, but further performance improvements are outside the scope of this commit and will likely result in more complexity increases.
2020-09-05 00:16:07 +01:00
Dylan K. Taylor
e1816bd415 SubChunkInterface: clarify documentation of isEmptyFast() 2020-09-04 22:10:42 +01:00
Dylan K. Taylor
2e45398072 World: skip random block ticking on chunks that don't have any light
typically this is a state that only lasts for a tick or so, but it's a race condition that is regardless very commonly encountered.
If you were very unlucky, you might have noticed grass randomly dying when you were spawning or flying around, even though it was in full sky light.
2020-09-04 18:08:42 +01:00
Dylan K. Taylor
a68b0b1f93 LightArray: make collectGarbage() more preload-friendly
opcache preloading doesn't store non-class constants, but it does store class constants. Class constants that reference non-class constants are pre-resolved into values before storing in opcache SHM, so class constants are OK to use, but non-class constants will come back as undefined.
2020-09-04 17:23:23 +01:00
Dylan K. Taylor
b81cc671e9 Major performance improvement to basic sky light calculation
this was degraded whenever it was I decided to make chunks always be allocated. This commit uses a fast path for light filling in subchunks which are completely clear of the heightmap, which returns the performance back to its old fast levels.
2020-09-04 15:51:33 +01:00
Dylan K. Taylor
62394811e3 Merge branch 'stable' into master
# Conflicts:
#	resources/vanilla
#	src/world/Explosion.php
2020-08-16 01:00:04 +01:00
Jack Honour
ff2a3baa8e
Implemented Jukebox & Records (#3742)
Co-authored-by: Dylan K. Taylor <odigiman@gmail.com>
2020-08-07 21:07:58 +01:00
Dylan K. Taylor
3d4470ed8d added nether quartz ore to nether generation 2020-08-06 13:23:03 +01:00
Dylan K. Taylor
7bcfece11e Flat: use block names instead of legacy block IDs for hardcoded preset 2020-08-06 12:58:49 +01:00
Dylan K. Taylor
de9856151a Flat: remove useless field 2020-08-06 12:58:08 +01:00
Dylan K. Taylor
aa682a865e Allow injecting arbitrary preimage block for ore generation
this will be useful for nether ore generation.
2020-08-06 12:46:07 +01:00
Dylan K. Taylor
180c0e4999 World: rely on Player being a ChunkListener instead of ChunkLoader
ChunkListeners are less dangerous, and also make more sense considering the usages.
Ideally we want to not have to care if a listener is a Player at all, but that's still some work away yet.
2020-07-11 18:20:32 +01:00
Dylan K. Taylor
279abb871d Remove all usages of CompoundTag->hasTag()
in pretty much every case, these usages really wanted to read the tag's contents anyway, which can be combined with a getTag() and instanceof call for more concise and static analysis friendly code.
In the few cases where the tag contents wasn't needed, it still wanted to check the type, which, again, can be done in a more static analysis friendly way by just using getTag() and instanceof.
2020-07-10 21:01:43 +01:00
Dylan K. Taylor
91b028c208 WorldManager: use ChunkSelector to find stuff to pre-generate 2020-07-10 20:06:26 +01:00
Dylan K. Taylor
f2cf453cd0 World: remove one more unnecessary vector3 field mutation 2020-07-09 12:53:16 +01:00
Dylan K. Taylor
a5d77d5106 LevelDB: remove unused function 2020-07-08 23:24:54 +01:00
Dylan K. Taylor
909f3f39de Block: get rid of getRuntimeId()
the runtime ID mapping should be non-global in case of multiple protocols.
2020-07-06 11:18:29 +01:00
Dylan K. Taylor
0188323d74 fixed a bunch of NBT-related phpstan level 8 errors 2020-07-05 21:01:13 +01:00
Dylan K. Taylor
670ad9eb9d Position: rename getWorldNonNull() to getWorld(), remove original getWorld() 2020-06-29 21:19:46 +01:00
Dylan K. Taylor
fc22fd80d8 Eradicate remaining usages of Position->getWorld() 2020-06-29 21:03:55 +01:00
Dylan K. Taylor
5a56f68991 Normal: make gaussian non-static
this allows each generator to (potentially) have a different gaussian curve for biome blending, as well as fixing a few phpstan level 7 errors.
2020-06-28 19:08:18 +01:00
Dylan K. Taylor
db8e094d11 Extract a Gaussian unit from Normal generator 2020-06-28 18:45:52 +01:00
Dylan K. Taylor
78c270a96e PopulationTask: check the correct instance 2020-06-28 18:45:51 +01:00
Dylan K. Taylor
2a9586f6fd Explosion: fixed assert failure on explodeB() 2020-06-27 23:17:27 +01:00
Dylan K. Taylor
17054e1001 Merge commit '89521f166d8b43f2fd2af99f367888a34b44c492'
# Conflicts:
#	resources/vanilla
#	src/world/Explosion.php
2020-06-26 18:42:30 +01:00
Dylan K. Taylor
137605ab8c Position: make World constructor parameter required 2020-06-22 14:15:27 +01:00
Dylan K. Taylor
a16de8747e Explosion: stop using Vector3->setComponents()
this kills two birds with one stone: this inlined version of the logic should be faster than the vector-abusing version.
2020-06-20 22:19:37 +01:00
Dylan K. Taylor
bf5c06f285 World: get rid of temporalPosition too (entirely unused) 2020-06-20 21:45:35 +01:00
Dylan K. Taylor
fc7672c6ba World: remove temporalVector (premature cold path optimisation again) 2020-06-20 21:44:05 +01:00
Dylan K. Taylor
d38c17835d Properly switch to string entity IDs 2020-06-20 13:43:31 +01:00
Dylan K. Taylor
012acdd4cb move runtime entity ID counter from EntityFactory back to Entity
EntityFactory is specialized for the purpose of deserializing data from worlds, and runtime ID assignment isn't related.
2020-06-19 21:55:49 +01:00
Dylan K. Taylor
fb4a99a0ef Position: x,y,z parameters are now mandatory 2020-06-19 11:21:47 +01:00