So, i know theres $item->setCustomName("God sword") But, is there somthing like $event->getBlock->setCustomName("Name")?
PHP: public function onItemHeld (PlayerItemHeldEvent $e){If ($e->getItem ()->getId () === 1){$e->getItem ()->setCustomName ("The lonely stone");}}
it should be same on hold stone get item -> set custom name (awesom stone) since anything that is in inventory can be consider an item so does a block name resets when place AFAIK
i have a plugin when i do /spawner (mob) it gives me a spawner, and sets the spawner name as "pig spawner", then when i place it, i do if $event->getBlock->getCustomName() == "pig spawner"{ set the spawner a certain mob spawner} but it doesnt get past the get name part
You can't setCustomName() on a block object. You are referring to the Item that the player is holding that would result in the block being placed. Item and Block are data objects. Calling most methods (with the exception of certain event handling functions like useOn()) on them only alters their own properties, does not change PocketMine behaviour, unless you then pass these altered objects to the PocketMine API. For example, callinlg setCustomName() alone doesn't do anything; you have to put it into an inventory slot.
A pocketmine\block\Block instance doesn't have an NBT tag (NamedTag/CompoundTag), that's what tiles are for. You'll want to save your custom NBT data to the mob spawners tile rather than the block. Like @SOFe said, there is not Block::setCustomName() as there is no NBT tag to save the custom name when the chunk the block is in unloads, if the function did exist it would be pretty useless if the custom name wasn't saved after every restart/chunk unload. Use the item constants, they're there for a reason and not just to look pretty.