Implement firework rocket & firework star (#5455)

Co-authored-by: Dylan T <dktapps@pmmp.io>
Co-authored-by: ipad54 <63200545+ipad54@users.noreply.github.com>
This commit is contained in:
IvanCraft623
2025-09-20 11:04:05 -06:00
committed by GitHub
parent dd9cbb74f0
commit ebeee29a88
17 changed files with 975 additions and 2 deletions

View File

@@ -0,0 +1,45 @@
<?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\data\bedrock;
use pocketmine\item\FireworkRocketType;
use pocketmine\utils\SingletonTrait;
final class FireworkRocketTypeIdMap{
use SingletonTrait;
/** @phpstan-use IntSaveIdMapTrait<FireworkRocketType> */
use IntSaveIdMapTrait;
private function __construct(){
foreach(FireworkRocketType::cases() as $case){
$this->register(match($case){
FireworkRocketType::SMALL_BALL => FireworkRocketTypeIds::SMALL_BALL,
FireworkRocketType::LARGE_BALL => FireworkRocketTypeIds::LARGE_BALL,
FireworkRocketType::STAR => FireworkRocketTypeIds::STAR,
FireworkRocketType::CREEPER => FireworkRocketTypeIds::CREEPER,
FireworkRocketType::BURST => FireworkRocketTypeIds::BURST,
}, $case);
}
}
}

View File

@@ -0,0 +1,32 @@
<?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\data\bedrock;
final class FireworkRocketTypeIds{
public const SMALL_BALL = 0;
public const LARGE_BALL = 1;
public const STAR = 2;
public const CREEPER = 3;
public const BURST = 4;
}

View File

@@ -40,6 +40,7 @@ use pocketmine\data\bedrock\PotionTypeIdMap;
use pocketmine\data\bedrock\SuspiciousStewTypeIdMap;
use pocketmine\item\Banner;
use pocketmine\item\Dye;
use pocketmine\item\FireworkStar;
use pocketmine\item\GoatHorn;
use pocketmine\item\Item;
use pocketmine\item\Medicine;
@@ -246,6 +247,7 @@ final class ItemSerializerDeserializerRegistrar{
$this->map1to1Item(Ids::EYE_ARMOR_TRIM_SMITHING_TEMPLATE, Items::EYE_ARMOR_TRIM_SMITHING_TEMPLATE());
$this->map1to1Item(Ids::FEATHER, Items::FEATHER());
$this->map1to1Item(Ids::FERMENTED_SPIDER_EYE, Items::FERMENTED_SPIDER_EYE());
$this->map1to1Item(Ids::FIREWORK_ROCKET, Items::FIREWORK_ROCKET());
$this->map1to1Item(Ids::FIRE_CHARGE, Items::FIRE_CHARGE());
$this->map1to1Item(Ids::FISHING_ROD, Items::FISHING_ROD());
$this->map1to1Item(Ids::FLINT, Items::FLINT());
@@ -501,6 +503,14 @@ final class ItemSerializerDeserializerRegistrar{
* in a unified manner.
*/
private function register1to1ItemWithMetaMappings() : void{
$this->map1to1ItemWithMeta(
Ids::FIREWORK_STAR,
Items::FIREWORK_STAR(),
function(FireworkStar $item, int $meta) : void{
// Colors will be defined by CompoundTag deserialization.
},
fn(FireworkStar $item) => DyeColorIdMap::getInstance()->toInvertedId($item->getExplosion()->getFlashColor())
);
$this->map1to1ItemWithMeta(
Ids::GOAT_HORN,
Items::GOAT_HORN(),