Commit Graph

113 Commits

Author SHA1 Message Date
c4793241f5 Mass removal of useless @param/@return PHPDoc annotations, pass 1 2020-01-21 15:10:18 +00:00
36cde9f352 inventory: populate missing return type information 2020-01-19 17:05:31 +00:00
9a4b72add5 PlayerInventory: fix type violation when calling equipItem() for non-Player holder 2019-12-12 16:31:22 +00:00
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
d71a543d10 Fixed a bunch of things PHPStan finds unpalatable
close #2614, fix a bunch of docs bugs, fix sendCreativeContents() crash on Human holders, move some inline variable declarations
2019-01-04 00:23:09 +00:00
6dd2597934 Merge branch 'release/3.3' into release/3.4 2018-10-21 18:17:07 +01:00
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
1dd6591ac1 Migrate a bunch of PluginManager->callEvent() usages to Event->call
This has the triple bonus effect of a) making a lot of code easier to read, b) reducing Server::getInstance() usages, and c) removing a whole bunch of Server dependencies.

The network and block namespaces are untouched by this commit due to potential for merge conflicts. These should be dealt with separately on master.
2018-10-05 17:30:06 +01:00
f6481eab8f Implemented an InventoryEventProcessor, fixes #1986 (#2176)
* Implemented InventoryEventProcessor, fixes #1986
Event processors can now be registered and unregistered at will. Entity inventory/armor change events are now handled by event processors instead of the inventories themselves, which allows enabling/disabling the calling of these events at will.
This now avoids stupid things happening when initializing inventory contents, since the callers for those events are now registered _after_ the contents are initialized.
2018-06-09 17:37:10 +01:00
f0535df96d Remove deprecated things 2018-02-27 11:59:16 +00:00
6543d96910 Inventory: Split up armor and player inventory (#1957)
* Inventory: Split up PlayerInventory and armour handling
* Fixed other players don't see armour changes. This bug also exists on master.
2018-01-23 20:01:26 +00:00
69ddaacc28 Inventory: Add a $send parameter to clearAll() 2018-01-22 18:39:39 +00:00
4d2549b50a PlayerInventory: Fixed $send parameter not working for setting armour slots 2018-01-06 16:24:41 +00:00
f01ce8e994 null and void typehints 2017-09-21 12:54:04 +01:00
38e11aae5e Some cleanup to how EntityInventoryChangeEvents are handled 2017-09-20 10:13:05 +01:00
8728547a11 Remove unused imports 2017-09-19 19:58:53 +01:00
90fb3c5e12 Moved getNetworkType() to ContainerInventory since it's not used anywhere else 2017-09-19 19:57:22 +01:00
1323d89139 Remove redundant duplicated code for sendContents() and sendSlot() 2017-09-19 19:07:12 +01:00
136ab1dba1 Inventory->getItem(): Removed useless clones
this already returns a copy of the item anyway... wtf?
2017-09-19 18:49:08 +01:00
8cae20e818 Removed hotbar slot linking (works like PC now) 2017-09-19 18:36:57 +01:00
297172d111 Send creative inventory for all gamemodes, fixed recipe book 2017-09-12 14:40:16 +01:00
a6c0f1512c Send the hotbar instead of contents when resetting hotbar
This used to be fine before 1.2, but now hotbar is handled separately.
2017-09-02 11:07:14 +01:00
604d8ecf9a Protocol changes for 1.2.0.25 2017-09-02 11:05:49 +01:00
445a67954d Merge changes from master 2017-08-22 14:13:31 +01:00
876659cc73 Item factory refactor and added capability to register custom items 2017-08-21 17:49:26 +01:00
8958b3c51c Many many changes related to inventory transactions, fixed item dropping, fixed creative menu 2017-08-11 19:57:30 +01:00
260179197b Use SplFixedArrays in inventory, added more typehints and cleaned up some duplicated code 2017-08-09 13:12:07 +01:00
98e0a2ecba Removed InventoryType, added new inventory API methods 2017-08-07 11:31:36 +01:00
63d2b341b9 Day 2 2017-08-06 17:21:51 +01:00
77cd8e7799 More broken mess to spawn 1.2 2017-08-06 17:21:51 +01:00
c0e0730923 Fixed PE armor screen glitching when equipping armor items 2017-07-30 17:41:44 +01:00
24bdf330d5 Merge branch 'moar-typehints' 2017-07-15 09:43:43 +01:00
c3b8be3f60 and more typehints 2017-07-14 10:56:51 +01:00
3a214b7ce6 Cleaned up isEncoded mess 2017-07-13 12:21:26 +01:00
5283975f20 Move inventory ID constants to their own interface
ContainerSetContentPacket will be removed in 1.2, and these aren't specific to ContainerSetContentPacket anyway.
2017-07-12 20:04:36 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
6ea0eb47ec Fixed PlayerInventory in_array recursion issue, close #1008
This is INTENDED BEHAVIOUR for comparing objects?????
2017-06-05 20:51:12 +01:00
1e9ff44890 New field for MobEquipmentPacket
If anyone wants to play with the off-hand, the window ID is 0x77 ;)
2017-06-05 19:10:00 +01:00
54453d0b0a Refactored entity IDs in packets for consistency and to clarify on types 2017-06-05 15:41:27 +01:00
31e2c1d26c fix stupid bug in PlayerInventory 2017-06-01 20:19:17 +01:00
38b8f14758 Fixed wrong reported slot in PlayerItemHeldEvent, fixed assert failures due to negative slot numbers in the hotbar
fixes some issues reported in #525
2017-05-29 16:33:48 +01:00
2f306c3a38 Fix crash when new players join due to attempting to send negative inventory slot 2017-05-29 15:30:11 +01:00
9c25ec3afd Some protocol changes for 1.1.0.0 2017-04-01 19:20:30 +01:00
8114ceaf68 Merge branch 'master' into api3/network 2017-03-18 16:29:38 +00:00
a8650a241c Removed @deprecated warning from PlayerInventory->setHotbarSlotIndex()
Core uses it, it's just that plugins shouldn't.
2017-03-14 17:37:29 +00:00
6c5dbd7359 Merge branch 'master' into api3/network 2017-03-12 12:22:11 +00:00
132e04fdbb Hotbar/inventory bugfixes (#399)
- Fixed most issues with item equipment in creative
- Added save and restore of currently-held item
- Reset hotbar on death, added API method PlayerInventory->resetHotbar()
- Creative players now have more leeway to get items, alleviates issues with item equipment in desktop GUI
- Fixed creative players wearing armour
- Found unknown field in ContainerSetSlotPacket
- Removed outdated/redundant constants
- Use a case statement in ContainerSetSlotPacket handler, added handling for 0x7a hotbar slot link update
2017-03-09 20:31:55 +00:00
56990eb28b MCPE protocol gets its own namespace 2017-03-08 20:28:39 +00:00
1ee689e759 Fixed mess of entity ID 0 for players, fixed emeralds 2017-03-02 11:04:00 +00:00
ab943a0462 Fix crashes 2017-01-16 14:50:32 +00:00