Exemplo n.º 1
0
 public function __construct(FullChunk $chunk, CompoundTag $nbt, $sourceEntity = null)
 {
     if (is_null($sourceEntity)) {
         // not spawned by plugin - may have been left over from a crash - just close
         parent::__construct($chunk, $nbt);
         // need to allow construction to finish or crash
         $this->close();
         return;
     }
     $possibleTypes = array(42, 85);
     $this->NETWORK_ID = $possibleTypes[array_rand($possibleTypes)];
     $this->batflags = 0;
     $chunk = $sourceEntity->getLevel()->getChunk($sourceEntity->getX() >> 4, $sourceEntity->getZ() >> 4);
     $nbt = new CompoundTag();
     $nbt->Pos = new ListTag("Pos", [new DoubleTag("", $sourceEntity->getX()), new DoubleTag("", $sourceEntity->getY()), new DoubleTag("", $sourceEntity->getZ())]);
     $nbt->Rotation = new ListTag("Rotation", [new FloatTag("", $sourceEntity->getYaw()), new FloatTag("", $sourceEntity->getPitch())]);
     $nbt->Health = new ShortTag("Health", 2);
     $nbt->NameTag = new StringTag("name", "HerobrineBat");
     $nbt->Invulnerable = new ByteTag("Invulnerable", 1);
     $nbt->BatFlags = new ByteTag("BatFlags", $this->batflags);
     $nbt->BatFlags = new ByteTag("ED1", $this->batflags);
     parent::__construct($chunk, $nbt);
     $this->setNameTagVisible(false);
     $this->spawnToAll();
     $this->setNameTagVisible(false);
     $this->currentDirection = rand(1, 8);
     $this->getLevel()->addSound(new BatSound($this), null);
 }
Exemplo n.º 2
0
 public function __construct(FullChunk $chunk, CompoundTag $nbt)
 {
     if (!isset($nbt->Profession)) {
         $nbt->Profession = new ByteTag("Profession", mt_rand(0, 5));
     }
     parent::__construct($chunk, $nbt);
     $this->setDataProperty(self::DATA_PROFESSION_ID, self::DATA_TYPE_BYTE, $this->getProfession());
 }