mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Implement Goat horns (#5232)
Co-authored-by: ipad54 <63200545+ipad54@users.noreply.github.com> Co-authored-by: Dylan T. <dktapps@pmmp.io>
This commit is contained in:
71
src/item/GoatHorn.php
Normal file
71
src/item/GoatHorn.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?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\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\GoatHornSound;
|
||||
|
||||
class GoatHorn extends Item implements Releasable{
|
||||
|
||||
private GoatHornType $goatHornType = GoatHornType::PONDER;
|
||||
|
||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||
$w->enum($this->goatHornType);
|
||||
}
|
||||
|
||||
public function getHornType() : GoatHornType{ return $this->goatHornType; }
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHornType(GoatHornType $type) : self{
|
||||
$this->goatHornType = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getCooldownTicks() : int{
|
||||
return 140;
|
||||
}
|
||||
|
||||
public function getCooldownTag() : ?string{
|
||||
return ItemCooldownTags::GOAT_HORN;
|
||||
}
|
||||
|
||||
public function canStartUsingItem(Player $player) : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onClickAir(Player $player, Vector3 $directionVector, array &$returnedItems) : ItemUseResult{
|
||||
$position = $player->getPosition();
|
||||
$position->getWorld()->addSound($position, new GoatHornSound($this->goatHornType));
|
||||
|
||||
return ItemUseResult::SUCCESS;
|
||||
}
|
||||
}
|
36
src/item/GoatHornType.php
Normal file
36
src/item/GoatHornType.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?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;
|
||||
|
||||
enum GoatHornType{
|
||||
|
||||
case PONDER;
|
||||
case SING;
|
||||
case SEEK;
|
||||
case FEEL;
|
||||
case ADMIRE;
|
||||
case CALL;
|
||||
case YEARN;
|
||||
case DREAM;
|
||||
}
|
@ -324,8 +324,9 @@ final class ItemTypeIds{
|
||||
public const SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = 20285;
|
||||
public const PITCHER_POD = 20286;
|
||||
public const NAME_TAG = 20287;
|
||||
public const GOAT_HORN = 20288;
|
||||
|
||||
public const FIRST_UNUSED_ITEM_ID = 20288;
|
||||
public const FIRST_UNUSED_ITEM_ID = 20289;
|
||||
|
||||
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;
|
||||
|
||||
|
@ -1184,6 +1184,13 @@ final class StringToItemParser extends StringToTParser{
|
||||
|
||||
$result->register($prefix("dye"), fn() => Items::DYE()->setColor($color));
|
||||
}
|
||||
|
||||
foreach(GoatHornType::cases() as $goatHornType){
|
||||
$prefix = fn(string $name) => strtolower($goatHornType->name) . "_" . $name;
|
||||
|
||||
$result->register($prefix("goat_horn"), fn() => Items::GOAT_HORN()->setHornType($goatHornType));
|
||||
}
|
||||
|
||||
foreach(SuspiciousStewType::cases() as $suspiciousStewType){
|
||||
$prefix = fn(string $name) => strtolower($suspiciousStewType->name) . "_" . $name;
|
||||
|
||||
@ -1341,6 +1348,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->register("glow_berries", fn() => Items::GLOW_BERRIES());
|
||||
$result->register("glow_ink_sac", fn() => Items::GLOW_INK_SAC());
|
||||
$result->register("glowstone_dust", fn() => Items::GLOWSTONE_DUST());
|
||||
$result->register("goat_horn", fn() => Items::GOAT_HORN());
|
||||
$result->register("gold_axe", fn() => Items::GOLDEN_AXE());
|
||||
$result->register("gold_boots", fn() => Items::GOLDEN_BOOTS());
|
||||
$result->register("gold_chestplate", fn() => Items::GOLDEN_CHESTPLATE());
|
||||
|
@ -171,6 +171,7 @@ use function strtolower;
|
||||
* @method static Item GLOWSTONE_DUST()
|
||||
* @method static GlowBerries GLOW_BERRIES()
|
||||
* @method static Item GLOW_INK_SAC()
|
||||
* @method static GoatHorn GOAT_HORN()
|
||||
* @method static GoldenApple GOLDEN_APPLE()
|
||||
* @method static Axe GOLDEN_AXE()
|
||||
* @method static Armor GOLDEN_BOOTS()
|
||||
@ -468,6 +469,7 @@ final class VanillaItems{
|
||||
self::register("glow_berries", new GlowBerries(new IID(Ids::GLOW_BERRIES), "Glow Berries"));
|
||||
self::register("glow_ink_sac", new Item(new IID(Ids::GLOW_INK_SAC), "Glow Ink Sac"));
|
||||
self::register("glowstone_dust", new Item(new IID(Ids::GLOWSTONE_DUST), "Glowstone Dust"));
|
||||
self::register("goat_horn", new GoatHorn(new IID(Ids::GOAT_HORN), "Goat Horn"));
|
||||
self::register("gold_ingot", new Item(new IID(Ids::GOLD_INGOT), "Gold Ingot"));
|
||||
self::register("gold_nugget", new Item(new IID(Ids::GOLD_NUGGET), "Gold Nugget"));
|
||||
self::register("golden_apple", new GoldenApple(new IID(Ids::GOLDEN_APPLE), "Golden Apple"));
|
||||
|
Reference in New Issue
Block a user