diff --git a/src/block/inventory/EnchantInventory.php b/src/block/inventory/EnchantInventory.php index 7b79ef21c..b726dbedf 100644 --- a/src/block/inventory/EnchantInventory.php +++ b/src/block/inventory/EnchantInventory.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace pocketmine\block\inventory; -use pocketmine\event\player\PlayerEnchantOptionsRequestEvent; +use pocketmine\event\player\PlayerEnchantingOptionsRequestEvent; use pocketmine\inventory\SimpleInventory; use pocketmine\inventory\TemporaryInventory; -use pocketmine\item\enchantment\EnchantHelper as Helper; -use pocketmine\item\enchantment\EnchantOption; +use pocketmine\item\enchantment\EnchantingHelper as Helper; +use pocketmine\item\enchantment\EnchantingOption; use pocketmine\item\Item; use pocketmine\world\Position; use function array_values; @@ -39,7 +39,7 @@ class EnchantInventory extends SimpleInventory implements BlockInventory, Tempor public const SLOT_INPUT = 0; public const SLOT_LAPIS = 1; - /** @var EnchantOption[] $options */ + /** @var EnchantingOption[] $options */ private array $options = []; public function __construct(Position $holder){ @@ -54,7 +54,7 @@ class EnchantInventory extends SimpleInventory implements BlockInventory, Tempor $item = $this->getInput(); $options = Helper::generateOptions($this->holder, $item, $viewer->getEnchantmentSeed()); - $event = new PlayerEnchantOptionsRequestEvent($viewer, $this, $options); + $event = new PlayerEnchantingOptionsRequestEvent($viewer, $this, $options); $event->call(); if(!$event->isCancelled() && count($event->getOptions()) > 0){ $this->options = array_values($event->getOptions()); @@ -79,7 +79,7 @@ class EnchantInventory extends SimpleInventory implements BlockInventory, Tempor return $option === null ? null : Helper::enchantItem($this->getInput(), $option->getEnchantments()); } - public function getOption(int $optionId) : ?EnchantOption{ + public function getOption(int $optionId) : ?EnchantingOption{ return $this->options[$optionId] ?? null; } } diff --git a/src/command/defaults/EnchantCommand.php b/src/command/defaults/EnchantCommand.php index ea1ead195..191a146b0 100644 --- a/src/command/defaults/EnchantCommand.php +++ b/src/command/defaults/EnchantCommand.php @@ -25,7 +25,7 @@ namespace pocketmine\command\defaults; use pocketmine\command\CommandSender; use pocketmine\command\utils\InvalidCommandSyntaxException; -use pocketmine\item\enchantment\EnchantHelper; +use pocketmine\item\enchantment\EnchantingHelper; use pocketmine\item\enchantment\EnchantmentInstance; use pocketmine\item\enchantment\StringToEnchantmentParser; use pocketmine\lang\KnownTranslationFactory; @@ -78,7 +78,7 @@ class EnchantCommand extends VanillaCommand{ } //this is necessary to deal with enchanted books, which are a different item type than regular books - $enchantedItem = EnchantHelper::enchantItem($item, [new EnchantmentInstance($enchantment, $level)]); + $enchantedItem = EnchantingHelper::enchantItem($item, [new EnchantmentInstance($enchantment, $level)]); $player->getInventory()->setItemInHand($enchantedItem); self::broadcastCommandMessage($sender, KnownTranslationFactory::commands_enchant_success($player->getName())); diff --git a/src/entity/Human.php b/src/entity/Human.php index 01da0cf9a..f2c4c7a74 100644 --- a/src/entity/Human.php +++ b/src/entity/Human.php @@ -37,7 +37,7 @@ use pocketmine\inventory\InventoryHolder; use pocketmine\inventory\PlayerEnderInventory; use pocketmine\inventory\PlayerInventory; use pocketmine\inventory\PlayerOffHandInventory; -use pocketmine\item\enchantment\EnchantHelper; +use pocketmine\item\enchantment\EnchantingHelper; use pocketmine\item\enchantment\VanillaEnchantments; use pocketmine\item\Item; use pocketmine\item\Totem; @@ -219,7 +219,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{ } public function regenerateEnchantmentSeed() : void{ - $this->xpSeed = EnchantHelper::generateSeed(); + $this->xpSeed = EnchantingHelper::generateSeed(); } public function getXpDropAmount() : int{ @@ -345,7 +345,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{ if(($xpSeedTag = $nbt->getTag(self::TAG_XP_SEED)) instanceof IntTag){ $this->xpSeed = $xpSeedTag->getValue(); }else{ - $this->xpSeed = EnchantHelper::generateSeed(); + $this->xpSeed = EnchantingHelper::generateSeed(); } } diff --git a/src/event/player/PlayerEnchantOptionsRequestEvent.php b/src/event/player/PlayerEnchantingOptionsRequestEvent.php similarity index 78% rename from src/event/player/PlayerEnchantOptionsRequestEvent.php rename to src/event/player/PlayerEnchantingOptionsRequestEvent.php index d0448bfd8..833185f76 100644 --- a/src/event/player/PlayerEnchantOptionsRequestEvent.php +++ b/src/event/player/PlayerEnchantingOptionsRequestEvent.php @@ -27,7 +27,7 @@ use pocketmine\block\inventory\EnchantInventory; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; use pocketmine\event\Event; -use pocketmine\item\enchantment\EnchantOption; +use pocketmine\item\enchantment\EnchantingOption; use pocketmine\player\Player; use pocketmine\utils\Utils; use function count; @@ -36,36 +36,36 @@ use function count; * Called when a player inserts an item into an enchanting table's input slot. * The options provided by the event will be shown on the enchanting table menu. */ -class PlayerEnchantOptionsRequestEvent extends PlayerEvent implements Cancellable{ +class PlayerEnchantingOptionsRequestEvent extends PlayerEvent implements Cancellable{ use CancellableTrait; /** - * @param EnchantOption[] $options + * @param EnchantingOption[] $options */ public function __construct( Player $player, - private readonly EnchantInventory $enchantInventory, + private readonly EnchantInventory $inventory, private array $options ){ $this->player = $player; } - public function getEnchantInventory() : EnchantInventory{ - return $this->enchantInventory; + public function getInventory() : EnchantInventory{ + return $this->inventory; } /** - * @return EnchantOption[] + * @return EnchantingOption[] */ public function getOptions() : array{ return $this->options; } /** - * @param EnchantOption[] $options + * @param EnchantingOption[] $options */ public function setOptions(array $options) : void{ - Utils::validateArrayValueType($options, function(EnchantOption $_) : void{ }); + Utils::validateArrayValueType($options, function(EnchantingOption $_) : void{ }); if(($optionCount = count($options)) > 3){ throw new \LogicException("The maximum number of options for an enchanting table is 3, but $optionCount have been passed"); } diff --git a/src/event/player/PlayerItemEnchantEvent.php b/src/event/player/PlayerItemEnchantEvent.php index 9974ab40a..76151384d 100644 --- a/src/event/player/PlayerItemEnchantEvent.php +++ b/src/event/player/PlayerItemEnchantEvent.php @@ -25,8 +25,8 @@ namespace pocketmine\event\player; use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; -use pocketmine\inventory\transaction\EnchantTransaction; -use pocketmine\item\enchantment\EnchantOption; +use pocketmine\inventory\transaction\EnchantingTransaction; +use pocketmine\item\enchantment\EnchantingOption; use pocketmine\item\Item; use pocketmine\player\Player; @@ -38,8 +38,8 @@ class PlayerItemEnchantEvent extends PlayerEvent implements Cancellable{ public function __construct( Player $player, - private readonly EnchantTransaction $transaction, - private readonly EnchantOption $option, + private readonly EnchantingTransaction $transaction, + private readonly EnchantingOption $option, private readonly Item $inputItem, private readonly Item $outputItem, private readonly int $cost @@ -50,14 +50,14 @@ class PlayerItemEnchantEvent extends PlayerEvent implements Cancellable{ /** * Returns the inventory transaction involved in this enchant event. */ - public function getTransaction() : EnchantTransaction{ + public function getTransaction() : EnchantingTransaction{ return $this->transaction; } /** * Returns the enchantment option used. */ - public function getOption() : EnchantOption{ + public function getOption() : EnchantingOption{ return $this->option; } diff --git a/src/inventory/transaction/EnchantTransaction.php b/src/inventory/transaction/EnchantingTransaction.php similarity index 93% rename from src/inventory/transaction/EnchantTransaction.php rename to src/inventory/transaction/EnchantingTransaction.php index 01e8043ec..d00df97e2 100644 --- a/src/inventory/transaction/EnchantTransaction.php +++ b/src/inventory/transaction/EnchantingTransaction.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\inventory\transaction; use pocketmine\event\player\PlayerItemEnchantEvent; -use pocketmine\item\enchantment\EnchantHelper; -use pocketmine\item\enchantment\EnchantOption; +use pocketmine\item\enchantment\EnchantingHelper; +use pocketmine\item\enchantment\EnchantingOption; use pocketmine\item\Item; use pocketmine\item\ItemTypeIds; use pocketmine\player\Player; @@ -33,14 +33,14 @@ use pocketmine\utils\AssumptionFailedError; use function count; use function min; -class EnchantTransaction extends InventoryTransaction{ +class EnchantingTransaction extends InventoryTransaction{ private ?Item $inputItem = null; private ?Item $outputItem = null; public function __construct( Player $source, - private readonly EnchantOption $option, + private readonly EnchantingOption $option, private readonly int $cost ){ parent::__construct($source); @@ -51,7 +51,7 @@ class EnchantTransaction extends InventoryTransaction{ throw new AssumptionFailedError("Expected that inputItem and outputItem are not null before validating output"); } - $enchantedInput = EnchantHelper::enchantItem($this->inputItem, $this->option->getEnchantments()); + $enchantedInput = EnchantingHelper::enchantItem($this->inputItem, $this->option->getEnchantments()); if(!$this->outputItem->equalsExact($enchantedInput)){ throw new TransactionValidationException("Invalid output item"); } diff --git a/src/item/enchantment/EnchantHelper.php b/src/item/enchantment/EnchantingHelper.php similarity index 93% rename from src/item/enchantment/EnchantHelper.php rename to src/item/enchantment/EnchantingHelper.php index 23ac11ddb..fb4e8f27c 100644 --- a/src/item/enchantment/EnchantHelper.php +++ b/src/item/enchantment/EnchantingHelper.php @@ -45,7 +45,7 @@ use function round; /** * Helper methods used for enchanting using the enchanting table. */ -final class EnchantHelper{ +final class EnchantingHelper{ private const MAX_BOOKSHELF_COUNT = 15; private function __construct(){ @@ -73,7 +73,7 @@ final class EnchantHelper{ } /** - * @return EnchantOption[] + * @return EnchantingOption[] */ public static function generateOptions(Position $tablePos, Item $input, int $seed) : array{ if($input->isNull() || $input->hasEnchantments()){ @@ -89,9 +89,9 @@ final class EnchantHelper{ $bottomRequiredLevel = max($baseRequiredLevel, $bookshelfCount * 2); return [ - self::createEnchantOption($random, $input, $topRequiredLevel), - self::createEnchantOption($random, $input, $middleRequiredLevel), - self::createEnchantOption($random, $input, $bottomRequiredLevel), + self::createOption($random, $input, $topRequiredLevel), + self::createOption($random, $input, $middleRequiredLevel), + self::createOption($random, $input, $bottomRequiredLevel), ]; } @@ -133,7 +133,7 @@ final class EnchantHelper{ return $bookshelfCount; } - private static function createEnchantOption(Random $random, Item $inputItem, int $requiredXpLevel) : EnchantOption{ + private static function createOption(Random $random, Item $inputItem, int $requiredXpLevel) : EnchantingOption{ $enchantingPower = $requiredXpLevel; $enchantability = $inputItem->getEnchantability(); @@ -171,7 +171,7 @@ final class EnchantHelper{ } } - return new EnchantOption($requiredXpLevel, self::getRandomOptionName($random), $resultEnchantments); + return new EnchantingOption($requiredXpLevel, self::getRandomOptionName($random), $resultEnchantments); } /** diff --git a/src/item/enchantment/EnchantOption.php b/src/item/enchantment/EnchantingOption.php similarity index 98% rename from src/item/enchantment/EnchantOption.php rename to src/item/enchantment/EnchantingOption.php index b1c3a7af5..2bedb0cc4 100644 --- a/src/item/enchantment/EnchantOption.php +++ b/src/item/enchantment/EnchantingOption.php @@ -27,7 +27,7 @@ namespace pocketmine\item\enchantment; * Represents an option on the enchanting table menu. * If selected, all the enchantments in the option will be applied to the item. */ -class EnchantOption{ +class EnchantingOption{ /** * @param EnchantmentInstance[] $enchantments diff --git a/src/network/mcpe/InventoryManager.php b/src/network/mcpe/InventoryManager.php index 8bdce489a..ebbd71146 100644 --- a/src/network/mcpe/InventoryManager.php +++ b/src/network/mcpe/InventoryManager.php @@ -39,8 +39,8 @@ use pocketmine\data\bedrock\EnchantmentIdMap; use pocketmine\inventory\Inventory; use pocketmine\inventory\transaction\action\SlotChangeAction; use pocketmine\inventory\transaction\InventoryTransaction; +use pocketmine\item\enchantment\EnchantingOption; use pocketmine\item\enchantment\EnchantmentInstance; -use pocketmine\item\enchantment\EnchantOption; use pocketmine\network\mcpe\cache\CreativeInventoryCache; use pocketmine\network\mcpe\protocol\ClientboundPacket; use pocketmine\network\mcpe\protocol\ContainerClosePacket; @@ -645,7 +645,7 @@ class InventoryManager{ } /** - * @param EnchantOption[] $options + * @param EnchantingOption[] $options */ public function syncEnchantingTableOptions(array $options) : void{ $protocolOptions = []; diff --git a/src/network/mcpe/handler/ItemStackRequestExecutor.php b/src/network/mcpe/handler/ItemStackRequestExecutor.php index 8273068ab..a36ae9f40 100644 --- a/src/network/mcpe/handler/ItemStackRequestExecutor.php +++ b/src/network/mcpe/handler/ItemStackRequestExecutor.php @@ -29,7 +29,7 @@ use pocketmine\inventory\transaction\action\CreateItemAction; use pocketmine\inventory\transaction\action\DestroyItemAction; use pocketmine\inventory\transaction\action\DropItemAction; use pocketmine\inventory\transaction\CraftingTransaction; -use pocketmine\inventory\transaction\EnchantTransaction; +use pocketmine\inventory\transaction\EnchantingTransaction; use pocketmine\inventory\transaction\InventoryTransaction; use pocketmine\inventory\transaction\TransactionBuilder; use pocketmine\inventory\transaction\TransactionBuilderInventory; @@ -289,7 +289,7 @@ class ItemStackRequestExecutor{ * @throws ItemStackRequestProcessException */ private function assertDoingCrafting() : void{ - if(!$this->specialTransaction instanceof CraftingTransaction && !$this->specialTransaction instanceof EnchantTransaction){ + if(!$this->specialTransaction instanceof CraftingTransaction && !$this->specialTransaction instanceof EnchantingTransaction){ if($this->specialTransaction === null){ throw new ItemStackRequestProcessException("Expected CraftRecipe or CraftRecipeAuto action to precede this action"); }else{ @@ -339,7 +339,7 @@ class ItemStackRequestExecutor{ if($window instanceof EnchantInventory){ $optionId = $this->inventoryManager->getEnchantingTableOptionIndex($action->getRecipeId()); if($optionId !== null && ($option = $window->getOption($optionId)) !== null){ - $this->specialTransaction = new EnchantTransaction($this->player, $option, $optionId + 1); + $this->specialTransaction = new EnchantingTransaction($this->player, $option, $optionId + 1); $this->setNextCreatedItem($window->getOutput($optionId)); } }else{