Commit Graph

215 Commits

Author SHA1 Message Date
Dylan K. Taylor
d1fa6edc50 InGamePacketHandler: fix weak comparisons 2025-01-06 23:08:18 +00:00
Dylan K. Taylor
9a6e258b6c Merge branch 'stable' of github.com:pmmp/PocketMine-MP into minor-next 2024-12-05 10:13:06 +00:00
Dries C
ba6828c6bd Release 5.22.0 (Bedrock 1.21.50 support) (#6559)
Co-authored-by: Dylan K. Taylor <dktapps@pmmp.io>
2024-12-04 13:36:52 +00:00
pmmp-restrictedactions-bot[bot]
ae9b4dbb05 Merge 'stable' into 'minor-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12111121061
2024-12-02 01:41:01 +00:00
Muqsit
44771c892d Use PlayerAuthInputPacket::SNEAKING flag to test for sneaking (#6544)
This binds internal sneaking to whether or not the player is currently pressing the shift key, which fixes #5792 and fixes #5903.

However, it does introduce visual issues with sneaking, as explained in #6548. This needs to be worked on separately. For now, it's better we trade 2 functional bugs for 1 visual bug.
2024-12-01 13:14:30 +00:00
Dylan K. Taylor
12ae8dc03b Merge branch 'stable' into minor-next 2024-11-25 14:32:30 +00:00
Dylan K. Taylor
5325ecee37 Deal with a whole lot of PHPStan suppressed key casting errors
closes #6534
2024-11-25 14:30:58 +00:00
Javier León
d3add78d3e Add support for basic entity picking via middle-click (#5397)
Support for more advanced stuff like NBT copying wasn't added in this PR, as the NBT used by PM is currently an inconsistent mess and doesn't play nice with vanilla. In the interests of avoiding this mess propagating, it's been left for another time.

Adds PlayerEntityPickEvent a la PlayerBlockPickEvent
and Entity->getPickedItem().
2024-11-15 21:27:10 +00:00
Dylan T.
ff695a5f97 PlayerInteractEvent: added APIs to independently control reaction of item and block (#4683)
This allows, for example, banning the usage of spawn eggs, without preventing opening of doors, without the need for item ID whitelists.

It also allows customizing the behaviour of item and block interactions when sneaking - it's now possible to force spawn eggs to work when sneaking, or force containers to open.

Finally, this also allows preventing any interaction at all without preventing block placement (by setting both to false). Since cancelling the event will typically prevent placement too (which might not be desired).

Side note: Blocks are now always synced when right-clicking on a block.
This differs from the previous behaviour, where the blocks were only synced when the action "failed".
However, since this change introduces a situation where the action may succeed but have different results than the client expects, it's best to just always sync blocks in this situation.

Fixes #3267
2024-11-15 21:19:54 +00:00
Dylan K. Taylor
ba48f258f3 Support for 1.20.70 2024-03-13 14:53:27 +00:00
Dylan K. Taylor
98042f844f Merge remote-tracking branch 'origin/stable' into minor-next 2024-02-28 17:36:21 +00:00
Dylan K. Taylor
a0cca53f52 Fixed mismatched predictions due to NBT key order differences
this is a pain :(
It appears the client always sorts the keys in alphabetical order due to use of std::map. However I'm not sure of the exact ordering behaviour, so it needs to be investigated.
2024-02-27 16:07:43 +00:00
Dylan K. Taylor
47f0119660 InGamePacketHandler: added an extra check 2024-02-26 14:35:21 +00:00
Dylan K. Taylor
25cca1b63f Changes for 1.20.50 2023-12-06 14:29:23 +00:00
Dylan K. Taylor
fe3e2cc90a Merge branch 'stable' into minor-next 2023-09-20 19:14:34 +01:00
Dylan K. Taylor
6553852d99 Updated for 1.20.30 release 2023-09-20 18:34:12 +01:00
Dylan K. Taylor
7ce33d9375 Migrate final remaining EnumTrait users to native enums 2023-09-08 10:34:12 +01:00
ねらひかだ
19e3d339f6 InGamePacketHandler: subtract from raw position before rounding it (#6022)
This allows better compensation for floating point errors introduced by the subtraction of the 1.62 height offset.

For example, if the player is at y=7 exactly, their Y coordinate will be reported as 8.62, which, because of floating point errors, will be something like `8.619999999`. Subtracting `1.62` from this (really something like `1.62000000000005...`) leads to the calculated Y coordinate being slightly below 7.

Rounding after subtracting this offset allows this to be rounded to 7 sharp. Similar errors appear in various other coordinates.
2023-08-29 11:43:21 +01:00
ipad54
6086ef667c Added handling for attack-air action (#5912) 2023-07-25 14:50:28 +01:00
Dylan K. Taylor
ef85fbffe1 Merge branch 'legacy/pm4' into stable 2023-07-11 15:10:55 +01:00
Dylan K. Taylor
0c250a2ef0 InGamePacketHandler: fixed inconsistent handling of invalid data in BlockActorDataPacket 2023-07-11 12:53:29 +01:00
Dylan K. Taylor
926f68d8c5 Move SkinAdapter under TypeConverter, remove SkinAdapterSingleton
this is legacy cruft from PM3, which didn't have TypeConverter or SingletonTrait.
2023-05-06 17:53:24 +01:00
Dylan K. Taylor
ed11fd5a83 CS again... 2023-05-06 17:51:00 +01:00
Dylan K. Taylor
e0a6ec0c24 Start deglobalizing TypeConverter
there's a bunch of places we can't reach with this right now:

- particles
- sounds
- tile NBT
- entity metadata
- crafting data cache
- chunk encoding
- world block update encoding

this is a work in progress, but ultimately we want to get rid of these singletons entirely.
2023-05-06 17:47:09 +01:00
Dylan K. Taylor
5c7f4570b4 Merge branch 'minor-next' into major-next 2023-05-06 17:20:37 +01:00
Dylan K. Taylor
7c19f14cf5 Fixed up offhand handling for ItemStackRequest, fixes #5723 2023-04-27 13:25:08 +01:00
Dylan K. Taylor
0dca85af44 Merge branch 'minor-next' into major-next 2023-04-26 23:28:27 +01:00
Dylan K. Taylor
0d21e591d1 Support sign editing UI in 1.19.80, with APIs to allow plugins to use it
this doesn't support editing the rear side of a sign, since the 1.12 format doesn't allow us to represent the rear text, and it would necessitate API breaks to support anyway.

However, we can quite trivially support APIs for the sign GUI, which plugins can use to enable editing signs. PocketMine-MP doesn't currently permit this, since it's currently an experimental feature in 1.20, but plugins can simply use Player->openSignEditor() to mimic it.

This is, however, a byproduct of the fact that APIs needed to be added in order to facilitate the use of OpenSignPacket in 1.19.80.
2023-04-26 22:55:05 +01:00
Dylan K. Taylor
a0346fb6d3 Merge branch 'minor-next' into major-next 2023-04-26 14:29:32 +01:00
Dylan K. Taylor
a4f2b99ed5 InGamePacketHandler: queue slots for syncing if they appear in requestChangedSlots
this is essentially a prediction without the actual predicted item. We have to sync these regardless of what happens.

fixes #5708
2023-04-24 14:06:29 +01:00
Dylan K. Taylor
a0dadc6e37 Merge branch 'minor-next' into major-next 2023-04-10 14:38:23 +01:00
Dylan K. Taylor
7b55c984bf InGamePacketHandler: reduce debug noise on outdated movements 2023-04-07 21:40:46 +01:00
Dylan K. Taylor
10f3145af2 Merge branch 'minor-next' into major-next 2023-03-29 23:22:02 +01:00
Dylan K. Taylor
3ee62d8440 InGamePacketHandler: increase max ItemStackRequest actions to 60
due to implementation quirks + some unforeseen ways these actions can behave, there can be as many as 53 actions in a single crafting request. This is an edge case, but it has to be catered for.
2023-03-27 15:44:42 +01:00
Dylan K. Taylor
811639f2cd InGamePacketHandler: relax errors on normal transactions to fix book editing
for some reason book edits generate a transaction in addition to BookEditPacket. PM has never used the transaction, and it doesn't pass anyway because CreateItemAction can't be used in survival mode.
However, since the strict validation introduced since ItemStackRequest, this dud transaction now causes the player to get kicked without these changes.
2023-03-27 13:26:26 +01:00
Dylan K. Taylor
58974765a6 InGamePacketHandler: fixed crash when attempting to drop more of an item than is available 2023-03-27 13:26:26 +01:00
Dylan K. Taylor
3b11191043 Merge remote-tracking branch 'origin/minor-next' into major-next 2023-03-22 22:49:22 +00:00
Dylan K. Taylor
ea386c42d3 InGamePacketHandler: fixed dropping items from unselected hotbar slots 2023-03-21 14:45:18 +00:00
Dylan K. Taylor
ccd288d7fa Avoid repeated calls to getItemInHand() in drop item handler 2023-03-21 00:04:29 +00:00
Dylan K. Taylor
097632902a InGamePacketHandler: fixed crash condition in drop item handler 2023-03-21 00:02:32 +00:00
Dylan K. Taylor
a4d34be6df Merge branch 'minor-next' into major-next 2023-03-20 23:42:40 +00:00
Dylan K. Taylor
63310cf764 Do not cache ItemStacks for every item
this is very memory inefficient, and only provides a performance advantage in cold code anyway.
2023-03-20 23:18:43 +00:00
Dylan K. Taylor
453ad997e9 Merge branch 'item-stack-request' into item-stack-request-pm5 2023-03-20 22:05:12 +00:00
Dylan K. Taylor
ca6d51498f Buffer slot and content syncing until the end of the tick
we may receive multiple requests in one tick (e.g. crafting in a batch)
2023-03-20 19:16:00 +00:00
Dylan K. Taylor
c91168db66 ... 2023-03-20 01:35:15 +00:00
Dylan K. Taylor
4e55433ed8 Fixed request rejecting 2023-03-20 01:35:03 +00:00
Dylan K. Taylor
eece6c4433 InGamePacketHandler: remove dead code 2023-03-20 01:28:18 +00:00
Dylan K. Taylor
804feedb67 Added some dumb limits 2023-03-20 00:54:33 +00:00
Dylan K. Taylor
7b0816e42f Properly handle transaction building errors instead of kicking the player 2023-03-20 00:52:26 +00:00
Dylan K. Taylor
6c29c3d2dd Merge branch 'item-stack-request' into item-stack-request-pm5 2023-03-14 22:56:47 +00:00