mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Flying damage
This commit is contained in:
parent
f53e08bb84
commit
e433f0f6dc
4 changed files with 25 additions and 11 deletions
|
|
@ -607,7 +607,6 @@ class Player{
|
|||
$this->dataPacket(MC_ADVENTURE_SETTINGS, array(
|
||||
"flags" => $flags,
|
||||
));
|
||||
$this->orderChunks();
|
||||
$this->getNextChunk();
|
||||
break;
|
||||
case 2://Chunk loaded?
|
||||
|
|
@ -683,9 +682,9 @@ class Player{
|
|||
switch($data["event"]){
|
||||
case 9: //Eating
|
||||
$items = array(
|
||||
260 => 2, //Apples
|
||||
APPLE => 2, //Apples
|
||||
282 => 10, //Stew
|
||||
297 => 5, //Bread
|
||||
BREAD => 5, //Bread
|
||||
319 => 3,
|
||||
320 => 8,
|
||||
363 => 3,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ define("ENTITY_OBJECT", 2);
|
|||
define("ENTITY_ITEM", 3);
|
||||
|
||||
class Entity extends stdClass{
|
||||
public $invincible;
|
||||
public $age;
|
||||
public $air;
|
||||
public $spawntime;
|
||||
|
|
@ -71,10 +70,12 @@ class Entity extends stdClass{
|
|||
public $closed;
|
||||
public $player;
|
||||
public $fallY;
|
||||
public $fallStart;
|
||||
private $tickCounter;
|
||||
private $server;
|
||||
function __construct(PocketMinecraftServer $server, $eid, $class, $type = 0, $data = array()){
|
||||
$this->fallY = false;
|
||||
$this->fallStart = false;
|
||||
$this->server = $server;
|
||||
$this->eid = (int) $eid;
|
||||
$this->type = (int) $type;
|
||||
|
|
@ -110,7 +111,6 @@ class Entity extends stdClass{
|
|||
switch($this->class){
|
||||
case ENTITY_PLAYER:
|
||||
$this->player = $this->data["player"];
|
||||
$this->health = &$this->player->data["health"];
|
||||
$this->setHealth($this->health, "generic");
|
||||
break;
|
||||
case ENTITY_ITEM:
|
||||
|
|
@ -272,18 +272,27 @@ class Entity extends stdClass{
|
|||
}
|
||||
}else{
|
||||
if($blockDown->isFlowable === true){
|
||||
if($this->fallY === false or $y > $this->fallY){
|
||||
if($this->fallY === false){
|
||||
$this->fallY = $y;
|
||||
$this->fallStart = microtime(true);
|
||||
}elseif($y > $this->fallY){
|
||||
$this->fallY = $y;
|
||||
}
|
||||
if($this->fallY !== false and ($this->fallStart + 8) < microtime(true)){ //Flying
|
||||
$this->harm(1, "flying");
|
||||
$this->fallY = $y;
|
||||
}
|
||||
}elseif($this->fallY !== false){ //Fall damage!
|
||||
if($y < $this->fallY){
|
||||
$d = $this->server->api->block->getBlock(new Vector3($x, $y + 1, $z));
|
||||
$dmg = ($this->fallY - $y) - 3;
|
||||
if($dmg > 0 and !($d instanceof LiquidBlock)){
|
||||
if($dmg > 0 and !($d instanceof LiquidBlock) and $d->getID() !== LADDER){
|
||||
$this->harm($dmg, "fall");
|
||||
}
|
||||
}
|
||||
$this->fallY = false;
|
||||
$this->fallStart = false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue