Commit Graph

396 Commits

Author SHA1 Message Date
Dylan K. Taylor
f0fa561c2f World: use arrow functions in useBreakOn() 2021-09-12 15:16:55 +01:00
Dylan T
4111d92b98 Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
Dylan K. Taylor
9d5a86fe53 Revert "World: make the second parameter for getCollidingEntities() mandatory and non-nullable"
This reverts commit e1b7bf31bb.

fixes #4447
2021-09-10 16:06:08 +01:00
Dylan K. Taylor
e0e19c67ef World: do not warn about leaked Player entities during world unload
this raises false-positives during shutdown if players were online.
The fact that the player entity leans on the World to clean up after it is slightly problematic, but I'm not sure what else to do about it for now.
2021-09-09 15:55:37 +01:00
Dylan K. Taylor
34f01a3ce3 World: Track entities separately from chunks
this allows entities to exist outside of generated chunks, with one caveat: they won't be saved in such cases.
Obviously, for player entities, this doesn't matter.

fixes #3947
2021-09-09 01:17:41 +01:00
Dylan K. Taylor
ba2bfe0e11 World: depopulate neighbourBlockUpdateQueueIndex sooner
this fixes 2 problems:
1) Blocks which set themselves to something else during onNearbyBlockChange() would not receive any block update
2) A memory leak when blocks in unloaded chunks were scheduled for an update.

