Added CanPlaceOn tag

This commit is contained in:
Shoghi Cervantes
2015-08-07 22:13:52 +02:00
parent 1fa467eb58
commit 01d93d6e10
2 changed files with 19 additions and 1 deletions

View File

@ -1706,6 +1706,24 @@ class Level implements ChunkManager, Metadatable{
}
}
$tag = $item->getNamedTagEntry("CanPlaceOn");
if($tag instanceof Enum){
$canPlace = false;
foreach($tag as $v){
if($v instanceof String){
$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);