mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Minecraft: Pocket Edition 0.7.0 dev. release
* Crafting enabled, report bugs * Chat handler
This commit is contained in:
@@ -100,6 +100,9 @@ class BlockAPI{
|
||||
array(LADDER, 0),
|
||||
array(TORCH, 0),
|
||||
array(GLASS_PANE, 0),
|
||||
array(BUCKET, 0),
|
||||
array(BUCKET, 8),
|
||||
array(BUCKET, 10),
|
||||
array(WOODEN_DOOR, 0),
|
||||
array(TRAPDOOR, 0),
|
||||
array(FENCE, 0),
|
||||
@@ -129,9 +132,15 @@ class BlockAPI{
|
||||
array(MELON_SEEDS, 0),
|
||||
array(DYE, 15), //Bonemeal
|
||||
array(IRON_HOE, 0),
|
||||
array(CAKE, 0),
|
||||
array(EGG, 0),
|
||||
array(IRON_SWORD, 0),
|
||||
array(BOW, 0),
|
||||
array(SIGN, 0),
|
||||
array(SPAWN_EGG, MOB_CHICKEN),
|
||||
array(SPAWN_EGG, MOB_COW),
|
||||
array(SPAWN_EGG, MOB_PIG),
|
||||
array(SPAWN_EGG, MOB_SHEEP),
|
||||
);
|
||||
|
||||
public static function fromString($str, $multiple = false){
|
||||
@@ -217,11 +226,7 @@ class BlockAPI{
|
||||
$output .= "Player is in creative mode.\n";
|
||||
break;
|
||||
}
|
||||
if($this->server->api->getProperty("item-enforcement") === false){
|
||||
$this->server->api->entity->drop(new Position($player->entity->x - 0.5, $player->entity->y, $player->entity->z - 0.5, $player->level), $item, true);
|
||||
}else{
|
||||
$player->addItem($item->getID(), $item->getMetadata(), $item->count);
|
||||
}
|
||||
$player->addItem($item->getID(), $item->getMetadata(), $item->count);
|
||||
$output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$player->username."\n";
|
||||
}else{
|
||||
$output .= "Unknown player.\n";
|
||||
@@ -240,16 +245,14 @@ class BlockAPI{
|
||||
"block" => $block->getID(),
|
||||
"meta" => $block->getMetadata()
|
||||
));
|
||||
if($player->itemEnforcement === true){
|
||||
$player->sendInventory();
|
||||
}
|
||||
$player->sendInventorySlot($player->slot);
|
||||
return false;
|
||||
}
|
||||
|
||||
public function playerBlockBreak(Player $player, Vector3 $vector){
|
||||
|
||||
$target = $player->level->getBlock($vector);
|
||||
$item = $player->equipment;
|
||||
$item = $player->getSlot($player->slot);
|
||||
|
||||
if($this->server->api->dhandle("player.block.touch", array("type" => "break", "player" => $player, "target" => $target, "item" => $item)) === false){
|
||||
return $this->cancelAction($target, $player);
|
||||
@@ -287,7 +290,7 @@ class BlockAPI{
|
||||
|
||||
$target = $player->level->getBlock($vector);
|
||||
$block = $target->getSide($face);
|
||||
$item = $player->equipment;
|
||||
$item = $player->getSlot($player->slot);
|
||||
|
||||
if($target->getID() === AIR and $this->server->api->dhandle("player.block.place.invalid", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){ //If no block exists or not allowed in CREATIVE
|
||||
$this->cancelAction($target, $player);
|
||||
@@ -343,7 +346,10 @@ class BlockAPI{
|
||||
}
|
||||
|
||||
if(($player->gamemode & 0x01) === 0x00){
|
||||
$player->removeItem($item->getID(), $item->getMetadata(), 1);
|
||||
--$item->count;
|
||||
if($item->count <= 0){
|
||||
$player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -419,7 +419,7 @@ class PlayerAPI{
|
||||
"y" => $this->server->spawn->y,
|
||||
"z" => $this->server->spawn->z,
|
||||
),
|
||||
"inventory" => array_fill(0, 36, array(AIR, 0, 0)),
|
||||
"inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, array(AIR, 0, 0)),
|
||||
"armor" => array_fill(0, 4, array(AIR, 0, 0)),
|
||||
"gamemode" => $this->server->gamemode,
|
||||
"health" => 20,
|
||||
|
@@ -72,7 +72,6 @@ class ServerAPI{
|
||||
"view-distance" => 10,
|
||||
"max-players" => 20,
|
||||
"allow-flight" => false,
|
||||
"item-enforcement" => false,
|
||||
"gamemode" => SURVIVAL,
|
||||
"hardcore" => false,
|
||||
"pvp" => true,
|
||||
@@ -289,7 +288,7 @@ class ServerAPI{
|
||||
if($this->getProperty("enable-query") === true){
|
||||
$this->query = new Query();
|
||||
}
|
||||
|
||||
CraftingRecipes::init();
|
||||
$this->server->init();
|
||||
unregister_tick_function(array($this->server, "tick"));
|
||||
$this->console->__destruct();
|
||||
|
@@ -1,122 +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 TileEntityAPI{
|
||||
private $server;
|
||||
private $tileEntities;
|
||||
private $tCnt = 1;
|
||||
function __construct(){
|
||||
$this->tileEntities = array();
|
||||
$this->server = ServerAPI::request();
|
||||
}
|
||||
|
||||
public function get(Position $pos){
|
||||
$tile = $this->server->query("SELECT * FROM tileentities WHERE level = '".$pos->level->getName()."' AND x = {$pos->x} AND y = {$pos->y} AND z = {$pos->z};", true);
|
||||
if($tile !== false and $tile !== true and ($tile = $this->getByID($tile["ID"])) !== false){
|
||||
return $tile;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getByID($id){
|
||||
if($id instanceof TileEntity){
|
||||
return $id;
|
||||
}elseif(isset($this->tileEntities[$id])){
|
||||
return $this->tileEntities[$id];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function init(){
|
||||
|
||||
}
|
||||
|
||||
public function getAll($level = null){
|
||||
if($level instanceof Level){
|
||||
$tileEntities = array();
|
||||
$l = $this->server->query("SELECT ID FROM tileentities WHERE level = '".$level->getName()."';");
|
||||
if($l !== false and $l !== true){
|
||||
while(($t = $l->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||
$t = $this->getByID($t["ID"]);
|
||||
if($t instanceof TileEntity){
|
||||
$tileEntities[$t->id] = $t;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tileEntities;
|
||||
}
|
||||
return $this->tileEntities;
|
||||
}
|
||||
|
||||
public function add(Level $level, $class, $x, $y, $z, $data = array()){
|
||||
$id = $this->tCnt++;
|
||||
$this->tileEntities[$id] = new TileEntity($level, $id, $class, $x, $y, $z, $data);
|
||||
$this->spawnToAll($this->tileEntities[$id]);
|
||||
return $this->tileEntities[$id];
|
||||
}
|
||||
|
||||
public function addSign(Level $level, $x, $y, $z, $lines = array("", "", "", "")){
|
||||
return $this->add($level, TILE_SIGN, $x, $y, $z, $data = array(
|
||||
"id" => "Sign",
|
||||
"x" => $x,
|
||||
"y" => $y,
|
||||
"z" => $z,
|
||||
"Text1" => $lines[0],
|
||||
"Text2" => $lines[1],
|
||||
"Text3" => $lines[2],
|
||||
"Text4" => $lines[3],
|
||||
));
|
||||
}
|
||||
|
||||
public function spawnToAll(TileEntity $t){
|
||||
foreach($this->server->api->player->getAll($t->level) as $player){
|
||||
if($player->eid !== false){
|
||||
$t->spawn($player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function spawnAll(Player $player){
|
||||
foreach($this->getAll($player->level) as $t){
|
||||
$t->spawn($player);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($id){
|
||||
if(isset($this->tileEntities[$id])){
|
||||
$t = $this->tileEntities[$id];
|
||||
$this->tileEntities[$id] = null;
|
||||
unset($this->tileEntities[$id]);
|
||||
$t->closed = true;
|
||||
$t->close();
|
||||
$this->server->query("DELETE FROM tileentities WHERE ID = ".$id.";");
|
||||
$this->server->api->dhandle("tile.remove", $t);
|
||||
$t = null;
|
||||
unset($t);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user