445 Commits

Author SHA1 Message Date
Dylan K. Taylor
a9dc447f8f Tile: make createFromData() retrieve the ID by itself 2018-12-11 14:56:25 +00:00
Dylan K. Taylor
d72e4cb9a1 Tile: remove createNBT(), add create(), createFromData(), createFromItem() 2018-12-10 19:40:37 +00:00
Dylan K. Taylor
4c848bb4c1 docs fixes 2018-11-22 17:07:36 +00:00
Dylan K. Taylor
8b350808ef Fixed merge error 2018-11-22 16:56:44 +00:00
Dylan K. Taylor
98efd27543 Remove ability to set blockID and blockdata independently
This was the cause of many inconsistency and broken world bugs. In the future (once we switch to paletted chunks) this won't be possible anyway. For now, some temporary API is provided to allow modifying chunkdata directly, but it is required that **both** must be provided.
2018-11-22 16:53:22 +00:00
Dylan K. Taylor
507d47a6f5 Merge branch 'release/3.4' 2018-11-22 16:49:30 +00:00
Dylan K. Taylor
449dda83fb Merge branch 'release/3.3' into release/3.4 2018-11-22 16:48:57 +00:00
Dylan K. Taylor
6bc79149c3 SubChunk: Fixed $changed not getting set in setBlock() when only block data changed
it was comparing a string and an int. This now compares the integer values first.
2018-11-22 16:47:25 +00:00
Dylan K. Taylor
a4e81674c3 Merge branch 'release/3.4' 2018-11-17 18:13:03 +00:00
Dylan K. Taylor
cdf7e28251 shut up PhpStorm 2018-11-17 18:12:48 +00:00
Dylan K. Taylor
f7ba4f553c Merge branch 'release/3.4' 2018-11-17 16:30:19 +00:00
Dylan K. Taylor
a02f422d85 SubChunk: Fixed constant redefinition on worker threads when autoloading
this happens when workers inherit constants but not classes.
2018-11-17 16:29:53 +00:00
Dylan K. Taylor
e67b1a20de Merge remote-tracking branch 'origin/release/3.4' 2018-11-17 14:47:35 +00:00
Dylan T
f8bfbc107d
Reduce chunk memory usage by 20-60% by exploiting PHP copy-on-write behaviour (#2527)
This takes advantage of two key behaviours of PHP:
1. Assigning a string does not copy the string
2. Changing an offset in a string causes the string to be copied.

These two factors combined, along with the fact that blocklight and skylight arrays are usually all-zeros, allow us to produce a significant memory usage reduction of loaded chunks.
A freshly generated PM world with 3,332 chunks loaded drops from 310MB to 200MB memory usage with these changes applied.
2018-11-17 14:46:05 +00:00
Dylan K. Taylor
8b9ec5dde3 Merge branch 'release/3.4' 2018-11-07 22:11:27 +00:00
Dylan K. Taylor
a5f776af2f Merge branch 'release/3.3' into release/3.4 2018-11-07 22:11:13 +00:00
Dylan K. Taylor
342a74ffcb Level: Collect garbage from chunk internals in doChunkGarbageCollection() 2018-11-07 20:01:07 +00:00
Dylan K. Taylor
67a5f3f557 Register MainLogger as SPL global, remove hard MainLogger dependency from many areas, break a bunch of cyclic dependencies 2018-11-05 19:01:59 +00:00
Dylan K. Taylor
0e87cf801e Merge branch 'release/3.4' 2018-11-03 19:44:00 +00:00
Dylan K. Taylor
af1227f154 Merge branch 'release/3.3' into release/3.4 2018-11-03 19:43:54 +00:00
Dylan K. Taylor
a50a863ab7 Chunk: be more intelligent about fast-serializing chunks
This reduces the amount of useless data that pthreads has to copy around.
2018-11-03 19:43:35 +00:00
Dylan K. Taylor
9caf62778c AsyncTask: remove $serialize parameter from setResult()
Whether serialization is necessary can be determined automatically based on the type of variable.
2018-11-03 16:56:24 +00:00
Dylan K. Taylor
d257d36e55 Merge branch 'release/3.3' into release/3.4 2018-11-03 15:14:27 +00:00
Dylan K. Taylor
6b9fee05d6 Fixed performance bug with chunk sending
this process of fast-serialization, fast-deserialize, network-serialize is an order of magnitude slower than just doing the network encode directly on the main thread, and also copies more useless data.

For the main thread, the figures were something like 3x more expensive, and then an extra 7x for deserialization on the worker thread. This is a ridiculously large overhead.
2018-11-03 15:12:30 +00:00
Dylan K. Taylor
011b9ae159 Update to latest NBT lib version 2018-10-23 16:47:00 +01:00
Dylan K. Taylor
a49abff099 Merge remote-tracking branch 'origin/release/3.4' 2018-10-22 17:46:37 +01:00
Dylan K. Taylor
cac21c2caf
SubChunk: implement branchless read/write for nibble arrays (#2489)
this was inspired by https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/browse/CraftBukkit-Patches/0121-Branchless-NibbleArray.patch
2018-10-22 17:46:14 +01:00
Dylan K. Taylor
90482e79bc Merge branch 'release/3.4' 2018-10-21 18:23:54 +01:00
Dylan K. Taylor
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
Dylan K. Taylor
517a21c418 RegionLoader: remove unused constant 2018-10-20 14:19:27 +01:00
Dylan K. Taylor
2e265423c7 Fixed NBT leveldata fixer never getting called 2018-10-10 04:44:45 -04:00
Dylan K. Taylor
8d1400115e fixed unsupported leveldb format versions crashing the server 2018-10-07 15:42:59 +01:00
Dylan K. Taylor
a430f7f4f7 Allow static properties and state masks to vary based on variant 2018-10-06 17:33:28 +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
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