Correct position for gates,doors,stairs,trapdoors

+ corrected cactus bug
This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-24 03:04:06 +01:00
parent dfa9f55115
commit 52810a11ba
3 changed files with 75 additions and 22 deletions

View File

@ -10,7 +10,6 @@ __Check Milestones [here](https://github.com/shoghicp/PocketMine-MP/issues/miles
- Random Chunk Updates
- Placing Half Slabs
- Water/lava spread
- Door, trapdoor, stair, fence gate placement/orientation (+should need ground/wall beneath)
- Opening/closing doors, fence gates, trapdoors (reflect it to all players)
- Fix spawn position resetting
- Correct block placement for beds
@ -18,7 +17,6 @@ __Check Milestones [here](https://github.com/shoghicp/PocketMine-MP/issues/miles
- Bonemeal use
- Hoes tilling dirt
- Players can often hear "echos" of their own block interactions' SFX (torch placed, block destroyed, etc. most noticeable when moving around as you place.)
- BUG? Breaking redstone ore blocks not dropping TONS of redstone ore blocks (One-time occurrence... can't reproduce XD;)
- Redstone ore blocks lighting up upon hit or contact
- Cactus placement requirements (needs open blocks beside)
- Sapling / flower placement requirements

View File

@ -97,7 +97,7 @@ class BlockAPI{
return;
}
$entity = $this->server->api->entity->get($this->eid);
$direction = $this->server->api->entity->get($data["eid"])->getDirection();
switch($data["block"]){
case 50: //Torch
@ -117,6 +117,41 @@ class BlockAPI{
}
$data["meta"] = $faces[$data["face"]];
break;
case 53://Stairs
case 67:
case 108:
$faces = array(
0 => 0,
1 => 2,
2 => 1,
3 => 3,
);
$data["meta"] = $faces[$direction] & 0x03;
break;
case 96: //trapdoor
if(isset(Material::$transparent[$target[0]])){
return;
}
$faces = array(
2 => 0,
3 => 1,
4 => 2,
5 => 3,
);
if(!isset($faces[$data["face"]])){
return false;
}
$data["meta"] = $faces[$data["face"]] & 0x03;
break;
case 107: //Fence gate
$faces = array(
0 => 3,
1 => 0,
2 => 1,
3 => 2,
);
$data["meta"] = $faces[$direction] & 0x03;
break;
case 64://Door placing
$blockUp = $this->server->api->level->getBlock($data["x"], $data["y"] + 1, $data["z"]);
$blockDown = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"]);
@ -124,8 +159,8 @@ class BlockAPI{
return;
}else{
$data2 = $data;
$data2["meta"] = $data2["meta"] | 0x08;
$data["meta"] = $data["meta"] & 0x07;
$data2["meta"] = 0x08;
$data["meta"] = $direction & 0x03;
++$data2["y"];
$this->server->handle("player.block.place", $data2);
}
@ -155,10 +190,10 @@ class BlockAPI{
break;
case 81: //Cactus
$blockDown = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"]);
$block0 = $this->server->api->level->getBlock($data["x"] + 1, $data["y"], $data["z"] + 1);
$block1 = $this->server->api->level->getBlock($data["x"] - 1, $data["y"], $data["z"] + 1);
$block2 = $this->server->api->level->getBlock($data["x"] + 1, $data["y"], $data["z"] - 1);
$block3 = $this->server->api->level->getBlock($data["x"] - 1, $data["y"], $data["z"] - 1);
$block0 = $this->server->api->level->getBlock($data["x"], $data["y"], $data["z"] + 1);
$block1 = $this->server->api->level->getBlock($data["x"], $data["y"], $data["z"] - 1);
$block2 = $this->server->api->level->getBlock($data["x"] + 1, $data["y"], $data["z"]);
$block3 = $this->server->api->level->getBlock($data["x"] - 1, $data["y"], $data["z"]);
if($blockDown[0] !== 12 or $block0[0] !== 0 or $block1[0] !== 0 or $block2[0] !== 0 or $block3[0] !== 0){
return;
}

View File

@ -2,20 +2,20 @@
/*
-
/ \
/ \
-
/ \
/ \
/ PocketMine \
/ MP \
|\ @shoghicp /|
|. \ / .|
| .. \ / .. |
| .. | .. |
| .. | .. |
\ | /
\ | /
\ | /
\ | /
/ MP \
|\ @shoghicp /|
|. \ / .|
| .. \ / .. |
| .. | .. |
| .. | .. |
\ | /
\ | /
\ | /
\ | /
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -74,6 +74,26 @@ class Entity extends stdClass{
}
}
public function getDirection(){
$rotation = ($this->yaw - 90) % 360;
if ($rotation < 0) {
$rotation += 360.0;
}
if(0 <= $rotation && $rotation < 45) {
return 2;
}elseif(45 <= $rotation && $rotation < 135) {
return 3;
}elseif(135 <= $rotation && $rotation < 225) {
return 0;
}elseif(225 <= $rotation && $rotation < 315) {
return 1;
}elseif(315 <= $rotation && $rotation < 360) {
return 2;
}else{
return null;
}
}
public function spawn($player){
if(!is_object($player)){
$player = $this->server->api->player->get($player);