mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Added Sign placement
This commit is contained in:
parent
3e87d1927d
commit
4f0517a5a7
@ -63,9 +63,9 @@ class BlockAPI{
|
|||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlock($block, $id, $meta){
|
public function setBlock($block, $id, $meta, $update = true, $tiles = false){
|
||||||
if(($block instanceof Vector3) or (($block instanceof Block) and $block->inWorld === true)){
|
if(($block instanceof Vector3) or (($block instanceof Block) and $block->inWorld === true)){
|
||||||
$this->server->api->level->setBlock($block->x, $block->y, $block->z, (int) $id, (int) $meta);
|
$this->server->api->level->setBlock($block->x, $block->y, $block->z, (int) $id, (int) $meta, $update, $tiles);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -307,12 +307,13 @@ class BlockAPI{
|
|||||||
return $this->cancelAction($block); //Entity in block
|
return $this->cancelAction($block); //Entity in block
|
||||||
}
|
}
|
||||||
|
|
||||||
//$direction = $player->entity->getDirection();
|
|
||||||
|
|
||||||
if($hand->place($this, $item, $player, $block, $target, $data["face"], $data["fx"], $data["fy"], $data["fz"]) === false){
|
if($hand->place($this, $item, $player, $block, $target, $data["face"], $data["fx"], $data["fy"], $data["fz"]) === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if($hand->getID() === SIGN_POST or $hand->getID() === WALL_POST){
|
||||||
|
$t = $this->server->api->tileentity->addSign($block->x, $block->y, $block->z);
|
||||||
|
$t->data["creator"] = $player->username;
|
||||||
|
}
|
||||||
/*switch($data["block"]){
|
/*switch($data["block"]){
|
||||||
case 26: //bed
|
case 26: //bed
|
||||||
$face = array(
|
$face = array(
|
||||||
@ -333,39 +334,6 @@ class BlockAPI{
|
|||||||
$data2["z"] = $next[2][2];
|
$data2["z"] = $next[2][2];
|
||||||
$this->server->handle("player.block.place", $data2);
|
$this->server->handle("player.block.place", $data2);
|
||||||
break;
|
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"], $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 !isset(Material::$transparent[$block0[0]]) or !isset(Material::$transparent[$block1[0]]) or !isset(Material::$transparent[$block2[0]]) or !isset(Material::$transparent[$block3[0]])){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 323: //Signs
|
|
||||||
$faces = array(
|
|
||||||
2 => 2,
|
|
||||||
3 => 3,
|
|
||||||
4 => 4,
|
|
||||||
5 => 5,
|
|
||||||
);
|
|
||||||
if(!isset($faces[$data["face"]])){
|
|
||||||
if($data["face"] === 1){
|
|
||||||
$data["block"] = 63;
|
|
||||||
$data["meta"] = 0;
|
|
||||||
$t = $this->server->api->tileentity->addSign($data["x"], $data["y"], $data["z"]);
|
|
||||||
$t->data["creator"] = $entity->player->username;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$data["block"] = 68;
|
|
||||||
$data["meta"] = $faces[$data["face"]];
|
|
||||||
$t = $this->server->api->tileentity->addSign($data["x"], $data["y"], $data["z"]);
|
|
||||||
$t->data["creator"] = $entity->player->username;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if($this->server->gamemode === 0 or $this->server->gamemode === 2){
|
if($this->server->gamemode === 0 or $this->server->gamemode === 2){
|
||||||
|
@ -32,6 +32,9 @@ class Item{
|
|||||||
SUGARCANE => "SugarcaneItem",
|
SUGARCANE => "SugarcaneItem",
|
||||||
WHEAT_SEEDS => "WheatSeedsItem",
|
WHEAT_SEEDS => "WheatSeedsItem",
|
||||||
MELON_SEEDS => "MelonSeedsItem",
|
MELON_SEEDS => "MelonSeedsItem",
|
||||||
|
SIGN => "SignItem",
|
||||||
|
WOODEN_DOOR => "WoodenDoorItem",
|
||||||
|
IRON_DOOR => "IronDoorItem",
|
||||||
);
|
);
|
||||||
protected $block;
|
protected $block;
|
||||||
protected $id;
|
protected $id;
|
||||||
|
@ -40,7 +40,7 @@ class GenericBlock extends Block{
|
|||||||
|
|
||||||
public function onBreak(BlockAPI $level, Item $item, Player $player){
|
public function onBreak(BlockAPI $level, Item $item, Player $player){
|
||||||
if($this->inWorld === true){
|
if($this->inWorld === true){
|
||||||
$level->setBlock($this, 0, 0);
|
$level->setBlock($this, AIR, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
67
src/classes/material/block/attachable/SignPost.php
Normal file
67
src/classes/material/block/attachable/SignPost.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?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 SignPostBlock extends TransparentBlock{
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
parent::__construct(SIGN_POST, $meta, "Sign Post");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
|
if($block->inWorld === true and $face !== 0){
|
||||||
|
if($face !== 0){
|
||||||
|
$faces = array(
|
||||||
|
2 => 2,
|
||||||
|
3 => 3,
|
||||||
|
4 => 4,
|
||||||
|
5 => 5,
|
||||||
|
);
|
||||||
|
if(!isset($faces[$face])){
|
||||||
|
$level->setBlock($block, SIGN_POST, 0);
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
$level->setBlock($block, WALL_SIGN, $faces[$face]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBreak(BlockAPI $level, Item $item, Player $player){
|
||||||
|
if($this->inWorld === true){
|
||||||
|
$level->setBlock($this, 0, 0, true, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item, Player $player){
|
||||||
|
return array(
|
||||||
|
array(SIGN, 0, 1),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -31,8 +31,8 @@ class TorchBlock extends FlowableBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if($block->inWorld === true){
|
if($block->inWorld === true and $face !== 0){
|
||||||
if($target->isTransparent === false and $face !== 0){
|
if($target->isTransparent === false){
|
||||||
$faces = array(
|
$faces = array(
|
||||||
1 => 5,
|
1 => 5,
|
||||||
2 => 4,
|
2 => 4,
|
||||||
|
68
src/classes/material/block/attachable/WallSign.php
Normal file
68
src/classes/material/block/attachable/WallSign.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?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 WallSignBlock extends TransparentBlock{
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
parent::__construct(WALL_SIGN, $meta, "Wall Sign");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
|
if($block->inWorld === true and $face !== 0){
|
||||||
|
if($face !== 0){
|
||||||
|
$faces = array(
|
||||||
|
2 => 2,
|
||||||
|
3 => 3,
|
||||||
|
4 => 4,
|
||||||
|
5 => 5,
|
||||||
|
);
|
||||||
|
if(!isset($faces[$face])){
|
||||||
|
$level->setBlock($block, SIGN_POST, 0);
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
$level->setBlock($block, WALL_SIGN, $faces[$face]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBreak(BlockAPI $level, Item $item, Player $player){
|
||||||
|
if($this->inWorld === true){
|
||||||
|
$level->setBlock($this, AIR, 0, true, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item, Player $player){
|
||||||
|
return array(
|
||||||
|
array(SIGN, 0, 1),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,13 +25,9 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SignPostBlock extends TransparentBlock{
|
class IronDoorItem extends Item{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0, $count = 1){
|
||||||
parent::__construct(SIGN_POST, $meta, "Sign Post");
|
$this->block = BlockAPI::get(IRON_DOOR_BLOCK);
|
||||||
}
|
parent::__construct(IRON_DOOR, 0, $count, "Iron Door");
|
||||||
public function getDrops(Item $item, Player $player){
|
|
||||||
return array(
|
|
||||||
array(323, 0, 1),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,14 +25,9 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class WallSignBlock extends TransparentBlock{
|
class SignItem extends Item{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0, $count = 1){
|
||||||
parent::__construct(WALL_SIGN, $meta, "Wall Sign");
|
$this->block = BlockAPI::get(SIGN_POST);
|
||||||
|
parent::__construct(SIGN, 0, $count, "Sign");
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
|
||||||
return array(
|
|
||||||
array(323, 0, 1),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
33
src/classes/material/item/generic/WoodenDoor.php
Normal file
33
src/classes/material/item/generic/WoodenDoor.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 WoodenDoorItem extends Item{
|
||||||
|
public function __construct($meta = 0, $count = 1){
|
||||||
|
$this->block = BlockAPI::get(WOODEN_DOOR_BLOCK);
|
||||||
|
parent::__construct(WOODEN_DOOR, 0, $count, "Wooden Door");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user