Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor 2021-12-07 00:41:48 +00:00
commit 1d14c8cb6b
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
6 changed files with 67 additions and 62 deletions

View File

@ -1026,6 +1026,7 @@ However, if we add `src-namespace-prefix: pmmp\TesterPlugin` to the `plugin.yml`
- `Player->continueBreakBlock()`: punch the target block during destruction in survival, advancing break animation and creating particles - `Player->continueBreakBlock()`: punch the target block during destruction in survival, advancing break animation and creating particles
- `Player->getCurrentWindow()`: returns the inventory window the player is currently viewing, or null if they aren't viewing an inventory - `Player->getCurrentWindow()`: returns the inventory window the player is currently viewing, or null if they aren't viewing an inventory
- `Player->getItemCooldownExpiry()`: returns the tick on which the player's cooldown for a given item expires - `Player->getItemCooldownExpiry()`: returns the tick on which the player's cooldown for a given item expires
- `Player->getLowerCaseName()`: use `strtolower(Player->getName())` instead
- `Player->getPlayerInfo()`: returns a `PlayerInfo` object containing various metadata about the player - `Player->getPlayerInfo()`: returns a `PlayerInfo` object containing various metadata about the player
- `Player->getSaveData()`: returns save data generated on the fly - `Player->getSaveData()`: returns save data generated on the fly
- `Player->hasFiniteResources()` - `Player->hasFiniteResources()`

98
composer.lock generated
View File

