1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Structure Block NBT

Discussion in 'Development' started by YarkaDev, Aug 28, 2019.

  1. YarkaDev

    YarkaDev Spider

    Messages:
    9
    GitHub:
    yarkadev
    Hello! What kind of NBT I should put in createAdditionalNBT? Where was my mistake? Rays emanating from the structural unit at a given NBT simply disappear

    This is a Tile class
    PHP:
    class StructureBlock extends Spawnable {
        
        protected static function 
    createAdditionalNBT(CompoundTag $nbtVector3 $posint $face null, ?Item $item null, ?Player $player null): void {
            
    $nbt->setByte('keepPacked'1);
            
    $nbt->setString('name''test');
            
    $nbt->setString('author''?');
            
    $nbt->setString('metadata''');
            
            
    $nbt->setInt('posX'$pos->x);
            
    $nbt->setInt('posY'$pos->y);
            
    $nbt->setInt('posZ'$pos->z);
            
    $nbt->setInt('sizeX'5);
            
    $nbt->setInt('sizeY'5);
            
    $nbt->setInt('sizeZ'5);
            
            
    $nbt->setString('rotation''NONE');
            
    $nbt->setString('mirror''NONE');
            
    $nbt->setString('mode''DATA');
            
            
    $nbt->setByte('ignoreEntities'1);
          
          
            echo 
    "Structure Block additional data wrote\n";
            
    var_dump($nbt);
        }


        protected function 
    addAdditionalSpawnData(CompoundTag $nbt): void {
            
            
        }

        protected function 
    readSaveData(CompoundTag $nbt): void {
            
        }

        protected function 
    writeSaveData(CompoundTag $nbt): void {

        }
    }
    And this is a Block class
    PHP:
    class StructureBlock extends Solid {
        protected 
    $id Block::STRUCTURE_BLOCK;
        
        public function 
    __construct() {
            
    parent::__construct($this->id0'Structure block''252');
            
        }
        
        public function 
    place(Item $itemBlock $blockReplaceBlock $blockClickedint $faceVector3 $clickVectorPlayer $player null): bool {
            
    $this->getLevel()->setBlock($blockReplace$thistruetrue);
            
    $tile Tile::createTile(Tile::STRUCTURE_BLOCK$this->getLevel(), StructureTile::createNBT($this));
            
            return 
    true;
        }
    }
    Where did I make a mistake?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.