Merge branch 'api3/network' into api3/network-mcpe-1.1

This commit is contained in:
Dylan K. Taylor
2017-04-21 22:50:14 +01:00
29 changed files with 224 additions and 117 deletions

View File

@ -1544,6 +1544,25 @@ class Level implements ChunkManager, Metadatable{
$ev->setCancelled();
}
}
if($player->isAdventure(true) and !$ev->isCancelled()){
$tag = $item->getNamedTagEntry("CanDestroy");
$canBreak = false;
if($tag instanceof ListTag){
foreach($tag as $v){
if($v instanceof StringTag){
$entry = Item::fromString($v->getValue());
if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){
$canBreak = true;
break;
}
}
}
}
$ev->setCancelled(!$canBreak);
}
$this->server->getPluginManager()->callEvent($ev);
if($ev->isCancelled()){
return false;
@ -1589,24 +1608,6 @@ class Level implements ChunkManager, Metadatable{
}
}
$tag = $item->getNamedTagEntry("CanDestroy");
if($tag instanceof ListTag){
$canBreak = false;
foreach($tag as $v){
if($v instanceof StringTag){
$entry = Item::fromString($v->getValue());
if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){
$canBreak = true;
break;
}
}
}
if(!$canBreak){
return false;
}
}
if($createParticles){
$this->addParticle(new DestroyBlockParticle($target->add(0.5, 0.5, 0.5), $target));
}
@ -1681,6 +1682,25 @@ class Level implements ChunkManager, Metadatable{
$ev->setCancelled();
}
}
if($player->isAdventure(true) and !$ev->isCancelled()){
$canPlace = false;
$tag = $item->getNamedTagEntry("CanPlaceOn");
if($tag instanceof ListTag){
foreach($tag as $v){
if($v instanceof StringTag){
$entry = Item::fromString($v->getValue());
if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){
$canPlace = true;
break;
}
}
}
}
$ev->setCancelled(!$canPlace);
}
$this->server->getPluginManager()->callEvent($ev);
if(!$ev->isCancelled()){
$target->onUpdate(self::BLOCK_UPDATE_TOUCH);
@ -1743,24 +1763,6 @@ class Level implements ChunkManager, Metadatable{
}
}
$tag = $item->getNamedTagEntry("CanPlaceOn");
if($tag instanceof ListTag){
$canPlace = false;
foreach($tag as $v){
if($v instanceof StringTag){
$entry = Item::fromString($v->getValue());
if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){
$canPlace = true;
break;
}
}
}
if(!$canPlace){
return false;
}
}
if($player !== null){
$ev = new BlockPlaceEvent($player, $hand, $block, $target, $item);