Fish items, block of redstone!

This commit is contained in:
Shoghi Cervantes 2015-04-08 15:34:50 +02:00
parent 3cae81c01b
commit 76767294bf
8 changed files with 176 additions and 8 deletions

View File

@ -2048,9 +2048,17 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
Item::CARROT => 4,
Item::POTATO => 1,
Item::BAKED_POTATO => 6,
//Item::COOKIE => 2,
//Item::COOKED_FISH => 5,
//Item::RAW_FISH => 2,
Item::COOKIE => 2,
Item::COOKED_FISH => [
0 => 5,
1 => 6
],
Item::RAW_FISH => [
0 => 2,
1 => 2,
2 => 1,
3 => 1
],
];
$slot = $this->inventory->getItemInHand();
if($this->getHealth() < 20 and isset($items[$slot->getId()])){
@ -2068,6 +2076,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
Server::broadcastPacket($this->getViewers(), $pk);
$amount = $items[$slot->getId()];
if(is_array($amount)){
$amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
}
$ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING);
$this->heal($ev->getAmount(), $ev);
@ -2075,6 +2086,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->inventory->setItemInHand($slot, $this);
if($slot->getId() === Item::MUSHROOM_STEW or $slot->getId() === Item::BEETROOT_SOUP){
$this->inventory->addItem(Item::get(Item::BOWL, 0, 1));
}elseif($slot->getId() === Item::RAW_FISH and $slot->getDamage() === 3){ //Pufferfish
//$this->addEffect(Effect::getEffect(Effect::HUNGER)->setAmplifier(2)->setDuration(15 * 20));
$this->addEffect(Effect::getEffect(Effect::NAUSEA)->setAmplifier(1)->setDuration(15 * 20));
$this->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(3)->setDuration(60 * 20));
}
}
break;

View File

@ -200,6 +200,8 @@ class Block extends Position implements Metadatable{
const CARROT_BLOCK = 141;
const POTATO_BLOCK = 142;
const REDSTONE_BLOCK = 152;
const QUARTZ_BLOCK = 155;
const QUARTZ_STAIRS = 156;
const DOUBLE_WOOD_SLAB = 157;
@ -351,6 +353,7 @@ class Block extends Position implements Metadatable{
[Item::LAPIS_BLOCK, 0],
[Item::COAL_BLOCK, 0],
[Item::EMERALD_BLOCK, 0],
[Item::REDSTONE_BLOCK, 0],
[Item::SNOW_LAYER, 0],
[Item::GLASS, 0],
[Item::GLOWSTONE_BLOCK, 0],
@ -504,6 +507,12 @@ class Block extends Position implements Metadatable{
[Item::POTATO, 0],
[Item::BEETROOT_SEEDS, 0],
[Item::EGG, 0],
[Item::RAW_FISH, 0],
[Item::RAW_FISH, 1],
[Item::RAW_FISH, 2],
[Item::RAW_FISH, 3],
[Item::COOKED_FISH, 0],
[Item::COOKED_FISH, 1],
[Item::DYE, 0],
[Item::DYE, 7],
[Item::DYE, 6],

View File

@ -0,0 +1,68 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
class Redstone extends Transparent{
protected $id = self::REDSTONE_BLOCK;
public function __construct(){
}
public function getHardness(){
return 30;
}
public function getName(){
return "Redstone Block";
}
public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.95;
case 4:
return 1.25;
case 3:
return 1.9;
case 2:
return 0.65;
case 1:
return 3.75;
default:
return 25;
}
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
return [
[Item::REDSTONE_BLOCK, 0, 1],
];
}else{
return [];
}
}
}

View File

@ -104,7 +104,7 @@ class EffectCommand extends VanillaCommand{
$effect->setDuration($duration)->setAmplifier($amplification);
$player->addEffect($effect);
self::broadcastCommandMessage($sender, "Given ". $effect->getName() ." (ID ". $effect->getId()." ) * ". $effect->getAmplifier()." to ". $player->getDisplayName() ." for ". ($effect->getDuration() / 20) ." seconds");
self::broadcastCommandMessage($sender, "Given ". $effect->getName() ." (ID ". $effect->getId().") * ". $effect->getAmplifier()." to ". $player->getDisplayName() ." for ". ($effect->getDuration() / 20) ." seconds");
}

View File

@ -128,7 +128,8 @@ class CraftingManager{
$this->registerRecipe(new FurnaceRecipe(Item::get(Item::NETHER_BRICK, 0, 1), Item::get(Item::NETHERRACK, 0, 1)));
$this->registerRecipe(new FurnaceRecipe(Item::get(Item::COOKED_PORKCHOP, 0, 1), Item::get(Item::RAW_PORKCHOP, 0, 1)));
$this->registerRecipe(new FurnaceRecipe(Item::get(Item::BRICK, 0, 1), Item::get(Item::CLAY, 0, 1)));
//$this->registerRecipe(new FurnaceRecipe(Item::get(Item::COOKED_FISH, 0, 1), Item::get(Item::RAW_FISH, 0, 1)));
$this->registerRecipe(new FurnaceRecipe(Item::get(Item::COOKED_FISH, 0, 1), Item::get(Item::RAW_FISH, 0, 1)));
$this->registerRecipe(new FurnaceRecipe(Item::get(Item::COOKED_FISH, 1, 1), Item::get(Item::RAW_FISH, 1, 1)));
$this->registerRecipe(new FurnaceRecipe(Item::get(Item::DYE, 2, 1), Item::get(Item::CACTUS, 0, 1)));
$this->registerRecipe(new FurnaceRecipe(Item::get(Item::DYE, 1, 1), Item::get(Item::RED_MUSHROOM, 0, 1)));
$this->registerRecipe(new FurnaceRecipe(Item::get(Item::STEAK, 0, 1), Item::get(Item::RAW_BEEF, 0, 1)));

View File

@ -0,0 +1,33 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\item;
class CookedFish extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::RAW_FISH, $meta, $count, "Cooked Fish");
if($this->meta === 1){
$this->name = "Cooked Salmon";
}
}
}

View File

@ -0,0 +1,37 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\item;
class Fish extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(self::RAW_FISH, $meta, $count, "Raw Fish");
if($this->meta === 1){
$this->name = "Raw Salmon";
}elseif($this->meta === 2){
$this->name = "Clownfish";
}elseif($this->meta === 3){
$this->name = "Pufferfish";
}
}
}

View File

@ -192,6 +192,8 @@ class Item{
const CARROT_BLOCK = 141;
const POTATO_BLOCK = 142;
const REDSTONE_BLOCK = 152;
const QUARTZ_BLOCK = 155;
const QUARTZ_STAIRS = 156;
const DOUBLE_WOOD_SLAB = 157;
@ -339,8 +341,8 @@ class Item{
const CLOCK = 347;
const GLOWSTONE_DUST = 348;
//const RAW_FISH = 349;
//const COOKED_FISH = 350;
const RAW_FISH = 349;
const COOKED_FISH = 350;
const DYE = 351;
const BONE = 352;
const SUGAR = 353;
@ -348,7 +350,7 @@ class Item{
const BED = 355;
//const COOKIE = 357;
const COOKIE = 357;
const SHEARS = 359;
@ -479,6 +481,9 @@ class Item{
self::$list[self::SHEARS] = Shears::class;
self::$list[self::BOW] = Bow::class;
self::$list[self::RAW_FISH] = Fish::class;
self::$list[self::COOKED_FISH] = CookedFish::class;
for($i = 0; $i < 256; ++$i){
if(Block::$list[$i] !== null){
self::$list[$i] = Block::$list[$i];