Merge remote-tracking branch 'origin/stable'

# Conflicts:
#	resources/vanilla
#	src/pocketmine/VersionInfo.php
This commit is contained in:
Dylan K. Taylor 2020-11-10 22:44:59 +00:00
commit d08c9ee634
2 changed files with 25 additions and 9 deletions

View File

@ -49,3 +49,6 @@ Plugin developers should **only** update their required API to this version if y
- `Maximum memory (system)` is no longer reported in `/status` due to having a misleading output (it was the same as the current memory usage).
- The `Player Chunk Send` timer on timings reports now actually reports measurements of chunk sending, not chunk loading.
- A new parent timer `World Load` has been added to timings reports, which aggregates timings from `syncChunkLoad` and subtimings from all worlds.
# 3.15.4
- Fixed a bug in the inventory transaction system that caused the server to freeze under some circumstances.

View File

@ -233,21 +233,34 @@ class InventoryTransaction{
protected function findResultItem(Item $needOrigin, array $possibleActions) : ?Item{
assert(count($possibleActions) > 0);
$candidate = null;
$newList = $possibleActions;
foreach($possibleActions as $i => $action){
if($action->getSourceItem()->equalsExact($needOrigin)){
$newList = $possibleActions;
if($candidate !== null){
/*
* we found multiple possible actions that match the origin action
* this means that there are multiple ways that this chain could play out
* if we cared so much about this, we could build all the possible chains in parallel and see which
* variation managed to complete the chain, but this has an extremely high complexity which is not
* worth the trouble for this scenario (we don't usually expect to see chains longer than a couple
* of actions in here anyway), and might still result in multiple possible results.
*/
return null;
}
$candidate = $action;
unset($newList[$i]);
if(count($newList) === 0){
return $action->getTargetItem();
}
$result = $this->findResultItem($action->getTargetItem(), $newList);
if($result !== null){
return $result;
}
}
}
if($candidate === null){
//chaining is not possible with this origin, none of the actions are valid
return null;
}
return null;
if(count($newList) === 0){
return $candidate->getTargetItem();
}
return $this->findResultItem($candidate->getTargetItem(), $newList);
}
/**