Commit Graph

65 Commits

Author SHA1 Message Date
efd113bdc8 Integrate pmmp/BedrockProtocol@65b3d0b341 2024-02-26 17:09:09 +00:00
eaab1a8784 ChunkSerializer: fixed count calculation for non-overworld chunks
plugins that implement dimensions can't change the number of subchunks used by Chunk, they can only choose to use a subset of them.
2024-02-07 18:58:41 +00:00
6492e7f4a2 1.20.60 support 2024-02-07 12:33:44 +00:00
289ede669d BlockTranslator: use less ambiguous function names 2023-05-05 14:47:23 +01:00
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
32e6fdd95a Rename RuntimeBlockMapping -> BlockTranslator 2023-05-03 22:18:27 +01:00
7abfc46567 First look at 3D biome support 2023-01-17 21:41:30 +00:00
43a3151de3 Merge branch 'next-minor' into next-major 2022-08-14 18:49:19 +01:00
036e06e889 Revert "Workaround items in blockentity NBT not being processed correctly in 1.19.10"
This reverts commit 2b61c025c2.
2022-08-14 17:25:55 +01:00
259f44e57c Merge branch 'next-minor' into next-major 2022-07-14 22:05:04 +01:00
2b61c025c2 Workaround items in blockentity NBT not being processed correctly in 1.19.10
closes #5154

this hack sends only the bare essential data to create the tiles in LevelChunkPacket,
and then separately sending the full tile data using BlockActorDataPacket afterwards.

