mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Bed placement
This commit is contained in:
parent
719dff6e3c
commit
565cb9781c
@ -322,7 +322,7 @@ class BlockAPI{
|
||||
2 => 2,
|
||||
3 => 5,
|
||||
);
|
||||
$next = $this->server->api->level->getBlockFace($block, $face[(($direction + 3) % 4)]);
|
||||
$next = $level->getBlockFace($block, $face[(($direction + 3) % 4)]);
|
||||
if(!isset(Material::$replaceable[$next[0]])){
|
||||
return false;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ class Item{
|
||||
SIGN => "SignItem",
|
||||
WOODEN_DOOR => "WoodenDoorItem",
|
||||
IRON_DOOR => "IronDoorItem",
|
||||
BED => "BedItem",
|
||||
);
|
||||
protected $block;
|
||||
protected $id;
|
||||
|
@ -31,4 +31,34 @@ class BedBlock extends TransparentBlock{
|
||||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($block->inWorld === true){
|
||||
$down = $level->getBlockFace($block, 0);
|
||||
if($down->isTransparent === false){
|
||||
$faces = array(
|
||||
0 => 3,
|
||||
1 => 4,
|
||||
2 => 2,
|
||||
3 => 5,
|
||||
);
|
||||
$d = $player->entity->getDirection();
|
||||
$next = $level->getBlockFace($block, $faces[(($d + 3) % 4)]);
|
||||
$downNext = $level->getBlockFace($next, 0);
|
||||
if($next->isReplaceable === true and $downNext->isTransparent === false){
|
||||
$meta = (($d + 3) % 4) & 0x03;
|
||||
$level->setBlock($block, $this->id, $meta);
|
||||
$level->setBlock($next, $this->id, $meta | 0x08);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(BED, 0, 1),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
33
src/classes/material/item/generic/Bed.php
Normal file
33
src/classes/material/item/generic/Bed.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?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 BedItem extends Item{
|
||||
public function __construct($meta = 0, $count = 1){
|
||||
$this->block = BlockAPI::get(BED_BLOCK);
|
||||
parent::__construct(BED, 0, $count, "Bed");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user