mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 15:19:56 +00:00
Added CanDestroy and Lock tag
This commit is contained in:
parent
01d93d6e10
commit
fcba9596d6
@ -117,6 +117,12 @@ class BurningFurnace extends Solid{
|
||||
$furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||
}
|
||||
|
||||
if(isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof String){
|
||||
if($furnace->namedtag->Lock->getValue() !== $item->getCustomName()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
}
|
||||
|
@ -158,6 +158,11 @@ class Chest extends Transparent{
|
||||
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
|
||||
}
|
||||
|
||||
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String){
|
||||
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
|
@ -85,6 +85,7 @@ class EnchantingTable extends Transparent{
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player){
|
||||
//TODO lock
|
||||
if($player->isCreative()){
|
||||
return true;
|
||||
}
|
||||
|
@ -1562,6 +1562,24 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
$tag = $item->getNamedTagEntry("CanDestroy");
|
||||
if($tag instanceof Enum){
|
||||
$canBreak = 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()){
|
||||
$canBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$canBreak){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if($createParticles){
|
||||
$players = $this->getChunkPlayers($target->x >> 4, $target->z >> 4);
|
||||
if($player !== null){
|
||||
|
Loading…
x
Reference in New Issue
Block a user