mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
added gravity
This commit is contained in:
parent
efca0f8398
commit
1239c31ebe
1 changed files with 5 additions and 1 deletions
|
|
@ -74,6 +74,7 @@ class Entity extends Position
|
||||||
public $hasJumped;
|
public $hasJumped;
|
||||||
public $onGround, $inWater;
|
public $onGround, $inWater;
|
||||||
public $carryoverDamage;
|
public $carryoverDamage;
|
||||||
|
public $gravity;
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
||||||
{
|
{
|
||||||
$this->random = new Random();
|
$this->random = new Random();
|
||||||
|
|
@ -128,6 +129,7 @@ class Entity extends Position
|
||||||
$this->moveTime = 0;
|
$this->moveTime = 0;
|
||||||
$this->lookTime = 0;
|
$this->lookTime = 0;
|
||||||
$this->onGround = false;
|
$this->onGround = false;
|
||||||
|
$this->gravity = 0.08;
|
||||||
switch($this->class) {
|
switch($this->class) {
|
||||||
case ENTITY_PLAYER:
|
case ENTITY_PLAYER:
|
||||||
$this->player = $this->data["player"];
|
$this->player = $this->data["player"];
|
||||||
|
|
@ -147,6 +149,7 @@ class Entity extends Position
|
||||||
$this->meta = (int) $this->data["meta"];
|
$this->meta = (int) $this->data["meta"];
|
||||||
$this->stack = (int) $this->data["stack"];
|
$this->stack = (int) $this->data["stack"];
|
||||||
}
|
}
|
||||||
|
$this->gravity = 0.06;
|
||||||
$this->hasGravity = true;
|
$this->hasGravity = true;
|
||||||
$this->setHealth(5, "generic");
|
$this->setHealth(5, "generic");
|
||||||
$this->setSize(0.25, 0.25);
|
$this->setSize(0.25, 0.25);
|
||||||
|
|
@ -155,6 +158,7 @@ class Entity extends Position
|
||||||
$this->setHealth(PHP_INT_MAX, "generic");
|
$this->setHealth(PHP_INT_MAX, "generic");
|
||||||
$this->height = 0.98;
|
$this->height = 0.98;
|
||||||
$this->width = 0.98;
|
$this->width = 0.98;
|
||||||
|
$this->gravity = 0.04;
|
||||||
$this->hasGravity = true;
|
$this->hasGravity = true;
|
||||||
break;
|
break;
|
||||||
case ENTITY_OBJECT:
|
case ENTITY_OBJECT:
|
||||||
|
|
@ -641,7 +645,7 @@ class Entity extends Position
|
||||||
$this->onGround = $support;
|
$this->onGround = $support;
|
||||||
|
|
||||||
if($this->hasGravity){
|
if($this->hasGravity){
|
||||||
$this->speedY -= ($this->class === ENTITY_FALLING) ? 0.04 : ($this->class === ENTITY_ITEM ? 0.06 : 0.08); // TODO: replace with $gravity
|
$this->speedY -= $this->gravity; // TODO: replace with $gravity
|
||||||
$update = true;
|
$update = true;
|
||||||
} elseif($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
|
} elseif($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
|
||||||
// $this->speedX = 0;
|
// $this->speedX = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue