Added entity id names

This commit is contained in:
Shoghi Cervantes 2014-08-27 17:42:38 +02:00
parent f4b92bcdfc
commit 90fa40de34
24 changed files with 99 additions and 47 deletions

View File

@ -25,6 +25,7 @@ namespace pocketmine\entity;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Short;
use pocketmine\nbt\tag\String;
use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\network\protocol\SetEntityMotionPacket;
use pocketmine\Player;
@ -39,13 +40,12 @@ class Arrow extends Projectile{
protected $drag = 0.01;
protected function initEntity(){
$this->namedtag->id = new String("id", "Arrow");
$this->setMaxHealth(1);
$this->setHealth(1);
if(isset($this->namedtag->Age)){
$this->age = $this->namedtag["Age"];
}
}
public function onUpdate(){

View File

@ -22,6 +22,11 @@
namespace pocketmine\entity;
use pocketmine\nbt\tag\String;
class Chicken extends Animal{
protected function initEntity(){
$this->namedtag->id = new String("id", "Chicken");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Cow extends Animal{
use pocketmine\nbt\tag\String;
class Cow extends Animal{
protected function initEntity(){
$this->namedtag->id = new String("id", "Cow");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Creeper extends Monster implements Explosive{
use pocketmine\nbt\tag\String;
class Creeper extends Monster implements Explosive{
protected function initEntity(){
$this->namedtag->id = new String("id", "Creeper");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Egg extends Projectile{
use pocketmine\nbt\tag\String;
class Egg extends Projectile{
protected function initEntity(){
$this->namedtag->id = new String("id", "Egg");
}
}

View File

@ -23,7 +23,10 @@ namespace pocketmine\entity;
use pocketmine\inventory\InventoryHolder;
use pocketmine\nbt\tag\String;
class Enderman extends Monster implements InventoryHolder{
protected function initEntity(){
$this->namedtag->id = new String("id", "Enderman");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class EnderPearl extends Projectile{
use pocketmine\nbt\tag\String;
class FallingSand extends Entity{
protected function initEntity(){
$this->namedtag->id = new String("id", "FallingSand");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Ocelot extends Animal implements Tameable{
use pocketmine\nbt\tag\String;
class Ocelot extends Animal implements Tameable{
protected function initEntity(){
$this->namedtag->id = new String("id", "Ozelot");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Painting extends Hanging{
use pocketmine\nbt\tag\String;
class Painting extends Hanging{
protected function initEntity(){
$this->namedtag->id = new String("id", "Painting");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Pig extends Animal implements Rideable{
use pocketmine\nbt\tag\String;
class Pig extends Animal implements Rideable{
protected function initEntity(){
$this->namedtag->id = new String("id", "Pig");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class PigZombie extends Zombie{
use pocketmine\nbt\tag\String;
class PigZombie extends Zombie{
protected function initEntity(){
$this->namedtag->id = new String("id", "PigZombie");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class FallingBlock extends Entity{
use pocketmine\nbt\tag\String;
class PrimedTNT extends Entity implements Explosive{
protected function initEntity(){
$this->namedtag->id = new String("id", "PrimedTNT");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Sheep extends Animal implements Colorable{
use pocketmine\nbt\tag\String;
class Sheep extends Animal implements Colorable{
protected function initEntity(){
$this->namedtag->id = new String("id", "Sheep");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Silverfish extends Monster{
use pocketmine\nbt\tag\String;
class Silverfish extends Monster{
protected function initEntity(){
$this->namedtag->id = new String("id", "Silverfish");
}
}

View File

@ -23,5 +23,7 @@ namespace pocketmine\entity;
class Skeleton extends Monster implements ProjectileSource{
protected function initEntity(){
$this->namedtag->id = new Skeleton("id", "Chicken");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Slime extends Living{
use pocketmine\nbt\tag\String;
class Slime extends Living{
protected function initEntity(){
$this->namedtag->id = new String("id", "Slime");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Snowball extends Projectile{
use pocketmine\nbt\tag\String;
class Snowball extends Projectile{
protected function initEntity(){
$this->namedtag->id = new String("id", "Snowball");
}
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Spider extends Monster{
use pocketmine\nbt\tag\String;
class Spider extends Monster{
protected function initEntity(){
$this->namedtag->id = new String("id", "Spider");
}
}

View File

@ -1,27 +0,0 @@
<?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\entity;
class TNTPrimed extends Entity implements Explosive{
}

View File

@ -23,6 +23,7 @@ namespace pocketmine\entity;
use pocketmine\nbt\tag\Int;
use pocketmine\nbt\tag\String;
use pocketmine\network\protocol\AddMobPacket;
use pocketmine\network\protocol\SetEntityMotionPacket;
use pocketmine\Player;
@ -47,6 +48,7 @@ class Villager extends Creature implements NPC, Ageable{
protected function initEntity(){
parent::initEntity();
$this->namedtag->id = new String("id", "Villager");
if(!isset($this->namedtag->Profession)){
$this->setProfession(self::PROFESSION_GENERIC);
}

View File

@ -22,6 +22,10 @@
namespace pocketmine\entity;
class Wolf extends Animal implements Tameable{
use pocketmine\nbt\tag\String;
class Wolf extends Animal implements Tameable{
protected function initEntity(){
$this->namedtag->id = new String("id", "Wolf");
}
}

View File

@ -24,6 +24,7 @@ namespace pocketmine\entity;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\item\Item;
use pocketmine\nbt\tag\String;
use pocketmine\network\protocol\AddMobPacket;
use pocketmine\network\protocol\SetEntityMotionPacket;
use pocketmine\Player;
@ -35,6 +36,10 @@ class Zombie extends Monster{
public $length = 0.6;
public $height = 1.8;
protected function initEntity(){
$this->namedtag->id = new String("id", "Zombie");
}
public function getName(){
return "Zombie";
}

View File

@ -105,7 +105,8 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
if(!isset($nbt->id)){
continue;
}
//TODO: add all entities
if($nbt->id instanceof String){ //New format
switch($nbt["id"]){
case "Item":

View File

@ -106,6 +106,7 @@ abstract class BaseFullChunk implements FullChunk{
continue;
}
//TODO: add all entities
if($nbt->id instanceof String){ //New format
switch($nbt["id"]){
case "Item":