Player: Fixed not being able to interact with blocks in adventure mode, close #1848

This allows other undesired behaviour like flint&steel, buckets to work in adventure mode when they shouldn't, but that's a bug for another time.
This commit is contained in:
Dylan K. Taylor 2018-01-02 16:26:59 +00:00
parent 43a0ede9d2
commit 7339c4ac2f

View File

@ -1874,24 +1874,6 @@ class Level implements ChunkManager, Metadatable{
$ev->setCancelled(); //set it to cancelled so plugins can bypass this
}
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 = ItemFactory::fromString($v->getValue());
if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $blockClicked->getId()){
$canPlace = true;
break;
}
}
}
}
$ev->setCancelled(!$canPlace);
}
$this->server->getPluginManager()->callEvent($ev);
if(!$ev->isCancelled()){
$blockClicked->onUpdate(self::BLOCK_UPDATE_TOUCH);
@ -1952,6 +1934,24 @@ 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 = ItemFactory::fromString($v->getValue());
if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $blockClicked->getId()){
$canPlace = true;
break;
}
}
}
}
$ev->setCancelled(!$canPlace);
}
$this->server->getPluginManager()->callEvent($ev);
if($ev->isCancelled()){
return false;