mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Human: Save skin data as TAG_ByteArray instead of TAG_String
TAG_String has a UTF-8 payload, which makes it more expensive to work with. Also, skins can contain bytes which are not valid UTF-8 characters and will therefore be treated as corrupted by external tools. Additionally a TAG_String can only hold 32767 bytes, which might become a problem in the future. A TAG_ByteArray can hold up to 2GB of data, and there is no character encoding restrictions on it.
This commit is contained in:
parent
7ec886faa2
commit
9478bc281f
@ -36,6 +36,7 @@ use pocketmine\item\FoodSource;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\ByteArrayTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
@ -485,7 +486,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
if($skin !== null){
|
||||
$this->setSkin(new Skin(
|
||||
$skin->getString("Name"),
|
||||
$skin->getString("Data")
|
||||
$skin->hasTag("Data", StringTag::class) ? $skin->getString("Data") : $skin->getByteArray("Data") //old data (this used to be saved as a StringTag in older versions of PM)
|
||||
));
|
||||
}
|
||||
|
||||
@ -673,7 +674,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
if($this->skin !== null){
|
||||
$this->namedtag->setTag(new CompoundTag("Skin", [
|
||||
//TODO: save cape & geometry
|
||||
new StringTag("Data", $this->skin->getSkinData()),
|
||||
new ByteArrayTag("Data", $this->skin->getSkinData()),
|
||||
new StringTag("Name", $this->skin->getSkinId())
|
||||
]));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user