mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
CraftingTransaction: simplifiy repetition calculation handling
This commit is contained in:
parent
033b44df5a
commit
eb354916d4
@ -116,15 +116,10 @@ class CraftingTransaction extends InventoryTransaction{
|
||||
throw new TransactionValidationException("Unable to match a recipe to transaction");
|
||||
}
|
||||
|
||||
try{
|
||||
$this->repetitions = $this->matchRecipeItems($this->outputs, $this->recipe->getResultsFor($this->source->getCraftingGrid()), false);
|
||||
|
||||
if(($inputIterations = $this->matchRecipeItems($this->inputs, $this->recipe->getIngredientList(), true, $this->repetitions)) !== $this->repetitions){
|
||||
throw new TransactionValidationException("Tried to craft recipe $this->repetitions times in batch, but have enough inputs for $inputIterations");
|
||||
}
|
||||
}catch(\InvalidStateException $e){
|
||||
throw new TransactionValidationException($e->getMessage());
|
||||
}
|
||||
//compute number of times recipe was crafted
|
||||
$this->repetitions = $this->matchRecipeItems($this->outputs, $this->recipe->getResultsFor($this->source->getCraftingGrid()), false);
|
||||
//assert that $repetitions x recipe ingredients should be consumed
|
||||
$this->matchRecipeItems($this->inputs, $this->recipe->getIngredientList(), true, $this->repetitions);
|
||||
}
|
||||
|
||||
protected function callExecuteEvent() : bool{
|
||||
|
Loading…
x
Reference in New Issue
Block a user