Correct Torch/Ladder placing

This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-24 01:54:05 +01:00
parent bcb65c2960
commit dfa9f55115
3 changed files with 76 additions and 14 deletions

View file

@ -100,9 +100,27 @@ class BlockAPI{
$entity = $this->server->api->entity->get($this->eid);
switch($data["block"]){
case 50: //Torch
if(isset(Material::$transparent[$target[0]])){
return;
}
$faces = array(
0 => 6,
1 => 5,
2 => 4,
3 => 3,
4 => 2,
5 => 1,
);
if(!isset($faces[$data["face"]])){
return false;
}
$data["meta"] = $faces[$data["face"]];
break;
case 64://Door placing
$blockUp = $this->server->api->level->getBlock($data["x"], $data["y"] + 1, $data["z"]);
if(!isset(Material::$replaceable[$blockUp[0]])){
$blockDown = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"]);
if(!isset(Material::$replaceable[$blockUp[0]]) or isset(Material::$transparent[$blockDown[0]])){
return;
}else{
$data2 = $data;
@ -112,6 +130,21 @@ class BlockAPI{
$this->server->handle("player.block.place", $data2);
}
break;
case 65: //Ladder
if(isset(Material::$transparent[$target[0]])){
return;
}
$faces = array(
2 => 2,
3 => 3,
4 => 4,
5 => 5,
);
if(!isset($faces[$data["face"]])){
return false;
}
$data["meta"] = $faces[$data["face"]];
break;
case 59://Seeds
case 105:
$blockDown = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"]);

View file

@ -26,6 +26,41 @@ the Free Software Foundation, either version 3 of the License, or
*/
class Material{
static $transparent = array(
0 => true,
6 => true,
8 => true,
9 => true,
10 => true,
11 => true,
18 => true,
20 => true,
26 => true,
30 => true,
31 => true,
32 => true,
37 => true,
38 => true,
39 => true,
40 => true,
46 => true,
50 => true,
51 => true,
53 => true,
59 => true,
65 => true,
67 => true,
78 => true,
79 => true,
81 => true,
83 => true,
89 => true,
96 => true,
102 => true,
105 => true,
107 => true,
108 => true,
);
static $replaceable = array(
0 => true,
8 => true,