Updated Entity class to reflect changes in BlockAPI

This commit is contained in:
Shoghi Cervantes Pueyo 2013-02-04 17:26:55 +01:00
parent 37f5626e9a
commit cdb05f0695
2 changed files with 7 additions and 28 deletions

View File

@ -375,26 +375,6 @@ class BlockAPI{
} }
/*switch($data["block"]){ /*switch($data["block"]){
case 338:
case 83: //Sugarcane
$data["block"] = 83;
$blockDown = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"]);
if($blockDown[0] === 83){
}elseif($blockDown[0] !== 2 and $blockDown[0] !== 3 and $blockDown[0] !== 12){
return false;
}else{
$block0 = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"] + 1);
$block1 = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"] - 1);
$block2 = $this->server->api->level->getBlock($data["x"] + 1, $data["y"] - 1, $data["z"]);
$block3 = $this->server->api->level->getBlock($data["x"] - 1, $data["y"] - 1, $data["z"]);
if($block0[0] === 9 or $block0[0] === 8 or $block1[0] === 9 or $block1[0] === 8 or $block2[0] === 9 or $block2[0] === 8 or $block3[0] === 9 or $block3[0] === 8){
}else{
return false;
}
}
break;
case 26: //bed case 26: //bed
$face = array( $face = array(
0 => 3, 0 => 3,

View File

@ -185,8 +185,8 @@ class Entity extends stdClass{
for($y = $startY; $y <= $endY; ++$y){ for($y = $startY; $y <= $endY; ++$y){
for($x = $startX; $x <= $endX; ++$x){ for($x = $startX; $x <= $endX; ++$x){
for($z = $startZ; $z <= $endZ; ++$z){ for($z = $startZ; $z <= $endZ; ++$z){
$b = $this->server->api->level->getBlock($x, $y, $z); $b = $this->server->api->block->getBlock(new Vector3($x, $y, $z));
switch($b[0]){ switch($b->getID()){
case WATER: case WATER:
case STILL_WATER: //Drowing case STILL_WATER: //Drowing
if($this->fire > 0 and $this->inBlock($x, $y, $z)){ if($this->fire > 0 and $this->inBlock($x, $y, $z)){
@ -221,7 +221,7 @@ class Entity extends stdClass{
} }
break; break;
default: default:
if($this->inBlock($x, $y, $z, 0.7) and $y == $endY and !isset(Material::$transparent[$b[0]]) and ($this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER)){ if($this->inBlock($x, $y, $z, 0.7) and $y == $endY and $b->isTransparent === false and ($this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER)){
$this->harm(1, "suffocation"); //Suffocation $this->harm(1, "suffocation"); //Suffocation
}elseif($x == ($endX - 1) and $y == $endY and $z == ($endZ - 1)){ }elseif($x == ($endX - 1) and $y == $endY and $z == ($endZ - 1)){
$this->air = 300; //Breathing $this->air = 300; //Breathing
@ -249,7 +249,7 @@ class Entity extends stdClass{
$x = (int) round($this->x - 0.5); $x = (int) round($this->x - 0.5);
$y = (int) round($this->y - 1); $y = (int) round($this->y - 1);
$z = (int) round($this->z - 0.5); $z = (int) round($this->z - 0.5);
$blockDown = $this->server->api->level->getBlock($x, $y, $z); $blockDown = $this->server->api->block->getBlock(new Vector3($x, $y, $z));
if($this->class === ENTITY_ITEM or $this->class === ENTITY_MOB){ if($this->class === ENTITY_ITEM or $this->class === ENTITY_MOB){
if($this->speedX != 0){ if($this->speedX != 0){
$this->x += $this->speedX * 5; $this->x += $this->speedX * 5;
@ -260,7 +260,7 @@ class Entity extends stdClass{
if($this->speedZ != 0){ if($this->speedZ != 0){
$this->z += $this->speedZ * 5; $this->z += $this->speedZ * 5;
} }
if(isset(Material::$transparent[$blockDown[0]])){ if(isset($blockDown->isFlowable === true){
$this->speedY -= 0.04 * 5; $this->speedY -= 0.04 * 5;
//$this->server->api->handle("entity.motion", $this); //$this->server->api->handle("entity.motion", $this);
}elseif($this->speedY < 0){ }elseif($this->speedY < 0){
@ -271,14 +271,13 @@ class Entity extends stdClass{
//$this->server->api->handle("entity.motion", $this); //$this->server->api->handle("entity.motion", $this);
} }
}else{ }else{
if(isset(Material::$flowable[$blockDown[0]])){ if(isset($blockDown->isFlowable === true){
if($this->fallY === false or $y > $this->fallY){ if($this->fallY === false or $y > $this->fallY){
$this->fallY = $y; $this->fallY = $y;
} }
}elseif($this->fallY !== false){ //Fall damage! }elseif($this->fallY !== false){ //Fall damage!
if($y < $this->fallY){ if($y < $this->fallY){
$d = $this->server->api->level->getBlock($x, $y + 1, $z); $d = $this->server->api->block->getBlock(new Vector3($x, $y + 1, $z));
$d = BlockAPI::get($d[0]);
$dmg = ($this->fallY - $y) - 3; $dmg = ($this->fallY - $y) - 3;
if($dmg > 0 and !($d instanceof LiquidBlock)){ if($dmg > 0 and !($d instanceof LiquidBlock)){
$this->harm($dmg, "fall"); $this->harm($dmg, "fall");