Write a short description about the issue
I was writing a plugin to check the item the player picked up, then noticed that they are not equal even though they are created the same way
If you are reporting a regression or unexpected behaviour, please include the below information:
Expected result: The 2 items should be equal
Actual result: They are not
Create a plugin with below code
Tap any block, it should drop a stone block, pick it up, notice the message "Pickup Item", i was expecting "Pickup HELLO Stone" since they are the same item?
-->
If the issue is not reproducible without plugins:
It is not a plugin issue, plugin is needed to demostrate
public function PlayerInteractEven(PlayerInteractEvent $event){
$event->getPlayer()->getLevel()->dropItem($event->getPlayer(),Item::get(1)->setCustomName("HELLO"));
}
public function InventoryPickupItemEvent(InventoryPickupItemEvent $event){
$p = $event->getInventory()->getHolder();
$item = $event->getItem()->getItem();
if($item->equals(Item::get(1)->setCustomName("HELLO")))
$p->sendMessage("Pickup HELLO Stone");
else $p->sendMessage("Pickup Item");
}
The name should replaced with getEntityItem() in my opinion.
For fix that, use ...->getItem()->getItem()
Huh? I dont understand
This should be moved to the forums tbh.
But why are you doing $event->getItem()->getItem()? It should be $event->getItem() if I'm correct.
@SalmonDE Referring to this line, the first getItem() is pocketmine\event\InventoryPickupItemEvent::getItem() : pocketmine\entity\Item while the second one is pocketmine\entity\Item::getItem() : pocketmine\item\Item.
@SalmonDE InventoryPickupItemEvent::getItem() returns a entity\Item not item\Item
I agree the entity\Item is very confusing to code with, and annoying when using both item\Item and entity\Item. It wouldn't be a bad idea to change that in my opinion.