Improved fall damage while on jump boost, new protocol update, build 7, allow for live inventory resizing

This commit is contained in:
Shoghi Cervantes 2015-04-24 16:43:29 +02:00
parent ba635b8858
commit 7b699d9afd
8 changed files with 61 additions and 47 deletions

View File

@ -865,7 +865,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
$this->sleeping = clone $pos;
//$this->teleport(new Position($pos->x + 0.5, $pos->y + 1, $pos->z + 0.5, $this->level));
$this->teleport(new Position($pos->x + 0.5, $pos->y - 0.5, $pos->z + 0.5, $this->level));
$this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [$pos->x, $pos->y, $pos->z]);
$this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, true);
@ -999,7 +999,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$spawnPosition = $this->getSpawn();
$pk = new StartGamePacket();
$pk->seed = $this->level->getSeed();
$pk->seed = -1;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
@ -1569,7 +1569,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->dead = false;
$pk = new StartGamePacket();
$pk->seed = $this->level->getSeed();
$pk->seed = -1;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;

View File

@ -74,7 +74,7 @@ namespace pocketmine {
const VERSION = "1.5dev";
const API_VERSION = "1.12.0";
const CODENAME = "活発(Kappatsu)フグ(Fugu)";
const MINECRAFT_VERSION = "v0.11.0 alpha build 6";
const MINECRAFT_VERSION = "v0.11.0 alpha build 7";
/*
* Startup code. Do not look at it, it may harm you.

View File

@ -446,6 +446,8 @@ abstract class Entity extends Location implements Metadatable{
$this->addEffect($effect);
}
}
$this->scheduleUpdate();
}
/**
@ -832,6 +834,17 @@ abstract class Entity extends Location implements Metadatable{
return false;
}
if($this->dead === true){
++$this->deadTicks;
if($this->deadTicks >= 10){
$this->despawnFromAll();
if(!($this instanceof Player)){
$this->close();
}
}
return $this->deadTicks < 10;
}
$tickDiff = $currentTick - $this->lastUpdate;
if($tickDiff <= 0){
return false;
@ -914,7 +927,7 @@ abstract class Entity extends Location implements Metadatable{
}
public function fall($fallDistance){
$damage = floor($fallDistance - 3);
$damage = floor($fallDistance - 3 - ($this->hasEffect(Effect::JUMP) ? $this->getEffect(Effect::JUMP)->getAmplifier() + 1 : 0));
if($damage > 0){
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage);
$this->attack($ev->getFinalDamage(), $ev);

View File

@ -146,28 +146,16 @@ abstract class Living extends Entity implements Damageable{
public function entityBaseTick($tickDiff = 1){
Timings::$timerEntityBaseTick->startTiming();
if($this->dead === true){
++$this->deadTicks;
if($this->deadTicks >= 10){
$this->despawnFromAll();
if(!($this instanceof Player)){
$this->close();
}
}
Timings::$timerEntityBaseTick->stopTiming();
return $this->deadTicks < 10;
}
$hasUpdate = parent::entityBaseTick($tickDiff);
if($this->dead !== true and $this->isInsideOfSolid()){
if($this->dead !== true){
if($this->isInsideOfSolid()){
$hasUpdate = true;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
$this->attack($ev->getFinalDamage(), $ev);
}
if($this->dead !== true and !$this->hasEffect(Effect::WATER_BREATHING) and $this->isInsideOfWater()){
if(!$this->hasEffect(Effect::WATER_BREATHING) and $this->isInsideOfWater()){
if($this instanceof WaterAnimal){
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
}else{
@ -196,6 +184,7 @@ abstract class Living extends Entity implements Damageable{
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
}
}
}
if($this->attackTime > 0){
$this->attackTime -= $tickDiff;

View File

@ -82,6 +82,10 @@ abstract class BaseInventory implements Inventory{
return $this->size;
}
public function setSize($size){
$this->size = (int) $size;
}
public function getMaxStackSize(){
return $this->maxStackSize;
}

View File

@ -49,6 +49,11 @@ class PlayerInventory extends BaseInventory{
return parent::getSize() - 4; //Remove armor slots
}
public function setSize($size){
parent::setSize($size + 4);
$this->sendContents($this->getViewers());
}
public function getHotbarSlotIndex($index){
return ($index >= 0 and $index < $this->getHotbarSize()) ? $this->hotbar[$index] : -1;
}

View File

@ -30,7 +30,7 @@ interface Info{
/**
* Actual Minecraft: PE protocol version
*/
const CURRENT_PROTOCOL = 23;
const CURRENT_PROTOCOL = 24;
const LOGIN_PACKET = 0x82;
const PLAY_STATUS_PACKET = 0x83;

View File

@ -36,6 +36,7 @@ class MovePlayerPacket extends DataPacket{
public $bodyYaw;
public $pitch;
public $mode = 0;
public $onGround;
public function pid(){
return Info::MOVE_PLAYER_PACKET;
@ -55,6 +56,7 @@ class MovePlayerPacket extends DataPacket{
$this->bodyYaw = $this->getFloat();
$this->pitch = $this->getFloat();
$this->mode = $this->getByte();
$this->onGround = $this->getByte() > 0;
}
public function encode(){
@ -67,6 +69,7 @@ class MovePlayerPacket extends DataPacket{
$this->putFloat($this->bodyYaw); //TODO
$this->putFloat($this->pitch);
$this->putByte($this->mode);
$this->putByte($this->onGround > 0);
}
}