@ -322,16 +322,16 @@
}, },
{ {
"name": "pocketmine/binaryutils", "name": "pocketmine/binaryutils",
"version": "0.2.2", "version": "0.2.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/BinaryUtils.git", "url": "https://github.com/pmmp/BinaryUtils.git",
"reference": "f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9" "reference": "dc94786fc6c30012b1892f548dbb8a8c9c0a8cd9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9", "url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/dc94786fc6c30012b1892f548dbb8a8c9c0a8cd9",
"reference": "f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9", "reference": "dc94786fc6c30012b1892f548dbb8a8c9c0a8cd9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -340,8 +340,10 @@
}, },
"require-dev": { "require-dev": {
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.99", "phpstan/phpstan": "1.2.0",
"phpstan/phpstan-strict-rules": "^0.12.4" "phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.5"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -356,9 +358,9 @@
"description": "Classes and methods for conveniently handling binary data", "description": "Classes and methods for conveniently handling binary data",
"support": { "support": {
"issues": "https://github.com/pmmp/BinaryUtils/issues", "issues": "https://github.com/pmmp/BinaryUtils/issues",
"source": "https://github.com/pmmp/BinaryUtils/tree/0.2.2" "source": "https://github.com/pmmp/BinaryUtils/tree/0.2.3"
}, },
"time": "2021-10-22T19:54:16+00:00" "time": "2021-12-04T20:56:05+00:00"
}, },
{ {
"name": "pocketmine/callback-validator", "name": "pocketmine/callback-validator",
@ -533,16 +535,16 @@
}, },
{ {
"name": "pocketmine/locale-data", "name": "pocketmine/locale-data",
"version": "2.0.20", "version": "2.0.22",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/Language.git", "url": "https://github.com/pmmp/Language.git",
"reference": "a6e4eb22587e0014f6d658732cf633262723f8d3" "reference": "181eb9d42653296e65d55a1bbba10e0dd76bbd61"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/Language/zipball/a6e4eb22587e0014f6d658732cf633262723f8d3", "url": "https://api.github.com/repos/pmmp/Language/zipball/181eb9d42653296e65d55a1bbba10e0dd76bbd61",
"reference": "a6e4eb22587e0014f6d658732cf633262723f8d3", "reference": "181eb9d42653296e65d55a1bbba10e0dd76bbd61",
"shasum": "" "shasum": ""
}, },
"type": "library", "type": "library",
@ -550,9 +552,9 @@
"description": "Language resources used by PocketMine-MP", "description": "Language resources used by PocketMine-MP",
"support": { "support": {
"issues": "https://github.com/pmmp/Language/issues", "issues": "https://github.com/pmmp/Language/issues",
"source": "https://github.com/pmmp/Language/tree/2.0.20" "source": "https://github.com/pmmp/Language/tree/2.0.22"
}, },
"time": "2021-11-25T20:56:12+00:00" "time": "2021-12-04T22:37:10+00:00"
}, },
{ {
"name": "pocketmine/log", "name": "pocketmine/log",
@ -641,16 +643,16 @@
}, },
{ {
"name": "pocketmine/math", "name": "pocketmine/math",
"version": "0.4.0", "version": "0.4.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/Math.git", "url": "https://github.com/pmmp/Math.git",
"reference": "6d64e2555bd2e95ed024574f75d1cefc135c89fc" "reference": "aacc3759a508a69dfa5bc4dfa770ab733c5c94bf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/Math/zipball/6d64e2555bd2e95ed024574f75d1cefc135c89fc", "url": "https://api.github.com/repos/pmmp/Math/zipball/aacc3759a508a69dfa5bc4dfa770ab733c5c94bf",
"reference": "6d64e2555bd2e95ed024574f75d1cefc135c89fc", "reference": "aacc3759a508a69dfa5bc4dfa770ab733c5c94bf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -658,10 +660,10 @@
"php-64bit": "*" "php-64bit": "*"
}, },
"require-dev": { "require-dev": {
"irstea/phpunit-shim": "^8.5 || ^9.5",
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.99", "phpstan/phpstan": "1.2.0",
"phpstan/phpstan-strict-rules": "^0.12.4" "phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^8.5 || ^9.5"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -676,22 +678,22 @@
"description": "PHP library containing math related code used in PocketMine-MP", "description": "PHP library containing math related code used in PocketMine-MP",
"support": { "support": {
"issues": "https://github.com/pmmp/Math/issues", "issues": "https://github.com/pmmp/Math/issues",
"source": "https://github.com/pmmp/Math/tree/0.4.0" "source": "https://github.com/pmmp/Math/tree/0.4.2"
}, },
"time": "2021-10-29T20:33:10+00:00" "time": "2021-12-05T01:15:17+00:00"
}, },
{ {
"name": "pocketmine/nbt", "name": "pocketmine/nbt",
"version": "0.3.0", "version": "0.3.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/NBT.git", "url": "https://github.com/pmmp/NBT.git",
"reference": "98c4a04b55a915e18f83d3b0c9beb24a71abcd31" "reference": "f43db89b8216b772407cdcedd90147db8eef34bc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/NBT/zipball/98c4a04b55a915e18f83d3b0c9beb24a71abcd31", "url": "https://api.github.com/repos/pmmp/NBT/zipball/f43db89b8216b772407cdcedd90147db8eef34bc",
"reference": "98c4a04b55a915e18f83d3b0c9beb24a71abcd31", "reference": "f43db89b8216b772407cdcedd90147db8eef34bc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -702,7 +704,7 @@
"require-dev": { "require-dev": {
"irstea/phpunit-shim": "^9.5", "irstea/phpunit-shim": "^9.5",
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.85", "phpstan/phpstan": "0.12.99",
"phpstan/phpstan-strict-rules": "^0.12.4" "phpstan/phpstan-strict-rules": "^0.12.4"
}, },
"type": "library", "type": "library",
@ -718,9 +720,9 @@
"description": "PHP library for working with Named Binary Tags", "description": "PHP library for working with Named Binary Tags",
"support": { "support": {
"issues": "https://github.com/pmmp/NBT/issues", "issues": "https://github.com/pmmp/NBT/issues",
"source": "https://github.com/pmmp/NBT/tree/0.3.0" "source": "https://github.com/pmmp/NBT/tree/0.3.1"
}, },
"time": "2021-05-18T15:46:33+00:00" "time": "2021-12-06T16:19:10+00:00"
}, },
{ {
"name": "pocketmine/raklib", "name": "pocketmine/raklib",
@ -1504,16 +1506,16 @@
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v4.13.1", "version": "v4.13.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" "reference": "210577fe3cf7badcc5814d99455df46564f3c077"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077",
"reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", "reference": "210577fe3cf7badcc5814d99455df46564f3c077",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1554,9 +1556,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/nikic/PHP-Parser/issues", "issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1" "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2"
}, },
"time": "2021-11-03T20:52:16+00:00" "time": "2021-11-30T19:35:32+00:00"
}, },
{ {
"name": "phar-io/manifest", "name": "phar-io/manifest",
@ -2068,16 +2070,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "9.2.9", "version": "9.2.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b" "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687",
"reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2133,7 +2135,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.9" "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10"
}, },
"funding": [ "funding": [
{ {
@ -2141,20 +2143,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-11-19T15:21:02+00:00" "time": "2021-12-05T09:12:13+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
"version": "3.0.5", "version": "3.0.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2193,7 +2195,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6"
}, },
"funding": [ "funding": [
{ {
@ -2201,7 +2203,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-09-28T05:57:25+00:00" "time": "2021-12-02T12:48:52+00:00"
}, },
{ {
"name": "phpunit/php-invoker", "name": "phpunit/php-invoker",

View File

@ -26,6 +26,7 @@ namespace pocketmine\entity\object;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\BlockFactory;
use pocketmine\block\utils\Fallable; use pocketmine\block\utils\Fallable;
use pocketmine\data\SavedDataLoadingException;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\entity\EntitySizeInfo; use pocketmine\entity\EntitySizeInfo;
use pocketmine\entity\Location; use pocketmine\entity\Location;
@ -71,7 +72,7 @@ class FallingBlock extends Entity{
} }
if($blockId === 0){ if($blockId === 0){
throw new \UnexpectedValueException("Missing block info from NBT"); throw new SavedDataLoadingException("Missing block info from NBT");
} }
$damage = $nbt->getByte("Data", 0); $damage = $nbt->getByte("Data", 0);

View File

@ -97,7 +97,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("anvil", fn() => VanillaBlocks::ANVIL()); $result->registerBlock("anvil", fn() => VanillaBlocks::ANVIL());
$result->registerBlock("ateupd_block", fn() => VanillaBlocks::INFO_UPDATE2()); $result->registerBlock("ateupd_block", fn() => VanillaBlocks::INFO_UPDATE2());
$result->registerBlock("azure_bluet", fn() => VanillaBlocks::AZURE_BLUET()); $result->registerBlock("azure_bluet", fn() => VanillaBlocks::AZURE_BLUET());
$result->registerBlock("bamboo", fn() => VanillaBlocks::BAMBOO_SAPLING()); $result->registerBlock("bamboo", fn() => VanillaBlocks::BAMBOO());
$result->registerBlock("bamboo_sapling", fn() => VanillaBlocks::BAMBOO_SAPLING()); $result->registerBlock("bamboo_sapling", fn() => VanillaBlocks::BAMBOO_SAPLING());
$result->registerBlock("banner", fn() => VanillaBlocks::BANNER()); $result->registerBlock("banner", fn() => VanillaBlocks::BANNER());
$result->registerBlock("barrel", fn() => VanillaBlocks::BARREL()); $result->registerBlock("barrel", fn() => VanillaBlocks::BARREL());
@ -798,13 +798,15 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("sea_lantern", fn() => VanillaBlocks::SEA_LANTERN()); $result->registerBlock("sea_lantern", fn() => VanillaBlocks::SEA_LANTERN());
$result->registerBlock("sea_pickle", fn() => VanillaBlocks::SEA_PICKLE()); $result->registerBlock("sea_pickle", fn() => VanillaBlocks::SEA_PICKLE());
$result->registerBlock("sealantern", fn() => VanillaBlocks::SEA_LANTERN()); $result->registerBlock("sealantern", fn() => VanillaBlocks::SEA_LANTERN());
$result->registerBlock("shulker_box", fn() => VanillaBlocks::DYED_SHULKER_BOX()); $result->registerBlock("shulker_box", fn() => VanillaBlocks::SHULKER_BOX());
$result->registerBlock("sign", fn() => VanillaBlocks::OAK_SIGN()); $result->registerBlock("sign", fn() => VanillaBlocks::OAK_SIGN());
$result->registerBlock("sign_post", fn() => VanillaBlocks::OAK_SIGN()); $result->registerBlock("sign_post", fn() => VanillaBlocks::OAK_SIGN());
$result->registerBlock("silver_glazed_terracotta", fn() => VanillaBlocks::LIGHT_GRAY_GLAZED_TERRACOTTA()); $result->registerBlock("silver_glazed_terracotta", fn() => VanillaBlocks::LIGHT_GRAY_GLAZED_TERRACOTTA());
$result->registerBlock("skull_block", fn() => VanillaBlocks::MOB_HEAD()); $result->registerBlock("skull_block", fn() => VanillaBlocks::MOB_HEAD());
$result->registerBlock("slab", fn() => VanillaBlocks::SMOOTH_STONE_SLAB()); $result->registerBlock("slab", fn() => VanillaBlocks::SMOOTH_STONE_SLAB());
$result->registerBlock("slabs", fn() => VanillaBlocks::SMOOTH_STONE_SLAB()); $result->registerBlock("slabs", fn() => VanillaBlocks::SMOOTH_STONE_SLAB());
$result->registerBlock("slime", fn() => VanillaBlocks::SLIME());
$result->registerBlock("slime_block", fn() => VanillaBlocks::SLIME());
$result->registerBlock("smoker", fn() => VanillaBlocks::SMOKER()); $result->registerBlock("smoker", fn() => VanillaBlocks::SMOKER());
$result->registerBlock("smooth_quartz", fn() => VanillaBlocks::SMOOTH_QUARTZ()); $result->registerBlock("smooth_quartz", fn() => VanillaBlocks::SMOOTH_QUARTZ());
$result->registerBlock("smooth_quartz_slab", fn() => VanillaBlocks::SMOOTH_QUARTZ_SLAB()); $result->registerBlock("smooth_quartz_slab", fn() => VanillaBlocks::SMOOTH_QUARTZ_SLAB());
@ -859,11 +861,11 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("stone_bricks", fn() => VanillaBlocks::STONE_BRICKS()); $result->registerBlock("stone_bricks", fn() => VanillaBlocks::STONE_BRICKS());
$result->registerBlock("stone_button", fn() => VanillaBlocks::STONE_BUTTON()); $result->registerBlock("stone_button", fn() => VanillaBlocks::STONE_BUTTON());
$result->registerBlock("stone_pressure_plate", fn() => VanillaBlocks::STONE_PRESSURE_PLATE()); $result->registerBlock("stone_pressure_plate", fn() => VanillaBlocks::STONE_PRESSURE_PLATE());
$result->registerBlock("stone_slab", fn() => VanillaBlocks::SMOOTH_STONE_SLAB()); $result->registerBlock("stone_slab", fn() => VanillaBlocks::STONE_SLAB());
$result->registerBlock("stone_slab2", fn() => VanillaBlocks::RED_SANDSTONE_SLAB()); $result->registerBlock("stone_slab2", fn() => VanillaBlocks::RED_SANDSTONE_SLAB());
$result->registerBlock("stone_slab3", fn() => VanillaBlocks::END_STONE_BRICK_SLAB()); $result->registerBlock("stone_slab3", fn() => VanillaBlocks::END_STONE_BRICK_SLAB());
$result->registerBlock("stone_slab4", fn() => VanillaBlocks::MOSSY_STONE_BRICK_SLAB()); $result->registerBlock("stone_slab4", fn() => VanillaBlocks::MOSSY_STONE_BRICK_SLAB());
$result->registerBlock("stone_stairs", fn() => VanillaBlocks::COBBLESTONE_STAIRS()); $result->registerBlock("stone_stairs", fn() => VanillaBlocks::STONE_STAIRS());
$result->registerBlock("stone_wall", fn() => VanillaBlocks::COBBLESTONE_WALL()); $result->registerBlock("stone_wall", fn() => VanillaBlocks::COBBLESTONE_WALL());
$result->registerBlock("stonebrick", fn() => VanillaBlocks::STONE_BRICKS()); $result->registerBlock("stonebrick", fn() => VanillaBlocks::STONE_BRICKS());
$result->registerBlock("stonecutter", fn() => VanillaBlocks::LEGACY_STONECUTTER()); $result->registerBlock("stonecutter", fn() => VanillaBlocks::LEGACY_STONECUTTER());
@ -885,7 +887,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("sugarcane_block", fn() => VanillaBlocks::SUGARCANE()); $result->registerBlock("sugarcane_block", fn() => VanillaBlocks::SUGARCANE());
$result->registerBlock("sunflower", fn() => VanillaBlocks::SUNFLOWER()); $result->registerBlock("sunflower", fn() => VanillaBlocks::SUNFLOWER());
$result->registerBlock("sweet_berry_bush", fn() => VanillaBlocks::SWEET_BERRY_BUSH()); $result->registerBlock("sweet_berry_bush", fn() => VanillaBlocks::SWEET_BERRY_BUSH());
$result->registerBlock("tall_grass", fn() => VanillaBlocks::FERN()); $result->registerBlock("tall_grass", fn() => VanillaBlocks::TALL_GRASS());
$result->registerBlock("tallgrass", fn() => VanillaBlocks::FERN()); $result->registerBlock("tallgrass", fn() => VanillaBlocks::FERN());
$result->registerBlock("terracotta", fn() => VanillaBlocks::STAINED_CLAY()); $result->registerBlock("terracotta", fn() => VanillaBlocks::STAINED_CLAY());
$result->registerBlock("tnt", fn() => VanillaBlocks::TNT()); $result->registerBlock("tnt", fn() => VanillaBlocks::TNT());

View File

@ -25,16 +25,14 @@ namespace pocketmine\inventory;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\ItemIds;
use pocketmine\item\VanillaItems; use pocketmine\item\VanillaItems;
class BaseInventoryTest extends TestCase{ class BaseInventoryTest extends TestCase{
public function testAddItemDifferentUserData() : void{ public function testAddItemDifferentUserData() : void{
$inv = new SimpleInventory(1); $inv = new SimpleInventory(1);
$item1 = ItemFactory::getInstance()->get(ItemIds::ARROW, 0, 1); $item1 = VanillaItems::ARROW()->setCount(1);
$item2 = ItemFactory::getInstance()->get(ItemIds::ARROW, 0, 1)->setCustomName("TEST"); $item2 = VanillaItems::ARROW()->setCount(1)->setCustomName("TEST");
$inv->addItem(clone $item1); $inv->addItem(clone $item1);
self::assertFalse($inv->canAddItem($item2), "Item WITHOUT userdata should not stack with item WITH userdata"); self::assertFalse($inv->canAddItem($item2), "Item WITHOUT userdata should not stack with item WITH userdata");

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use pocketmine\block\VanillaBlocks;
use pocketmine\item\enchantment\EnchantmentInstance; use pocketmine\item\enchantment\EnchantmentInstance;
use pocketmine\item\enchantment\VanillaEnchantments; use pocketmine\item\enchantment\VanillaEnchantments;
@ -33,14 +34,14 @@ class ItemTest extends TestCase{
private $item; private $item;
public function setUp() : void{ public function setUp() : void{
$this->item = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD); $this->item = VanillaItems::DIAMOND_SWORD();
} }
/** /**
* Test for issue #1145 (items aren't considered equal after NBT serializing and deserializing * Test for issue #1145 (items aren't considered equal after NBT serializing and deserializing
*/ */
public function testItemEquals() : void{ public function testItemEquals() : void{
$item = ItemFactory::getInstance()->get(ItemIds::STONE)->setCustomName("HI"); $item = VanillaBlocks::STONE()->asItem()->setCustomName("HI");
$item2 = Item::nbtDeserialize($item->nbtSerialize()); $item2 = Item::nbtDeserialize($item->nbtSerialize());
self::assertTrue($item2->equals($item)); self::assertTrue($item2->equals($item));
self::assertTrue($item->equals($item2)); self::assertTrue($item->equals($item2));
@ -50,7 +51,7 @@ class ItemTest extends TestCase{
* Test that same items without NBT are considered equal * Test that same items without NBT are considered equal
*/ */
public function testItemEqualsNoNbt() : void{ public function testItemEqualsNoNbt() : void{
$item1 = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD); $item1 = VanillaItems::DIAMOND_SWORD();
$item2 = clone $item1; $item2 = clone $item1;
self::assertTrue($item1->equals($item2)); self::assertTrue($item1->equals($item2));
} }
@ -62,7 +63,7 @@ class ItemTest extends TestCase{
public function testItemPersistsDisplayProperties() : void{ public function testItemPersistsDisplayProperties() : void{
$lore = ["Line A", "Line B"]; $lore = ["Line A", "Line B"];
$name = "HI"; $name = "HI";
$item = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD); $item = VanillaItems::DIAMOND_SWORD();
$item->setCustomName($name); $item->setCustomName($name);
$item->setLore($lore); $item->setLore($lore);
$item = Item::nbtDeserialize($item->nbtSerialize()); $item = Item::nbtDeserialize($item->nbtSerialize());