121 Commits

Author SHA1 Message Date
Dylan K. Taylor
84a943bcec
BaseInventory: slap a TODO on isSlotEmpty() 2023-05-05 16:06:37 +01:00
Dylan K. Taylor
eb136e60c8
BaseInventory: added getMatchingItemCount() helper
this eliminates the performance issues described by #5719.
closes #5719

we may want to consider exposing a public API for this in the future, since it might be useful for plugins.
2023-04-27 21:08:35 +01:00
Dylan K. Taylor
4228880509
BaseInventory: change dumb variable names in internalAddItem() 2023-04-27 20:29:02 +01:00
Dylan K. Taylor
709d874204
BaseInventory: clean up max stack size handling
we can safely assume that:
- the inventory's max stack size won't change during the operation
- two items which stack together have the same max stack size
- the item's max stack size won't change during the operation
2023-04-27 20:27:05 +01:00
Dylan K. Taylor
7f6269c432
Introduce and use optimised versions of Inventory->isSlotEmpty()
this avoids useless cloning, improving the performance of several functions.
2023-04-27 16:52:52 +01:00
Dylan K. Taylor
023460db2c
BaseInventory: fixed internalAddItem() doing useless canStackWith() checks on null items
if the item is null, it's never going to stack with anything given to this function, because addItem() already discards null items.
2023-04-27 14:53:54 +01:00
Dylan K. Taylor
7e92da126d
DelegateInventory: fixed slots being synced twice and breaking ItemStackRequests
the second time the slot is synced, there is no prediction, so the slot update isn't associated with a request anymore. This causes subsequent requests in the same packet to fail, since the dependency request ID isn't associated with the slot anymore.

This change fixes the problem by only allowing the backing inventory to trigger a call to DelegateInventory->on*Change(). While we could have removed and re-added the listener instead, this way is safer since it doesn't assume that the backing inventory won't modify the given item in setItem().

