pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.27k stars 1.55k forks source link

Durable Class #2009

Closed tbhDequan closed 6 years ago

tbhDequan commented 6 years ago

What I expected : For the item to be unbreakable What happened : Item still breaks

Code:

item = Item::get(Item::DIAMOND_PICKAXE);

if($item instanceof Durable){ $item->setUnbreakable(); }

dktapps commented 6 years ago

Please provide example code to demonstrate what you're doing. Code > words.

Also, you can edit your issue, so no need to create a new one next time.

tbhDequan commented 6 years ago

Done

dktapps commented 6 years ago
public function onPlayerJoin(PlayerJoinEvent $event){
        $p = $event->getPlayer();
        $item = ItemFactory::get(Item::DIAMOND_AXE);
        if($item instanceof Durable){
            $item->setUnbreakable();
            var_dump($item->isUnbreakable());
        }

        $p->getInventory()->setItemInHand($item);
        $p->getInventory()->sendHeldItem($p);
}

works for me.

Closing due to not reproducible. Please seek code assistance on the forums; do not use this issue tracker for support requests.

tbhDequan commented 6 years ago

Ok thanks