mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +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();
|
$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);
|
$this->server->getPluginManager()->callEvent($ev);
|
||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
return false;
|
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){
|
if($createParticles){
|
||||||
$this->addParticle(new DestroyBlockParticle($target->add(0.5, 0.5, 0.5), $target));
|
$this->addParticle(new DestroyBlockParticle($target->add(0.5, 0.5, 0.5), $target));
|
||||||
}
|
}
|
||||||
@ -1707,6 +1708,25 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$ev->setCancelled();
|
$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);
|
$this->server->getPluginManager()->callEvent($ev);
|
||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
$target->onUpdate(self::BLOCK_UPDATE_TOUCH);
|
$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){
|
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