Commit Graph

1340 Commits

Author SHA1 Message Date
Dylan K. Taylor
495a0b1dc2 Merge branch 'release/3.3' 2018-10-05 18:11:33 +01:00
Dylan K. Taylor
1dd6591ac1 Migrate a bunch of PluginManager->callEvent() usages to Event->call
This has the triple bonus effect of a) making a lot of code easier to read, b) reducing Server::getInstance() usages, and c) removing a whole bunch of Server dependencies.

The network and block namespaces are untouched by this commit due to potential for merge conflicts. These should be dealt with separately on master.
2018-10-05 17:30:06 +01:00
Dylan K. Taylor
47f43c5e6b Remove some internal constants from public API 2018-10-04 20:03:11 +01:00
Dylan K. Taylor
b407eba1a3 Apply typehints to level\format\io namespace 2018-10-04 19:59:26 +01:00
Dylan K. Taylor
b214601a82 Silence PhpStorm complaining about hardcoded classpaths 2018-10-04 19:58:39 +01:00
Dylan K. Taylor
a273a0c8a9 Fixed remaining cases of undefined behaviour on ambiguous world format
It was still possible to produce undefined behaviour by creating a db folder in a region-based world, or adding regions to a leveldb world. This now solves the problem completely by refusing to load the world if multiple formats match the world.
2018-10-04 19:43:31 +01:00
Dylan K. Taylor
0cc4bc48cc Move generator classpath hack out of BaseLevelProvider 2018-10-04 18:55:20 +01:00
Dylan K. Taylor
49e47edcf5 Separate level data handling from the main LevelProvider 2018-10-04 18:45:02 +01:00
Dylan K. Taylor
f23bba053b Merge branch 'release/3.3' 2018-10-04 16:41:11 +01:00
Dylan K. Taylor
c065cfbeda Merge branch 'release/3.2' into release/3.3 2018-10-04 16:41:03 +01:00
Dylan K. Taylor
722924a779 Merge branch 'release/3.1' into release/3.2 2018-10-04 16:40:55 +01:00
Dylan K. Taylor
60e1b29462 RegionLoader: Remove incorrect size cap
This assumes that the region is properly garbage-collected and packed, but if the file contains uncollected garbage this may not be the case, resulting in a region larger than a gigabyte.
2018-10-04 16:40:45 +01:00
Dylan K. Taylor
b0f1863c4f Region loaders don't need to know their own coordinates 2018-10-04 16:37:19 +01:00
Dylan K. Taylor
41f335e7d9 Level: Remove setSeed()
Seed is immutable information about the world, like its generator type, generator options, name, etc. We don't allow changing any of those things, so why the fuck would we allow changing the seed? This makes no sense at all.

I'm removing this because a) its existence makes no sense, and b) it will not produce the behaviour expected from such a function (what even is the expected behaviour???)
2018-10-04 16:24:07 +01:00
Dylan K. Taylor
4d9d4d7c60 More cleanups to level provider hierarchy, move more garbage out of BaseLevelProvider 2018-10-04 16:02:55 +01:00
Dylan K. Taylor
4f421d561c BaseLevelProvider: clean up not-exists error handling disaster
It checks for the existence of (and creates) the world directory if it doesn't exist. But what sense does this make when the world obviously doesn't exist in this case and must be generated first?
2018-10-04 15:41:18 +01:00
Dylan K. Taylor
f787552e97 Remove LevelProvider::getProviderName()
This is problematic because child level providers can forget to override the provider name of their parents, and then override them by error. Instead, they should be used in a mapping fashion to make sure they are unique and not inherited.
Also, the old method did not permit registering multiple aliases for the same provider. This now makes that possible.
2018-10-04 14:56:42 +01:00
Dylan K. Taylor
65b49dec71 Refactor hierarchy of Region-based world formats
In the future, McRegion and PMAnvil will become deprecated legacy formats which we won't support for writing anymore. However, this brings complications because Anvil (which would not be deprecated) would be sandwiched between its deprecated base (McRegion) and its deprecated child (PMAnvil), complicating the implementation (particularly for PMAnvil).

This abstracts away the generic Region-based world functionality into a separate class, making McRegion, Anvil and PMAnvil all inherit from it directly. Since only the chunk formats are different, they are more accurately siblings rather than parent-child (although Anvil and PMAnvil are cousins, ish).
2018-10-04 14:19:19 +01:00
Dylan K. Taylor
050e972add Clean up default level provider management 2018-10-04 12:49:46 +01:00
Dylan K. Taylor
23132b899c Added LevelProvider->getAllChunks() method
this returns a generator which yields known chunks. This will be used in the future for world format conversions.
2018-10-03 19:43:16 +01:00
Dylan K. Taylor
8a062f440d Chunk: remove column methods
these were (mostly) unused, and the places they were used breaks the interface definitions. It also exposes internals that are sensitive to change.
2018-10-03 18:35:39 +01:00
Dylan K. Taylor
2600cf5977 Split some block variants into their own classes where behaviour differs 2018-09-28 16:21:03 +01:00
Dylan K. Taylor
35d51570be Add and make use of Block->isSameType() 2018-09-27 17:59:06 +01:00
Dylan K. Taylor
75f364fcf2 Level: Remove obsolete \$direct parameter from setBlock()
this parameter was previously used to send blocks with a different set of flags, immediately, to players. However, the flags have been demonstrated useless and the direct sending is pointless now since packets are buffered now per session, so we might as well take advantage of the batched block update sending.
2018-09-27 16:15:07 +01:00
Dylan K. Taylor
16f2ac14b3 Clean up block update sending, remove UpdateBlockPacket flag constants
These flags are not intended for network use, instead they are supposed to be used internally by the game. For network, we only need to care about the 0x02 flag (send to players) because that's necessary for the client to render the block.
2018-09-27 15:56:08 +01:00
Dylan K. Taylor
c501c740a1 Get rid of Block->canPassThrough()
This is only implemented in 1 place where the collision box should just be zero anyway, so there's no point this existing.

