mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Fixed adventure mode being useless
This commit is contained in:
parent
d2efcee115
commit
207056fb9d
@ -1570,6 +1570,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;
|
||||
@ -1615,24 +1634,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));
|
||||
}
|
||||
@ -1707,6 +1708,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);
|
||||
@ -1769,24 +1789,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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user