Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into pm5
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/item/component/IconComponent.php
  • Loading branch information
DavyCraft648 committed Nov 24, 2024
2 parents 23362f8 + cb263ff commit bee2bde
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/item/ItemComponentsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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));
}
}
}

/**
Expand Down
25 changes: 25 additions & 0 deletions src/item/component/AttackDamageComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);

namespace customiesdevs\customies\item\component;

final class AttackDamageComponent implements ItemComponent {

private int $damage;

public function __construct(int $damage) {
$this->damage = $damage;
}

public function getName(): string {
return "damage";
}

public function getValue(): int {
return $this->damage;
}

public function isProperty(): bool {
return true;
}
}
2 changes: 1 addition & 1 deletion src/item/component/IconComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function getName(): string {

public function getValue(): array {
return [
"texture" => $this->texture,
"texture" => $this->texture,
"textures" => [
"default" => $this->texture
]
Expand Down
32 changes: 32 additions & 0 deletions src/item/component/RarityComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);

namespace customiesdevs\customies\item\component;

final class RarityComponent implements ItemComponent {

public const COMMON = "common";
public const UNCOMMON = "uncommon";
public const RARE = "rare";
public const EPIC = "epic";

private string $rarity;

public function __construct(string $rarity) {
$this->rarity = $rarity;
}

public function getName(): string {
return "minecraft:rarity";
}

public function getValue(): array {
return [
"value" => $this->rarity
];
}

public function isProperty(): bool {
return false;
}
}
24 changes: 24 additions & 0 deletions src/item/component/UseModifiersComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);

namespace customiesdevs\customies\item\component;

final class UseModifiersComponent implements ItemComponent {

public function __construct(private float $movementModifier, private float $useDuration) {}

public function getName(): string {
return "minecraft:use_modifiers";
}

public function getValue(): array {
return [
"movement_modifier" => $this->movementModifier,
"use_duration" => $this->useDuration
];
}

public function isProperty(): bool {
return false;
}
}

0 comments on commit bee2bde

Please sign in to comment.