Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/item/ItemComponentsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use customiesdevs\customies\item\component\MaxStackSizeComponent;
use customiesdevs\customies\item\component\ProjectileComponent;
use customiesdevs\customies\item\component\ThrowableComponent;
use customiesdevs\customies\item\component\UnbreakableComponent;
use customiesdevs\customies\item\component\UseAnimationComponent;
use customiesdevs\customies\item\component\UseDurationComponent;
use customiesdevs\customies\item\component\WearableComponent;
Expand Down Expand Up @@ -123,6 +124,10 @@ protected function initComponent(string $texture, ?CreativeInventoryInfo $creati
$this->addComponent(new CanDestroyInCreativeComponent(false));
}
}

if($this instanceof Durable && $this->isUnbreakable()){
$this->addComponent(new UnbreakableComponent(true));
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/item/component/GlintComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(bool $glint = true) {
}

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

public function getValue(): bool {
Expand Down
2 changes: 1 addition & 1 deletion src/item/component/RecordComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class RecordComponent implements ItemComponent {
* @param float $duration Specifies duration of sound event in seconds, float value
* @param string $soundEvent Sound event type: 13, cat, blocks, chirp, far, mall, mellohi, stal, strad, ward, 11, wait, pigstep, otherside, 5, relic
*/
public function __construct(int $comparatorSignal = 1, float $duration, string $soundEvent = "undefined") {
public function __construct(float $duration, int $comparatorSignal = 1, string $soundEvent = "undefined") {
$this->comparatorSignal = $comparatorSignal;
$this->duration = $duration;
$this->soundEvent = $soundEvent;
Expand Down
30 changes: 30 additions & 0 deletions src/item/component/UnbreakableComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace customiesdevs\customies\item\component;

final class UnbreakableComponent implements ItemComponent
{

private bool $unbreakable;

/**
* Allows the item to be unbreakable, meaning it will not lose durability when used.
* @param bool $unbreakable If true, the item will not lose durability when used. Defaults to true.
*/
public function __construct(bool $unbreakable = true){
$this->unbreakable = $unbreakable;
}

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

public function getValue(): bool {
return $this->unbreakable;
}

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

}