mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 23:37:45 +00:00
Implement Suspicious Stew (#5224)
This commit is contained in:
@@ -297,8 +297,9 @@ final class ItemTypeIds{
|
||||
public const POWDER_SNOW_BUCKET = 20258;
|
||||
public const LINGERING_POTION = 20259;
|
||||
public const FIRE_CHARGE = 20260;
|
||||
public const SUSPICIOUS_STEW = 20261;
|
||||
|
||||
public const FIRST_UNUSED_ITEM_ID = 20261;
|
||||
public const FIRST_UNUSED_ITEM_ID = 20262;
|
||||
|
||||
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;
|
||||
|
||||
|
@@ -1118,6 +1118,11 @@ final class StringToItemParser extends StringToTParser{
|
||||
|
||||
$result->register($prefix("dye"), fn() => Items::DYE()->setColor($color));
|
||||
}
|
||||
foreach(SuspiciousStewType::getAll() as $suspiciousStewType){
|
||||
$prefix = fn(string $name) => $suspiciousStewType->name() . "_" . $name;
|
||||
|
||||
$result->register($prefix("suspicious_stew"), fn() => Items::SUSPICIOUS_STEW()->setType($suspiciousStewType));
|
||||
}
|
||||
}
|
||||
|
||||
private static function registerItems(self $result) : void{
|
||||
@@ -1474,6 +1479,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->register("strong_turtle_master_potion", fn() => Items::POTION()->setType(PotionType::STRONG_TURTLE_MASTER()));
|
||||
$result->register("strong_turtle_master_splash_potion", fn() => Items::SPLASH_POTION()->setType(PotionType::STRONG_TURTLE_MASTER()));
|
||||
$result->register("sugar", fn() => Items::SUGAR());
|
||||
$result->register("suspicious_stew", fn() => Items::SUSPICIOUS_STEW());
|
||||
$result->register("sweet_berries", fn() => Items::SWEET_BERRIES());
|
||||
$result->register("swiftness_potion", fn() => Items::POTION()->setType(PotionType::SWIFTNESS()));
|
||||
$result->register("swiftness_splash_potion", fn() => Items::SPLASH_POTION()->setType(PotionType::SWIFTNESS()));
|
||||
|
74
src/item/SuspiciousStew.php
Normal file
74
src/item/SuspiciousStew.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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\RuntimeDataWriter;
|
||||
|
||||
class SuspiciousStew extends Food{
|
||||
|
||||
private SuspiciousStewType $suspiciousStewType;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name){
|
||||
$this->suspiciousStewType = SuspiciousStewType::POPPY();
|
||||
parent::__construct($identifier, $name);
|
||||
}
|
||||
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->suspiciousStewType($this->suspiciousStewType);
|
||||
}
|
||||
|
||||
public function getType() : SuspiciousStewType{ return $this->suspiciousStewType; }
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setType(SuspiciousStewType $type) : self{
|
||||
$this->suspiciousStewType = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function requiresHunger() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 7.2;
|
||||
}
|
||||
|
||||
public function getAdditionalEffects() : array{
|
||||
return $this->suspiciousStewType->getEffects();
|
||||
}
|
||||
|
||||
public function getResidue() : Item{
|
||||
return VanillaItems::BOWL();
|
||||
}
|
||||
}
|
104
src/item/SuspiciousStewType.php
Normal file
104
src/item/SuspiciousStewType.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?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\effect\EffectInstance;
|
||||
use pocketmine\entity\effect\VanillaEffects;
|
||||
use pocketmine\utils\EnumTrait;
|
||||
|
||||
/**
|
||||
* This doc-block is generated automatically, do not modify it manually.
|
||||
* This must be regenerated whenever registry members are added, removed or changed.
|
||||
* @see build/generate-registry-annotations.php
|
||||
* @generate-registry-docblock
|
||||
*
|
||||
* @method static SuspiciousStewType ALLIUM()
|
||||
* @method static SuspiciousStewType AZURE_BLUET()
|
||||
* @method static SuspiciousStewType BLUE_ORCHID()
|
||||
* @method static SuspiciousStewType CORNFLOWER()
|
||||
* @method static SuspiciousStewType DANDELION()
|
||||
* @method static SuspiciousStewType LILY_OF_THE_VALLEY()
|
||||
* @method static SuspiciousStewType OXEYE_DAISY()
|
||||
* @method static SuspiciousStewType POPPY()
|
||||
* @method static SuspiciousStewType TULIP()
|
||||
* @method static SuspiciousStewType WITHER_ROSE()
|
||||
*/
|
||||
final class SuspiciousStewType{
|
||||
use EnumTrait {
|
||||
__construct as Enum___construct;
|
||||
}
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new self("poppy", fn() => [
|
||||
new EffectInstance(VanillaEffects::NIGHT_VISION(), 80)
|
||||
]),
|
||||
new self("cornflower", fn() => [
|
||||
new EffectInstance(VanillaEffects::JUMP_BOOST(), 80)
|
||||
]),
|
||||
new self("tulip", fn() => [
|
||||
new EffectInstance(VanillaEffects::WEAKNESS(), 140)
|
||||
]),
|
||||
new self("azure_bluet", fn() => [
|
||||
new EffectInstance(VanillaEffects::BLINDNESS(), 120)
|
||||
]),
|
||||
new self("lily_of_the_valley", fn() => [
|
||||
new EffectInstance(VanillaEffects::POISON(), 200)
|
||||
]),
|
||||
new self("dandelion", fn() => [
|
||||
new EffectInstance(VanillaEffects::SATURATION(), 6)
|
||||
]),
|
||||
new self("blue_orchid", fn() => [
|
||||
new EffectInstance(VanillaEffects::SATURATION(), 6)
|
||||
]),
|
||||
new self("allium", fn() => [
|
||||
new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 40)
|
||||
]),
|
||||
new self("oxeye_daisy", fn() => [
|
||||
new EffectInstance(VanillaEffects::REGENERATION(), 120)
|
||||
]),
|
||||
new self("wither_rose", fn() => [
|
||||
new EffectInstance(VanillaEffects::WITHER(), 120)
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param \Closure() : list<EffectInstance> $effectsGetter
|
||||
*/
|
||||
private function __construct(
|
||||
string $enumName,
|
||||
private \Closure $effectsGetter
|
||||
){
|
||||
$this->Enum___construct($enumName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EffectInstance[]
|
||||
* @phpstan-return list<EffectInstance>
|
||||
*/
|
||||
public function getEffects() : array{
|
||||
return ($this->effectsGetter)();
|
||||
}
|
||||
}
|
@@ -286,6 +286,7 @@ use pocketmine\world\World;
|
||||
* @method static Sword STONE_SWORD()
|
||||
* @method static StringItem STRING()
|
||||
* @method static Item SUGAR()
|
||||
* @method static SuspiciousStew SUSPICIOUS_STEW()
|
||||
* @method static SweetBerries SWEET_BERRIES()
|
||||
* @method static Totem TOTEM()
|
||||
* @method static SpawnEgg VILLAGER_SPAWN_EGG()
|
||||
@@ -518,6 +519,7 @@ final class VanillaItems{
|
||||
self::register("stick", new Stick(new IID(Ids::STICK), "Stick"));
|
||||
self::register("string", new StringItem(new IID(Ids::STRING), "String"));
|
||||
self::register("sugar", new Item(new IID(Ids::SUGAR), "Sugar"));
|
||||
self::register("suspicious_stew", new SuspiciousStew(new IID(Ids::SUSPICIOUS_STEW), "Suspicious Stew"));
|
||||
self::register("sweet_berries", new SweetBerries(new IID(Ids::SWEET_BERRIES), "Sweet Berries"));
|
||||
self::register("totem", new Totem(new IID(Ids::TOTEM), "Totem of Undying"));
|
||||
self::register("warped_sign", new ItemBlockWallOrFloor(new IID(Ids::WARPED_SIGN), Blocks::WARPED_SIGN(), Blocks::WARPED_WALL_SIGN()));
|
||||
|
Reference in New Issue
Block a user