Improved format constants, fixed cake eating when max health is > 20

This commit is contained in:
Shoghi Cervantes 2015-04-20 17:25:58 +02:00
parent f88aed1208
commit 15b4cd8fb3
3 changed files with 27 additions and 25 deletions

View File

@ -90,7 +90,7 @@ class Cake extends Transparent{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($player instanceof Player and $player->getHealth() < 20){ if($player instanceof Player and $player->getHealth() < $player->getMaxHealth()){
++$this->meta; ++$this->meta;
$ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING); $ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING);

View File

@ -224,8 +224,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
public function despawnFrom(Player $player){ public function despawnFrom(Player $player){
if(isset($this->hasSpawned[$player->getId()])){ if(isset($this->hasSpawned[$player->getId()])){
$pk = new RemovePlayerPacket(); $pk = new RemovePlayerPacket();
$pk->eid = $this->id; $pk->eid = $this->getId();
$pk->clientID = $this->id; $pk->clientID = $this->getId();
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
unset($this->hasSpawned[$player->getId()]); unset($this->hasSpawned[$player->getId()]);
} }

View File

@ -25,29 +25,31 @@ namespace pocketmine\utils;
* Class used to handle Minecraft chat format, and convert it to other formats like ANSI or HTML * Class used to handle Minecraft chat format, and convert it to other formats like ANSI or HTML
*/ */
abstract class TextFormat{ abstract class TextFormat{
const BLACK = "§0"; const ESCAPE = "§";
const DARK_BLUE = "§1";
const DARK_GREEN = "§2"; const BLACK = TextFormat::ESCAPE . "0";
const DARK_AQUA = "§3"; const DARK_BLUE = TextFormat::ESCAPE . "1";
const DARK_RED = "§4"; const DARK_GREEN = TextFormat::ESCAPE . "2";
const DARK_PURPLE = "§5"; const DARK_AQUA = TextFormat::ESCAPE . "3";
const GOLD = "§6"; const DARK_RED = TextFormat::ESCAPE . "4";
const GRAY = "§7"; const DARK_PURPLE = TextFormat::ESCAPE . "5";
const DARK_GRAY = "§8"; const GOLD = TextFormat::ESCAPE . "6";
const BLUE = "§9"; const GRAY = TextFormat::ESCAPE . "7";
const GREEN = "§a"; const DARK_GRAY = TextFormat::ESCAPE . "8";
const AQUA = "§b"; const BLUE = TextFormat::ESCAPE . "9";
const RED = "§c"; const GREEN = TextFormat::ESCAPE . "a";
const LIGHT_PURPLE = "§d"; const AQUA = TextFormat::ESCAPE . "b";
const YELLOW = "§e"; const RED = TextFormat::ESCAPE . "c";
const WHITE = "§f"; const LIGHT_PURPLE = TextFormat::ESCAPE . "d";
const YELLOW = TextFormat::ESCAPE . "e";
const WHITE = TextFormat::ESCAPE . "f";
const OBFUSCATED = "§k"; const OBFUSCATED = TextFormat::ESCAPE . "k";
const BOLD = "§l"; const BOLD = TextFormat::ESCAPE . "l";
const STRIKETHROUGH = "§m"; const STRIKETHROUGH = TextFormat::ESCAPE . "m";
const UNDERLINE = "§n"; const UNDERLINE = TextFormat::ESCAPE . "n";
const ITALIC = "§o"; const ITALIC = TextFormat::ESCAPE . "o";
const RESET = "§r"; const RESET = TextFormat::ESCAPE . "r";
/** /**
* Splits the string by Format tokens * Splits the string by Format tokens