mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Added Spawn Eggs
This commit is contained in:
@@ -39,6 +39,7 @@ class Item{
|
||||
PAINTING => "PaintingItem",
|
||||
COAL => "CoalItem",
|
||||
APPLE => "AppleItem",
|
||||
SPAWN_EGG => "SpawnEggItem",
|
||||
DIAMOND => "DiamondItem",
|
||||
STICK => "StickItem",
|
||||
BOWL => "BowlItem",
|
||||
|
54
src/material/item/generic/SpawnEgg.php
Normal file
54
src/material/item/generic/SpawnEgg.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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 SpawnEggItem extends Item{
|
||||
public function __construct($meta = 0, $count = 1){
|
||||
parent::__construct(SPAWN_EGG, 0, $count, "Spawn Egg");
|
||||
$this->meta = $meta;
|
||||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
switch($this->meta){
|
||||
case MOB_CHICKEN:
|
||||
case MOB_SHEEP:
|
||||
case MOB_COW:
|
||||
case MOB_PIG:
|
||||
$data = array(
|
||||
"x" => $block->x + 0.5,
|
||||
"y" => $block->y,
|
||||
"z" => $block->z + 0.5,
|
||||
);
|
||||
$e = ServerAPI::request()->api->entity->add($block->level, ENTITY_MOB, $this->meta, $data);
|
||||
ServerAPI::request()->api->entity->spawnToAll($e);
|
||||
--$this->count;
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user