From d99e2a18688f109a7ef2c80f2d1f33ca73e6c210 Mon Sep 17 00:00:00 2001 From: SleepSpace9 Date: Sun, 4 Jun 2023 15:11:33 +0200 Subject: [PATCH 1/3] fix cooldown component --- .../item/properties/component/CooldownComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alvin0319/CustomItemLoader/item/properties/component/CooldownComponent.php b/src/alvin0319/CustomItemLoader/item/properties/component/CooldownComponent.php index aabde7f..5e3acf0 100644 --- a/src/alvin0319/CustomItemLoader/item/properties/component/CooldownComponent.php +++ b/src/alvin0319/CustomItemLoader/item/properties/component/CooldownComponent.php @@ -48,6 +48,6 @@ public function processComponent(CompoundTag $rootNBT) : void{ throw new InvalidNBTStateException("Component tree is not built"); } $cooldownTag->setString("category", "attack"); // TODO: Find out this - $cooldownTag->setFloat("value", $this->cooldown / 20); // maybe in tick + $cooldownTag->setFloat("duration", $this->cooldown / 20); // maybe in tick } } \ No newline at end of file From 6a0de8a55111ae6c384cfefb0839acf0393cd3d5 Mon Sep 17 00:00:00 2001 From: SleepSpace9 Date: Sun, 4 Jun 2023 22:29:34 +0200 Subject: [PATCH 2/3] Fix DisplayNameComponent The display_name compound tag is not nested in components, it's in the root. --- .../properties/component/DisplayNameComponent.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/alvin0319/CustomItemLoader/item/properties/component/DisplayNameComponent.php b/src/alvin0319/CustomItemLoader/item/properties/component/DisplayNameComponent.php index d246bc3..107c4c0 100644 --- a/src/alvin0319/CustomItemLoader/item/properties/component/DisplayNameComponent.php +++ b/src/alvin0319/CustomItemLoader/item/properties/component/DisplayNameComponent.php @@ -32,22 +32,18 @@ final class DisplayNameComponent extends Component{ public function __construct(private readonly string $displayName){ } public function getName() : string{ - return "texture"; + return "display_name"; } public function buildComponent(CompoundTag $rootNBT) : void{ - $componentTag = $rootNBT->getCompoundTag(Component::TAG_COMPONENTS); - if($componentTag === null){ - throw new InvalidNBTStateException("Component tree is not built"); - } - $componentTag->setTag(self::TAG_DISPLAY_NAME, CompoundTag::create()); + $rootNBT->setTag(self::TAG_DISPLAY_NAME, CompoundTag::create()); } public function processComponent(CompoundTag $rootNBT) : void{ - $displayNameTag = $rootNBT->getCompoundTag(Component::TAG_COMPONENTS)?->getCompoundTag(self::TAG_DISPLAY_NAME); + $displayNameTag = $rootNBT->getCompoundTag(self::TAG_DISPLAY_NAME); if($displayNameTag === null){ throw new InvalidNBTStateException("Component tree is not built"); } $displayNameTag->setString("value", $this->displayName); } -} \ No newline at end of file +} From fb4140b9800781f769e78033a42a6c5ce1231040 Mon Sep 17 00:00:00 2001 From: SleepSpace9 Date: Sun, 4 Jun 2023 22:41:44 +0200 Subject: [PATCH 3/3] Fix max_stack_size getting ignored from config --- .../CustomItemLoader/item/properties/CustomItemProperties.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/alvin0319/CustomItemLoader/item/properties/CustomItemProperties.php b/src/alvin0319/CustomItemLoader/item/properties/CustomItemProperties.php index e1f1fe7..ad8055b 100644 --- a/src/alvin0319/CustomItemLoader/item/properties/CustomItemProperties.php +++ b/src/alvin0319/CustomItemLoader/item/properties/CustomItemProperties.php @@ -158,7 +158,8 @@ private function parseData(array $data) : void{ $itemPropertiesComponent->addComponent("hand_equipped", $trueTag); } if(isset($data["max_stack_size"])){ - $itemPropertiesComponent->addComponent("max_stack_size", new IntTag($data["max_stack_size"])); + $this->max_stack_size = (int)$data["max_stack_size"]; + $itemPropertiesComponent->addComponent("max_stack_size", new IntTag($this->max_stack_size)); } // if(isset($data["mining_speed"])){ // $this->setMiningSpeed($data["mining_speed"]);