mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Get Item Lists from BlockAPI::fromString() method
This commit is contained in:
parent
6c4900cd32
commit
e8c2662258
@ -38,23 +38,31 @@ define("BLOCK_UPDATE_WEAK", 3);
|
||||
class BlockAPI{
|
||||
private $server;
|
||||
|
||||
public static function fromString($str){
|
||||
$b = explode(":", str_replace(" ", "_", trim($str)));
|
||||
if(!isset($b[1])){
|
||||
$meta = 0;
|
||||
public static function fromString($str, $multiple = false){
|
||||
if($multiple === true){
|
||||
$blocks = array();
|
||||
foreach(explode(",",$str) as $b){
|
||||
$blocks[] = BlockAPI::fromString($b, false);
|
||||
}
|
||||
return $blocks;
|
||||
}else{
|
||||
$meta = ((int) $b[1]) & 0xFFFF;
|
||||
}
|
||||
|
||||
if(defined(strtoupper($b[0]))){
|
||||
$item = BlockAPI::getItem(constant(strtoupper($b[0])), $meta);
|
||||
if($item->getID() === AIR and strtoupper($b[0]) !== "AIR"){
|
||||
$b = explode(":", str_replace(" ", "_", trim($str)));
|
||||
if(!isset($b[1])){
|
||||
$meta = 0;
|
||||
}else{
|
||||
$meta = ((int) $b[1]) & 0xFFFF;
|
||||
}
|
||||
|
||||
if(defined(strtoupper($b[0]))){
|
||||
$item = BlockAPI::getItem(constant(strtoupper($b[0])), $meta);
|
||||
if($item->getID() === AIR and strtoupper($b[0]) !== "AIR"){
|
||||
$item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta);
|
||||
}
|
||||
}else{
|
||||
$item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta);
|
||||
}
|
||||
}else{
|
||||
$item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta);
|
||||
return $item;
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function get($id, $meta = 0, $v = false){
|
||||
|
@ -47,5 +47,5 @@ define("MAJOR_VERSION", "Alpha_1.3dev");
|
||||
define("CURRENT_STRUCTURE", 5);
|
||||
define("CURRENT_PROTOCOL", 9);
|
||||
define("CURRENT_MINECRAFT_VERSION", "v0.6.1 alpha");
|
||||
define("CURRENT_API_VERSION", 3);
|
||||
define("CURRENT_API_VERSION", 4);
|
||||
define("CURRENT_PHP_VERSION", "5.4.12");
|
Loading…
x
Reference in New Issue
Block a user