本文整理汇总了PHP中pocketmine\entity\Human类的典型用法代码示例。如果您正苦于以下问题:PHP Human类的具体用法?PHP Human怎么用?PHP Human使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Human类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Vector3 $v
* @param mixed $data
* @param int $id
* @param FullChunk $chunk
*/
public function __construct($v, $data, $id = -2, $chunk = null)
{
$this->data = $data;
if (!$v instanceof Vector3) {
if ($v instanceof FullChunk) {
$v->removeEntity($this);
}
throw new \RuntimeException("BadConstructCustomHuman");
}
$nbt = new Compound();
$nbt->Pos = new Enum("Motion", [new Double(0, $v->x), new Double(1, $v->y), new Double(2, $v->z)]);
$nbt->Motion = new Enum("Motion", [new Double(0, 0), new Double(1, 0), new Double(2, 0)]);
$nbt->Rotation = new Enum("Rotation", [new Float(0, $this->getDefaultYaw()), new Float(1, $this->getDefaultPitch())]);
$nbt->FallDistance = new Float("FallDistance", 0);
$nbt->Fire = new Short("Fire", 0);
$nbt->Air = new Short("Air", 0);
$nbt->OnGround = new Byte("OnGround", 1);
$nbt->Invulnerable = new Byte("Invulnerable", 1);
$nbt->Health = new Short("Health", 20);
$nbt->NameTag = $this->getDefaultName();
$nbt->Inventory = new Enum("Inventory", []);
$nbt->Inventory->setTagType(NBT::TAG_Compound);
$this->inventory = new PlayerInventory($this);
$this->setSkin($this->getDefaultSkin());
parent::__construct($chunk, $nbt);
}
示例2: setExp
public function setExp($exp)
{
$this->progress = $exp / Human::getLevelXpRequirement($this->level);
}
示例3: loadSkin
/**
* Load skin
* @param Human $human
* @param bool $slim
* @param str $fn
* @return bool
*/
public static function loadSkin(Human $human, $slim, $fn)
{
if (self::isPngExt($fn)) {
if (!extension_loaded("gd")) {
return false;
}
if (!self::isSkinFile($fn)) {
return false;
}
$img = imagecreatefrompng($fn);
if ($img === false) {
return false;
}
$bytes = "";
$x = $y = 0;
while ($y < 32) {
$rgb = imagecolorat($img, $x, $y);
$r = $rgb >> 16 & 0xff;
$g = $rgb >> 8 & 0xff;
$b = $rgb & 0xff;
$bytes .= chr($r) . chr($g) . chr($b) . chr(255);
$x++;
if ($x === 64) {
$x = 0;
$y++;
}
}
imagedestroy($img);
echo "BYTES=" . strlen($bytes) . "\n";
//##DEBUG
$human->setSkin($bytes, $slim);
return true;
}
$bin = file_get_contents($fn);
if ($bin === false) {
return false;
}
$human->setSkin(zlib_decode($bin), $slim);
return true;
}
示例4: toFile
/**
* Creates a new file containing skin data
* @param Human $human
*/
public static function toFile(Human $human)
{
@mkdir(SkinTools::getInstance()->getDataFolder() . "data/");
file_put_contents(SkinTools::getInstance()->getDataFolder() . "data/" . strtolower($human->getName()) . ".dat", self::compress($human->getSkinData()));
}
示例5: teleportImmediate
/**
* This method may not be reliable. Clients don't like to be moved into unloaded chunks.
* Use teleport() for a delayed teleport after chunks have been sent.
*
* @param Vector3 $pos
* @param float $yaw
* @param float $pitch
*/
public function teleportImmediate(Vector3 $pos, $yaw = null, $pitch = null)
{
if (parent::teleport($pos, $yaw, $pitch)) {
foreach ($this->windowIndex as $window) {
if ($window === $this->inventory) {
continue;
}
$this->removeWindow($window);
}
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
$this->sendPosition($this, $this->yaw, $this->pitch, 1);
$this->resetFallDistance();
$this->orderChunks();
$this->nextChunkOrderRun = 0;
$this->newPosition = null;
}
}
示例6: teleport
public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
{
if (parent::teleport($pos, $yaw, $pitch)) {
foreach ($this->windowIndex as $window) {
if ($window === $this->inventory) {
continue;
}
$this->removeWindow($window);
}
$this->airTicks = 300;
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
$pk = new MovePlayerPacket();
$pk->eid = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y + $this->getEyeHeight();
$pk->z = $this->z;
$pk->bodyYaw = 0;
$pk->pitch = $this->pitch;
$pk->yaw = $this->yaw;
$pk->mode = 1;
$pk->teleport = 1;
$this->directDataPacket($pk);
$this->resetFallDistance();
$this->orderChunks();
$this->nextChunkOrderRun = 0;
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
$this->newPosition = null;
}
}
示例7: kill
public function kill()
{
parent::kill();
$this->poofAway();
}
示例8: knockBack
public function knockBack(Entity $attacker, $damage, $x, $z, $base = 0.4)
{
$this->knockback = time() + 1;
// Stunned for 1 second...
parent::knockBack($attacker, $damage, 0.1, 0.1, 0.1);
}
示例9: teleport
public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
{
if (!$this->isOnline()) {
return;
}
$oldPos = $this->getPosition();
if (parent::teleport($pos, $yaw, $pitch)) {
foreach ($this->windowIndex as $window) {
if ($window === $this->inventory) {
continue;
}
$this->removeWindow($window);
}
$this->teleportPosition = new Vector3($this->x, $this->y, $this->z);
if (!$this->checkTeleportPosition()) {
$this->forceMovement = $oldPos;
} else {
$this->spawnToAll();
}
$this->resetFallDistance();
$this->nextChunkOrderRun = 0;
$this->newPosition = null;
}
}
示例10: spawnTo
public function spawnTo(Player $player)
{
parent::spawnTo($player);
}
示例11: teleport
public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
{
if (parent::teleport($pos, $yaw, $pitch)) {
$this->airTicks = 300;
$this->fallDistance = 0;
$this->orderChunks();
$this->chunkLoadTask->setNextRun(0);
$this->forceMovement = $pos;
$pk = new MovePlayerPacket();
$pk->eid = 0;
$pk->x = $this->x;
$pk->y = $this->y + $this->getEyeHeight();
$pk->z = $this->z;
$pk->bodyYaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->yaw = $this->yaw;
$pk->teleport = true;
$this->directDataPacket($pk);
}
}
示例12: addEffect
/**
* @param Effect
*/
public function addEffect(Effect $effect)
{
//Overwrite
if ($effect->isBad() && $this->isCreative()) {
return;
}
parent::addEffect($effect);
}