There's a lot of other blocks which should have bounding boxes without collision boxes as well, but that's outside the scope of this commit.
2018-09-23 17:05:03 +01:00
Dylan K. Taylor
3eca64e893 Merge branch 'release/3.3' 2018-09-23 16:45:22 +01:00
Dylan K. Taylor
5eeaeb6c3e Level: Bail on trying to unload a level during level tick (#2435) 2018-09-22 13:40:50 +01:00
Dylan K. Taylor
56d9943b0d Nuke Block->meta, split into variant and state properties, lots of cleanup
This is a major change to the way block metadata is handled within the PM core. This separates variant metadata (which really ought to be part of the ID) from state metadata, and in a couple of cases flattens separate states of blocks together.

The result of this is that invalid variants can be much more easily detected, and additionally state handling is much cleaner since meta is only needed at the serialize layer instead of throughout the code.
2018-09-21 19:28:10 +01:00
Dylan K. Taylor
9b4d82630b BlockFactory: remove $solid
this is premature optimization and will run into problems once we enter the flattening.
2018-09-20 16:26:15 +01:00
Dylan K. Taylor
19e68f98a7 Level: Remove unnecessary BlockFactory::$lightFilter usage 2018-09-20 16:16:28 +01:00
Dylan K. Taylor
d92e79ba54 Level: fix crashdump #754691 2018-09-19 17:39:31 +01:00
Dylan K. Taylor
0f33459632 missed this because it was too far to the right of the screen... 2018-09-19 16:20:54 +01:00
Dylan K. Taylor
caca097300 Merge branch 'release/3.3' 2018-09-19 16:18:53 +01:00
Dylan K. Taylor
5e94d20d79 Merge branch 'release/3.2' into release/3.3 2018-09-19 16:17:00 +01:00
Dylan K. Taylor
a0bb747d6d Merge branch 'release/3.1' into release/3.2 2018-09-19 16:16:18 +01:00
Dylan K. Taylor
4bc0d850b1 Added Block->getRuntimeId(), clean up some mess 2018-09-19 16:16:10 +01:00
Dylan K. Taylor
ef038d9625 Level: use block directly in updateBlockSkyLight() 2018-09-19 15:07:24 +01:00
Dylan K. Taylor
48a5eeb3a4 BlockFactory: remove some useless static arrays 2018-09-19 15:06:58 +01:00
Dylan K. Taylor
22077c1fdd Merge branch 'release/3.2' into release/3.3 2018-09-14 16:18:19 +01:00
Dylan K. Taylor
7d54d18732 Merge branch 'release/3.1' into release/3.2 2018-09-14 16:18:12 +01:00
Dylan K. Taylor
bfbc845efa Remove impossible uses of PlayerInteractEvent CLICK_AIR constants 2018-09-14 16:17:55 +01:00
Dylan K. Taylor
f488e594f6 Remove hardcoded facing literals in for loops 2018-09-13 19:34:27 +01:00
Dylan K. Taylor
ebc1524f9a Merge remote-tracking branch 'origin/release/3.3' 2018-09-12 10:39:49 +01:00
Dylan K. Taylor
09dea035d4 Level: Batch light updates at the end of the tick to amortize CPU cost (#2429)
this produces a 5x performance improvement for lighting updates during water flow, and 25% improvement for lava flow.
2018-09-12 10:33:28 +01:00
Dylan K. Taylor
b3902ed76f Merge branch 'release/3.3' 2018-09-11 11:40:54 +01:00
Dylan K. Taylor
0aa63d269a Merge branch 'release/3.2' into release/3.3 2018-09-11 11:35:46 +01:00
Dylan K. Taylor
53a76c0d14 Merge branch 'release/3.1' into release/3.2 2018-09-11 11:35:38 +01:00
Dylan K. Taylor
69500fe183 LightUpdate: Remove garbage left over from dab73d8950 2018-09-11 11:35:31 +01:00
Dylan K. Taylor
191f0038b8 LightUpdate: Allow a single position to be set more than once before executing
This is needed for batched lighting updates to work. It also reduces the overhead involved with simply preparing a lighting update and moves the pain to the execute() instead.
2018-09-11 11:33:57 +01:00