Fixed #39 placing blocks inside an entity

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-12 16:47:12 +01:00
parent 4bda101ab8
commit e4d71949e3
3 changed files with 21 additions and 4 deletions

View File

@ -391,8 +391,16 @@ class BlockAPI{
}else{
return $this->cancelAction($block);
}
$entity = $this->server->api->entity->get($data["eid"]);
if(($entity instanceof Entity) !== true){
return $this->cancelAction($block); //No Entity WTF?
}
if($entity->inBlock($block[2][0], $block[2][1], $block[2][2])){
return $this->cancelAction($block); //Entity in block
}
$direction = $this->server->api->entity->get($data["eid"])->getDirection();
$direction = $entity->getDirection();
switch($data["block"]){
case 6:

View File

@ -229,6 +229,16 @@ class Entity extends stdClass{
$this->server->api->dhandle("entity.move", $this);
}
public function inBlock($x, $y, $z){
$block = new Vector3($x + 0.5, $y, $z + 0.5);
$me = new Vector3($this->x, $this->y, $this->z);
$up = new Vector3($this->x, $this->y + 1, $this->z);
if($block->distance($me) < 0.8 or $block->distance($up) < 0.8){
return true;
}
return false;
}
public function updateVelocity(){
$diffTime = microtime(true) - $this->last[3];
$this->last[3] = microtime(true);

View File

@ -32,7 +32,7 @@ class PocketMinecraftServer{
private function load(){
$this->version = new VersionString();
console("[INFO] PocketMine-MP ".MAJOR_VERSION." #".$this->version->getNumber()." by @shoghicp, LGPL License", true, true, 0);
console("[DEBUG] Target Minecraft PE: ".CURRENT_MINECRAFT_VERSION, true, true, 2);
console("[DEBUG] Target Minecraft PE: ".CURRENT_MINECRAFT_VERSION.", protocol #".CURRENT_PROTOCOL, true, true, 2);
console("[INFO] Starting Minecraft PE Server at *:".$this->port);
if($this->port < 19132 or $this->port > 19135){
console("[WARNING] You've selected a not-standard port. Normal port range is from 19132 to 19135 included");
@ -72,8 +72,7 @@ class PocketMinecraftServer{
$this->interface = new MinecraftInterface("255.255.255.255", $this->port, true, false);
$this->reloadConfig();
console("[INFO] Server Name: ".$this->name);
console("[INFO] Server GUID: ".$this->serverID);
console("[INFO] Protocol Version: ".CURRENT_PROTOCOL);
console("[DEBUG] Server GUID: ".$this->serverID, true, true, 2);
$this->stop = false;
}