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