the second parameter to this callback is the OLD slots, not the changed slots. This means that ALL slots are included, including empty and unchanged slots.
in PM3, this was done by implicitly relying on the client to send a MobEquipmentPacket selecting the same hotbar slot when the slot contents changes.
In PM4, we avoid relying on this, and fire the event directly when the listener detects a held slot change.
This ensures that the behaviour remains consistent regardless of what the client starts doing in the future.
closes#4905
mb_strlen() is O(n), whereas strlen() is O(1). If we receive very large chat messages (e.g. 2 MB), mb_strlen() will take a very long time to return a result (around 8ms on my machine).
Since the max size of a UTF-8 character is 4 bytes (according to standard), we can use strlen() with 4x the char limit to gate it and prevent this from happening.
Due to the way positions are updated over the network, we only see the end result of a movement and not its preceding actions. In addition, we don't know for sure whether the MCPE collision checks work the same exact way as PM.
TL;DR: It's possible for the client to capture and send a movement frame after they collided with a step and then already moved forward from it some distance, resulting in a weird arc pattern.
This PR checks the range between the old and new positions for collision boxes to ensure that all possible areas are checked for detecting fall damage.
This has been tested and successfully resolves various issues involving running down stairs:
- missing sounds
- random fall damage
- The following events have been added:
- PlayerToggleGlideEvent
- PlayerToggleSwimEvent
- The following API methods have been added:
- Entity->getSize()
- Living->isSwimming()
- Living->setSwimming()
- Living->isGliding()
- Living->setSwimming()
- Player->toggleSwim()
- Player->toggleGlide()
- Added the following API methods:
- `Player::hasBlockCollision()`
- `Player::setHasBlockCollision()`
This enables spectator-like noclip behaviour in other gamemodes (could be useful for builders).
if a chunk was requested for generation, count++ and count(activeRequests)++, which means that we would only get to submit half as many generation requests as we're allowed to.
Calculate the limit at the start and remember it instead.
we don't want to allow sending further chunks when we haven't generated near ones, because we won't be able to see them anyway, and we might end up not needing them.
This now fully matches the results of PM3.
this ensures that the edge of loaded terain is always the same distance
away in any direction. This also means that when flying parallel to X or
Z axes, you now have about 12% more chunks directly in front of you,
instead of to your left and right, which gives the impression that
chunks are loading faster (they aren't, they are just being ordered in a
more sensible way).
this fixes the horrible spotty chunk loading seen in https://twitter.com/dktapps/status/1456397007946461190?s=20.
In practice, this made chunks invisible on teleport for several tens of seconds after teleporting. Having a larger chunks-per-tick with large render distance compounded to worsen the problem.
It wasn't really noticeable on small render distances, but very obvious on large ones with fast chunk sending and slow generation.
This also fixes#4187 (at least to the extent that it works on PM3, anyway).
this can happen especially on large render distances when flying fast and changing direction - we decide we don't want the chunk, then, after changing direction and re-ordering chunks, we decide we do want it again, and end up registering a second callback. In this case, we need to ensure that only one of the callbacks gets executed (it doesn't matter which one).
This reverts commit 866020dfdb06434b4f361a4a0f0faf7a89c30ed2.
For some fucking reason this broke resending chunks in some cases (and
sending chunks at all in others). I don't have time to debug this right
now, so it's going to have to remain broken, infuriatingly enough.
back when this was just hardcoded >> 4 everywhere, nobody thought anything of it, but now it uses constants, it's easy to cross-reference and see where the duplicates are.