mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 10:49:10 +00:00
Added CanPlaceOn tag
This commit is contained in:
parent
1fa467eb58
commit
01d93d6e10
@ -918,7 +918,7 @@ class Item{
|
||||
|
||||
return $blocks;
|
||||
}else{
|
||||
$b = explode(":", str_replace(" ", "_", trim($str)));
|
||||
$b = explode(":", str_replace([" ", "minecraft:"], ["_", ""], trim($str)));
|
||||
if(!isset($b[1])){
|
||||
$meta = 0;
|
||||
}else{
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user