mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-05 09:39:56 +00:00
Added extra data printing for Items, non-automatic bytearray on NBT
This commit is contained in:
parent
d0bfc826ea
commit
2cec6812a8
@ -921,6 +921,9 @@ class Item{
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getCompoundTag(){
|
public function getCompoundTag(){
|
||||||
return $this->nbt;
|
return $this->nbt;
|
||||||
}
|
}
|
||||||
@ -1045,7 +1048,7 @@ class Item{
|
|||||||
}
|
}
|
||||||
|
|
||||||
final public function __toString(){
|
final public function __toString(){
|
||||||
return "Item " . $this->name . " (" . $this->id . ":" . ($this->meta === null ? "?" : $this->meta) . ")x" . $this->count;
|
return "Item " . $this->name . " (" . $this->id . ":" . ($this->meta === null ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " userData:0x".bin2hex($this->getCompoundTag()) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDestroySpeed(Block $block, Player $player){
|
public function getDestroySpeed(Block $block, Player $player){
|
||||||
|
@ -278,7 +278,7 @@ class NBT{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fromArray(Tag $tag, array $data){
|
private function fromArray(Tag $tag, array $data, $byteArray = false){
|
||||||
foreach($data as $key => $value){
|
foreach($data as $key => $value){
|
||||||
if(is_array($value)){
|
if(is_array($value)){
|
||||||
$isNumeric = true;
|
$isNumeric = true;
|
||||||
@ -298,7 +298,7 @@ class NBT{
|
|||||||
}elseif(is_float($value)){
|
}elseif(is_float($value)){
|
||||||
$tag{$key} = new Float($key, $value);
|
$tag{$key} = new Float($key, $value);
|
||||||
}elseif(is_string($value)){
|
}elseif(is_string($value)){
|
||||||
if(Utils::printable($value) !== $value){
|
if($byteArray and Utils::printable($value) !== $value){
|
||||||
$tag{$key} = new ByteArray($key, $value);
|
$tag{$key} = new ByteArray($key, $value);
|
||||||
}else{
|
}else{
|
||||||
$tag{$key} = new String($key, $value);
|
$tag{$key} = new String($key, $value);
|
||||||
@ -309,9 +309,9 @@ class NBT{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setArray(array $data){
|
public function setArray(array $data, $byteArray = false){
|
||||||
$this->data = new Compound("", []);
|
$this->data = new Compound("", []);
|
||||||
$this->fromArray($this->data, $data);
|
$this->fromArray($this->data, $data, $byteArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user