mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
rail connection is enabled by default + some tweaks
This commit is contained in:
parent
8e5d2bb1c7
commit
ba85d69149
5 changed files with 50 additions and 22 deletions
|
|
@ -20,5 +20,40 @@ abstract class RailBaseBlock extends FlowableBlock //TODO move some methods here
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function updateState(){}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
|
||||
$meta = $this->getMetadata();
|
||||
if($this->id === POWERED_RAIL){
|
||||
$meta &= 7;
|
||||
}
|
||||
$x = $this->x;
|
||||
$y = $this->y;
|
||||
$z = $this->z;
|
||||
if(
|
||||
($this->level->level->getBlockID($x, $y - 1, $z) === 0) ||
|
||||
(($meta == 2) && $this->level->level->getBlockID($x + 1, $y, $z) === 0) ||
|
||||
(($meta == 3) && $this->level->level->getBlockID($x - 1, $y, $z) === 0) ||
|
||||
(($meta == 4) && $this->level->level->getBlockID($x, $y, $z - 1) === 0) ||
|
||||
(($meta == 5) && $this->level->level->getBlockID($x, $y, $z + 1) === 0)
|
||||
){
|
||||
$this->level->setBlock($this, new AirBlock(), true, false, true);
|
||||
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1));
|
||||
}else{
|
||||
$this->updateState();
|
||||
}
|
||||
|
||||
|
||||
//if($this->getSide(0)->getID() === AIR){//Replace with common break method
|
||||
// ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1));
|
||||
// $this->level->setBlock($this, new AirBlock(), true, false, true);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue