namedtag->TileID)){ $this->blockId = $this->namedtag["TileID"]; }elseif(isset($this->namedtag->Tile)){ $this->blockId = $this->namedtag["Tile"]; $this->namedtag["TileID"] = new Int("TileID", $this->blockId); } if(isset($this->namedtag->Data)){ $this->damage = $this->namedtag["Data"]; } if($this->blockId === 0){ $this->close(); return; } $this->setDataProperty(self::DATA_BLOCK_INFO, self::DATA_TYPE_INT, $this->getBlock() | ($this->getDamage() << 8)); } public function canCollideWith(Entity $entity){ return false; } public function attack($damage, EntityDamageEvent $source){ } public function onUpdate($currentTick){ if($this->closed){ return false; } $this->timings->startTiming(); $tickDiff = $currentTick - $this->lastUpdate; if($tickDiff <= 0 and !$this->justCreated){ return true; } $this->lastUpdate = $currentTick; $hasUpdate = $this->entityBaseTick($tickDiff); if($this->isAlive()){ $pos = (new Vector3($this->x - 0.5, $this->y, $this->z - 0.5))->floor(); if($this->ticksLived === 1){ $block = $this->level->getBlock($pos); if($block->getId() !== $this->blockId){ $this->kill(); return true; } $this->level->setBlock($pos, Block::get(0), true); } $this->motionY -= $this->gravity; $this->move($this->motionX, $this->motionY, $this->motionZ); $friction = 1 - $this->drag; $this->motionX *= $friction; $this->motionY *= 1 - $this->drag; $this->motionZ *= $friction; $pos = (new Vector3($this->x - 0.5, $this->y, $this->z - 0.5))->floor(); if($this->onGround){ $this->kill(); $block = $this->level->getBlock($pos); if($block->getId() > 0 and !$block->isSolid() and !($block instanceof Liquid)){ $this->getLevel()->dropItem($this, ItemItem::get($this->getBlock(), $this->getDamage(), 1)); }else{ $this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage()))); if(!$ev->isCancelled()){ $this->getLevel()->setBlock($pos, $ev->getTo(), true); } } $hasUpdate = true; } $this->updateMovement(); } return $hasUpdate or !$this->onGround or abs($this->motionX) > 0.00001 or abs($this->motionY) > 0.00001 or abs($this->motionZ) > 0.00001; } public function getBlock(){ return $this->blockId; } public function getDamage(){ return $this->damage; } public function saveNBT(){ $this->namedtag->TileID = new Int("TileID", $this->blockId); $this->namedtag->Data = new Byte("Data", $this->damage); } public function spawnTo(Player $player){ $pk = new AddEntityPacket(); $pk->type = FallingSand::NETWORK_ID; $pk->eid = $this->getId(); $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->speedX = $this->motionX; $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); parent::spawnTo($player); } }