I maked one rate plugin. When players break cobblestone or stone this plugin drops ores and cases. But I couldn't edit the item names. How can i change dropping item names? Code: case 5: $dusur->dropItem($blok,Item::get(131):setCustomName("test")); $oyuncu->sendPopup("dropped case!"); break;
Check out the plugin I've created. https://github.com/ErikPDev/ItemsDropped You'll have to extend ItemEntity, and add these functions. PHP: $this->setNameTag("Hi!");$this->setNameTagVisible(true);$this->setNameTagAlwaysVisible(true); https://github.com/ErikPDev/ItemsDropped Enjoy!
I dont understand. I am new. Pls fix and send me. PHP: <?phpnamespace androcyber;use pocketmine\plugin\Plugin;use pocketmine\plugin\PluginBase;use pocketmine\item\Item;use pocketmine\Player;use pocketmine\Server;use pocketmine\math\Vector3;use pocketmine\block\Block;use pocketmine\event\Listener;use pocketmine\event\block\BlockBreakEvent;use pocketmine\level\Level;use pocketmine\entity\Entity;use pocketmine\entity\object\ItemEntity;class oran extends PluginBase implements Listener { public function onEnable() : void{ $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onBreak(BlockBreakEvent $event){ $oyuncu = $event->getPlayer(); $blok = $event->getBlock(); $dusur = $oyuncu->getLevel(); $item = $event->getItem(); if($blok->getId() == "4" || $blok->getId() == "1"){ $oran = rand(0,270); switch($oran){ case 0: $dusur->dropItem($blok,Item::get(264)); $oyuncu->sendPopup("elmas düşürdün!"); break; case 1: $dusur->dropItem($blok,Item::get(265)); $oyuncu->sendPopup("demir düşürdün!"); break; case 2: $dusur->dropItem($blok,Item::get(266)); $oyuncu->sendPopup("altın düşürdün!"); break; case 3: $dusur->dropItem($blok,Item::get(388)); $oyuncu->sendPopup("zümrüt düşürdün!"); break; case 4: $dusur->dropItem($blok,Item::get(263)); $oyuncu->sendPopup("kömür düşürdün!"); break; case 5: $dusur->dropItem($blok,Item::get(131)); $this->setNameTag("Hi!"); $this->setNameTagVisible(true); $this->setNameTagAlwaysVisible(true); $oyuncu->sendPopup("kasa anahtarı düşürdün!"); break; } } }} ?>
You want to set the item name? Extend the ItemEntity from Class Item and modify the function named entityBaseTick, Then you can set the nametag since it's an entity. On the main file you'll need to register it like this PHP: Entity::registerEntity(Item::class, true, ["Item", "minecraft:item"]); It's pretty simple. An example is on this github page. https://github.com/ErikPDev/ItemsDropped/tree/main/src/ErikPDev/ItemsDropped
dropItem will return the item entity, this will do PHP: $entity=$dusur->dropItem($blok,Item::get(131)); $entity->setNameTag("Hi!"); $entity->setNameTagVisible(true); $entity->setNameTagAlwaysVisible(true);