diff --git a/src/block/TNT.php b/src/block/TNT.php index dca4920d3..cf1158a67 100644 --- a/src/block/TNT.php +++ b/src/block/TNT.php @@ -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); diff --git a/src/data/bedrock/item/ItemDeserializer.php b/src/data/bedrock/item/ItemDeserializer.php index 85d415d6a..a9012af89 100644 --- a/src/data/bedrock/item/ItemDeserializer.php +++ b/src/data/bedrock/item/ItemDeserializer.php @@ -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 diff --git a/src/data/bedrock/item/ItemSerializer.php b/src/data/bedrock/item/ItemSerializer.php index 0c993f2e6..19754739d 100644 --- a/src/data/bedrock/item/ItemSerializer.php +++ b/src/data/bedrock/item/ItemSerializer.php @@ -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)); diff --git a/src/item/FireCharge.php b/src/item/FireCharge.php new file mode 100644 index 000000000..20e7e4f89 --- /dev/null +++ b/src/item/FireCharge.php @@ -0,0 +1,48 @@ +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(); + } +} diff --git a/src/item/ItemTypeIds.php b/src/item/ItemTypeIds.php index 06ee39be4..6f23fb9f8 100644 --- a/src/item/ItemTypeIds.php +++ b/src/item/ItemTypeIds.php @@ -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; diff --git a/src/item/StringToItemParser.php b/src/item/StringToItemParser.php index a538380ce..d0bdcb5f9 100644 --- a/src/item/StringToItemParser.php +++ b/src/item/StringToItemParser.php @@ -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()); diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index b229039ec..11129238e 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -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"));