71 Commits

Author SHA1 Message Date
Dylan K. Taylor
a4d34be6df
Merge branch 'minor-next' into major-next 2023-03-20 23:42:40 +00:00
Dylan K. Taylor
ecc830a689
InventoryManager: avoid calling TypeConverter::getInstance() in a loop 2023-03-20 23:24:52 +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
1992d3b6db
InventoryManager: avoid useless work in trackItemStack()
this attempts to accommodate slots being set to themselves, which is a rare enough occurrence (only plugins will cause it) that it doesn't make sense to penalize every inventory update this way.
attempting to avoid changing the itemstackID in this way is detrimental to performance, and it doesn't actually matter if we set a new itemstackID anyway.
2023-03-20 23:08:17 +00:00
Dylan K. Taylor
035a0a4e9d
InventoryManager: specialize trackItemStack() to avoid useless lookups 2023-03-20 22:57:58 +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
c9601ae67d
Fixed crash when opening crafting table and other 'UI' inventories 2023-03-20 22:00:38 +00:00
Dylan K. Taylor
758b5ee500
InventoryManager: fixed armor slots hack
the correct condition for this should be an unsynced armor slot changed during a transaction, but conveying this information to syncSlot() is a bit of a hassle, so this will do for now.
2023-03-20 21:27:56 +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
e8085e22a0
Fixed crash when opening main inventory
the InventoryManagerEntry was getting overwritten, since we don't expect to open the same inventory with two different window IDs.
2023-03-20 18:40:18 +00:00
Dylan K. Taylor
3d70a169e1
Reduce chaos in InventoryManager
the information in these arrays is usually needed all at the same time, so it doesn't make sense to force multiple array lookups for it.

in addition, this (obviously) cleans up the code quite a lot.
2023-03-20 17:31:54 +00:00
Dylan K. Taylor
59bae9b077
Give InventoryManager internals clearer names
and stop mixing 'window' and 'inventory' terminology...
2023-03-20 16:53:57 +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
dace20ad1f
Merge branch 'item-stack-request' into item-stack-request-pm5 2023-03-14 22:34:47 +00:00
Dylan K. Taylor
1123a5aa23
InventoryManager: Track predictions using ItemStack directly, instead of internal Item
this removes the need for deserializing network itemstacks to core items, thereby eliminating a whole bunch of potential security issues.
2023-01-06 20:45:08 +00:00
Dylan K. Taylor
8633804f15
InventoryManager: disentangle slot tracking from slot syncing 2023-01-06 20:26:19 +00:00
Dylan K. Taylor
b24eb153f9
Constrain inventory transaction predictions
these are now only used for actions done with a closed inventory window. This means that they can only predict the slots of inventory, offhand and armor (total 41 slots) and perhaps include some DropItem actions.
2023-01-05 21:18:30 +00:00
Dylan K. Taylor
3d6baa8a55
Working creative inventory, with a few more hacks than I'd like 2023-01-05 18:09:57 +00:00
Dylan K. Taylor
5fdbb19852
Fixed a whole bunch of issues with legacy transactions 2023-01-04 00:13:51 +00:00
Dylan K. Taylor
142ccc7e87
Merge branch 'next-minor' into next-major 2022-12-05 14:14:39 +00:00
Dylan K. Taylor
b5cfab497d
Clean up inventory content syncing, fixes #5441
these remnants should have been cleaned up in 4.11, but I somehow managed to skip over them.
2022-12-04 23:05:30 +00:00
Dylan K. Taylor
0039af984d
Merge branch 'next-minor' into item-stack-request 2022-10-16 16:56:26 +01:00
Dylan K. Taylor
a6cc611e9f
Merge branch 'next-minor' into next-major 2022-09-28 01:06:11 +01:00
Dylan K. Taylor
86a2f8e360
Merge branch 'stable' into next-minor 2022-09-28 01:01:51 +01:00
Dylan K. Taylor
def2f8c145
InventoryManager: ensure the windowID is valid before attempting to remove any window
this is currently a harmless bug, since remove() isn't currently doing any heavy lifting.
2022-09-28 01:01:42 +01:00
Dylan K. Taylor
4dabac8420
Merge branch 'next-minor' into next-major 2022-08-27 17:28:06 +01:00
Dylan K. Taylor
5b89833d5c
Merge branch 'stable' into next-minor 2022-08-27 17:27:15 +01:00
Dylan K. Taylor
fb25e05416
InventoryManager: fixed current window getting removed in race conditions with close window ACK
this could be observed by pressing E and immediately clicking a chest, which, if timed correctly, would lead to the chest lid closing, but the inventory being opened anyway.
2022-08-27 17:26:43 +01:00
Dylan K. Taylor
1ecb10acba
Merge branch 'next-minor' into next-major 2022-08-21 19:19:07 +01:00
Dylan K. Taylor
2b7510945a
First look at ItemStackRequest usage (very unstable) 2022-08-18 17:38:57 +01:00
Dylan K. Taylor
e90abecf38
Rewrite InventoryManager handling of complex mapped inventories
this turned out to be necessary when dealing with the ItemStackRequest system.
2022-08-17 14:42:30 +01:00
Dylan K. Taylor
eb8fb63409
Added cartography and smithing tables
these have working inventories, and their crafting menus will 'just work' once the items for the associated recipes have been implemented (maps, netherite).
2022-07-14 18:01:47 +01:00
Dylan K. Taylor
e040c2b281
InventoryManager: fixed windows not opening when the server removes windows
closes #5094
2022-06-05 16:03:24 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
86efa0aae6
Merge remote-tracking branch 'origin/stable' into next-minor 2022-05-20 17:49:04 +01:00
Dylan K. Taylor
554f96bc24
InventoryManager: Defer opening new windows to the client until the window close handshake has been completed
fixes #5021 and probably a bunch of other inventory related glitches

