forked from pmmp/PocketMine-MP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace pocketmine\data\bedrock; | ||
|
||
use pocketmine\item\GoatHornType; | ||
use pocketmine\utils\SingletonTrait; | ||
|
||
final class GoatHornTypeIdMap{ | ||
use SingletonTrait; | ||
/** @phpstan-use IntSaveIdMapTrait<GoatHornType> */ | ||
use IntSaveIdMapTrait; | ||
|
||
private function __construct(){ | ||
foreach(GoatHornType::cases() as $case){ | ||
$this->register(match($case){ | ||
GoatHornType::PONDER => GoatHornTypeIds::PONDER, | ||
GoatHornType::SING => GoatHornTypeIds::SING, | ||
GoatHornType::SEEK => GoatHornTypeIds::SEEK, | ||
GoatHornType::FEEL => GoatHornTypeIds::FEEL, | ||
GoatHornType::ADMIRE => GoatHornTypeIds::ADMIRE, | ||
GoatHornType::CALL => GoatHornTypeIds::CALL, | ||
GoatHornType::YEARN => GoatHornTypeIds::YEARN, | ||
GoatHornType::DREAM => GoatHornTypeIds::DREAM | ||
}, $case); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace pocketmine\data\bedrock; | ||
|
||
final class GoatHornTypeIds{ | ||
public const PONDER = 0; | ||
public const SING = 1; | ||
public const SEEK = 2; | ||
public const FEEL = 3; | ||
public const ADMIRE = 4; | ||
public const CALL = 5; | ||
public const YEARN = 6; | ||
public const DREAM = 7; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace pocketmine\item; | ||
|
||
use pocketmine\data\runtime\RuntimeDataDescriber; | ||
use pocketmine\math\Vector3; | ||
use pocketmine\player\Player; | ||
use pocketmine\world\sound\GoatHornSound; | ||
|
||
class GoatHorn extends Item implements Releasable{ | ||
|
||
private GoatHornType $goatHornType = GoatHornType::PONDER; | ||
|
||
protected function describeState(RuntimeDataDescriber $w) : void{ | ||
$w->enum($this->goatHornType); | ||
} | ||
|
||
public function getHornType() : GoatHornType{ | ||
return $this->goatHornType; | ||
} | ||
|
||
/** @return $this */ | ||
public function setHornType(GoatHornType $type) : self{ | ||
$this->goatHornType = $type; | ||
return $this; | ||
} | ||
|
||
public function getMaxStackSize() : int{ | ||
return 1; | ||
} | ||
|
||
public function getCooldownTicks() : int{ | ||
return 140; | ||
} | ||
|
||
public function canStartUsingItem(Player $player) : bool{ | ||
return true; | ||
} | ||
|
||
public function onClickAir(Player $player, Vector3 $directionVector, array &$returnedItems) : ItemUseResult{ | ||
$position = $player->getPosition(); | ||
$position->getWorld()->addSound($position, new GoatHornSound($this->goatHornType)); | ||
|
||
return ItemUseResult::SUCCESS; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace pocketmine\item; | ||
|
||
enum GoatHornType{ | ||
|
||
case PONDER; | ||
case SING; | ||
case SEEK; | ||
case FEEL; | ||
case ADMIRE; | ||
case CALL; | ||
case YEARN; | ||
case DREAM; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace pocketmine\world\sound; | ||
|
||
use pocketmine\item\GoatHornType; | ||
use pocketmine\math\Vector3; | ||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; | ||
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; | ||
|
||
class GoatHornSound implements Sound{ | ||
public function __construct(private GoatHornType $goatHornType){ | ||
} | ||
|
||
public function encode(Vector3 $pos) : array{ | ||
return [LevelSoundEventPacket::nonActorSound(match ($this->goatHornType) { | ||
GoatHornType::PONDER => LevelSoundEvent::HORN_CALL0, | ||
GoatHornType::SING => LevelSoundEvent::HORN_CALL1, | ||
GoatHornType::SEEK => LevelSoundEvent::HORN_CALL2, | ||
GoatHornType::FEEL => LevelSoundEvent::HORN_CALL3, | ||
GoatHornType::ADMIRE => LevelSoundEvent::HORN_CALL4, | ||
GoatHornType::CALL => LevelSoundEvent::HORN_CALL5, | ||
GoatHornType::YEARN => LevelSoundEvent::HORN_CALL6, | ||
GoatHornType::DREAM => LevelSoundEvent::HORN_CALL7 | ||
}, $pos, false)]; | ||
} | ||
} |