closes #5692
2023-04-12 15:43:51 +01:00
Dylan K. Taylor
6e8eda4ac1
Fixed creative inventory items getting modified by ItemStackRequests 2023-04-03 22:22:21 +01: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
a573a279fa
Merge branch 'minor-next' into item-stack-request 2023-03-14 22:25:49 +00:00
Dylan K. Taylor
cfa1e7486a
Move legacy recipes and creative items in-house
having them here allows BedrockData to represent latest versions freely, without being limited by technical limitations of PM4.
2023-02-02 15:25:03 +00:00
Dylan K. Taylor
8633804f15
InventoryManager: disentangle slot tracking from slot syncing 2023-01-06 20:26:19 +00:00
Dylan K. Taylor
2e9a3f9160
Working crafting :woohoo: 2023-01-04 22:29:29 +00:00
Dylan K. Taylor
0d169b4e80
Filesystem: added fileGetContents to reduce ErrorToExceptionHandler boilerplate code 2022-12-25 17:13:51 +00:00
Dylan K. Taylor
d79e6354a0
Merge branch 'stable' into next-minor 2022-11-25 14:41:05 +00:00
Dylan K. Taylor
a66f966b08
Update API documentation for Inventory methods 2022-11-15 21:00:13 +00:00
Dylan K. Taylor
824ed0a56a
Merge branch 'stable' into next-minor 2022-11-07 15:04:48 +00:00
alvin0319
1e9d83f014
BaseInventory: validate given array in setContents() (#5391) 2022-11-07 13:09:05 +00:00
Dylan K. Taylor
cdbdcb5d67
Merge branch 'stable' into next-minor 2022-11-04 20:44:28 +00:00
Dylan K. Taylor
2fdc46c165
PHPStan 1.9 features 2022-11-04 20:23:34 +00:00
Dylan K. Taylor
7bcc663b60
Migrate core code to using symfony/filesystem
webmozart/path-util is retained for plugin compatibility, but is dropped in 5.0
2022-10-14 21:51:29 +01:00
Dylan K. Taylor
3feaa18f6c
DelegateInventory: use WeakReference and __destruct to clean up inventory listener
this is more sane, since it allows the delegate to be reused without unexpected behaviour.
2022-09-30 15:12:37 +01:00
Dylan K. Taylor
441b06f6c7
Merge branch 'stable' into next-minor 2022-09-15 12:44:53 +01:00
Dylan K. Taylor
6866c86d39
BaseInventory: fix CS 2022-09-02 19:36:45 +01:00
Dylan K. Taylor
a735a69870
BaseInventory: improve type info available to setContents() and internalSetContents() 2022-09-02 19:36:08 +01:00
Dylan K. Taylor
a0ea74c08f
Inventory: Improve quality of type info of arrays 2022-09-02 19:34:12 +01:00
Dylan K. Taylor
c16893cbac
Merge branch 'stable' into next-minor 2022-08-25 19:25:19 +01:00
Dylan K. Taylor
5426b41447
InventoryTransaction: prevent client-authoritative item overstacking
this cheat is often used to carry more items in the inventory, wear multiple pieces of armour in one slot, and more.
2022-08-21 20:35:23 +01:00
Dylan K. Taylor
792c1b62b7
Introduce and use TransactionBuilder for inventory evacuations 2022-08-18 17:04:12 +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
179cac45f5
Merge branch 'stable' into next-minor 2022-05-22 16:21:05 +01:00
Dylan K. Taylor
5d92eddc82
InventoryTransaction: provide object ID of failed action for debugging identification
closes #3235
2022-05-21 17:35:21 +01:00
Dylan K. Taylor
d4b7f66e15
Promote some constructors 2022-05-17 22:34:58 +01:00
Dylan K. Taylor
fb4d332d1a
Modernize private property declarations in src/inventory/transaction 2022-05-17 20:51:22 +01:00
Dylan K. Taylor
a06b9294df
Modernize private property declarations in src/inventory 2022-05-17 20:49:12 +01:00
Dylan K. Taylor
bf71eb448a
Reduce chaos in inventory classes 2022-03-22 17:19:55 +00:00
Dylan K. Taylor
2c29d272ad
BaseInventory: move setMaxStackSize() to a more sensible place 2022-03-22 17:11:48 +00:00
Dylan K. Taylor
98aa2b9ff9
Inventory: move removeItem() next to remove()
this should hopefully be more attention grabbing and a bit less misleading, since people will wonder why there are 'remove' and 'removeItem' both.

we really need to rename one of these...
2022-03-22 17:08:30 +00:00
Dylan K. Taylor
51a3043dfd
PlayerInventory: fixed isHotbarSlot() returning bogus result for 9 2022-02-20 20:29:51 +00:00
Dylan K. Taylor
d16b6fe61e
Merge branch 'stable' into staging/4.1 2022-01-28 20:40:07 +00:00
Covered123
6673289c33
Fixed spectator players being able to drop items (#4775)
closes #4765
2022-01-27 00:03:19 +00:00
Dylan K. Taylor
e986a0a4f2
Replace disallowed operators in src/inventory/ 2022-01-20 19:20:32 +00:00
Dylan K. Taylor
a0bb7059c1
Merge remote-tracking branch 'origin/stable' into next-minor 2022-01-19 19:48:51 +00:00
Dylan K. Taylor
858024afb7
Remove useless docs noticed by php-cs-fixer 3.5 2022-01-18 00:24:12 +00:00
Dylan K. Taylor
75fc7a2d1f
Merge branch 'stable' into next-minor 2022-01-07 20:16:35 +00:00
Dylan K. Taylor
6d249026cc
Merge branch 'legacy/pm3' into stable 2022-01-07 20:15:15 +00:00
Dylan K. Taylor
e04dfe96af
Merge branch 'stable' into next-minor 2022-01-01 17:55:17 +00:00
Dylan K. Taylor
72f2c794ab
SimpleInventory: improved performance of setContents()
avoid the overhead incurred by clear() and setItem(), because in internalSetContents(), we already have no listeners or viewers to talk to anyway, so this is just spamming shit into /dev/null.
2021-12-31 18:32:19 +00:00
Dylan K. Taylor
ed4978c31b
Added VanillaItems::AIR()
we don't usually add VanillaItems entries for blocks since they already exist in VanillaBlocks, but air has a special use case specifically as an itemstack, so we make an exception for this case.
2021-12-07 00:41:07 +00:00
Dylan K. Taylor
fed59d3ebe
added missing file 2021-11-09 00:11:39 +00:00