Commit Graph

225 Commits

Author SHA1 Message Date
09eb904f6b fixed explicit-mixed errors exposed by upgrading pocketmine/nbt 2020-08-28 15:47:41 +01:00
f8ce01e2fd ItemFactory: extract fromStringSingle() from fromString()
on PM4, the multiple functionality is removed, but on PM3 this is a problem for phpstan.
2020-03-13 17:54:25 +00:00
7aa8bd18d3 Revert "Item: restrict bounds of count to 0-255"
This reverts commit 10317527e4.

this breaks user code which exceeds stack limits in legitimate
circumstances. For example, it should be OK to add 6000x diamond to a
player's inventory without being forced to manually split the count up
for addItem().
2020-02-25 20:42:03 +00:00
50fcdd6e7e Item: fixed documentation of pop() return type (it's not fluent) 2020-02-23 17:32:50 +00:00
10317527e4 Item: restrict bounds of count to 0-255 2020-02-23 17:23:53 +00:00
1257378198 clean up function imports 2020-02-08 09:31:15 +00:00
9b02b8e51e Item: do not compare serialized NBT in equals()
this isn't cached anymore, and would be a performance drag.
It would be nice to have some kind of fast path for this, but comparing NBT binary isn't it.
2020-02-06 20:23:58 +00:00
0ec869932f Item: clean up internal NBT storage, discard useless legacy network cache
this will now bail if the NBT string given is invalid upon setCompoundTag(), rather than shitting the bed when it's accessed.
2020-02-06 17:59:05 +00:00
4518d9d9ce Item: drop useless @var confusing PHPStan 2020-02-05 20:55:58 +00:00
1a5228e7a6 Fixed property types with missing null PhpDoc types 2020-02-05 20:55:03 +00:00
260ac47588 add some phpstan array types 2020-01-30 22:23:11 +00:00
5d8bb84269 add more mixed[] to item namespace 2020-01-30 21:48:11 +00:00
3b9a5c5ccc populate missing array value types in item namespace 2020-01-30 20:54:38 +00:00
f624871b3f strip extra blank lines (php-cs-fixer) 2020-01-22 14:50:29 +00:00
c4793241f5 Mass removal of useless @param/@return PHPDoc annotations, pass 1 2020-01-21 15:10:18 +00:00
e6ba3ce8a6 item: populate missing return type information 2020-01-19 17:13:33 +00:00
e544bc0d4b Item: added missing return type info for clearCustomBlockData() 2020-01-18 20:11:47 +00:00
fd27227cc7 Item: fix @return annotations for fluent methods (needed for correct auto complete) 2020-01-18 20:10:46 +00:00
ee60a7bc36 Item: add documentation for addCreativeItem(), removeCreativeItem() and clearCreativeItems()
[ci skip]
2019-10-07 09:37:59 +01:00
b788982d60 Item: fixed setCustomName() not removing display NBT tag with empty name (#3049) 2019-07-19 20:07:53 +01:00
eb161f8e1c Use base64 instead of hex to display binary in some places
base64 takes less space than hex, which is beneficial for logging larger payloads.
2019-06-06 14:43:20 +01:00
b8703d5dff Protocol changes for 1.9.0 2019-02-07 21:56:42 +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
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
8db1ccc1ae Merge branch 'release/3.1' into release/3.2 2018-09-20 19:02:09 +01:00
5d56030afa Item: make nbtDeserialize() return AIR when reading an unknown PC item
This is scummy, but it's better than crashing the whole server just because a chest contained an unknown item.
2018-09-20 19:00:44 +01:00
16c253d7a9 Item: allow negative IDs
this will be needed in the future for extended blocks support.
2018-07-16 12:46:16 +01:00
9f7f62e9e5 Don't use Config for builtin JSON resources
it doesn't make sense to use a config in these cases, and also it just hides problems when the files are missing.
2018-06-16 16:35:47 +01:00
2e9e44ba05 Moved JSON blobs to submodule 2018-06-12 18:49:18 +01:00
3def3cd502 Item: use base64 instead of hex for json encoding NBT 2018-06-12 18:31:35 +01:00
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
e3d2fa10a5 Item: added count parameter to pop()
this allows popping an arbitrary number of items from the stack, instead of just 1.
2018-05-29 10:21:04 +01:00
083ac8a770 Clean up Tool garbage leftovers
these were intended to be removed long ago, but other things came up and durability handling still depended on them.
2018-05-11 09:23:51 +01:00
b21572774a Tool: cleanup durability handling, closes #379
long overdue... this isn't quite as extensible as the original api3/blocks system was, but this is primarily intended to replace Item->useOn(). If plugins want to use it it can be extended later on.
2018-05-10 19:48:51 +01:00
3095eb544d Item: removed isTool()
this should be replaced with `instanceof Tool`.
2018-05-01 20:05:53 +01:00
0247dff909 Fixed mis-uses of Item->isTool()
this has been wrongly used to indicate a durable item, but not just tools are durable items.
2018-05-01 20:05:02 +01:00
ac5a91b67e Cleaned up bool comparison mess 2018-03-19 14:10:55 +00:00
2f266a5922 Player: added a server-side forced cooldown mechanism
This is necessary because the stupid client constantly spams right-click actions if you carry on trying to eat/throw/whatever the item when cooldown is in effect. Therefore ender pearls would be fired like machine guns without these checks server side.
2018-03-09 14:45:01 +00:00
f0535df96d Remove deprecated things 2018-02-27 11:59:16 +00:00
093cb5b39e Updated PocketMine-NBT dependency 2018-02-17 14:29:20 +00:00
88a05845c2 Item: Removed protected block field, items should now override getBlock() 2018-02-16 11:06:29 +00:00
be1ddb9f5b Item: Added API method getVanillaName()
This allows retrieving the name of an item without the custom name being plastered over the top. This will also allow weird things to have special functions for their names.
2018-02-16 10:57:02 +00:00
8e6ec04abc Item: Replace a usage of hardcoded resource path with \pocketmine\RESOURCE_PATH 2018-02-15 12:24:57 +00:00
42a7b7fa36 More NBT updates
This library is going to be completely different before I'm done here >.>
2018-02-15 12:11:36 +00:00
9abfd54cc1 Updated with ListTag changes from PocketMine-NBT 2018-02-13 16:50:49 +00:00
de0741f727 Item: remove unused imports 2018-01-26 17:12:00 -05:00
6c8a1a5b80 Item: Remove redundant Level parameter from onActivate()
there are three other sources this could be gotten from, an arbitrary level doesn't make sense.
2018-01-25 10:15:36 +00:00
efca9f0450 Item: Moved getMaxDurability() to Durable class only, and make it abstract
It's only now used in the Durable class, so it does not make sense to keep it in Item anymore. This is a leftover from the days where Durable did not exist.
2018-01-18 14:16:30 +00:00
b04cee12ea Item: Added API method getEnchantmentLevel() 2018-01-11 18:22:29 +00:00