PocketMine-MP
PocketMine-MP copied to clipboard
fix: canPlaceOn and canDestroy will be passed on conversion
Introduction
TypeConverter now also uses canPlaceOn and canDestroy parameters for item conversions.
Relevant issues
- Fixes #6460
Changes
API changes
Behavioural changes
Backwards compatibility
Follow-up
This is enough to fix #6460, but still has the following issues:
- Crashes when using new IDs such as
minecraft:grass_block -
ItemStackextra data contains unnecessary NBT data:- Minecraft vanilla:
//8BCgAAAwYARGFtYWdlAAAAAAAAAAAAAQAAABUAbWluZWNyYWZ0OmdyYXNzX2Jsb2Nr - pmmp:
//8BCgAACQoAQ2FuRGVzdHJveQgBAAAAFQBtaW5lY3JhZnQ6Z3Jhc3NfYmxvY2sAAAAAAAEAAAAVAG1pbmVjcmFmdDpncmFzc19ibG9jaw==
- Minecraft vanilla:
Tests
I tested this PR by doing the following (tick all that apply):
- [ ] Writing PHPUnit tests (commit these in the
tests/phpunitfolder) - [x] Playtesting using a Minecraft client (provide screenshots or a video)
- [x] Writing a test plugin (provide the code and sample output)
- [ ] Other (provide details)
$item = VanillaItems::IRON_HOE();
$item->setCanDestroy(["grass"]); // minecraft:grass_block or grass_block will crash
$player->getInventory()->addItem($item);