mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Added Spawn Eggs
This commit is contained in:
parent
7970b8aeed
commit
82aa76be17
4 changed files with 61 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue