ItemFactory: extract fromStringSingle() from fromString()

on PM4, the multiple functionality is removed, but on PM3 this is a problem for phpstan.
This commit is contained in:
Dylan K. Taylor
2020-03-13 17:54:25 +00:00
parent 3907a2b6ba
commit f8ce01e2fd
6 changed files with 29 additions and 25 deletions

View File

@ -1764,7 +1764,7 @@ class Level implements ChunkManager, Metadatable{
if($tag instanceof ListTag){
foreach($tag as $v){
if($v instanceof StringTag){
$entry = ItemFactory::fromString($v->getValue());
$entry = ItemFactory::fromStringSingle($v->getValue());
if($entry->getId() > 0 and $entry->getBlock()->getId() === $target->getId()){
$canBreak = true;
break;
@ -1919,7 +1919,7 @@ class Level implements ChunkManager, Metadatable{
if($tag instanceof ListTag){
foreach($tag as $v){
if($v instanceof StringTag){
$entry = ItemFactory::fromString($v->getValue());
$entry = ItemFactory::fromStringSingle($v->getValue());
if($entry->getId() > 0 and $entry->getBlock()->getId() === $blockClicked->getId()){
$canPlace = true;
break;

View File

@ -120,7 +120,7 @@ class Flat extends Generator{
$cnt = $matches[1] !== "" ? (int) $matches[1] : 1;
try{
$b = ItemFactory::fromString($matches[2])->getBlock();
$b = ItemFactory::fromStringSingle($matches[2])->getBlock();
}catch(\InvalidArgumentException $e){
throw new InvalidGeneratorOptionsException("Invalid preset layer \"$line\": " . $e->getMessage(), 0, $e);
}