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){
if($player instanceof Player and $player->getHealth() < 20){
if($player instanceof Player and $player->getHealth() < $player->getMaxHealth()){
++$this->meta;
$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){
if(isset($this->hasSpawned[$player->getId()])){
$pk = new RemovePlayerPacket();
$pk->eid = $this->id;
$pk->clientID = $this->id;
$pk->eid = $this->getId();
$pk->clientID = $this->getId();
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
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
*/
abstract class TextFormat{
const BLACK = "§0";
const DARK_BLUE = "§1";
const DARK_GREEN = "§2";
const DARK_AQUA = "§3";
const DARK_RED = "§4";
const DARK_PURPLE = "§5";
const GOLD = "§6";
const GRAY = "§7";
const DARK_GRAY = "§8";
const BLUE = "§9";
const GREEN = "§a";
const AQUA = "§b";
const RED = "§c";
const LIGHT_PURPLE = "§d";
const YELLOW = "§e";
const WHITE = "§f";
const ESCAPE = "§";
const BLACK = TextFormat::ESCAPE . "0";
const DARK_BLUE = TextFormat::ESCAPE . "1";
const DARK_GREEN = TextFormat::ESCAPE . "2";
const DARK_AQUA = TextFormat::ESCAPE . "3";
const DARK_RED = TextFormat::ESCAPE . "4";
const DARK_PURPLE = TextFormat::ESCAPE . "5";
const GOLD = TextFormat::ESCAPE . "6";
const GRAY = TextFormat::ESCAPE . "7";
const DARK_GRAY = TextFormat::ESCAPE . "8";
const BLUE = TextFormat::ESCAPE . "9";
const GREEN = TextFormat::ESCAPE . "a";
const AQUA = TextFormat::ESCAPE . "b";
const RED = TextFormat::ESCAPE . "c";
const LIGHT_PURPLE = TextFormat::ESCAPE . "d";
const YELLOW = TextFormat::ESCAPE . "e";
const WHITE = TextFormat::ESCAPE . "f";
const OBFUSCATED = "§k";
const BOLD = "§l";
const STRIKETHROUGH = "§m";
const UNDERLINE = "§n";
const ITALIC = "§o";
const RESET = "§r";
const OBFUSCATED = TextFormat::ESCAPE . "k";
const BOLD = TextFormat::ESCAPE . "l";
const STRIKETHROUGH = TextFormat::ESCAPE . "m";
const UNDERLINE = TextFormat::ESCAPE . "n";
const ITALIC = TextFormat::ESCAPE . "o";
const RESET = TextFormat::ESCAPE . "r";
/**
* Splits the string by Format tokens