I'm a little uneasy about this change, because there must have been some reason why I put this at the end of the block and not at the start, but whatever it is, I can't reason about it, and there's reasons not to put it at the end too.
2021-09-08 22:11:17 +01:00
Dylan K. Taylor
72fb49b356 World: add notifyNeighbourBlockUpdate() to allow triggering neighbour block updates on blocks manually
this can be useful if blocks were modified asynchronously.
2021-09-07 20:18:53 +01:00
Dylan K. Taylor
e1b7bf31bb World: make the second parameter for getCollidingEntities() mandatory and non-nullable
the only reason to use getCollidingEntities() instead of getNearbyEntities() is if you have an entity that may or may not be collidable depending on certain conditions.
Really, I don't think this logic belongs in World at all, but for now it has to stay, because some other stuff depends on it.
2021-09-05 15:22:12 +01:00
Dylan K. Taylor
2fc33d3bff World: remove unused variable 2021-09-05 15:15:48 +01:00
Dylan K. Taylor
19513c65f0 World: avoid code duplication between getCollidingEntities() and getNearbyEntities()
these two methods are very misleadingly named, but they do almost exactly the same thing - the only difference is that getCollidingEntities() does a couple of additional checks.
2021-09-05 15:13:22 +01:00
Dylan K. Taylor
0289b45202 Chunk: Drop dirty flags for tiles and entities
instead, just ungate this and allow the provider to decide what to do.
Any chunk that contains entities or tiles is already always considered dirty, so the only thing the flags are good for is flagging chunks that previously had tiles and/or entities but no longer do.
In those cases, it's just removing keys from LevelDB anyway, so it's already very cheap.
Avoiding these redundant deletions is not worth the extra complexity and fragility of relying on flags to track this stuff.
2021-08-30 00:09:36 +01:00
Dylan K. Taylor
994a2c9eb9 Clean up entity/tile data loading from world providers 2021-08-29 23:11:18 +01:00
marshall
ee16a00c57 World: do not attempt placement of itemblock if stack size is zero (#4410)
This doesn't make any sense, and also caused a crash.
2021-08-27 13:14:56 +01:00
Colin
224d71f272 World: renamed getChunks() to getLoadedChunks() (#4393) 2021-08-23 21:23:35 +01:00
SalmonDE
7fd712c1ff Refactor Block & Tile: getPos() to getPosition() (#4395)
this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
2021-08-23 14:01:32 +01:00
Dylan K. Taylor
7d9f8ff4ed World: do not use static:: for private property access 2021-08-21 15:46:19 +01:00
Dylan K. Taylor
2293bd948d Added KnownTranslationFactory and use it in as many places as possible
this makes translation usage much more statically analysable.
The only places this isn't used are:
- places that prefix translations with colours (those are still a problem)
- places where server/client translations don't match (e.g. gameMode.changed accepts different parameters in vanilla than in PM)
2021-08-10 14:50:40 +01:00
Dylan K. Taylor
91d54ff0ad Removed unnecessary and/or obsolete GC hacks
the intent of these hacks was to break cyclic references to avoid having objects lingering in memory. However, all of the stuff that's being removed in this commit no longer has any effect anyway, due to the fact that these things don't circularly reference each other anymore. Notably, Tile inventories now keep Position instead of a Tile ref.
2021-06-30 19:16:25 +01:00
Dylan K. Taylor
94e16f416d Added KnownTranslationKeys (generated) and start using it 2021-06-29 22:46:04 +01:00
Dylan K. Taylor
02fab77e55 World: change 'closed' to 'unloaded'
this makes more sense overall from a reader's perspective.
and also provide a rug-jerk for any idiots using World->close() when they aren't supposed to? ....
2021-06-26 21:54:18 +01:00
Dylan K. Taylor
fc70b625b3 ExperienceOrb: Require providing XP value in constructor 2021-06-19 19:42:13 +01:00
Dylan K. Taylor
981b0285d1 Isolate config casting nastiness in one place
this doesn't solve the underlying problem, but it does reduce the amount of noise made by PHPStan about it, as well as avoiding code litter.
2021-06-19 19:14:02 +01:00
Dylan K. Taylor
d96fc17339 World: Check placed block collision boxes after place()
since we write these into a transaction instead of actually modifying the world directly, we can use the transaction to verify that the placement location is OK before setting the blocks.
closes #4248
2021-06-18 19:07:38 +01:00
Dylan K. Taylor
e7b21cf9dc World: remove obsolete TODO comment
[ci skip]
2021-05-21 13:10:48 +01:00
Dylan K. Taylor
2ab751f985 World: fixed potential bug scheduling async light updates multiple times 2021-05-21 13:09:38 +01:00
Dylan K. Taylor
7217ff5ff5 World: added an extra subtiming for random chunk updates 2021-05-17 23:18:56 +01:00
Dylan K. Taylor
4736b5968d WorldTimings: change some idiotic timer names 2021-05-17 23:14:30 +01:00
Dylan K. Taylor
cdaf734470 World: Clean up ticking chunk loader tracking 2021-05-17 23:07:48 +01:00
Dylan K. Taylor
643c3ed14e World: Require all adjacent chunks to a ticking chunk candidate to be unlocked, generated, loaded and light-populated
this should address the remaining problems with grass spread/death.
2021-05-17 20:59:40 +01:00
Dylan K. Taylor
7abf50f503 World: Extracted a tickChunk() method from tickChunks()
most of what's left in tickChunks() is just selecting the chunks, rather than actually ticking them.
2021-05-17 20:54:51 +01:00
Dylan K. Taylor
bab76f4a6e World: extract some blocks of logic from tickChunks() into their own methods
the amount of nested loops, cx/dx/chunkx/etc clusterfuck in this code makes it very difficult to work with...
2021-05-17 20:50:46 +01:00
Dylan K. Taylor
b2e806e2fa World: Harden chunk loading against bad data in entity/tile NBT 2021-05-12 12:26:41 +01:00
Dylan K. Taylor
0ff21557e4 World: fixed generation requests being rejected during resolution
when a chunk population is ordered, its only chunk loader is the one that the World installed to keep the chunk loaded while it was generated. So, when the resolver removes its chunk loader from the chunk, it triggers the chunk unloading mechanism, which causes the promise to directly be rejected.
2021-05-10 17:20:04 +01:00
Dylan K. Taylor
624495f4d3 Added a generic Promise type
I anticipate increasing demand for promises, and since all the libraries I could find suck, we'll stick to our own impl for now.
2021-05-08 15:57:30 +01:00
Dylan K. Taylor
998a583815 World: Fixed inverted completion callbacks for chunk population
this would have caused any chunk populated by a plugin to remain loaded forever.
2021-05-07 23:39:44 +01:00
Dylan K. Taylor
742f86e022 Rename DestroyBlockParticle -> BlockBreakParticle
closes #3461

literally every other particle/sound has the subject first, followed by the (optional) verb, and finally Particle (or Sound).
In addition, we refer to breaking blocks as 'break' everywhere except here, where we refer to it as 'destroy'.
2021-05-06 18:33:18 +01:00
Dylan K. Taylor
7b2c6c5ceb Avoid more $this refs on long-life closures 2021-05-06 14:27:56 +01:00
Dylan K. Taylor
4f4069d403 World: remove another noisy debug message 2021-04-19 00:55:42 +01:00
Dylan K. Taylor
caf3ec1b54 World: improve documentation of World::getPotentialBlockSkyLightAt() 2021-04-18 20:31:42 +01:00
Dylan K. Taylor
53ebe4f9f9 World: added getHighestAdjacentFullLightAt() 2021-04-18 20:20:08 +01:00
Dylan K. Taylor
51b0685881 World: document getFullLight() and getFullLightAt() 2021-04-18 20:14:16 +01:00
Dylan K. Taylor
f29ababf8d World: Rearrange some light-related methods
these things are all over the place ...
2021-04-18 20:07:36 +01:00
Dylan K. Taylor
b31b097b8e LightPopulationTask no longer hard-depends on Server 2021-04-16 15:41:14 +01:00
Dylan K. Taylor
e6ecacbb2b World: do not access chunks for light if they aren't yet light-populated 2021-04-15 21:21:34 +01:00
Dylan K. Taylor
ab9615fb9c World: fixed documentation for getHighestAdjacentPotentialBlockSkyLight()
[ci skip]
2021-04-15 21:19:58 +01:00
Dylan K. Taylor
9655cb819d World: Remove duplicated code 2021-04-15 19:41:03 +01:00
Dylan K. Taylor
203cc7fcef World: Removed noisy debug message 2021-04-13 22:32:00 +01:00
Dylan T
f047ecfd2d Fixed player spawning in ungenerated terrain (#4087)
fixes #4044
fixes #2724

this is significantly more complex than I hoped for, but it's a start... and it works.
2021-03-26 21:36:27 +00:00
Dylan K. Taylor
a515b5e1b8 World: remove dead constant Y_MASK 2021-03-19 21:13:56 +00:00
Dylan K. Taylor
5dd0b3ac35 OOOPS
it's a bit too early for this
2021-03-19 21:12:46 +00:00