mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Implement Fire Charge (#5225)
This commit is contained in:
48
src/item/FireCharge.php
Normal file
48
src/item/FireCharge.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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\block\Block;
|
||||
use pocketmine\block\BlockTypeIds;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\BlazeShootSound;
|
||||
|
||||
class FireCharge extends Item{
|
||||
|
||||
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems) : ItemUseResult{
|
||||
if($blockReplace->getTypeId() === BlockTypeIds::AIR){
|
||||
$world = $player->getWorld();
|
||||
$world->setBlock($blockReplace->getPosition(), VanillaBlocks::FIRE());
|
||||
$world->addSound($blockReplace->getPosition()->add(0.5, 0.5, 0.5), new BlazeShootSound());
|
||||
|
||||
$this->pop();
|
||||
|
||||
return ItemUseResult::SUCCESS();
|
||||
}
|
||||
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
}
|
@@ -296,8 +296,9 @@ final class ItemTypeIds{
|
||||
public const NETHERITE_SCRAP = 20257;
|
||||
public const POWDER_SNOW_BUCKET = 20258;
|
||||
public const LINGERING_POTION = 20259;
|
||||
public const FIRE_CHARGE = 20260;
|
||||
|
||||
public const FIRST_UNUSED_ITEM_ID = 20260;
|
||||
public const FIRST_UNUSED_ITEM_ID = 20261;
|
||||
|
||||
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;
|
||||
|
||||
|
@@ -1246,6 +1246,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->register("experience_bottle", fn() => Items::EXPERIENCE_BOTTLE());
|
||||
$result->register("feather", fn() => Items::FEATHER());
|
||||
$result->register("fermented_spider_eye", fn() => Items::FERMENTED_SPIDER_EYE());
|
||||
$result->register("fire_charge", fn() => Items::FIRE_CHARGE());
|
||||
$result->register("fire_resistance_potion", fn() => Items::POTION()->setType(PotionType::FIRE_RESISTANCE()));
|
||||
$result->register("fire_resistance_splash_potion", fn() => Items::SPLASH_POTION()->setType(PotionType::FIRE_RESISTANCE()));
|
||||
$result->register("fish", fn() => Items::RAW_FISH());
|
||||
|
@@ -156,6 +156,7 @@ use pocketmine\world\World;
|
||||
* @method static ExperienceBottle EXPERIENCE_BOTTLE()
|
||||
* @method static Item FEATHER()
|
||||
* @method static Item FERMENTED_SPIDER_EYE()
|
||||
* @method static FireCharge FIRE_CHARGE()
|
||||
* @method static FishingRod FISHING_ROD()
|
||||
* @method static Item FLINT()
|
||||
* @method static FlintSteel FLINT_AND_STEEL()
|
||||
@@ -423,6 +424,7 @@ final class VanillaItems{
|
||||
self::register("experience_bottle", new ExperienceBottle(new IID(Ids::EXPERIENCE_BOTTLE), "Bottle o' Enchanting"));
|
||||
self::register("feather", new Item(new IID(Ids::FEATHER), "Feather"));
|
||||
self::register("fermented_spider_eye", new Item(new IID(Ids::FERMENTED_SPIDER_EYE), "Fermented Spider Eye"));
|
||||
self::register("fire_charge", new FireCharge(new IID(Ids::FIRE_CHARGE), "Fire Charge"));
|
||||
self::register("fishing_rod", new FishingRod(new IID(Ids::FISHING_ROD), "Fishing Rod"));
|
||||
self::register("flint", new Item(new IID(Ids::FLINT), "Flint"));
|
||||
self::register("flint_and_steel", new FlintSteel(new IID(Ids::FLINT_AND_STEEL), "Flint and Steel"));
|
||||
|
Reference in New Issue
Block a user