mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Trapdoor placement & activation
This commit is contained in:
parent
e15392f7bc
commit
59ae4f6faa
@ -438,39 +438,6 @@ class BlockAPI{
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 53://Stairs
|
||||
case 67:
|
||||
case 108:
|
||||
case 109:
|
||||
case 114:
|
||||
case 128:
|
||||
case 156:
|
||||
$faces = array(
|
||||
0 => 0,
|
||||
1 => 2,
|
||||
2 => 1,
|
||||
3 => 3,
|
||||
);
|
||||
$data["meta"] = $faces[$direction] & 0x03;
|
||||
if(($data["y"] - 1) > $entity->y){
|
||||
$data["meta"] |= 0x04; //Upside-down stairs
|
||||
}
|
||||
break;
|
||||
case 96: //trapdoor
|
||||
if(isset(Material::$transparent[$target[0]])){
|
||||
return false;
|
||||
}
|
||||
$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,
|
||||
|
@ -45,7 +45,7 @@ class TorchBlock extends FlowableBlock{
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
|
62
src/classes/material/block/attachable/Trapdoor.php
Normal file
62
src/classes/material/block/attachable/Trapdoor.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ PocketMine \
|
||||
/ 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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class TrapdoorBlock extends TransparentBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(TRAPDOOR, $meta, "Trapdoor");
|
||||
$this->isActivable = true;
|
||||
}
|
||||
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($block->inWorld === true){
|
||||
if($target->isTransparent === false and $face !== 0 and $face !== 1){
|
||||
$faces = array(
|
||||
2 => 0,
|
||||
3 => 1,
|
||||
4 => 2,
|
||||
5 => 3,
|
||||
);
|
||||
$this->meta = $faces[$face] & 0x03;
|
||||
if($fy > 0.5){
|
||||
$this->meta |= 0x08;
|
||||
}
|
||||
$level->setBlock($block, $this->id, $this->meta);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
}
|
||||
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
||||
$this->meta ^= 0x04;
|
||||
$level->setBlock($this, $this->id, $this->meta);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ PocketMine \
|
||||
/ 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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class TrapdoorBlock extends TransparentBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(TRAPDOOR, $meta, "Trapdoor");
|
||||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user