mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
phpdoc armageddon for master, pass 1
This commit is contained in:
@ -105,11 +105,6 @@ class CraftingGrid extends BaseInventory{
|
||||
|
||||
/**
|
||||
* Returns the item at offset x,y, offset by where the starts of the recipe rectangle are.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getIngredient(int $x, int $y) : Item{
|
||||
if($this->startX !== null and $this->startY !== null){
|
||||
@ -121,8 +116,6 @@ class CraftingGrid extends BaseInventory{
|
||||
|
||||
/**
|
||||
* Returns the width of the recipe we're trying to craft, based on items currently in the grid.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRecipeWidth() : int{
|
||||
return $this->xLen ?? 0;
|
||||
@ -130,7 +123,6 @@ class CraftingGrid extends BaseInventory{
|
||||
|
||||
/**
|
||||
* Returns the height of the recipe we're trying to craft, based on items currently in the grid.
|
||||
* @return int
|
||||
*/
|
||||
public function getRecipeHeight() : int{
|
||||
return $this->yLen ?? 0;
|
||||
|
@ -124,8 +124,6 @@ class CraftingManager{
|
||||
|
||||
/**
|
||||
* Returns a pre-compressed CraftingDataPacket for sending to players. Rebuilds the cache if it is not found.
|
||||
*
|
||||
* @return CompressBatchPromise
|
||||
*/
|
||||
public function getCraftingDataPacket() : CompressBatchPromise{
|
||||
if($this->craftingDataCache === null){
|
||||
@ -137,11 +135,6 @@ class CraftingManager{
|
||||
|
||||
/**
|
||||
* Function used to arrange Shapeless Recipe ingredient lists into a consistent order.
|
||||
*
|
||||
* @param Item $i1
|
||||
* @param Item $i2
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function sort(Item $i1, Item $i2) : int{
|
||||
//Use spaceship operator to compare each property, then try the next one if they are equivalent.
|
||||
@ -206,27 +199,18 @@ class CraftingManager{
|
||||
return $this->furnaceRecipes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ShapedRecipe $recipe
|
||||
*/
|
||||
public function registerShapedRecipe(ShapedRecipe $recipe) : void{
|
||||
$this->shapedRecipes[self::hashOutputs($recipe->getResults())][] = $recipe;
|
||||
|
||||
$this->craftingDataCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ShapelessRecipe $recipe
|
||||
*/
|
||||
public function registerShapelessRecipe(ShapelessRecipe $recipe) : void{
|
||||
$this->shapelessRecipes[self::hashOutputs($recipe->getResults())][] = $recipe;
|
||||
|
||||
$this->craftingDataCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FurnaceRecipe $recipe
|
||||
*/
|
||||
public function registerFurnaceRecipe(FurnaceRecipe $recipe) : void{
|
||||
$input = $recipe->getInput();
|
||||
$this->furnaceRecipes[$input->getId() . ":" . ($input->hasAnyDamageValue() ? "?" : $input->getMeta())] = $recipe;
|
||||
@ -234,10 +218,7 @@ class CraftingManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
* @param Item[] $outputs
|
||||
*
|
||||
* @return CraftingRecipe|null
|
||||
*/
|
||||
public function matchRecipe(CraftingGrid $grid, array $outputs) : ?CraftingRecipe{
|
||||
//TODO: try to match special recipes before anything else (first they need to be implemented!)
|
||||
@ -286,11 +267,6 @@ class CraftingManager{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $input
|
||||
*
|
||||
* @return FurnaceRecipe|null
|
||||
*/
|
||||
public function matchFurnaceRecipe(Item $input) : ?FurnaceRecipe{
|
||||
return $this->furnaceRecipes[$input->getId() . ":" . $input->getMeta()] ?? $this->furnaceRecipes[$input->getId() . ":?"] ?? null;
|
||||
}
|
||||
|
@ -36,18 +36,12 @@ interface CraftingRecipe{
|
||||
/**
|
||||
* Returns a list of results this recipe will produce when the inputs in the given crafting grid are consumed.
|
||||
*
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getResultsFor(CraftingGrid $grid) : array;
|
||||
|
||||
/**
|
||||
* Returns whether the given crafting grid meets the requirements to craft this recipe.
|
||||
*
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matchesCraftingGrid(CraftingGrid $grid) : bool;
|
||||
}
|
||||
|
@ -33,25 +33,15 @@ class FurnaceRecipe{
|
||||
/** @var Item */
|
||||
private $ingredient;
|
||||
|
||||
/**
|
||||
* @param Item $result
|
||||
* @param Item $ingredient
|
||||
*/
|
||||
public function __construct(Item $result, Item $ingredient){
|
||||
$this->output = clone $result;
|
||||
$this->ingredient = clone $ingredient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getInput() : Item{
|
||||
return clone $this->ingredient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getResult() : Item{
|
||||
return clone $this->output;
|
||||
}
|
||||
|
@ -114,8 +114,6 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getResultsFor(CraftingGrid $grid) : array{
|
||||
@ -155,12 +153,6 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
return $ingredients;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getIngredient(int $x, int $y) : Item{
|
||||
$exists = $this->ingredientList[$this->shape[$y]{$x}] ?? null;
|
||||
return $exists !== null ? clone $exists : ItemFactory::air();
|
||||
@ -174,12 +166,6 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
return $this->shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
* @param bool $reverse
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function matchInputMap(CraftingGrid $grid, bool $reverse) : bool{
|
||||
for($y = 0; $y < $this->height; ++$y){
|
||||
for($x = 0; $x < $this->width; ++$x){
|
||||
@ -195,11 +181,6 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matchesCraftingGrid(CraftingGrid $grid) : bool{
|
||||
if($this->width !== $grid->getRecipeWidth() or $this->height !== $grid->getRecipeHeight()){
|
||||
return false;
|
||||
|
@ -67,9 +67,6 @@ class ShapelessRecipe implements CraftingRecipe{
|
||||
return Utils::cloneObjectArray($this->ingredients);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIngredientCount() : int{
|
||||
$count = 0;
|
||||
foreach($this->ingredients as $ingredient){
|
||||
@ -79,11 +76,6 @@ class ShapelessRecipe implements CraftingRecipe{
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matchesCraftingGrid(CraftingGrid $grid) : bool{
|
||||
//don't pack the ingredients - shapeless recipes require that each ingredient be in a separate slot
|
||||
$input = $grid->getContents();
|
||||
|
Reference in New Issue
Block a user