16880 Commits

Author SHA1 Message Date
Dylan K. Taylor
092d130c96
RuntimeBlockMapping: borrow a hack from PM5 to reduce memory footprint
we can't change the internals of this on a patch release, but this hack provides a 12 MB memory usage reduction, which is very significant.
2023-05-04 23:01:10 +01:00
Dylan K. Taylor
c09390d20f
4.20.3 is next 2023-05-04 21:06:30 +01:00
Dylan K. Taylor
22f8623e17
Release 4.20.2 4.20.2 2023-05-04 21:06:27 +01:00
Dylan K. Taylor
d8e77c1920
Tidy up crafting block registration
according to data dumps from bds-mod-mapping, fletching tables have a blast resistance of 12.5, just like the others.
2023-05-04 18:47:06 +01:00
Dylan K. Taylor
85372633eb
Tidy up BlockLegacyIdHelper stuff
I don't plan to make wood-like blocks have a dynamic wood/leaves/sapling type, as it's entirely possible their type properties will continue to diverge in future versions.
2023-05-04 17:05:22 +01:00
Dylan K. Taylor
2c81446e5b
Move TreeType to generator package, added dedicated SaplingType enum
TreeType includes a bunch of stuff that don't have regular saplings associated with them, such as mangrove and azalea trees.
Mangrove has a dedicated propagule block with different behaviour than the others, and azalea trees are grown from azalea blocks, which are solid and have different behaviour to saplings.

We may also want to account for crimson and warped 'trees' in TreeType too, although I'm not sure if those belong there or not.
2023-05-04 16:54:10 +01:00
Dylan K. Taylor
299ff5d912
Register mangrove boat item 2023-05-04 16:39:23 +01:00
Dylan K. Taylor
896dd2ec9d
Boat: use BoatType enum instead of TreeType
TreeType really belongs in the generator package. Not all types of tree may have their own boat type (e.g. azalea).
We can't use WoodType for this either, because some types of wood also don't have associated boat types (crimson, warped).
2023-05-04 16:35:31 +01:00
Dylan K. Taylor
f1417e8dc9
BlockStateDictionaryEntry: deduplicate encoded states
this saves about 500 KB of memory at no cost.
2023-05-04 16:14:41 +01:00
Dylan K. Taylor
897ba9f2d9
BlockStateLookupCache: combine arrays for stateless and stateful blocks
this reduces memory usage by another 20 KB or so.
2023-05-04 15:29:27 +01:00
Dylan K. Taylor
d2c37d8bcf
BlockStateLookupCache: avoid allocating useless arrays for blocks with only 1 permutation
this saves about 120 KB of memory.
2023-05-04 15:16:18 +01:00
Dylan K. Taylor
43fe819862
BlockStateDictionary: added a smelly hack that saves another 40 KB
this is really diminishing returns at this point...
2023-05-03 23:18:06 +01:00
Dylan K. Taylor
f9d9cbd0f6
BlockStateDictionary: slash another 14% off memory usage by deduplicating block type names
perhaps we could construct a dictionary from BlockTypeNames reflection??
2023-05-03 23:14:53 +01:00
Dylan K. Taylor
ed021d193d
BlockTranslator: cut memory usage in half
this was achieved by storing binary representations of the blockstates, rather than the original BlockStateData.

Due to the insane object:data ratio of Tag objects (40:1 for ByteTag for example), modestly sized NBT can explode in memory footprint. This has been previously seen with the absurd 25 MB footprint on file load.
Previously, I attempted to mitigate this by deduplicating tag objects, but this was mitigating a symptom rather than addressing the cause.

We don't actually need to keep the NBT around in memory, since we don't actually use it for anything other than matching blockstates. In this case, we can allow the code to be possibly a little slower, since the lookup is anyway slow and the result will be cached.
In fact, using encoded ordered states as hash keys significantly improves the speed of lookups for stuff like walls, which have many thousands of states.

