From 7b95c78e83b9140adb6438ff211bde6f6cdbcb5c Mon Sep 17 00:00:00 2001 From: zSALLAZAR Date: Wed, 16 Nov 2022 11:28:51 +0100 Subject: [PATCH 1/5] Add missing sounds when equipping or unequipping armour using right-click --- src/item/Armor.php | 17 +++++++++++ src/world/sound/ArmorEquipChainSound.php | 35 ++++++++++++++++++++++ src/world/sound/ArmorEquipDiamondSound.php | 35 ++++++++++++++++++++++ src/world/sound/ArmorEquipGoldSound.php | 35 ++++++++++++++++++++++ src/world/sound/ArmorEquipIronSound.php | 35 ++++++++++++++++++++++ src/world/sound/ArmorEquipLeatherSound.php | 35 ++++++++++++++++++++++ 6 files changed, 192 insertions(+) create mode 100644 src/world/sound/ArmorEquipChainSound.php create mode 100644 src/world/sound/ArmorEquipDiamondSound.php create mode 100644 src/world/sound/ArmorEquipGoldSound.php create mode 100644 src/world/sound/ArmorEquipIronSound.php create mode 100644 src/world/sound/ArmorEquipLeatherSound.php diff --git a/src/item/Armor.php b/src/item/Armor.php index 8d77db8dc8e..cfc51b2dc03 100644 --- a/src/item/Armor.php +++ b/src/item/Armor.php @@ -33,6 +33,11 @@ use pocketmine\nbt\tag\IntTag; use pocketmine\player\Player; use pocketmine\utils\Binary; +use pocketmine\world\sound\ArmorEquipChainSound; +use pocketmine\world\sound\ArmorEquipDiamondSound; +use pocketmine\world\sound\ArmorEquipGoldSound; +use pocketmine\world\sound\ArmorEquipIronSound; +use pocketmine\world\sound\ArmorEquipLeatherSound; use function lcg_value; use function mt_rand; @@ -125,6 +130,18 @@ public function onClickAir(Player $player, Vector3 $directionVector) : ItemUseRe $thisCopy = clone $this; $new = $thisCopy->pop(); $player->getArmorInventory()->setItem($this->getArmorSlot(), $new); + $sound = match($this->getId()){ + ItemIds::TURTLE_HELMET, ItemIds::LEATHER_HELMET, ItemIds::LEATHER_CHESTPLATE, ItemIds::LEATHER_LEGGINGS, ItemIds::LEATHER_BOOTS => new ArmorEquipLeatherSound(), + ItemIds::CHAIN_HELMET, ItemIds::CHAIN_CHESTPLATE, ItemIds::CHAIN_LEGGINGS, ItemIds::CHAIN_BOOTS => new ArmorEquipChainSound(), + ItemIds::IRON_HELMET, ItemIds::IRON_CHESTPLATE, ItemIds::IRON_LEGGINGS, ItemIds::IRON_BOOTS => new ArmorEquipIronSound(), + ItemIds::DIAMOND_HELMET, ItemIds::DIAMOND_CHESTPLATE, ItemIds::DIAMOND_LEGGINGS, ItemIds::DIAMOND_BOOTS => new ArmorEquipDiamondSound(), + ItemIds::GOLD_HELMET, ItemIds::GOLD_CHESTPLATE, ItemIds::GOLD_LEGGINGS, ItemIds::GOLD_BOOTS => new ArmorEquipGoldSound(), + //TODO: Netherite equip sounds + default => null + }; + if($sound !== null){ + $player->getLocation()->getWorld()->addSound($player->getLocation(), $sound); + } if($thisCopy->getCount() === 0){ $player->getInventory()->setItemInHand($existing); }else{ //if the stack size was bigger than 1 (usually won't happen, but might be caused by plugins diff --git a/src/world/sound/ArmorEquipChainSound.php b/src/world/sound/ArmorEquipChainSound.php new file mode 100644 index 00000000000..efcb4f982e3 --- /dev/null +++ b/src/world/sound/ArmorEquipChainSound.php @@ -0,0 +1,35 @@ + Date: Mon, 13 Feb 2023 16:49:12 +0100 Subject: [PATCH 2/5] Requested changes --- src/item/Armor.php | 36 ++++++++++++++-------------- src/item/ItemFactory.php | 51 ++++++++++++++++++++++++---------------- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/item/Armor.php b/src/item/Armor.php index cfc51b2dc03..edfc3413ced 100644 --- a/src/item/Armor.php +++ b/src/item/Armor.php @@ -33,11 +33,7 @@ use pocketmine\nbt\tag\IntTag; use pocketmine\player\Player; use pocketmine\utils\Binary; -use pocketmine\world\sound\ArmorEquipChainSound; -use pocketmine\world\sound\ArmorEquipDiamondSound; -use pocketmine\world\sound\ArmorEquipGoldSound; -use pocketmine\world\sound\ArmorEquipIronSound; -use pocketmine\world\sound\ArmorEquipLeatherSound; +use pocketmine\world\sound\Sound; use function lcg_value; use function mt_rand; @@ -47,12 +43,15 @@ class Armor extends Durable{ private ArmorTypeInfo $armorInfo; + private ?Sound $equipSound; + /** @var Color|null */ protected $customColor = null; - public function __construct(ItemIdentifier $identifier, string $name, ArmorTypeInfo $info){ + public function __construct(ItemIdentifier $identifier, string $name, ArmorTypeInfo $info, ?Sound $equipSound = null){ parent::__construct($identifier, $name); $this->armorInfo = $info; + $this->equipSound = $equipSound; } public function getMaxDurability() : int{ @@ -74,6 +73,18 @@ public function getMaxStackSize() : int{ return 1; } + public function getEquipSound() : ?Sound{ + return $this->equipSound; + } + + /** + * @return $this + */ + public function setEquipSound(?Sound $equipSound) : self{ + $this->equipSound = $equipSound; + return $this; + } + /** * Returns the dyed colour of this armour piece. This generally only applies to leather armour. */ @@ -130,17 +141,8 @@ public function onClickAir(Player $player, Vector3 $directionVector) : ItemUseRe $thisCopy = clone $this; $new = $thisCopy->pop(); $player->getArmorInventory()->setItem($this->getArmorSlot(), $new); - $sound = match($this->getId()){ - ItemIds::TURTLE_HELMET, ItemIds::LEATHER_HELMET, ItemIds::LEATHER_CHESTPLATE, ItemIds::LEATHER_LEGGINGS, ItemIds::LEATHER_BOOTS => new ArmorEquipLeatherSound(), - ItemIds::CHAIN_HELMET, ItemIds::CHAIN_CHESTPLATE, ItemIds::CHAIN_LEGGINGS, ItemIds::CHAIN_BOOTS => new ArmorEquipChainSound(), - ItemIds::IRON_HELMET, ItemIds::IRON_CHESTPLATE, ItemIds::IRON_LEGGINGS, ItemIds::IRON_BOOTS => new ArmorEquipIronSound(), - ItemIds::DIAMOND_HELMET, ItemIds::DIAMOND_CHESTPLATE, ItemIds::DIAMOND_LEGGINGS, ItemIds::DIAMOND_BOOTS => new ArmorEquipDiamondSound(), - ItemIds::GOLD_HELMET, ItemIds::GOLD_CHESTPLATE, ItemIds::GOLD_LEGGINGS, ItemIds::GOLD_BOOTS => new ArmorEquipGoldSound(), - //TODO: Netherite equip sounds - default => null - }; - if($sound !== null){ - $player->getLocation()->getWorld()->addSound($player->getLocation(), $sound); + if($this->equipSound !== null){ + $player->getLocation()->getWorld()->addSound($player->getLocation(), $this->equipSound); } if($thisCopy->getCount() === 0){ $player->getInventory()->setItemInHand($existing); diff --git a/src/item/ItemFactory.php b/src/item/ItemFactory.php index 4a949f843ea..e849be02e0c 100644 --- a/src/item/ItemFactory.php +++ b/src/item/ItemFactory.php @@ -47,6 +47,11 @@ use pocketmine\nbt\NbtException; use pocketmine\nbt\tag\CompoundTag; use pocketmine\utils\SingletonTrait; +use pocketmine\world\sound\ArmorEquipChainSound; +use pocketmine\world\sound\ArmorEquipDiamondSound; +use pocketmine\world\sound\ArmorEquipGoldSound; +use pocketmine\world\sound\ArmorEquipIronSound; +use pocketmine\world\sound\ArmorEquipLeatherSound; use pocketmine\world\World; /** @@ -400,26 +405,32 @@ private function registerTierToolItems() : void{ } private function registerArmorItems() : void{ - $this->register(new Armor(new IID(Ids::CHAIN_BOOTS, 0), "Chainmail Boots", new ArmorTypeInfo(1, 196, ArmorInventory::SLOT_FEET))); - $this->register(new Armor(new IID(Ids::DIAMOND_BOOTS, 0), "Diamond Boots", new ArmorTypeInfo(3, 430, ArmorInventory::SLOT_FEET))); - $this->register(new Armor(new IID(Ids::GOLDEN_BOOTS, 0), "Golden Boots", new ArmorTypeInfo(1, 92, ArmorInventory::SLOT_FEET))); - $this->register(new Armor(new IID(Ids::IRON_BOOTS, 0), "Iron Boots", new ArmorTypeInfo(2, 196, ArmorInventory::SLOT_FEET))); - $this->register(new Armor(new IID(Ids::LEATHER_BOOTS, 0), "Leather Boots", new ArmorTypeInfo(1, 66, ArmorInventory::SLOT_FEET))); - $this->register(new Armor(new IID(Ids::CHAIN_CHESTPLATE, 0), "Chainmail Chestplate", new ArmorTypeInfo(5, 241, ArmorInventory::SLOT_CHEST))); - $this->register(new Armor(new IID(Ids::DIAMOND_CHESTPLATE, 0), "Diamond Chestplate", new ArmorTypeInfo(8, 529, ArmorInventory::SLOT_CHEST))); - $this->register(new Armor(new IID(Ids::GOLDEN_CHESTPLATE, 0), "Golden Chestplate", new ArmorTypeInfo(5, 113, ArmorInventory::SLOT_CHEST))); - $this->register(new Armor(new IID(Ids::IRON_CHESTPLATE, 0), "Iron Chestplate", new ArmorTypeInfo(6, 241, ArmorInventory::SLOT_CHEST))); - $this->register(new Armor(new IID(Ids::LEATHER_CHESTPLATE, 0), "Leather Tunic", new ArmorTypeInfo(3, 81, ArmorInventory::SLOT_CHEST))); - $this->register(new Armor(new IID(Ids::CHAIN_HELMET, 0), "Chainmail Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD))); - $this->register(new Armor(new IID(Ids::DIAMOND_HELMET, 0), "Diamond Helmet", new ArmorTypeInfo(3, 364, ArmorInventory::SLOT_HEAD))); - $this->register(new Armor(new IID(Ids::GOLDEN_HELMET, 0), "Golden Helmet", new ArmorTypeInfo(2, 78, ArmorInventory::SLOT_HEAD))); - $this->register(new Armor(new IID(Ids::IRON_HELMET, 0), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD))); - $this->register(new Armor(new IID(Ids::LEATHER_HELMET, 0), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD))); - $this->register(new Armor(new IID(Ids::CHAIN_LEGGINGS, 0), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS))); - $this->register(new Armor(new IID(Ids::DIAMOND_LEGGINGS, 0), "Diamond Leggings", new ArmorTypeInfo(6, 496, ArmorInventory::SLOT_LEGS))); - $this->register(new Armor(new IID(Ids::GOLDEN_LEGGINGS, 0), "Golden Leggings", new ArmorTypeInfo(3, 106, ArmorInventory::SLOT_LEGS))); - $this->register(new Armor(new IID(Ids::IRON_LEGGINGS, 0), "Iron Leggings", new ArmorTypeInfo(5, 226, ArmorInventory::SLOT_LEGS))); - $this->register(new Armor(new IID(Ids::LEATHER_LEGGINGS, 0), "Leather Pants", new ArmorTypeInfo(2, 76, ArmorInventory::SLOT_LEGS))); + $chainSound = new ArmorEquipChainSound(); + $diamondSound = new ArmorEquipDiamondSound(); + $goldSound = new ArmorEquipGoldSound(); + $ironSound = new ArmorEquipIronSound(); + $leatherSound = new ArmorEquipLeatherSound(); + + $this->register(new Armor(new IID(Ids::CHAIN_BOOTS, 0), "Chainmail Boots", new ArmorTypeInfo(1, 196, ArmorInventory::SLOT_FEET), $chainSound)); + $this->register(new Armor(new IID(Ids::DIAMOND_BOOTS, 0), "Diamond Boots", new ArmorTypeInfo(3, 430, ArmorInventory::SLOT_FEET), $diamondSound)); + $this->register(new Armor(new IID(Ids::GOLDEN_BOOTS, 0), "Golden Boots", new ArmorTypeInfo(1, 92, ArmorInventory::SLOT_FEET), $goldSound)); + $this->register(new Armor(new IID(Ids::IRON_BOOTS, 0), "Iron Boots", new ArmorTypeInfo(2, 196, ArmorInventory::SLOT_FEET), $ironSound)); + $this->register(new Armor(new IID(Ids::LEATHER_BOOTS, 0), "Leather Boots", new ArmorTypeInfo(1, 66, ArmorInventory::SLOT_FEET), $leatherSound)); + $this->register(new Armor(new IID(Ids::CHAIN_CHESTPLATE, 0), "Chainmail Chestplate", new ArmorTypeInfo(5, 241, ArmorInventory::SLOT_CHEST), $chainSound)); + $this->register(new Armor(new IID(Ids::DIAMOND_CHESTPLATE, 0), "Diamond Chestplate", new ArmorTypeInfo(8, 529, ArmorInventory::SLOT_CHEST), $diamondSound)); + $this->register(new Armor(new IID(Ids::GOLDEN_CHESTPLATE, 0), "Golden Chestplate", new ArmorTypeInfo(5, 113, ArmorInventory::SLOT_CHEST), $goldSound)); + $this->register(new Armor(new IID(Ids::IRON_CHESTPLATE, 0), "Iron Chestplate", new ArmorTypeInfo(6, 241, ArmorInventory::SLOT_CHEST), $ironSound)); + $this->register(new Armor(new IID(Ids::LEATHER_CHESTPLATE, 0), "Leather Tunic", new ArmorTypeInfo(3, 81, ArmorInventory::SLOT_CHEST), $leatherSound)); + $this->register(new Armor(new IID(Ids::CHAIN_HELMET, 0), "Chainmail Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD), $chainSound)); + $this->register(new Armor(new IID(Ids::DIAMOND_HELMET, 0), "Diamond Helmet", new ArmorTypeInfo(3, 364, ArmorInventory::SLOT_HEAD), $diamondSound)); + $this->register(new Armor(new IID(Ids::GOLDEN_HELMET, 0), "Golden Helmet", new ArmorTypeInfo(2, 78, ArmorInventory::SLOT_HEAD), $goldSound)); + $this->register(new Armor(new IID(Ids::IRON_HELMET, 0), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD), $ironSound)); + $this->register(new Armor(new IID(Ids::LEATHER_HELMET, 0), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD), $leatherSound)); + $this->register(new Armor(new IID(Ids::CHAIN_LEGGINGS, 0), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS), $chainSound)); + $this->register(new Armor(new IID(Ids::DIAMOND_LEGGINGS, 0), "Diamond Leggings", new ArmorTypeInfo(6, 496, ArmorInventory::SLOT_LEGS), $diamondSound)); + $this->register(new Armor(new IID(Ids::GOLDEN_LEGGINGS, 0), "Golden Leggings", new ArmorTypeInfo(3, 106, ArmorInventory::SLOT_LEGS), $goldSound)); + $this->register(new Armor(new IID(Ids::IRON_LEGGINGS, 0), "Iron Leggings", new ArmorTypeInfo(5, 226, ArmorInventory::SLOT_LEGS), $ironSound)); + $this->register(new Armor(new IID(Ids::LEATHER_LEGGINGS, 0), "Leather Pants", new ArmorTypeInfo(2, 76, ArmorInventory::SLOT_LEGS), $leatherSound)); } /** From 32e11fbad681357b40884d5b3f87582f200a9d1f Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 Date: Mon, 17 Jul 2023 18:44:34 +0200 Subject: [PATCH 3/5] fix: implement sound for PM5 --- src/item/VanillaItems.php | 51 ++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index b7c32ebc111..e41838bb343 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -37,6 +37,11 @@ use pocketmine\math\Vector3; use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\CloningRegistryTrait; +use pocketmine\world\sound\ArmorEquipChainSound; +use pocketmine\world\sound\ArmorEquipDiamondSound; +use pocketmine\world\sound\ArmorEquipGoldSound; +use pocketmine\world\sound\ArmorEquipIronSound; +use pocketmine\world\sound\ArmorEquipLeatherSound; use pocketmine\world\World; /** @@ -610,33 +615,39 @@ private static function registerTierToolItems() : void{ } private static function registerArmorItems() : void{ - self::register("chainmail_boots", new Armor(new IID(Ids::CHAINMAIL_BOOTS), "Chainmail Boots", new ArmorTypeInfo(1, 196, ArmorInventory::SLOT_FEET))); - self::register("diamond_boots", new Armor(new IID(Ids::DIAMOND_BOOTS), "Diamond Boots", new ArmorTypeInfo(3, 430, ArmorInventory::SLOT_FEET, 2))); - self::register("golden_boots", new Armor(new IID(Ids::GOLDEN_BOOTS), "Golden Boots", new ArmorTypeInfo(1, 92, ArmorInventory::SLOT_FEET))); - self::register("iron_boots", new Armor(new IID(Ids::IRON_BOOTS), "Iron Boots", new ArmorTypeInfo(2, 196, ArmorInventory::SLOT_FEET))); - self::register("leather_boots", new Armor(new IID(Ids::LEATHER_BOOTS), "Leather Boots", new ArmorTypeInfo(1, 66, ArmorInventory::SLOT_FEET))); + $chainSound = new ArmorEquipChainSound(); + $diamondSound = new ArmorEquipDiamondSound(); + $goldSound = new ArmorEquipGoldSound(); + $ironSound = new ArmorEquipIronSound(); + $leatherSound = new ArmorEquipLeatherSound(); + + self::register("chainmail_boots", new Armor(new IID(Ids::CHAINMAIL_BOOTS), "Chainmail Boots", new ArmorTypeInfo(1, 196, ArmorInventory::SLOT_FEET), $chainSound)); + self::register("diamond_boots", new Armor(new IID(Ids::DIAMOND_BOOTS), "Diamond Boots", new ArmorTypeInfo(3, 430, ArmorInventory::SLOT_FEET, 2), $diamondSound)); + self::register("golden_boots", new Armor(new IID(Ids::GOLDEN_BOOTS), "Golden Boots", new ArmorTypeInfo(1, 92, ArmorInventory::SLOT_FEET), $goldSound)); + self::register("iron_boots", new Armor(new IID(Ids::IRON_BOOTS), "Iron Boots", new ArmorTypeInfo(2, 196, ArmorInventory::SLOT_FEET), $ironSound)); + self::register("leather_boots", new Armor(new IID(Ids::LEATHER_BOOTS), "Leather Boots", new ArmorTypeInfo(1, 66, ArmorInventory::SLOT_FEET), $leatherSound)); self::register("netherite_boots", new Armor(new IID(Ids::NETHERITE_BOOTS), "Netherite Boots", new ArmorTypeInfo(3, 482, ArmorInventory::SLOT_FEET, 3, true))); - self::register("chainmail_chestplate", new Armor(new IID(Ids::CHAINMAIL_CHESTPLATE), "Chainmail Chestplate", new ArmorTypeInfo(5, 241, ArmorInventory::SLOT_CHEST))); - self::register("diamond_chestplate", new Armor(new IID(Ids::DIAMOND_CHESTPLATE), "Diamond Chestplate", new ArmorTypeInfo(8, 529, ArmorInventory::SLOT_CHEST, 2))); - self::register("golden_chestplate", new Armor(new IID(Ids::GOLDEN_CHESTPLATE), "Golden Chestplate", new ArmorTypeInfo(5, 113, ArmorInventory::SLOT_CHEST))); - self::register("iron_chestplate", new Armor(new IID(Ids::IRON_CHESTPLATE), "Iron Chestplate", new ArmorTypeInfo(6, 241, ArmorInventory::SLOT_CHEST))); - self::register("leather_tunic", new Armor(new IID(Ids::LEATHER_TUNIC), "Leather Tunic", new ArmorTypeInfo(3, 81, ArmorInventory::SLOT_CHEST))); + self::register("chainmail_chestplate", new Armor(new IID(Ids::CHAINMAIL_CHESTPLATE), "Chainmail Chestplate", new ArmorTypeInfo(5, 241, ArmorInventory::SLOT_CHEST), $chainSound)); + self::register("diamond_chestplate", new Armor(new IID(Ids::DIAMOND_CHESTPLATE), "Diamond Chestplate", new ArmorTypeInfo(8, 529, ArmorInventory::SLOT_CHEST, 2), $diamondSound)); + self::register("golden_chestplate", new Armor(new IID(Ids::GOLDEN_CHESTPLATE), "Golden Chestplate", new ArmorTypeInfo(5, 113, ArmorInventory::SLOT_CHEST), $goldSound)); + self::register("iron_chestplate", new Armor(new IID(Ids::IRON_CHESTPLATE), "Iron Chestplate", new ArmorTypeInfo(6, 241, ArmorInventory::SLOT_CHEST), $ironSound)); + self::register("leather_tunic", new Armor(new IID(Ids::LEATHER_TUNIC), "Leather Tunic", new ArmorTypeInfo(3, 81, ArmorInventory::SLOT_CHEST), $leatherSound)); self::register("netherite_chestplate", new Armor(new IID(Ids::NETHERITE_CHESTPLATE), "Netherite Chestplate", new ArmorTypeInfo(8, 593, ArmorInventory::SLOT_CHEST, 3, true))); - self::register("chainmail_helmet", new Armor(new IID(Ids::CHAINMAIL_HELMET), "Chainmail Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD))); - self::register("diamond_helmet", new Armor(new IID(Ids::DIAMOND_HELMET), "Diamond Helmet", new ArmorTypeInfo(3, 364, ArmorInventory::SLOT_HEAD, 2))); - self::register("golden_helmet", new Armor(new IID(Ids::GOLDEN_HELMET), "Golden Helmet", new ArmorTypeInfo(2, 78, ArmorInventory::SLOT_HEAD))); - self::register("iron_helmet", new Armor(new IID(Ids::IRON_HELMET), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD))); - self::register("leather_cap", new Armor(new IID(Ids::LEATHER_CAP), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD))); + self::register("chainmail_helmet", new Armor(new IID(Ids::CHAINMAIL_HELMET), "Chainmail Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD), $chainSound)); + self::register("diamond_helmet", new Armor(new IID(Ids::DIAMOND_HELMET), "Diamond Helmet", new ArmorTypeInfo(3, 364, ArmorInventory::SLOT_HEAD, 2), $diamondSound)); + self::register("golden_helmet", new Armor(new IID(Ids::GOLDEN_HELMET), "Golden Helmet", new ArmorTypeInfo(2, 78, ArmorInventory::SLOT_HEAD), $goldSound)); + self::register("iron_helmet", new Armor(new IID(Ids::IRON_HELMET), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD), $ironSound)); + self::register("leather_cap", new Armor(new IID(Ids::LEATHER_CAP), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD), $leatherSound)); self::register("netherite_helmet", new Armor(new IID(Ids::NETHERITE_HELMET), "Netherite Helmet", new ArmorTypeInfo(3, 408, ArmorInventory::SLOT_HEAD, 3, true))); self::register("turtle_helmet", new TurtleHelmet(new IID(Ids::TURTLE_HELMET), "Turtle Shell", new ArmorTypeInfo(2, 276, ArmorInventory::SLOT_HEAD))); - self::register("chainmail_leggings", new Armor(new IID(Ids::CHAINMAIL_LEGGINGS), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS))); - self::register("diamond_leggings", new Armor(new IID(Ids::DIAMOND_LEGGINGS), "Diamond Leggings", new ArmorTypeInfo(6, 496, ArmorInventory::SLOT_LEGS, 2))); - self::register("golden_leggings", new Armor(new IID(Ids::GOLDEN_LEGGINGS), "Golden Leggings", new ArmorTypeInfo(3, 106, ArmorInventory::SLOT_LEGS))); - self::register("iron_leggings", new Armor(new IID(Ids::IRON_LEGGINGS), "Iron Leggings", new ArmorTypeInfo(5, 226, ArmorInventory::SLOT_LEGS))); - self::register("leather_pants", new Armor(new IID(Ids::LEATHER_PANTS), "Leather Pants", new ArmorTypeInfo(2, 76, ArmorInventory::SLOT_LEGS))); + self::register("chainmail_leggings", new Armor(new IID(Ids::CHAINMAIL_LEGGINGS), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS), $chainSound)); + self::register("diamond_leggings", new Armor(new IID(Ids::DIAMOND_LEGGINGS), "Diamond Leggings", new ArmorTypeInfo(6, 496, ArmorInventory::SLOT_LEGS, 2), $diamondSound)); + self::register("golden_leggings", new Armor(new IID(Ids::GOLDEN_LEGGINGS), "Golden Leggings", new ArmorTypeInfo(3, 106, ArmorInventory::SLOT_LEGS), $goldSound)); + self::register("iron_leggings", new Armor(new IID(Ids::IRON_LEGGINGS), "Iron Leggings", new ArmorTypeInfo(5, 226, ArmorInventory::SLOT_LEGS), $ironSound)); + self::register("leather_pants", new Armor(new IID(Ids::LEATHER_PANTS), "Leather Pants", new ArmorTypeInfo(2, 76, ArmorInventory::SLOT_LEGS), $leatherSound)); self::register("netherite_leggings", new Armor(new IID(Ids::NETHERITE_LEGGINGS), "Netherite Leggings", new ArmorTypeInfo(6, 556, ArmorInventory::SLOT_LEGS, 3, true))); } From ef34cde2bb9de865136ba2b3e1d61bece82cccc9 Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 Date: Mon, 17 Jul 2023 18:46:27 +0200 Subject: [PATCH 4/5] add netherite sound --- src/item/VanillaItems.php | 10 +++--- src/world/sound/ArmorEquipNetheriteSound.php | 35 ++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 src/world/sound/ArmorEquipNetheriteSound.php diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index e41838bb343..55adfc65591 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -42,6 +42,7 @@ use pocketmine\world\sound\ArmorEquipGoldSound; use pocketmine\world\sound\ArmorEquipIronSound; use pocketmine\world\sound\ArmorEquipLeatherSound; +use pocketmine\world\sound\ArmorEquipNetheriteSound; use pocketmine\world\World; /** @@ -620,27 +621,28 @@ private static function registerArmorItems() : void{ $goldSound = new ArmorEquipGoldSound(); $ironSound = new ArmorEquipIronSound(); $leatherSound = new ArmorEquipLeatherSound(); + $netheriteSound = new ArmorEquipNetheriteSound(); self::register("chainmail_boots", new Armor(new IID(Ids::CHAINMAIL_BOOTS), "Chainmail Boots", new ArmorTypeInfo(1, 196, ArmorInventory::SLOT_FEET), $chainSound)); self::register("diamond_boots", new Armor(new IID(Ids::DIAMOND_BOOTS), "Diamond Boots", new ArmorTypeInfo(3, 430, ArmorInventory::SLOT_FEET, 2), $diamondSound)); self::register("golden_boots", new Armor(new IID(Ids::GOLDEN_BOOTS), "Golden Boots", new ArmorTypeInfo(1, 92, ArmorInventory::SLOT_FEET), $goldSound)); self::register("iron_boots", new Armor(new IID(Ids::IRON_BOOTS), "Iron Boots", new ArmorTypeInfo(2, 196, ArmorInventory::SLOT_FEET), $ironSound)); self::register("leather_boots", new Armor(new IID(Ids::LEATHER_BOOTS), "Leather Boots", new ArmorTypeInfo(1, 66, ArmorInventory::SLOT_FEET), $leatherSound)); - self::register("netherite_boots", new Armor(new IID(Ids::NETHERITE_BOOTS), "Netherite Boots", new ArmorTypeInfo(3, 482, ArmorInventory::SLOT_FEET, 3, true))); + self::register("netherite_boots", new Armor(new IID(Ids::NETHERITE_BOOTS), "Netherite Boots", new ArmorTypeInfo(3, 482, ArmorInventory::SLOT_FEET, 3, true), $netheriteSound)); self::register("chainmail_chestplate", new Armor(new IID(Ids::CHAINMAIL_CHESTPLATE), "Chainmail Chestplate", new ArmorTypeInfo(5, 241, ArmorInventory::SLOT_CHEST), $chainSound)); self::register("diamond_chestplate", new Armor(new IID(Ids::DIAMOND_CHESTPLATE), "Diamond Chestplate", new ArmorTypeInfo(8, 529, ArmorInventory::SLOT_CHEST, 2), $diamondSound)); self::register("golden_chestplate", new Armor(new IID(Ids::GOLDEN_CHESTPLATE), "Golden Chestplate", new ArmorTypeInfo(5, 113, ArmorInventory::SLOT_CHEST), $goldSound)); self::register("iron_chestplate", new Armor(new IID(Ids::IRON_CHESTPLATE), "Iron Chestplate", new ArmorTypeInfo(6, 241, ArmorInventory::SLOT_CHEST), $ironSound)); self::register("leather_tunic", new Armor(new IID(Ids::LEATHER_TUNIC), "Leather Tunic", new ArmorTypeInfo(3, 81, ArmorInventory::SLOT_CHEST), $leatherSound)); - self::register("netherite_chestplate", new Armor(new IID(Ids::NETHERITE_CHESTPLATE), "Netherite Chestplate", new ArmorTypeInfo(8, 593, ArmorInventory::SLOT_CHEST, 3, true))); + self::register("netherite_chestplate", new Armor(new IID(Ids::NETHERITE_CHESTPLATE), "Netherite Chestplate", new ArmorTypeInfo(8, 593, ArmorInventory::SLOT_CHEST, 3, true), $netheriteSound)); self::register("chainmail_helmet", new Armor(new IID(Ids::CHAINMAIL_HELMET), "Chainmail Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD), $chainSound)); self::register("diamond_helmet", new Armor(new IID(Ids::DIAMOND_HELMET), "Diamond Helmet", new ArmorTypeInfo(3, 364, ArmorInventory::SLOT_HEAD, 2), $diamondSound)); self::register("golden_helmet", new Armor(new IID(Ids::GOLDEN_HELMET), "Golden Helmet", new ArmorTypeInfo(2, 78, ArmorInventory::SLOT_HEAD), $goldSound)); self::register("iron_helmet", new Armor(new IID(Ids::IRON_HELMET), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD), $ironSound)); self::register("leather_cap", new Armor(new IID(Ids::LEATHER_CAP), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD), $leatherSound)); - self::register("netherite_helmet", new Armor(new IID(Ids::NETHERITE_HELMET), "Netherite Helmet", new ArmorTypeInfo(3, 408, ArmorInventory::SLOT_HEAD, 3, true))); + self::register("netherite_helmet", new Armor(new IID(Ids::NETHERITE_HELMET), "Netherite Helmet", new ArmorTypeInfo(3, 408, ArmorInventory::SLOT_HEAD, 3, true), $netheriteSound)); self::register("turtle_helmet", new TurtleHelmet(new IID(Ids::TURTLE_HELMET), "Turtle Shell", new ArmorTypeInfo(2, 276, ArmorInventory::SLOT_HEAD))); self::register("chainmail_leggings", new Armor(new IID(Ids::CHAINMAIL_LEGGINGS), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS), $chainSound)); @@ -648,7 +650,7 @@ private static function registerArmorItems() : void{ self::register("golden_leggings", new Armor(new IID(Ids::GOLDEN_LEGGINGS), "Golden Leggings", new ArmorTypeInfo(3, 106, ArmorInventory::SLOT_LEGS), $goldSound)); self::register("iron_leggings", new Armor(new IID(Ids::IRON_LEGGINGS), "Iron Leggings", new ArmorTypeInfo(5, 226, ArmorInventory::SLOT_LEGS), $ironSound)); self::register("leather_pants", new Armor(new IID(Ids::LEATHER_PANTS), "Leather Pants", new ArmorTypeInfo(2, 76, ArmorInventory::SLOT_LEGS), $leatherSound)); - self::register("netherite_leggings", new Armor(new IID(Ids::NETHERITE_LEGGINGS), "Netherite Leggings", new ArmorTypeInfo(6, 556, ArmorInventory::SLOT_LEGS, 3, true))); + self::register("netherite_leggings", new Armor(new IID(Ids::NETHERITE_LEGGINGS), "Netherite Leggings", new ArmorTypeInfo(6, 556, ArmorInventory::SLOT_LEGS, 3, true), $netheriteSound)); } } diff --git a/src/world/sound/ArmorEquipNetheriteSound.php b/src/world/sound/ArmorEquipNetheriteSound.php new file mode 100644 index 00000000000..a75c461060a --- /dev/null +++ b/src/world/sound/ArmorEquipNetheriteSound.php @@ -0,0 +1,35 @@ + Date: Mon, 17 Jul 2023 18:50:33 +0200 Subject: [PATCH 5/5] remove dead code + add generic sound for turtle helmet --- src/item/Armor.php | 8 ----- src/item/VanillaItems.php | 4 ++- src/world/sound/ArmorEquipGenericSound.php | 35 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 src/world/sound/ArmorEquipGenericSound.php diff --git a/src/item/Armor.php b/src/item/Armor.php index 0da7cfaebde..7295baa1a3a 100644 --- a/src/item/Armor.php +++ b/src/item/Armor.php @@ -80,14 +80,6 @@ public function getEquipSound() : ?Sound{ return $this->equipSound; } - /** - * @return $this - */ - public function setEquipSound(?Sound $equipSound) : self{ - $this->equipSound = $equipSound; - return $this; - } - /** * Returns the dyed colour of this armour piece. This generally only applies to leather armour. */ diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index 55adfc65591..ea7d3ec9905 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -39,6 +39,7 @@ use pocketmine\utils\CloningRegistryTrait; use pocketmine\world\sound\ArmorEquipChainSound; use pocketmine\world\sound\ArmorEquipDiamondSound; +use pocketmine\world\sound\ArmorEquipGenericSound; use pocketmine\world\sound\ArmorEquipGoldSound; use pocketmine\world\sound\ArmorEquipIronSound; use pocketmine\world\sound\ArmorEquipLeatherSound; @@ -622,6 +623,7 @@ private static function registerArmorItems() : void{ $ironSound = new ArmorEquipIronSound(); $leatherSound = new ArmorEquipLeatherSound(); $netheriteSound = new ArmorEquipNetheriteSound(); + $genericSound = new ArmorEquipGenericSound(); self::register("chainmail_boots", new Armor(new IID(Ids::CHAINMAIL_BOOTS), "Chainmail Boots", new ArmorTypeInfo(1, 196, ArmorInventory::SLOT_FEET), $chainSound)); self::register("diamond_boots", new Armor(new IID(Ids::DIAMOND_BOOTS), "Diamond Boots", new ArmorTypeInfo(3, 430, ArmorInventory::SLOT_FEET, 2), $diamondSound)); @@ -643,7 +645,7 @@ private static function registerArmorItems() : void{ self::register("iron_helmet", new Armor(new IID(Ids::IRON_HELMET), "Iron Helmet", new ArmorTypeInfo(2, 166, ArmorInventory::SLOT_HEAD), $ironSound)); self::register("leather_cap", new Armor(new IID(Ids::LEATHER_CAP), "Leather Cap", new ArmorTypeInfo(1, 56, ArmorInventory::SLOT_HEAD), $leatherSound)); self::register("netherite_helmet", new Armor(new IID(Ids::NETHERITE_HELMET), "Netherite Helmet", new ArmorTypeInfo(3, 408, ArmorInventory::SLOT_HEAD, 3, true), $netheriteSound)); - self::register("turtle_helmet", new TurtleHelmet(new IID(Ids::TURTLE_HELMET), "Turtle Shell", new ArmorTypeInfo(2, 276, ArmorInventory::SLOT_HEAD))); + self::register("turtle_helmet", new TurtleHelmet(new IID(Ids::TURTLE_HELMET), "Turtle Shell", new ArmorTypeInfo(2, 276, ArmorInventory::SLOT_HEAD), $genericSound)); self::register("chainmail_leggings", new Armor(new IID(Ids::CHAINMAIL_LEGGINGS), "Chainmail Leggings", new ArmorTypeInfo(4, 226, ArmorInventory::SLOT_LEGS), $chainSound)); self::register("diamond_leggings", new Armor(new IID(Ids::DIAMOND_LEGGINGS), "Diamond Leggings", new ArmorTypeInfo(6, 496, ArmorInventory::SLOT_LEGS, 2), $diamondSound)); diff --git a/src/world/sound/ArmorEquipGenericSound.php b/src/world/sound/ArmorEquipGenericSound.php new file mode 100644 index 00000000000..c11567bdd5d --- /dev/null +++ b/src/world/sound/ArmorEquipGenericSound.php @@ -0,0 +1,35 @@ +