From 5d5c61b5e05f48edfc793da4cd5d412897063eec Mon Sep 17 00:00:00 2001 From: Artem Vasyagin <58974140+Lunarelly@users.noreply.github.com> Date: Sun, 3 Nov 2024 19:01:35 +0300 Subject: [PATCH 1/3] AttackDamage, Rarity components (#142) --- src/item/ItemComponentsTrait.php | 14 +++++++++ src/item/component/AttackDamageComponent.php | 25 +++++++++++++++ src/item/component/RarityComponent.php | 32 ++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 src/item/component/AttackDamageComponent.php create mode 100644 src/item/component/RarityComponent.php diff --git a/src/item/ItemComponentsTrait.php b/src/item/ItemComponentsTrait.php index b6ad929..8a2553b 100644 --- a/src/item/ItemComponentsTrait.php +++ b/src/item/ItemComponentsTrait.php @@ -5,6 +5,7 @@ use customiesdevs\customies\item\component\AllowOffHandComponent; use customiesdevs\customies\item\component\ArmorComponent; +use customiesdevs\customies\item\component\AttackDamageComponent; use customiesdevs\customies\item\component\CanDestroyInCreativeComponent; use customiesdevs\customies\item\component\CooldownComponent; use customiesdevs\customies\item\component\CreativeCategoryComponent; @@ -30,6 +31,8 @@ use pocketmine\item\Durable; use pocketmine\item\Food; use pocketmine\item\ProjectileItem; +use pocketmine\item\Sword; +use pocketmine\item\Tool; use pocketmine\nbt\tag\CompoundTag; use RuntimeException; @@ -112,6 +115,17 @@ protected function initComponent(string $texture, ?CreativeInventoryInfo $creati if($this->getFuelTime() > 0) { $this->addComponent(new FuelComponent($this->getFuelTime())); } + + if($this->getAttackPoints() > 0) { + $this->addComponent(new AttackDamageComponent($this->getAttackPoints() - 1)); + } + + if($this instanceof Tool) { + $this->addComponent(new HandEquippedComponent()); + if ($this instanceof Sword) { + $this->addComponent(new CanDestroyInCreativeComponent(false)); + } + } } /** diff --git a/src/item/component/AttackDamageComponent.php b/src/item/component/AttackDamageComponent.php new file mode 100644 index 0000000..7c49483 --- /dev/null +++ b/src/item/component/AttackDamageComponent.php @@ -0,0 +1,25 @@ +damage = $damage; + } + + public function getName(): string { + return "damage"; + } + + public function getValue(): int { + return $this->damage; + } + + public function isProperty(): bool { + return true; + } +} \ No newline at end of file diff --git a/src/item/component/RarityComponent.php b/src/item/component/RarityComponent.php new file mode 100644 index 0000000..b15a370 --- /dev/null +++ b/src/item/component/RarityComponent.php @@ -0,0 +1,32 @@ +rarity = $rarity; + } + + public function getName(): string { + return "minecraft:rarity"; + } + + public function getValue(): array { + return [ + "value" => $this->rarity + ]; + } + + public function isProperty(): bool { + return false; + } +} \ No newline at end of file From 7f06d5c2dc66fc04ccd24c5135afbb0a6f2dfe29 Mon Sep 17 00:00:00 2001 From: "Florian S." <112857696+floriiian@users.noreply.github.com> Date: Sun, 3 Nov 2024 17:02:06 +0100 Subject: [PATCH 2/3] Update IconComponent.php (#138) Fixes the icon texture not showing up --- src/item/component/IconComponent.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/item/component/IconComponent.php b/src/item/component/IconComponent.php index 09c8b54..60147b3 100644 --- a/src/item/component/IconComponent.php +++ b/src/item/component/IconComponent.php @@ -17,6 +17,7 @@ public function getName(): string { public function getValue(): array { return [ + "texture" => $this->texture, "textures" => [ "default" => $this->texture ] From cb263ff74433096aa605e7f9315cf36f5bbc7314 Mon Sep 17 00:00:00 2001 From: Neopolitan <82135652+LuciaDX@users.noreply.github.com> Date: Sun, 3 Nov 2024 08:08:02 -0800 Subject: [PATCH 3/3] Add minecraft:use_modifiers component (#125) --- src/item/component/UseModifiersComponent.php | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/item/component/UseModifiersComponent.php diff --git a/src/item/component/UseModifiersComponent.php b/src/item/component/UseModifiersComponent.php new file mode 100644 index 0000000..16e7cb4 --- /dev/null +++ b/src/item/component/UseModifiersComponent.php @@ -0,0 +1,24 @@ + $this->movementModifier, + "use_duration" => $this->useDuration + ]; + } + + public function isProperty(): bool { + return false; + } +}