Merge branch 'minor-next' into major-next

This commit is contained in:
Dylan K. Taylor
2024-03-14 12:47:18 +00:00
70 changed files with 1196 additions and 555 deletions

View File

@ -323,8 +323,9 @@ final class ItemTypeIds{
public const EYE_ARMOR_TRIM_SMITHING_TEMPLATE = 20284;
public const SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = 20285;
public const PITCHER_POD = 20286;
public const NAME_TAG = 20287;
public const FIRST_UNUSED_ITEM_ID = 20287;
public const FIRST_UNUSED_ITEM_ID = 20288;
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;

40
src/item/NameTag.php Normal file
View File

@ -0,0 +1,40 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\entity\Entity;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
class NameTag extends Item{
public function onInteractEntity(Player $player, Entity $entity, Vector3 $clickVector) : bool{
if($entity->canBeRenamed() && $this->hasCustomName()){
$entity->setNameTag($this->getCustomName());
$this->pop();
return true;
}
return false;
}
}

View File

@ -1384,6 +1384,7 @@ final class StringToItemParser extends StringToTParser{
$result->register("mutton_raw", fn() => Items::RAW_MUTTON());
$result->register("muttoncooked", fn() => Items::COOKED_MUTTON());
$result->register("muttonraw", fn() => Items::RAW_MUTTON());
$result->register("name_tag", fn() => Items::NAME_TAG());
$result->register("nautilus_shell", fn() => Items::NAUTILUS_SHELL());
$result->register("nether_brick", fn() => Items::NETHER_BRICK());
$result->register("nether_quartz", fn() => Items::NETHER_QUARTZ());

View File

@ -219,6 +219,7 @@ use function strtolower;
* @method static MilkBucket MILK_BUCKET()
* @method static Minecart MINECART()
* @method static MushroomStew MUSHROOM_STEW()
* @method static NameTag NAME_TAG()
* @method static Item NAUTILUS_SHELL()
* @method static Axe NETHERITE_AXE()
* @method static Armor NETHERITE_BOOTS()
@ -490,6 +491,7 @@ final class VanillaItems{
self::register("milk_bucket", new MilkBucket(new IID(Ids::MILK_BUCKET), "Milk Bucket"));
self::register("minecart", new Minecart(new IID(Ids::MINECART), "Minecart"));
self::register("mushroom_stew", new MushroomStew(new IID(Ids::MUSHROOM_STEW), "Mushroom Stew"));
self::register("name_tag", new NameTag(new IID(Ids::NAME_TAG), "Name Tag"));
self::register("nautilus_shell", new Item(new IID(Ids::NAUTILUS_SHELL), "Nautilus Shell"));
self::register("nether_brick", new Item(new IID(Ids::NETHER_BRICK), "Nether Brick"));
self::register("nether_quartz", new Item(new IID(Ids::NETHER_QUARTZ), "Nether Quartz"));