64 Commits

Author SHA1 Message Date
Dylan K. Taylor
205617f29e Untether LightUpdate and children from BlockFactory 2020-09-08 18:14:35 +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
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
f2cf453cd0 World: remove one more unnecessary vector3 field mutation 2020-07-09 12:53:16 +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
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
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
4b528aa637 NBT is no longer needed to create an entity
it's still able to be provided, but shouldn't be needed in the majority of cases (constructor args and/or API methods should be sufficient).
2020-06-19 10:51:27 +01:00
Dylan K. Taylor
1205432c34 Extract mandatory parameters into constructor parameters
the goal is obviously to ditch NBT entirely here, but there's more work to be done before that becomes possible.
2020-06-19 10:51:27 +01:00
Dylan K. Taylor
6a26c0bebf EntityFactory now exclusively handles loading data from disk
this commit removes the ability to replace centrally registered entity classes in favour of using constructors directly.
In future commits I may introduce a dedicated factory interface which allows an _actual_ factory pattern (e.g. factory->createArrow(world, pos, shooter, isCritical) with proper static analysability) but for now it's peripheral to my intended objective.
The purpose of this change is to facilitate untangling of NBT from entity constructors so that they can be properly created without using NBT at all, and instead use nice APIs.

Spawn eggs now support arbitrary entity creation functions like EntityFactory does, allowing much more flexibility in what can be passed to an entity's constructor (e.g. a Plugin reference can be injected by use()ing it in a closure or via traditional DI.
2020-06-19 10:51:27 +01:00
Dylan K. Taylor
f55a7f8b53 Merge commit 'd8d994351'
# Conflicts:
#	composer.lock
#	resources/vanilla
#	tests/phpstan/configs/l7-baseline.neon
2020-06-14 19:47:21 +01:00
Dylan K. Taylor
899da1b7f7 Merge commit '42e14f749'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/Player.php
#	src/pocketmine/item/Bow.php
#	src/world/World.php
2020-06-03 12:31:17 +01:00
Dylan K. Taylor
bbf3f4c476 Merge branch 'next-minor' 2020-05-31 18:40:19 +01:00
Dylan K. Taylor
fe649d8d70 Extract ServerConfigGroup from Server
this API isn't very nice, but it's pretty much the same as the original, and at least this can be _kinda_ unit-tested...
2020-05-24 15:48:03 +01:00
Dylan K. Taylor
c9af5ce7a9 Convert GeneratorManager to singleton 2020-05-23 10:13:03 +01:00
Dylan K. Taylor
148228e360 update pocketmine/math, adapt to add() changes 2020-05-19 12:26:18 +01:00
Dylan K. Taylor
58fb185e05 Merge commit '58e32086c04d6622c01f59d0cd7216bd8a50eddb'
# Conflicts:
#	resources/vanilla
#	src/world/World.php
2020-05-18 10:47:37 +01:00
Dylan K. Taylor
11ef9fb0c0 Item-from-string parsing no longer depends on ItemIds
after this is done I'm banning the constant() function.
2020-05-13 00:18:49 +01:00
Dylan K. Taylor
8efe7fcfb0 World: allow configuring blocks-per-tick for random updating
this makes it much easier to observe and debug stuff that depends on it, such as grass, crop and tree growth, since they'll happen much faster.
A future improvement would be to have the update function use a non-global random so that the output can be reproduced using a given seed.
2020-05-10 11:50:31 +01:00
Dylan K. Taylor
53a33e8c20 World: remove unused import
we're getting so close !!!
2020-05-04 11:58:57 +01:00
Dylan K. Taylor
d40152e3bb World: fix time sync 2020-05-04 11:23:44 +01:00
Dylan K. Taylor
aac017eae4 World: drop unused and very misleadingly named addChunkPacket() 2020-05-04 10:22:39 +01:00
Dylan K. Taylor
c490bc5a8c World: drop global packet broadcast 2020-05-04 02:31:19 +01:00
Dylan K. Taylor
b1021315b0 World: remove protocol-specialized broadcastLevelEvent() 2020-05-04 02:28:34 +01:00
Dylan K. Taylor
3ce9a4801f World: allow registering unload hooks
this will be used for cache management when worlds get unloaded.
2020-04-29 18:48:16 +01:00
Dylan K. Taylor
bb11cbd89c World: relocate packet stuff for time and difficulty behind NetworkSession API 2020-04-29 18:31:54 +01:00
Dylan K. Taylor
a178a14732 Merge commit '34a3e0d' 2020-04-25 12:13:03 +01:00
Dylan K. Taylor
7d9df6af6f Convert EntityFactory to singleton 2020-04-24 22:43:02 +01:00
Dylan K. Taylor
5a94af40e2 Convert ItemFactory to singleton 2020-04-24 00:18:31 +01:00
Dylan K. Taylor
13d784cd0c Convert BlockFactory to singleton 2020-04-23 23:45:13 +01:00
Dylan K. Taylor
aac7da6c96 eliminate remaining empty() usages 2020-02-07 21:51:50 +00:00
Dylan K. Taylor
fb1126797a Merge branch 'stable' 2020-02-07 18:13:55 +00:00
Dylan K. Taylor
ff63f6d055 fill in more iterable types (master) 2020-02-01 20:19:57 +00:00
Dylan K. Taylor
465d8cda79 Merge commit 'a5764b3ae98a70fe8f20f9b403a4ab84b51b11d8'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/level/format/io/LevelProvider.php
#	src/world/generator/Generator.php
#	src/world/generator/GeneratorRegisterTask.php
2020-01-31 19:32:38 +00:00
Dylan K. Taylor
5955ff5393 fix phpdoc spacing screwed up by phpstorm 2020-01-22 15:20:50 +00:00
Dylan K. Taylor
8efc4d12ec trim phpdoc lines 2020-01-22 15:18:37 +00:00
Dylan K. Taylor
055b13a6cf strip extra blank lines (php-cs-fixer) 2020-01-22 15:14:10 +00:00
Dylan K. Taylor
1b33143f4f pass 2, manual removal of incorrect non-nullable phpdoc types 2020-01-22 12:06:47 +00:00
Dylan K. Taylor
67bcc1c0fb phpdoc armageddon for master, pass 1 2020-01-22 11:55:03 +00:00
Dylan K. Taylor
3ee6887792 populate remaining missing return types, using native returns where possible
this is done separately to stable so that stable changes can be integrated easily using an empty merge.
2020-01-19 10:26:35 +00:00
Dylan K. Taylor
96b91af66a Merge branch 'stable' 2020-01-11 21:41:38 +00:00
Dylan K. Taylor
cda1143a79 Merge branch 'stable' 2020-01-09 17:17:42 +00:00
Dylan K. Taylor
0f718ea28b Merge commit '8726604899d1a371567141e0831ed570d3233356' 2019-12-25 14:19:35 +00:00
Dylan K. Taylor
a9c09e4517 Merge branch 'next-minor' 2019-12-12 13:52:14 +00:00
Dylan K. Taylor
d3d7709ead Merge branch 'next-minor' 2019-12-03 11:55:45 +00:00
Dylan K. Taylor
9aab97578b World: clean up lighting update API 2019-10-23 21:52:39 +01:00
Dylan K. Taylor
3768f3008e World: group light-related functions
i don't know why these were dumped between getBlock() and setBlock() to begin with.
2019-10-23 21:29:00 +01:00
Dylan K. Taylor
f01b7b74ba World: remove setBlockLightAt() and setBlockSkyLightAt() 2019-10-23 21:25:29 +01:00