mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Implement Turtle Shell (#5235)
This commit is contained in:
parent
383dc2a2b9
commit
1366a43c22
@ -350,6 +350,7 @@ final class ItemSerializerDeserializerRegistrar{
|
||||
$this->map1to1Item(Ids::SWEET_BERRIES, Items::SWEET_BERRIES());
|
||||
$this->map1to1Item(Ids::TOTEM_OF_UNDYING, Items::TOTEM());
|
||||
$this->map1to1Item(Ids::TROPICAL_FISH, Items::CLOWNFISH());
|
||||
$this->map1to1Item(Ids::TURTLE_HELMET, Items::TURTLE_HELMET());
|
||||
$this->map1to1Item(Ids::VILLAGER_SPAWN_EGG, Items::VILLAGER_SPAWN_EGG());
|
||||
$this->map1to1Item(Ids::WARPED_SIGN, Items::WARPED_SIGN());
|
||||
$this->map1to1Item(Ids::WATER_BUCKET, Items::WATER_BUCKET());
|
||||
|
@ -610,6 +610,13 @@ abstract class Living extends Entity{
|
||||
if($this->doAirSupplyTick($tickDiff)){
|
||||
$hasUpdate = true;
|
||||
}
|
||||
|
||||
foreach($this->armorInventory->getContents() as $index => $item){
|
||||
if($item->onTickWorn($this)){
|
||||
$hasUpdate = true;
|
||||
$this->armorInventory->setItem($index, $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->attackTime > 0){
|
||||
|
@ -36,6 +36,7 @@ use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\SavedDataLoadingException;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\item\enchantment\EnchantmentInstance;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\LittleEndianNbtSerializer;
|
||||
@ -559,6 +560,14 @@ class Item implements \JsonSerializable{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this item is being worn by an entity.
|
||||
* Returns whether it did something.
|
||||
*/
|
||||
public function onTickWorn(Living $entity) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of ticks a player must wait before activating this item again.
|
||||
*/
|
||||
|
@ -298,8 +298,9 @@ final class ItemTypeIds{
|
||||
public const LINGERING_POTION = 20259;
|
||||
public const FIRE_CHARGE = 20260;
|
||||
public const SUSPICIOUS_STEW = 20261;
|
||||
public const TURTLE_HELMET = 20262;
|
||||
|
||||
public const FIRST_UNUSED_ITEM_ID = 20262;
|
||||
public const FIRST_UNUSED_ITEM_ID = 20263;
|
||||
|
||||
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;
|
||||
|
||||
|
@ -1486,6 +1486,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->register("thick_potion", fn() => Items::POTION()->setType(PotionType::THICK()));
|
||||
$result->register("thick_splash_potion", fn() => Items::SPLASH_POTION()->setType(PotionType::THICK()));
|
||||
$result->register("totem", fn() => Items::TOTEM());
|
||||
$result->register("turtle_helmet", fn() => Items::TURTLE_HELMET());
|
||||
$result->register("turtle_master_potion", fn() => Items::POTION()->setType(PotionType::TURTLE_MASTER()));
|
||||
$result->register("turtle_master_splash_potion", fn() => Items::SPLASH_POTION()->setType(PotionType::TURTLE_MASTER()));
|
||||
$result->register("turtle_shell_piece", fn() => Items::SCUTE());
|
||||
|
41
src/item/TurtleHelmet.php
Normal file
41
src/item/TurtleHelmet.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?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\entity\Human;
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
class TurtleHelmet extends Armor{
|
||||
|
||||
public function onTickWorn(Living $entity) : bool{
|
||||
if($entity instanceof Human && !$entity->isUnderwater()){
|
||||
$entity->getEffects()->add(new EffectInstance(VanillaEffects::WATER_BREATHING(), 200, 0, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -289,6 +289,7 @@ use pocketmine\world\World;
|
||||
* @method static SuspiciousStew SUSPICIOUS_STEW()
|
||||
* @method static SweetBerries SWEET_BERRIES()
|
||||
* @method static Totem TOTEM()
|
||||
* @method static TurtleHelmet TURTLE_HELMET()
|
||||
* @method static SpawnEgg VILLAGER_SPAWN_EGG()
|
||||
* @method static ItemBlockWallOrFloor WARPED_SIGN()
|
||||
* @method static LiquidBucket WATER_BUCKET()
|
||||
@ -616,6 +617,7 @@ final class VanillaItems{
|
||||
self::register("iron_helmet", new Armor(new IID(Ids::IRON_HELMET), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD)));
|
||||
self::register("leather_cap", new Armor(new IID(Ids::LEATHER_CAP), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD)));
|
||||
self::register("netherite_helmet", new Armor(new IID(Ids::NETHERITE_HELMET), "Netherite Helmet", new ArmorTypeInfo(3, 408, ArmorInventory::SLOT_HEAD, 3, true)));
|
||||
self::register("turtle_helmet", new TurtleHelmet(new IID(Ids::TURTLE_HELMET), "Turtle Shell", new ArmorTypeInfo(2, 276, ArmorInventory::SLOT_HEAD)));
|
||||
|
||||
self::register("chainmail_leggings", new Armor(new IID(Ids::CHAINMAIL_LEGGINGS), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS)));
|
||||
self::register("diamond_leggings", new Armor(new IID(Ids::DIAMOND_LEGGINGS), "Diamond Leggings", new ArmorTypeInfo(6, 496, ArmorInventory::SLOT_LEGS, 2)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user