Remove item NBT runtime usage, marginalize to serialize/deserialize

this is a more tame version of my initial attempt to firehose item NBT. It marginalizes the use of item NBT to the places where it's needed on interfaces, leaving the internals clean to operate on whatever they like.
This commit is contained in:
Dylan K. Taylor
2019-07-16 16:51:45 +01:00
parent d624c38ab1
commit 27352486a0
8 changed files with 450 additions and 298 deletions

View File

@@ -51,8 +51,6 @@ use pocketmine\item\ItemFactory;
use pocketmine\item\ItemUseResult;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\protocol\BlockActorDataPacket;
use pocketmine\network\mcpe\protocol\ClientboundPacket;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
@@ -1611,17 +1609,12 @@ class World implements ChunkManager{
}
if($player->isAdventure(true) and !$ev->isCancelled()){
$tag = $item->getNamedTag()->getListTag("CanDestroy");
$canBreak = false;
if($tag instanceof ListTag){
foreach($tag as $v){
if($v instanceof StringTag){
$entry = ItemFactory::fromString($v->getValue());
if($entry->getBlock()->isSameType($target)){
$canBreak = true;
break;
}
}
foreach($item->getCanDestroy() as $v){
$entry = ItemFactory::fromString($v);
if($entry->getBlock()->isSameType($target)){
$canBreak = true;
break;
}
}
@@ -1759,16 +1752,11 @@ class World implements ChunkManager{
$ev = new BlockPlaceEvent($player, $hand, $blockReplace, $blockClicked, $item);
if($player->isAdventure(true) and !$ev->isCancelled()){
$canPlace = false;
$tag = $item->getNamedTag()->getListTag("CanPlaceOn");
if($tag instanceof ListTag){
foreach($tag as $v){
if($v instanceof StringTag){
$entry = ItemFactory::fromString($v->getValue());
if($entry->getBlock()->isSameType($blockClicked)){
$canPlace = true;
break;
}
}
foreach($item->getCanPlaceOn() as $v){
$entry = ItemFactory::fromString($v);
if($entry->getBlock()->isSameType($blockClicked)){
$canPlace = true;
break;
}
}