PocketMine-MP icon indicating copy to clipboard operation
PocketMine-MP copied to clipboard

fix: canPlaceOn and canDestroy will be passed on conversion

Open Nerahikada opened this issue 1 year ago • 0 comments

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
  • ItemStack extra data contains unnecessary NBT data:
    • Minecraft vanilla: //8BCgAAAwYARGFtYWdlAAAAAAAAAAAAAQAAABUAbWluZWNyYWZ0OmdyYXNzX2Jsb2Nr
    • pmmp: //8BCgAACQoAQ2FuRGVzdHJveQgBAAAAFQBtaW5lY3JhZnQ6Z3Jhc3NfYmxvY2sAAAAAAAEAAAAVAG1pbmVjcmFmdDpncmFzc19ibG9jaw==

Tests

I tested this PR by doing the following (tick all that apply):

  • [ ] Writing PHPUnit tests (commit these in the tests/phpunit folder)
  • [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);

Nerahikada avatar Sep 26 '24 16:09 Nerahikada