mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-05 09:39:56 +00:00
Fixed #287 Items dropped will be deleted if picked up in creative mode [gh#287]
This commit is contained in:
parent
5e1dddaba0
commit
a538543e4c
@ -266,6 +266,32 @@ class Player{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasSpace($type, $damage, $count){
|
||||||
|
$inv = $this->inventory;
|
||||||
|
while($count > 0){
|
||||||
|
$add = 0;
|
||||||
|
foreach($inv as $s => $data){
|
||||||
|
if($data[0] === AIR){
|
||||||
|
$add = min(64, $count);
|
||||||
|
$inv[$s] = array($type, $damage, $add);
|
||||||
|
break;
|
||||||
|
}elseif($data[0] === $type and $data[1] === $damage){
|
||||||
|
$add = min(64 - $data[2], $count);
|
||||||
|
if($add <= 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$inv[$s] = array($type, $damage, $data[2] + $add);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($add === 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$count -= $add;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function addItem($type, $damage, $count){
|
public function addItem($type, $damage, $count){
|
||||||
while($count > 0){
|
while($count > 0){
|
||||||
$add = 0;
|
$add = 0;
|
||||||
|
@ -183,17 +183,19 @@ class Entity extends Position{
|
|||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(($player instanceof Player) and ($player->gamemode & 0x01) === 0x00 and $player->spawned === true){
|
if(($player instanceof Player) and $player->spawned === true){
|
||||||
if($this->server->api->dhandle("player.pickup", array(
|
if(($player->gamemode & 0x01) === 0x00){
|
||||||
"eid" => $player->eid,
|
if($player->hasSpace($this->type, $this->meta, $this->stack) === true and $this->server->api->dhandle("player.pickup", array(
|
||||||
"player" => $player,
|
"eid" => $player->eid,
|
||||||
"entity" => $this,
|
"player" => $player,
|
||||||
"block" => $this->type,
|
"entity" => $this,
|
||||||
"meta" => $this->meta,
|
"block" => $this->type,
|
||||||
"target" => $this->eid
|
"meta" => $this->meta,
|
||||||
)) !== false){
|
"target" => $this->eid
|
||||||
$this->close();
|
)) !== false){
|
||||||
return false;
|
$this->close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user