mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-19 15:35:52 +00:00
Item Drop
This commit is contained in:
parent
c2a45212dd
commit
9ebe68294b
@ -204,11 +204,13 @@ class BlockAPI{
|
||||
$data["x"] += mt_rand(2, 8) / 10;
|
||||
$data["y"] += 0.19;
|
||||
$data["z"] += mt_rand(2, 8) / 10;
|
||||
for($count = $stack; $count > 0; ){
|
||||
$data["stack"] = min(64, $count);
|
||||
$count -= $data["stack"];
|
||||
$e = $this->server->api->entity->add(ENTITY_ITEM, $block, $data);
|
||||
$this->server->api->entity->spawnToAll($e->eid);
|
||||
if($this->server->api->handle("item.drop", $data) !== false){
|
||||
for($count = $stack; $count > 0; ){
|
||||
$data["stack"] = min(64, $count);
|
||||
$count -= $data["stack"];
|
||||
$e = $this->server->api->entity->add(ENTITY_ITEM, $block, $data);
|
||||
$this->server->api->entity->spawnToAll($e->eid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,22 @@ class CustomPacketHandler{
|
||||
$this->raw .= Utils::writeFloat($this->data["x"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["y"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["z"]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MC_DROP_ITEM:
|
||||
if($this->c === false){
|
||||
$this->data["eid"] = Utils::readInt($this->get(4));
|
||||
$this->data["unknown1"] = ord($this->get(1));
|
||||
$this->data["block"] = Utils::readShort($this->get(2), false);
|
||||
$this->data["stack"] = ord($this->get(1));
|
||||
$this->data["meta"] = Utils::readShort($this->get(2), false);
|
||||
}else{
|
||||
$this->raw .= Utils::writeInt($this->data["eid"]);
|
||||
$this->raw .= chr($this->data["unknown1"]);
|
||||
$this->raw .= Utils::writeShort($this->data["block"]);
|
||||
$this->raw .= chr($this->data["stack"]);
|
||||
$this->raw .= Utils::writeShort($this->data["meta"]);
|
||||
}
|
||||
break;
|
||||
case MC_CLIENT_MESSAGE:
|
||||
if($this->c === false){
|
||||
|
@ -373,6 +373,9 @@ class Player{
|
||||
$this->entity->setHealth(20, "respawn");
|
||||
$this->entity->setPosition($data["x"], $data["y"], $data["z"], 0, 0);
|
||||
break;
|
||||
case MC_DROP_ITEM:
|
||||
$this->server->api->block->drop($this->entity->x, $this->entity->y, $this->entity->z, $data["block"], $data["meta"], $data["stack"]);
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
@ -75,6 +75,8 @@ $dataName = array(
|
||||
MC_ANIMATE => "Animate",
|
||||
MC_RESPAWN => "Respawn",
|
||||
|
||||
MC_DROP_ITEM => "DropItem",
|
||||
|
||||
MC_CLIENT_MESSAGE => "ClientMessage",
|
||||
MC_SIGN_UPDATE => "SignUpdate",
|
||||
MC_ADVENTURE_SETTINGS => "AdventureSettings",
|
||||
|
@ -77,6 +77,8 @@ define("MC_SET_SPAWN_POSITION", 0xa6);
|
||||
define("MC_ANIMATE", 0xa7);
|
||||
define("MC_RESPAWN", 0xa8);
|
||||
|
||||
define("MC_DROP_ITEM", 0xaa);
|
||||
|
||||
define("MC_CLIENT_MESSAGE", 0xb1);
|
||||
define("MC_SIGN_UPDATE", 0xb2);
|
||||
define("MC_ADVENTURE_SETTINGS", 0xb3);
|
Loading…
x
Reference in New Issue
Block a user