mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Implement Fire Charge (#5225)
This commit is contained in:
parent
8e97e9dcda
commit
223de3ad23
@ -32,6 +32,7 @@ use pocketmine\item\Durable;
|
||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||
use pocketmine\item\FlintSteel;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemTypeIds;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -82,6 +83,11 @@ class TNT extends Opaque{
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){
|
||||
$item->pop();
|
||||
$this->ignite();
|
||||
return true;
|
||||
}
|
||||
if($item instanceof FlintSteel || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){
|
||||
if($item instanceof Durable){
|
||||
$item->applyDamage(1);
|
||||
|
@ -338,7 +338,7 @@ final class ItemDeserializer{
|
||||
$this->map(Ids::FERMENTED_SPIDER_EYE, fn() => Items::FERMENTED_SPIDER_EYE());
|
||||
//TODO: minecraft:field_masoned_banner_pattern
|
||||
//TODO: minecraft:filled_map
|
||||
//TODO: minecraft:fire_charge
|
||||
$this->map(Ids::FIRE_CHARGE, fn() => Items::FIRE_CHARGE());
|
||||
//TODO: minecraft:firefly_spawn_egg
|
||||
//TODO: minecraft:firework_rocket
|
||||
//TODO: minecraft:firework_star
|
||||
|
@ -383,6 +383,7 @@ final class ItemSerializer{
|
||||
$this->map(Items::EXPERIENCE_BOTTLE(), self::id(Ids::EXPERIENCE_BOTTLE));
|
||||
$this->map(Items::FEATHER(), self::id(Ids::FEATHER));
|
||||
$this->map(Items::FERMENTED_SPIDER_EYE(), self::id(Ids::FERMENTED_SPIDER_EYE));
|
||||
$this->map(Items::FIRE_CHARGE(), self::id(Ids::FIRE_CHARGE));
|
||||
$this->map(Items::FISHING_ROD(), self::id(Ids::FISHING_ROD));
|
||||
$this->map(Items::FLINT(), self::id(Ids::FLINT));
|
||||
$this->map(Items::FLINT_AND_STEEL(), self::id(Ids::FLINT_AND_STEEL));
|
||||
|
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"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user