106 Commits

Author SHA1 Message Date
Dylan K. Taylor
3ee78e20a5
BlockInventoryTrait: include a Block ref instead of Position 2024-12-07 19:28:10 +00:00
Dylan K. Taylor
3099129272
Merge branch 'major-next' into inventory-rework 2024-11-25 14:38:56 +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
Dylan K. Taylor
5c221247fe
Merge branch 'major-next' into inventory-rework 2024-11-24 23:51:16 +00:00
Dylan K. Taylor
aef4fa7174
Remove unused variable 2024-11-24 23:50:30 +00:00
Dylan K. Taylor
7f58122ac6
Avoid unnecessary repeated calls 2024-11-24 23:43:51 +00:00
Dylan K. Taylor
fe1a8d98e7
namespace tidy 2024-11-24 23:29:13 +00:00
Dylan K. Taylor
45a4282e8b
First look: Split up Inventory & InventoryWindow
this unblocks a variety of changes, such as positionless tiles, enhanced APIs on Blocks for inventories, and also eliminates a bunch of cyclic references within the core code.

linked to #5033
2024-11-24 21:40:47 +00:00
Dylan K. Taylor
473bbe64e0
BaseInventory no longer uses viewers to send updates to players
we want viewers to be as close to decorative as possible, so that they provide useful information to plugins, but don't get in the way of other changes.
2024-11-24 21:22:44 +00:00
Dylan K. Taylor
f98cebbd62
Separate hotbar from player inventory
this allows this functionality to be used with any type of inventory, and also makes it a little nicer to use in many cases.
2024-11-24 17:58:58 +00:00
Dylan K. Taylor
c63d0ef1b6
Fix dodgy ignored PHPStan error 2024-11-03 14:43:34 +00:00
Dries C
4814db4fe7
Assemble 1.21.40 (#6471) 2024-10-25 14:21:51 +01:00
Dries C
60cac18104
Assemble 1.21.30 (#6453) 2024-09-20 18:47:25 -05:00
Dries C
0f365886e0
Assemble 1.21.20 (#6423)
Co-authored-by: Dylan T. <dktapps@pmmp.io>
Co-authored-by: IvanCraft623 <ivancraft623@gmail.com>
2024-08-16 11:26:49 +01:00
Dylan K. Taylor
f121654452
Assemble 1.21.0 2024-06-13 18:41:41 +01: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
94d98fb5c4
Migrate all but two remaining legacy enums to native PHP 8.1 enums 2023-09-07 19:32:45 +01:00
Dylan K. Taylor
1504fdca24
Use 'enchanting' terminology
'enchant' just didn't feel right, being a verb.
All these things pertain to the act of enchanting.

This is now also consistent with CraftingTransaction etc. The ship already sailed on EnchantInventory, which will have to be renamed at a later datte. However, that was already inconsistent with 'enchanting table', so that's the odd one out here.
2023-08-23 16:14:17 +01:00
Dylan K. Taylor
b3c740081e
Merge branch 'stable' into minor-next 2023-08-18 12:28:45 +01:00
Dylan K. Taylor
4b41fca991
Merge branch 'legacy/pm4' into stable 2023-08-18 12:28:29 +01:00
Dylan K. Taylor
9f09acc079
Workaround for slot IDs not changing client side when old item == new item
this is a really dumb bug and seems similar to the armor bug I fixed a while ago.

fixes #5987

it's unlikely that #5727 will be solved by this, but one can hope...
2023-08-18 12:27:27 +01:00
S3v3Nice
39867b97c5
Implement enchanting using enchanting tables (#5953)
Co-authored-by: Dylan K. Taylor <dktapps@pmmp.io>
2023-08-15 17:28:26 +01:00
Dylan K. Taylor
914dd90b3d
Use first-class closures in more places 2023-07-19 13:56:48 +01:00
Dylan K. Taylor
537721fe7d
Replace Closure::fromCallable() usages with first-class callables
PHP 8.1 <3
2023-07-19 13:34:42 +01:00
BrandPVP
c01d2dc718
CreativeInventory per Player (#5694) 2023-07-06 11:08:13 +01:00
Dylan K. Taylor
0ed5e94a72
Merge branch 'minor-next' into major-next 2023-05-30 16:15:56 +01:00
ShockedPlot7560
db95bf8b9b
Caching creative inventory entries (#5703)
Due to the high cost of Item::serializeCompoundTag(), it's very costly to rebuild this every time we need it. This is sent during the pre-spawn step, where we need to minimize costs as much as possible.
2023-05-18 14:11:28 +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
5a54d09869
InventoryManager: verify slot existence in locateWindowAndSlot()
previously, this would happily return invalid slot IDs, potentially leading to a crash.
2023-04-27 13:18:28 +01:00
Dylan K. Taylor
10f3145af2
Merge branch 'minor-next' into major-next 2023-03-29 23:22:02 +01:00
Dylan K. Taylor
af385668c2
InventoryManager: give more detailed information on failure to get info for held item 2023-03-27 17:55:39 +01:00
Dylan K. Taylor
0220a30780
Merge branch 'minor-next' into major-next 2023-03-25 20:26:59 +00:00
Dylan K. Taylor
58d5126ada
InventoryManager: fixed crashes when setting contents or slots of inventories during InventoryCloseEvent (and other similar logic) 2023-03-24 13:31:30 +00:00
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