Commit Graph

263 Commits

Author SHA1 Message Date
Drew B
ce54d268f2 Player: allow controlling client-sided block collisions irrespective of Spectator Mode (#4563)
- Added the following API methods:
  - `Player::hasBlockCollision()`
  - `Player::setHasBlockCollision()`

This enables spectator-like noclip behaviour in other gamemodes (could be useful for builders).
2021-12-06 21:14:22 +00:00
Dylan K. Taylor
c7beb0a702 Clean up inventory auto close mess from PM3
on PM3 there was no concept of 'current window', we had no idea which window the player was actually looking at.
2021-11-08 23:51:25 +00:00
Dylan K. Taylor
5be429a8c4 Ensure inventories get evacuated on server-side window close 2021-11-08 23:48:05 +00:00
Dylan K. Taylor
ab002ca06d Improved handling of temporary inventory windows
evacuation behaviour is now consistent regardless of who is doing it
2021-11-08 23:36:58 +00:00
Dylan K. Taylor
45edb94607 Crafting tables now work the same way as anvils and enchanting tables
Removing almost all special-case logic for crafting tables.
2021-11-07 16:20:07 +00:00
Dylan K. Taylor
b8523f7a18 Player: fix the fix which just degraded performance
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.
2021-11-06 01:00:35 +00:00
Dylan K. Taylor
640e88009b Player: fixed a mistake in generation rate limit
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.
2021-11-06 00:57:37 +00:00
Dylan K. Taylor
0989c77037 Player: check that horizontal distance travelled is > 0 before adding exhaustion, or triggering a new chunk order
closes #4548
2021-11-05 15:46:55 +00:00
Dylan K. Taylor
5107d0df4e Player: cap maximum number of active generation requests
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).
2021-11-05 15:09:42 +00:00
Dylan K. Taylor
2405e45b35 Player: mark as not using item when held item slot is changed
closes #4538
2021-11-03 21:26:20 +00:00
Dylan K. Taylor
ef82a2cd79 Fixed PlayerEmoteEvent::setEmoteId() being useless 2021-11-02 23:10:26 +00:00
Dylan K. Taylor
87031627bf Do not call PlayerEmoteEvent if rate limit was reached 2021-11-02 23:09:43 +00:00
Hashim
f066199971 Implement emote support (#4523) 2021-11-02 23:04:55 +00:00
Dylan K. Taylor
e34364412b Replace InvalidStateException usages with InvalidArgument or LogicException 2021-11-02 16:05:54 +00:00
Rush2929
ede4157814 Check to see if the player can start using the Releasable item. (#4532) 2021-11-02 14:36:16 +00:00
Dylan K. Taylor
804fb3f603 Merge commit 141fbde660 2021-11-01 17:39:40 +00:00
Dylan K. Taylor
46b7d35cd3 Player: return from callback if used chunk status is not REQUESTED_GENERATION()
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).
2021-11-01 01:45:49 +00:00
Dylan K. Taylor
bd60e41268 Revert "Revert "Player: do not re-request the same ungenerated chunks multiple times""
This reverts commit 3265d3f6b4.
2021-10-31 22:57:56 +00:00
Dylan K. Taylor
3265d3f6b4 Revert "Player: do not re-request the same ungenerated chunks multiple times"
This reverts commit 866020dfdb.

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.
2021-10-31 21:25:21 +00:00
Dylan K. Taylor
866020dfdb Player: do not re-request the same ungenerated chunks multiple times
this doesn't affect chunk resends, since they'll be kicked back to NEEDED, which is detected by orderChunks().
2021-10-31 18:52:37 +00:00
Dylan K. Taylor
4f816d03a7 SurvivalBlockBreakHandler: remove useless code 2021-10-30 21:35:58 +01:00
Dylan K. Taylor
8a2ecfe1d4 Merge branch 'stable' 2021-10-29 19:04:01 +01:00
Dylan K. Taylor
6d89265510 Player: reduce code duplication
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.
2021-10-26 23:02:50 +01:00
Dylan K. Taylor
c773e43eda Updated BedrockProtocol to pmmp/BedrockProtocol@97fa88e9ef 2021-10-23 01:16:45 +01:00
Dylan K. Taylor
bb6ea8cbdc Do not call PlayerLoginEvent during the Player constructor
this closes a lot of loopholes in the login sequence that plugins were using to cause crashes.
2021-10-04 22:36:50 +01:00
Dylan K. Taylor
3836a57ba6 Player: add getPlayerInfo(), closes #4450 2021-09-17 22:17:36 +01:00
Dylan K. Taylor
5ddd94b7e8 Remove redundant World->isChunkGenerated() calls
isChunkGenerated() merely checks if the chunk can be loaded from disk, if it's not in the runtime cache already.
This is pointless in all of these cases, because the check is prefaced by an isChunkLoaded() check, which already limits the possibility anyway. If the chunk is not generated, it'll also be considered not loaded.
2021-09-12 15:21:09 +01:00
Dylan T
4111d92b98 Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
Dylan K. Taylor
cf762d345d Player: Log debug messages when canInteract() prevents block interaction 2021-09-10 15:58:38 +01:00
Dylan K. Taylor
082f0f2d57 Player: Generate an InventoryTransaction (with event) for crafting grid/cursor evacuation
this fixes the crack in the armour that allows creative players to drop items even when all drops are being cancelled by plugins.

closes #3284
2021-09-09 17:11:59 +01:00
Dylan K. Taylor
34f01a3ce3 World: Track entities separately from chunks
this allows entities to exist outside of generated chunks, with one caveat: they won't be saved in such cases.
Obviously, for player entities, this doesn't matter.

fixes #3947
2021-09-09 01:17:41 +01:00
Dylan K. Taylor
d4d00a9b80 Living: added calculateFallDamage()
to clean up the way that fall damage is handled for flying players; also, onHitGround() isn't only doing fall damage things these days.
2021-09-05 14:36:58 +01:00
Dylan K. Taylor
d329bfb25d Entity: rename movX/movY/movZ to wantedX/wantedY/wantedZ
this makes the code much easier to understand.
2021-09-05 14:06:53 +01:00
Dylan K. Taylor
8be1f34736 Entity: Rename fall() to onHitGround(), and make it protected
this had no business being exposed to public API in the first place.
2021-09-05 13:36:40 +01:00
Dylan K. Taylor
6ecad153ea Entity: remove fallDistance parameter from fall() 2021-09-05 13:34:43 +01:00
marshall
6e68e99ec0 Added PlayerEntityInteractEvent (#4374) 2021-08-24 11:56:10 +01:00
SalmonDE
7fd712c1ff Refactor Block & Tile: getPos() to getPosition() (#4395)
this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
2021-08-23 14:01:32 +01:00
alvin0319
34a7405820 Player: fixed player can fly after respawn (#4388) 2021-08-20 22:51:36 +01:00
Dylan K. Taylor
bf8b5905e4 Player: Play ItemBreakSounds when items break due to usage
closes #4381
2021-08-19 15:56:40 +01:00
Dylan K. Taylor
b4b3c21d30 Merge branch 'stable' 2021-08-19 15:39:16 +01:00
Dylan K. Taylor
5da90b9530 Stop auto-translating strings when not asked
fixes #4371
2021-08-15 20:44:27 +01:00
Dylan K. Taylor
a81680c5c6 missed a few more hardcoded translation keys 2021-08-15 20:12:55 +01:00
Dylan K. Taylor
789a669395 Rename TranslationContainer -> Translatable 2021-08-15 16:17:46 +01:00
Dylan K. Taylor
8b9d7d6390 Support for nested TranslationContainers 2021-08-14 20:57:13 +01:00
Dylan K. Taylor
804d02b086 TranslationContainer: added prefix(), postfix() and format() 2021-08-14 16:08:22 +01:00
Dylan K. Taylor
13d4131d0d Remove player update warnings
a player ingame is not going to have access to the terminal to update PM, and if they do, they can see the warning on the console themselves anyway.
2021-08-14 13:27:21 +01:00
Dylan K. Taylor
b4c0ddd155 Use native union types for TranslationContainer|string 2021-08-10 15:17:26 +01:00
Dylan K. Taylor
2293bd948d Added KnownTranslationFactory and use it in as many places as possible
this makes translation usage much more statically analysable.
The only places this isn't used are:
- places that prefix translations with colours (those are still a problem)
- places where server/client translations don't match (e.g. gameMode.changed accepts different parameters in vanilla than in PM)
2021-08-10 14:50:40 +01:00
Dylan K. Taylor
b31dce2119 Player: fixed type of loadQueue field 2021-08-04 21:17:44 +01:00
Dylan K. Taylor
c567ed4b7a fix build error 2021-08-03 15:32:21 +01:00