Fix missing sound when a projectile strikes an amethyst block (#5382)

closes #5358
This commit is contained in:
zSALLAZAR 2022-11-15 15:50:05 +01:00 committed by GitHub
parent b3b8516661
commit 34839da757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 1 deletions

View File

@ -55,9 +55,13 @@ use pocketmine\block\tile\Skull as TileSkull;
use pocketmine\block\tile\Smoker as TileSmoker; use pocketmine\block\tile\Smoker as TileSmoker;
use pocketmine\block\utils\TreeType; use pocketmine\block\utils\TreeType;
use pocketmine\block\utils\WoodType; use pocketmine\block\utils\WoodType;
use pocketmine\entity\projectile\Projectile;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\ToolTier; use pocketmine\item\ToolTier;
use pocketmine\math\RayTraceResult;
use pocketmine\utils\CloningRegistryTrait; use pocketmine\utils\CloningRegistryTrait;
use pocketmine\world\sound\AmethystBlockChimeSound;
use pocketmine\world\sound\BlockPunchSound;
use function mb_strtolower; use function mb_strtolower;
/** /**
@ -1466,7 +1470,12 @@ final class VanillaBlocks{
private static function registerBlocksR17() : void{ private static function registerBlocksR17() : void{
//in java this can be acquired using any tool - seems to be a parity issue in bedrock //in java this can be acquired using any tool - seems to be a parity issue in bedrock
self::register("amethyst", new Opaque(new BID(Ids::AMETHYST), "Amethyst", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD())))); self::register("amethyst", new class(new BID(Ids::AMETHYST), "Amethyst", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD()))) extends Opaque{
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
$this->position->getWorld()->addSound($this->position, new AmethystBlockChimeSound());
$this->position->getWorld()->addSound($this->position, new BlockPunchSound($this));
}
});
self::register("calcite", new Opaque(new BID(Ids::CALCITE), "Calcite", new Info(BreakInfo::pickaxe(0.75, ToolTier::WOOD())))); self::register("calcite", new Opaque(new BID(Ids::CALCITE), "Calcite", new Info(BreakInfo::pickaxe(0.75, ToolTier::WOOD()))));
self::register("tuff", new Opaque(new BID(Ids::TUFF), "Tuff", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD(), 30.0)))); self::register("tuff", new Opaque(new BID(Ids::TUFF), "Tuff", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD(), 30.0))));

View File

@ -0,0 +1,35 @@
<?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\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
class AmethystBlockChimeSound implements Sound{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::AMETHYST_BLOCK_CHIME, $pos, false)];
}
}