Implement Piglin Head (#5839)

This commit is contained in:
ace 2023-06-19 19:07:49 +08:00 committed by GitHub
parent 8f48f8a596
commit bccda4fe44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 10 deletions

View File

@ -33,6 +33,7 @@ use pocketmine\utils\EnumTrait;
* *
* @method static MobHeadType CREEPER() * @method static MobHeadType CREEPER()
* @method static MobHeadType DRAGON() * @method static MobHeadType DRAGON()
* @method static MobHeadType PIGLIN()
* @method static MobHeadType PLAYER() * @method static MobHeadType PLAYER()
* @method static MobHeadType SKELETON() * @method static MobHeadType SKELETON()
* @method static MobHeadType WITHER_SKELETON() * @method static MobHeadType WITHER_SKELETON()
@ -50,7 +51,8 @@ final class MobHeadType{
new MobHeadType("zombie", "Zombie Head"), new MobHeadType("zombie", "Zombie Head"),
new MobHeadType("player", "Player Head"), new MobHeadType("player", "Player Head"),
new MobHeadType("creeper", "Creeper Head"), new MobHeadType("creeper", "Creeper Head"),
new MobHeadType("dragon", "Dragon Head") new MobHeadType("dragon", "Dragon Head"),
new MobHeadType("piglin", "Piglin Head")
); );
} }

View File

@ -48,6 +48,7 @@ final class MobHeadTypeIdMap{
$this->register(3, MobHeadType::PLAYER()); $this->register(3, MobHeadType::PLAYER());
$this->register(4, MobHeadType::CREEPER()); $this->register(4, MobHeadType::CREEPER());
$this->register(5, MobHeadType::DRAGON()); $this->register(5, MobHeadType::DRAGON());
$this->register(6, MobHeadType::PIGLIN());
} }
private function register(int $id, MobHeadType $type) : void{ private function register(int $id, MobHeadType $type) : void{

View File

@ -130,10 +130,11 @@ trait RuntimeEnumDeserializerTrait{
$value = match($this->readInt(3)){ $value = match($this->readInt(3)){
0 => \pocketmine\block\utils\MobHeadType::CREEPER(), 0 => \pocketmine\block\utils\MobHeadType::CREEPER(),
1 => \pocketmine\block\utils\MobHeadType::DRAGON(), 1 => \pocketmine\block\utils\MobHeadType::DRAGON(),
2 => \pocketmine\block\utils\MobHeadType::PLAYER(), 2 => \pocketmine\block\utils\MobHeadType::PIGLIN(),
3 => \pocketmine\block\utils\MobHeadType::SKELETON(), 3 => \pocketmine\block\utils\MobHeadType::PLAYER(),
4 => \pocketmine\block\utils\MobHeadType::WITHER_SKELETON(), 4 => \pocketmine\block\utils\MobHeadType::SKELETON(),
5 => \pocketmine\block\utils\MobHeadType::ZOMBIE(), 5 => \pocketmine\block\utils\MobHeadType::WITHER_SKELETON(),
6 => \pocketmine\block\utils\MobHeadType::ZOMBIE(),
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for MobHeadType") default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for MobHeadType")
}; };
} }

View File

@ -130,10 +130,11 @@ trait RuntimeEnumSerializerTrait{
$this->writeInt(3, match($value){ $this->writeInt(3, match($value){
\pocketmine\block\utils\MobHeadType::CREEPER() => 0, \pocketmine\block\utils\MobHeadType::CREEPER() => 0,
\pocketmine\block\utils\MobHeadType::DRAGON() => 1, \pocketmine\block\utils\MobHeadType::DRAGON() => 1,
\pocketmine\block\utils\MobHeadType::PLAYER() => 2, \pocketmine\block\utils\MobHeadType::PIGLIN() => 2,
\pocketmine\block\utils\MobHeadType::SKELETON() => 3, \pocketmine\block\utils\MobHeadType::PLAYER() => 3,
\pocketmine\block\utils\MobHeadType::WITHER_SKELETON() => 4, \pocketmine\block\utils\MobHeadType::SKELETON() => 4,
\pocketmine\block\utils\MobHeadType::ZOMBIE() => 5, \pocketmine\block\utils\MobHeadType::WITHER_SKELETON() => 5,
\pocketmine\block\utils\MobHeadType::ZOMBIE() => 6,
default => throw new \pocketmine\utils\AssumptionFailedError("All MobHeadType cases should be covered") default => throw new \pocketmine\utils\AssumptionFailedError("All MobHeadType cases should be covered")
}); });
} }

View File

@ -843,6 +843,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("packed_mud", fn() => Blocks::PACKED_MUD()); $result->registerBlock("packed_mud", fn() => Blocks::PACKED_MUD());
$result->registerBlock("peony", fn() => Blocks::PEONY()); $result->registerBlock("peony", fn() => Blocks::PEONY());
$result->registerBlock("pink_tulip", fn() => Blocks::PINK_TULIP()); $result->registerBlock("pink_tulip", fn() => Blocks::PINK_TULIP());
$result->registerBlock("piglin_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::PIGLIN()));
$result->registerBlock("plank", fn() => Blocks::OAK_PLANKS()); $result->registerBlock("plank", fn() => Blocks::OAK_PLANKS());
$result->registerBlock("planks", fn() => Blocks::OAK_PLANKS()); $result->registerBlock("planks", fn() => Blocks::OAK_PLANKS());
$result->registerBlock("player_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::PLAYER())); $result->registerBlock("player_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::PLAYER()));

File diff suppressed because one or more lines are too long