mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Rename EnchantHelper related stuff
Perhaps this and EnchantOption should be called EnchantingHelper and EnchantingOption respectively. The terminology used is rather inconsistent, but 'enchantment' definitely isn't the right word here.
This commit is contained in:
parent
d942748203
commit
bf668c0f6c
@ -26,7 +26,7 @@ namespace pocketmine\block\inventory;
|
||||
use pocketmine\event\player\PlayerEnchantOptionsRequestEvent;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\inventory\TemporaryInventory;
|
||||
use pocketmine\item\enchantment\EnchantmentHelper as Helper;
|
||||
use pocketmine\item\enchantment\EnchantHelper as Helper;
|
||||
use pocketmine\item\enchantment\EnchantOption;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\world\Position;
|
||||
@ -52,7 +52,7 @@ class EnchantInventory extends SimpleInventory implements BlockInventory, Tempor
|
||||
foreach($this->viewers as $viewer){
|
||||
$this->options = [];
|
||||
$item = $this->getInput();
|
||||
$options = Helper::getEnchantOptions($this->holder, $item, $viewer->getEnchantmentSeed());
|
||||
$options = Helper::generateOptions($this->holder, $item, $viewer->getEnchantmentSeed());
|
||||
|
||||
$event = new PlayerEnchantOptionsRequestEvent($viewer, $this, $options);
|
||||
$event->call();
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\command\defaults;
|
||||
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\item\enchantment\EnchantmentHelper;
|
||||
use pocketmine\item\enchantment\EnchantHelper;
|
||||
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 = EnchantmentHelper::enchantItem($item, [new EnchantmentInstance($enchantment, $level)]);
|
||||
$enchantedItem = EnchantHelper::enchantItem($item, [new EnchantmentInstance($enchantment, $level)]);
|
||||
$player->getInventory()->setItemInHand($enchantedItem);
|
||||
|
||||
self::broadcastCommandMessage($sender, KnownTranslationFactory::commands_enchant_success($player->getName()));
|
||||
|
@ -37,7 +37,7 @@ use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerEnderInventory;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\inventory\PlayerOffHandInventory;
|
||||
use pocketmine\item\enchantment\EnchantmentHelper;
|
||||
use pocketmine\item\enchantment\EnchantHelper;
|
||||
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 = EnchantmentHelper::generateSeed();
|
||||
$this->xpSeed = EnchantHelper::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 = EnchantmentHelper::generateSeed();
|
||||
$this->xpSeed = EnchantHelper::generateSeed();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\inventory\transaction;
|
||||
|
||||
use pocketmine\event\player\PlayerItemEnchantEvent;
|
||||
use pocketmine\item\enchantment\EnchantmentHelper;
|
||||
use pocketmine\item\enchantment\EnchantHelper;
|
||||
use pocketmine\item\enchantment\EnchantOption;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemTypeIds;
|
||||
@ -51,7 +51,7 @@ class EnchantTransaction extends InventoryTransaction{
|
||||
throw new AssumptionFailedError("Expected that inputItem and outputItem are not null before validating output");
|
||||
}
|
||||
|
||||
$enchantedInput = EnchantmentHelper::enchantItem($this->inputItem, $this->option->getEnchantments());
|
||||
$enchantedInput = EnchantHelper::enchantItem($this->inputItem, $this->option->getEnchantments());
|
||||
if(!$this->outputItem->equalsExact($enchantedInput)){
|
||||
throw new TransactionValidationException("Invalid output item");
|
||||
}
|
||||
|
@ -42,7 +42,10 @@ use function mt_rand;
|
||||
use function ord;
|
||||
use function round;
|
||||
|
||||
final class EnchantmentHelper{
|
||||
/**
|
||||
* Helper methods used for enchanting using the enchanting table.
|
||||
*/
|
||||
final class EnchantHelper{
|
||||
private const MAX_BOOKSHELF_COUNT = 15;
|
||||
|
||||
private function __construct(){
|
||||
@ -72,7 +75,7 @@ final class EnchantmentHelper{
|
||||
/**
|
||||
* @return EnchantOption[]
|
||||
*/
|
||||
public static function getEnchantOptions(Position $tablePos, Item $input, int $seed) : array{
|
||||
public static function generateOptions(Position $tablePos, Item $input, int $seed) : array{
|
||||
if($input->isNull() || $input->hasEnchantments()){
|
||||
return [];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user