When the server initiates a window close, it does so by sending a ContainerClose to the client, which causes the
client to behave as if it initiated the close itself. It responds by sending a ContainerClose back to the server,
which the server is then expected to respond to.

Sending the client a new window before sending this final response creates buggy behaviour on the client, which
is problematic when switching windows. Therefore, we defer sending any new windows until after the client
responds to our window close instruction, so that we can complete the window handshake correctly.

This is a pile of complicated garbage that only exists because Mojang overengineered the process of opening and
closing inventory windows.
2022-05-20 16:54:15 +01:00
Dylan K. Taylor
6eac2ea7a5
Modernize private property declarations in src/network 2022-05-17 21:22:33 +01:00
ipad54
1e59679ec2
Implemented Stonecutter (#4732) 2022-05-17 16:01:03 +01:00
Dylan K. Taylor
4e777572c9
fix CS 2022-03-23 13:28:21 +00:00
Dylan K. Taylor
90a8595a40
Check for mismatched inventory slot predictions in transactions
this should limit the problems caused by mismatched gameplay features that result in ghost items, such as #4896.
2022-03-22 17:42:19 +00:00
Dylan K. Taylor
3232a83965
InventoryManager: beware possible crash due to invalid items 2022-02-22 16:50:36 +00:00
Dylan K. Taylor
4f25ab10e9
InventoryManager: Do not sync slots the client correctly predicted during using items
closes #4825
2022-02-22 16:46:23 +00:00
Dylan K. Taylor
be1996752a
Replace disallowed operators in src/network/ 2022-01-20 19:11:32 +00:00
Dylan K. Taylor
6fdcfb01c8
Seal up main inventory open/close logic inside InventoryManager where it belongs 2021-11-08 22:58:06 +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
e131c2cefa
Drop pocketmine/spl 2021-11-02 16:08:29 +00:00
Dylan K. Taylor
88b7389080
InventoryManager: reduce code duplication 2021-10-29 15:37:52 +01:00
Dylan K. Taylor
c773e43eda
Updated BedrockProtocol to pmmp/BedrockProtocol@97fa88e9ef 2021-10-23 01:16:45 +01:00
Rush2929
58bc9332cd
Workaround for offhand sync (#4359)
fixes #4231
2021-08-12 23:27:53 +01:00
Dylan T
27e0ecf7ee
Implemented Blast Furnace and Smoker (#4362) 2021-08-12 23:27:05 +01:00