This is necessary because the client doesn't handle items correctly in NBT when chunks are sent without using the SubChunkRequest system.
In 4.6 this is observed with incorrect items shown in item frames; in 5.0 it's seen with items simply not showing up at all (difference due to modernization of the serialization format in 5.0).
2022-07-14 21:54:01 +01:00
1ff69136a3 Merge branch 'next-major' into modern-world-support 2022-06-07 20:01:40 +01:00
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
e383f6d8f8 Merge branch 'next-major' into modern-world-support 2022-04-20 14:29:22 +01:00
c085bf0db4 Changes for 1.18.30 2022-04-20 13:59:50 +01:00
eafbc3a468 Expand height range to include -64 to 320 2022-04-15 19:10:24 +01:00
f4f4ea1483 fix CS 2022-02-01 17:44:12 +00:00
979f6f3d57 Rewrite RuntimeBlockMapping to use BlockStateSerializer 2022-02-01 17:34:32 +00:00
aea124af74 Fix inconsistent class name 2021-11-30 19:17:26 +00:00
8620e67d88 Protocol changes for 1.18.0 2021-11-30 19:16:38 +00:00
c6c992a1f0 Preparations for negative Y support 2021-11-08 17:28:22 +00:00
5b818827db Chunk: stop exposing SplFixedArray<SubChunk> to the API
this fixes a large number of PHPStan errors, and also brings us a step closer to negative-build-height readiness.
2021-10-01 22:17:28 +01:00
8e2d06a880 ChunkSerializer: support writing 0 bpb palettes on the wire
these are now supported as of 1.17.30.
2021-09-25 01:17:32 +01:00
11d2e1ef08 Require ext-chunkutils ^0.3.0 2021-09-07 22:53:50 +01:00
17d0767db5 ChunkSerializer: implement support for persistent network chunk format 2021-07-17 18:45:04 +01:00
e5327a0f3e ChunkSerializer: Extract serializeSubChunk() from main serialize() routine
this will be used in the future for cache-based chunk sends.
2021-07-17 18:29:14 +01:00
1ad38d499c Deglobalize ItemTypeDictionary usage, at least for the protocol
while this is a bit hacky outside of the protocol namespace, it makes it much easier to use the protocol library for alternative purposes, such as for a client or MITM proxy.
It also removes all but one remaining core dependency of the protocol library, making it very close to being able to be separated from the server core entirely.
2021-07-14 14:26:32 +01:00
4549522289 Rename Chunk::getSubChunkChecked() -> getSubChunk() 2020-10-31 23:12:03 +00:00
01001dca74 Use Chunk::getSubChunkChecked() in places where we know that an invalid coordinate cannot be requested 2020-10-31 22:48:41 +00:00
5661d0496f RuntimeBlockMapping::toRuntimeId() now accepts a single integer instead of id/meta
the expectation is that eventually this will receive arbitrary internal runtime IDs instead of static id/meta, and RuntimeBlockMapping doesn't really care about this crap anyway.
2020-09-20 12:16:11 +01:00
ad99dc5884 ChunkSerializer micro optimisation: reduce indirections when writing runtime IDs 2020-07-05 22:00:42 +01:00
6c096c44aa Rename NetworkBinaryStream -> PacketSerializer 2020-06-17 11:31:13 +01:00
6b037d6a4c RuntimeBlockMapping: these IDs are not static any more 2020-05-11 12:40:55 +01:00
a73c54bdd0 making tile spawn compound cache use CacheableNbt instead of strings 2020-05-04 12:35:13 +01:00
c2857a91bd [Network]ChunkSerializer: allow injecting RuntimeBlockMapping
this will allow the same serializer to be reused with different mapping tables (will be needed for multi version).
2020-05-04 12:14:27 +01:00
a97cafd4f6 moving serializers into protocol namespace 2020-04-27 13:54:39 +01:00
287bf4274f move RuntimeBlockMapping to convert package 2020-04-24 12:42:43 +01:00
aa1828aa98 RuntimeBlockMapping is now a singleton instead of static class
this prepares for a fully dynamic block mapper, as well as allowing a small performance improvement to chunk encoding by eliding the constant lazy-init checks.
2020-04-23 21:09:58 +01:00
18d48869a0 the great airgapping of recipes and itemstacks 2020-04-23 14:11:48 +01:00
9bfc1df486 Merge branch 'stable' 2020-04-18 13:19:31 +01:00
ab62a792e1 Merge commit '7a072931d' 2020-04-18 12:10:02 +01:00
da7ff9b1fe Airgap Attribute, fix decoding of non-registered attributes for protocol debugging 2020-03-24 00:43:44 +00:00
d930abce2d ChunkSerializer: improve palette writing performance with one weird trick
this optimization relies on the fact that palette entries are always unsigned, and positive zigzag varints are just the same as their non-zigzag counterparts, except shifted left by 1 bit. This eliminates some function call overhead, making the encoding slightly less agonizingly slow.
2020-03-17 21:16:43 +00:00
bd00ee5038 Merge branch 'stable' 2020-02-24 22:11:13 +00:00
ce0af8b040 DataPacket now encapsulates NetworkBinaryStream instead of extending it
ultimately the goal is to remove the NetworkBinaryStream crap entirely, but this change has most of the same benefits and is less disruptive.
2020-02-24 18:59:54 +00:00
04a3e71047 ChunkSerializer: avoid using loop vars outside loop scope 2020-02-07 22:10:23 +00:00
fb1126797a Merge branch 'stable' 2020-02-07 18:13:55 +00:00
cb16f5c142 Merge commit '260ac47588c76a2e6814cfba46773a990fb8c5da'
# Conflicts:
#	resources/vanilla
#	src/Server.php
#	src/lang/Language.php
#	src/network/mcpe/protocol/AddItemActorPacket.php
#	src/network/mcpe/protocol/AddPlayerPacket.php
#	src/network/mcpe/protocol/SetActorDataPacket.php
#	src/network/mcpe/serializer/NetworkBinaryStream.php
#	src/permission/Permission.php
#	src/pocketmine/block/Leaves.php
#	src/pocketmine/entity/DataPropertyManager.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/item/Banner.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/io/LevelProvider.php
#	src/pocketmine/level/format/io/LevelProviderManager.php
#	src/pocketmine/network/mcpe/protocol/AddActorPacket.php
#	src/pocketmine/network/mcpe/protocol/LoginPacket.php
#	src/pocketmine/tile/Banner.php
#	src/scheduler/BulkCurlTask.php
#	src/updater/AutoUpdater.php
#	src/utils/Config.php
#	src/utils/Utils.php
#	src/world/generator/Flat.php
#	src/world/generator/Generator.php
2020-01-31 21:07:34 +00:00
20d39846b7 Merge commit 'fc0619ee6e4fa08aba2719e58a9289edd11f0b6e'
# Conflicts:
#	resources/vanilla
#	src/network/mcpe/protocol/AddItemActorPacket.php
#	src/network/mcpe/protocol/AddPlayerPacket.php
#	src/network/mcpe/protocol/SetActorDataPacket.php
#	src/network/mcpe/serializer/NetworkBinaryStream.php
#	src/pocketmine/network/mcpe/protocol/AddActorPacket.php
#	src/pocketmine/network/mcpe/protocol/LoginPacket.php
2020-01-31 19:42:07 +00:00
055b13a6cf strip extra blank lines (php-cs-fixer) 2020-01-22 15:14:10 +00:00