We keep around generateStateData(), since it's still possible we may need the BlockStateData associated, and it can be easily reconstructed from the binary-encoded representation in BlockStateDictionaryEntry.
2023-05-03 23:11:00 +01:00
Dylan K. Taylor
32e6fdd95a
Rename RuntimeBlockMapping -> BlockTranslator 2023-05-03 22:18:27 +01:00
Dylan K. Taylor
01f340985a
Centralize all conversion-related stuff under TypeConverter
instead of having singletons for everything, which are a nightmare to manage for multi version
2023-05-03 16:33:17 +01:00
Dylan K. Taylor
5e462db0f8
Move MOTD game mode stringifying to RakLibInterface
since this is contextless (there's no way to know the version of the client requesting the MOTD), we can safely assume that this is not going to vary between protocol versions.
2023-05-03 13:36:24 +01:00
Dylan K. Taylor
6beb80b8fe
Fixed usages of BlockDataUpgrader which weren't accounting for thrown exceptions 2023-05-02 17:13:31 +01:00
Dylan K. Taylor
4d0cecbac2
RegionWorldProvider: use provider logger instead of global logger 2023-05-02 16:47:25 +01:00
Dylan K. Taylor
5fcf5e0c40
LevelDB: log more stuff, stop bailing on recoverable errors 2023-05-02 16:46:45 +01:00
Dylan K. Taylor
f29e2f7110
WorldProviders now accept Loggers 2023-05-02 15:41:11 +01:00
Dylan K. Taylor
d0d263191d
Fix build 2023-05-02 14:21:33 +01:00
Dylan K. Taylor
3366e1084b
LightUpdate: squeeze 10-15% more performance out of propagation
we can use SubChunkExplorerStatus to decide whether or not to update the local light array reference.

We also dereference some properties into local variables, because dereferencing properties is slow. Indirect property dereferences add an extra performance penalty for every layer.
2023-05-02 14:05:55 +01:00
Dylan K. Taylor
d0b9234841
SkyLightUpdate: deal with effective light during initial node discovery
this allows the propagation stage to ignore effective light, which allows for further optimisations.
2023-05-01 22:29:31 +01:00
Dylan K. Taylor
d80f65ae7c
BedrockWorldData: do not load worlds with a newer NetworkVersion than we support
often, protocol updates are done without consideration for the current world format version. We don't want to require the world support to be updated at the same time, since this might delay updates.
2023-05-01 17:53:08 +01:00
Dylan K. Taylor
096daef0d0
World: added setDisplayName()
this is an obvious use case, and I'm not really sure why it wasn't supported sooner.
2023-05-01 16:29:07 +01:00
Dylan K. Taylor
29694c19af
BlockStateUpgradeSchemaUtils: Use independent suffixes for each property mapping list 2023-05-01 14:46:30 +01:00
Dylan K. Taylor
b3e94ef1dc
Chunk: update documentation 2023-05-01 14:46:30 +01:00
Lee Siu San
f04151dbe6
README: next-major branch was renamed (#5731)
[ci skip]
2023-05-01 14:08:20 +01:00
dependabot[bot]
5dcd8bf289
Bump symfony/filesystem from 5.4.21 to 5.4.23 (#5730)
Bumps [symfony/filesystem](https://github.com/symfony/filesystem) from 5.4.21 to 5.4.23.
- [Release notes](https://github.com/symfony/filesystem/releases)
- [Changelog](https://github.com/symfony/filesystem/blob/6.2/CHANGELOG.md)
- [Commits](https://github.com/symfony/filesystem/compare/v5.4.21...v5.4.23)

---
updated-dependencies:
- dependency-name: symfony/filesystem
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 13:30:02 +01:00
kenzeve
17fe894229
TypeConverter: fixed crash on unknown blockitems (#5729)
morton2d_encode is 64-bit function when NBT int tag is 32-bit only, resulting in crash
2023-04-30 12:11:07 +01:00
Dylan K. Taylor
728e0bc869
tools/generate-blockstate-upgrade-schema: allow multi-ID remaps to be processed as regular states if their ID didn't change
this allows remappedStates to only deal with stuff that has a different ID, which reduced the size of the 1.12 -> 1.13 schema quite nicely.
2023-04-28 20:58:18 +01:00
Dylan K. Taylor
a1d44de487
Added support for compressing blockstate remaps using copiedState
this significantly reduces the size of schemas when state remaps are used (see pmmp/BedrockBlockUpgradeSchema@85b83b360e).

in addition, this will likely offer a substantial performance and memory saving when walls get flattened, which will eventually happen.
2023-04-28 20:35:37 +01:00
Dylan K. Taylor
263e1e9950
Fixed bogus test expectations 2023-04-28 20:05:51 +01:00
Dylan K. Taylor
2121152b76
Fix CS 2023-04-28 20:03:53 +01:00
Dylan K. Taylor
a1cd1d7433
... 2023-04-28 19:35:03 +01:00
Dylan K. Taylor
04aabaee5e
Fix CS 2023-04-28 19:31:08 +01:00
Dylan K. Taylor
75410a5412
BlockStateUpgradeSchemaUtils: sort data before emitting JSON
this makes it easier to see what's changing, as well as making the order stable across multiple regenerations.
2023-04-28 19:31:00 +01:00
Dylan K. Taylor
e2108557ab
BlockStateUpgrader: make sure the returned state always has an updated version ID
PM itself doesn't require this, but it's useful for tools to know whether to upgrade the schema again (e.g. in testing scenarios).
2023-04-28 17:26:19 +01:00
Dylan K. Taylor
ff8301b86c
BlockStateData: fixed outdated version ID 2023-04-28 17:23:32 +01:00
Dylan K. Taylor
869c836e2d
BlockStateUpgradeSchemaUtils: ensure that remapped values are generated in a consistent order
this uses lexical order, which isn't ideal for numeric values (1, 10, 2, etc), but it's good enough to ensure that the order is stable.
2023-04-28 17:12:52 +01:00
Dylan K. Taylor
b70ff32548
ItemTranslator: Fixed log items not displaying correctly on the client
closes #5724

this uses a (potentially bogus) assumption that the lowest mapped meta value associated with an ID is valid. I don't want to break this during a patch release, and this works for now.

In the future it would probably make more sense to bypass ItemTranslator entirely, and rely solely on the blockstate returned by RuntimeBlockMapping to fetch the correct ID. This is similar to how we serialize items for saving on disk in PM5.
2023-04-28 13:54:40 +01:00
Dylan K. Taylor
73bf5d4b29
DoubleChestInventory: specialize isSlotEmpty() and getMatchingItemCount() 2023-04-27 21:17:55 +01:00
Dylan K. Taylor
eb136e60c8
BaseInventory: added getMatchingItemCount() helper
this eliminates the performance issues described by #5719.
closes #5719

we may want to consider exposing a public API for this in the future, since it might be useful for plugins.
2023-04-27 21:08:35 +01:00
Dylan K. Taylor
4228880509
BaseInventory: change dumb variable names in internalAddItem() 2023-04-27 20:29:02 +01:00
Dylan K. Taylor
709d874204
BaseInventory: clean up max stack size handling
we can safely assume that:
- the inventory's max stack size won't change during the operation
- two items which stack together have the same max stack size
- the item's max stack size won't change during the operation
2023-04-27 20:27:05 +01:00
Dylan T
07dc10d6e6
World: improve performance of tickChunks() selection process (#5721)
Since light population is required to make a chunk tickable, a chunk may not be tickable for some time if the async workers get backlogged.
The previous version of this system only cached the eligibility result if the result was a "yes", but we can also track it when it's a "no", rather than rechecking it every tick.

This change should improve performance in factions and similar gamemodes, which involve large maps with sparsely distributed players, where each player likely has an independent, non-overlapping ticking chunk circle.

We also ditch TickingChunkEntry in favour of multiple arrays to track the eligibility states. This allows us to avoid rechecking the (even cached) readiness of potentially thousands of chunks. If there are no ticking chunks to recheck, this reduces the cost of the selection process to zero.
2023-04-27 16:59:29 +01:00
Dylan K. Taylor
7f6269c432
Introduce and use optimised versions of Inventory->isSlotEmpty()
this avoids useless cloning, improving the performance of several functions.
2023-04-27 16:52:52 +01:00
Dylan K. Taylor
194714b448
Merge branch 'stable' into minor-next 2023-04-27 15:37:54 +01:00
Dylan K. Taylor
023460db2c
BaseInventory: fixed internalAddItem() doing useless canStackWith() checks on null items
if the item is null, it's never going to stack with anything given to this function, because addItem() already discards null items.
2023-04-27 14:53:54 +01:00