11075 Commits

Author SHA1 Message Date
Dylan K. Taylor
23e5ade77e Merge branch 'stable' into master
# Conflicts:
#	build/make-release.php
#	composer.lock
#	resources/vanilla
#	src/plugin/PluginDescription.php
#	src/pocketmine/entity/Human.php
2020-10-21 16:55:52 +01:00
Dylan K. Taylor
2a1d1e90a2 php-cs-fixer nits 2020-10-21 16:44:57 +01:00
Dylan K. Taylor
286ac2a975 Rework World::blockHash() to use morton3d
this uses the unused bits on the Y component to expand the X/Z axes to 2^27 blocks long instead of 2^21 permitted by a regular morton3d code. It does require the sacrifice of an additional bit on the Y axis, but the performance advantages are more than worth it.
I'm exploring how realistic it would be to just eliminate blockHash global usage (currently in lighting updates and explosions). This would allow scaling up to 2^32 without larger hashes (morton2d for chunks).
2020-10-20 20:31:10 +01:00
Dylan K. Taylor
9a282e2646 Noise: Improve fastNoise3D performance by ~25-30% 2020-10-17 20:03:19 +01:00
Dylan K. Taylor
095449e86a Normal (generator): micro optimisations (and readability improvements) 2020-10-17 19:24:01 +01:00
Dylan K. Taylor
0f9d5f7011 ext-morton is now required and used for World::chunkHash() and World::chunkBlockHash() 2020-10-17 16:09:30 +01:00
Dylan K. Taylor
de6d260b76 Fixed cactus and sugarcane trying to grow past the top of the world 2020-10-17 15:05:55 +01:00
Dylan K. Taylor
a251960c1c AsyncPool: expose workerUsage to the API
this allows plugins (and maybe later on the core) to detect async worker overload and warn the user about potential performance issues.
I planned to implement such detection in the core directly, but it turned out to be a bit more complex than I anticipated. At the least, this API might be useful to someone else.
2020-10-16 21:20:49 +01:00
Dylan K. Taylor
d38791e27d Listener: Drop support for @softDepend annotation
literally nobody uses this. I don't think anyone even knows it exists.
It's also an obstacle to separating event handler registration from PluginManager.
2020-10-16 21:10:57 +01:00
Dylan K. Taylor
52f734799e Human: do not modify totalXp unless setting XP succeeds 2020-10-16 20:43:03 +01:00
Dylan K. Taylor
42171f6e06 Human: beware negative values in addXp() 2020-10-16 20:42:13 +01:00
Dylan K. Taylor
792f38f474 Carpet and Wool now have dynamic colours 2020-10-15 14:45:28 +01:00
Dylan K. Taylor
0ef0848c44 Concrete and ConcretePowder colour is now dynamic 2020-10-15 14:30:07 +01:00
Dylan K. Taylor
1fe4fdc67c PluginDescription: fixed some very old refactoring errors 2020-10-15 13:55:40 +01:00
Dylan K. Taylor
3aca03d262 Player: clean up refs when forced chunk unload is detected
this might happen because of a plugin, or low memory condition.
2020-10-13 18:17:12 +01:00
Dylan K. Taylor
44e446b621 Merge remote-tracking branch 'origin/stable' into master
# Conflicts:
#	build/php
#	composer.lock
#	phpstan.neon.dist
#	resources/vanilla
#	src/pocketmine/Server.php
#	src/pocketmine/VersionInfo.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/lang/locale
#	src/utils/Timezone.php
#	tests/phpstan/bootstrap.php
#	tests/phpstan/configs/custom-leveldb.neon
2020-10-13 17:51:49 +01:00
Dylan K. Taylor
03837c1b71 ZlibCompressor: use libdeflate if available
I may make libdeflate mandatory later on, but right now we haven't been able to ship it on all platforms yet.
2020-10-13 17:30:27 +01:00
Dylan K. Taylor
3e2926441d PluginDescription: make sure that extensions constraints are actually strings 2020-10-13 17:21:10 +01:00
Dylan K. Taylor
0b33762be0 PluginDescription: fixed type of extensions (reported by phpstan 0.12.49) 2020-10-13 17:21:10 +01:00
Dylan T
e6f89213dc
Entity: properly account for upwards motion when calculating fall distance (#3867)
Previously, upwards movement wouldn't be considered, but downwards would, so if an entity bobbed up and down in the air for a while (e.g. while being comboed in PvP), the downwards distance would accumulate and deal a large amount of fall damage on touchdown.
This commit changes fall distance measurement to correctly account for upwards movement.

A better way of measuring fall distance would simply be to record the highest Y coordinate reached while in the air, and then measure the distance between that and the point of contact when landing. This would also remove the need to constantly update the fallDistance field. However, this would involve a BC break and will therefore have to wait until PM4.
2020-10-13 14:16:09 +01:00
jasonwynn10
7027a9b972
camelCase 2020-10-12 08:25:34 -04:00
Jason
b02f3f4090
Isolate and always show IP details on install 2020-10-11 18:57:30 -04:00
Dylan K. Taylor
eabfd2a37b World: replace sendBlocks() with createBlockUpdatePackets()
this allows the caller to decide how the packets should be sent.
2020-10-11 16:30:54 +01:00
Dylan K. Taylor
ca9f3020b4 World: added private broadcastPacketToPlayersUsingChunk()
this is equivalent to the old addChunkPacket, but private and with a less stupid name.
2020-10-11 15:21:15 +01:00
Dylan K. Taylor
a05b1fec7e World: rename chunkPackets -> packetBuffersByChunk 2020-10-11 15:18:57 +01:00
Dylan K. Taylor
bd3bf3d0ce Revert "World: do not group broadcasted packets by chunk, broadcast directly instead"
This reverts commit b172c93e45e60ee3dbfd8a2efbede60b894673a3.

I made a significant mistake with this change: the scaling factor of
batch-by-chunk is O(nSendBytes), while the scaling factor of sending
directly to players is O(nSendBytes * nActivePlayers). It seems like the
real problem is that this system isn't getting enough usage.

While it does reduce compression efficiency in some cases, it falls back
to letting the sessions do individual compression when the amount of
data is less than 256 bytes anyway (compression-threshold in
pocketmine.yml).

My motivation for scrapping this system was to reduce the broadcast
system's complexity to make it easier to thread the living shit out of
compression, but it seems like this change was a step in the wrong
direction for performance.

A few steps can be taken to improve the usefulness of this system (and
also improve output bandwidth):
- Make general entity updates use this system. Movement and velocity
  already kinda used this system, but crucially, players did not,
  because we couldn't prevent the player from receiving its own movement
  updates if we did that, which caused all kinds of problems.
  - Therefore, we need to reintroduce static "self" entity IDs, like we
    had in the shoghi days when entity ID 0 referred to the "self"
    player.
  - However, since entity ID 0 has a variety of interesting bugs since
    it usually refers to "no entity" in MCPE, it would be better to use
    1 (or 2, like MiNET does).
  - The fixed ID used should be close to zero to maximize varint
    encoding efficiency.
  - We assumed that changes to player's position and velocity would be
    ignored by the client. This assumption depends on the client and
    could be broken at any time, so it's best not to rely on it.
- Make block updates use this system (when chunk updates are not sent).
  Currently, block updates use a separate mechanism which creates a
  second batch for every active chunk, which wastes CPU, and decreases
  bandwidth efficiency on multiple fronts (reduced compression
  efficiency, more cross-thread interactions, more bytes wasted on
  RakNet packet headers).
2020-10-11 14:55:54 +01:00
Dylan K. Taylor
2e3940e8f5 NetworkSession: remove circular dependency between queueCompressed() and flushSendBuffer()
this cycle makes the code fragile and prone to infinite looping bugs when modified, as well as making the code harder to follow.
2020-10-11 12:22:59 +01:00
Dylan K. Taylor
46c57e4e24 TimingsCommand: fixed crash on result handling
since AsyncTask->getResult() returns mixed, phpstan has no idea what is being returned here, so it doesn't report any errors.
2020-10-11 11:35:03 +01:00
Dylan K. Taylor
e11dbf03e2 Process: apply native typehint to kill() 2020-10-09 18:06:33 +01:00
Dylan K. Taylor
40fca0936f Internet: make getURL() and postURL() return InternetRequestResult objects
this reduces the amount of reference parameters, and generally reduces the number of parameters, while guaranteeing consistency of the APIs.
2020-10-09 18:03:20 +01:00
Dylan K. Taylor
873535f719 Timezone: explicitly check result of getURL()
phpstan-strict-rules should report this, but it doesn't ...
2020-10-09 17:23:22 +01:00
Dylan K. Taylor
78f4fcf6ab StatusCommand: removed "Maximum memory (system)"
it's not clear what this was actually supposed to represent, but it actually reports VmSize, which is already reported by "Total virtual memory". This line confuses users and is misleading.
2020-10-08 22:58:37 +01:00
Dylan K. Taylor
a91710b199 Fixed player knockback not working since 531c6344fe6bd920ef2b6639b7ff649cfe8bf11c
player knockback silently depended on the chunk packet broadcast system sending the player's motion back to itself, which broadcasting to hasSpawned will not do.
2020-10-08 21:56:08 +01:00
Dylan K. Taylor
15a2fd6e4f LegacySkinAdapter: check return value of json_encode() for resource patch 2020-10-08 21:42:07 +01:00
Dylan K. Taylor
b0b08d45d5 Entity: clean up sendData() handling, remove send-to-self hack 2020-10-08 21:35:36 +01:00
Dylan K. Taylor
01b44ab0bc protocol: moved skin data types to their own namespace 2020-10-08 21:20:57 +01:00
Dylan K. Taylor
90b749c260 net: reduce default compression level to 6
On larger packets, this worsens compression ratio by 1-2%, but reduces CPU load due to compression by 15-20%. Higher levels than 6 are far more expensive for diminishing returns.
Level 5 produces a further 25-30% CPU reduction, but increases bandwidth usage by 20-25%, so 6 is the sweet spot.
2020-10-08 16:51:10 +01:00
Dylan K. Taylor
94c58c00b5 NetworkSession: Restore PM3 unexpected XUID handling behaviour (removes XUID instead of kicking the player)
close #3861, close #3089
2020-10-08 14:36:07 +01:00
Dylan K. Taylor
df7bafe2bc TileFactory: fixed missing Beacon tile registration
I had this locally but forgot to commit it ...
2020-10-07 15:16:27 +01:00
Dylan K. Taylor
cbc6ebebad Entity: make use of MoveActorAbsolutePacket::create() 2020-10-06 18:35:02 +01:00
Dylan K. Taylor
d8ee657d20 MoveActorAbsolutePacket: added ::create() method 2020-10-06 18:34:38 +01:00
Dylan K. Taylor
69cad3e694 InGamePacketHandler: Ignore LevelSoundEventPacket completely 2020-10-06 18:26:57 +01:00
Dylan K. Taylor
531c6344fe Entity: stop using broadcastPacketToViewers for movement / motion
this is now effectively identical to sending packets to each of hasSpawned, with the exception that it won't send packets to itself if it's a player.
2020-10-06 18:22:46 +01:00
Dylan K. Taylor
d7f7e1c4ff InventoryManager: remove useless repeated code 2020-10-06 18:14:46 +01:00
Dylan K. Taylor
15eac8a65a NetworkSession: renamed some instructions to imperative instead of onWhatever()
these aren't listening to events, they are telling the client that an event has taken place.
2020-10-06 18:06:48 +01:00
Dylan K. Taylor
945a2598b7 Player: fix documented type of kick $quitMessage 2020-10-06 17:55:32 +01:00
Dylan K. Taylor
49d611168f Player: fix documented type of disconnect $quitMessage 2020-10-06 17:54:44 +01:00
Dylan K. Taylor
b172c93e45 World: do not group broadcasted packets by chunk, broadcast directly instead
Grouping packets to batch by chunk instead of by player reduces bandwidth efficiency, because the number of active chunks is almost always larger than the number of active players.
With the old mechanism, a batch of packets for each active chunk (which could be dozens, or hundreds... or thousands) would be created once, and then sent to many players. This makes the compression load factor O(nActiveChunks). Broadcasting directly is simpler and changes the load factor to O(nActivePlayers), which usually means a smaller number of larger batches are created, achieving better compression ratios for approximately the same cost (the same amount of data is being compressed, just in a different way).
2020-10-06 17:27:17 +01:00
Dylan K. Taylor
78bddac823 Player: remove removeFormat, chat formatting is now unconditionally available
This change was made after exploring turning this into a permission. It occurred to me that this feature is entirely superfluous because it's non-vanilla, can be done by plugins, and is usually considered as a bug. In addition, disabling this behaviour required third party code just for this one thing because it was not able to be managed by a permissions plugin.
Instead, it's better to produce a plugin which implements this behaviour if it's desired, by making use of SignChangeEvent and PlayerChatEvent/PlayerCommandPreprocessEvent.

close #3856, close #2288
2020-10-06 14:00:23 +01:00
Dylan K. Taylor
e39d2c4621 Beacon: fixed crash in PC worlds 2020-10-06 13:40:49 +01:00