mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 17:59:41 +00:00
Entity: make getNetworkTypeId
non-static (#6037)
This was static to permit ItemFactory to register spawn eggs for all known entity types in early PM4. However, nowadays we provide a callback to the spawn egg instead, and spawn eggs must be manually implemented, so this is no longer needed. In addition, having this static forces everyone to make a new entity class for every unique type of entity, which isn't ideal.
This commit is contained in:
parent
4dc9d696d0
commit
ed61a68013
@ -1473,7 +1473,7 @@ abstract class Entity{
|
||||
return $this->hasSpawned;
|
||||
}
|
||||
|
||||
abstract public static function getNetworkTypeId() : string;
|
||||
abstract public function getNetworkTypeId() : string;
|
||||
|
||||
/**
|
||||
* Called by spawnTo() to send whatever packets needed to spawn the entity to the client.
|
||||
@ -1482,7 +1482,7 @@ abstract class Entity{
|
||||
$player->getNetworkSession()->sendDataPacket(AddActorPacket::create(
|
||||
$this->getId(), //TODO: actor unique ID
|
||||
$this->getId(),
|
||||
static::getNetworkTypeId(),
|
||||
$this->getNetworkTypeId(),
|
||||
$this->location->asVector3(),
|
||||
$this->getMotion(),
|
||||
$this->location->pitch,
|
||||
|
@ -98,7 +98,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
private const TAG_SKIN_GEOMETRY_NAME = "GeometryName"; //TAG_String
|
||||
private const TAG_SKIN_GEOMETRY_DATA = "GeometryData"; //TAG_ByteArray
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::PLAYER; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::PLAYER; }
|
||||
|
||||
protected PlayerInventory $inventory;
|
||||
protected PlayerOffHandInventory $offHandInventory;
|
||||
|
@ -37,7 +37,7 @@ use const M_PI;
|
||||
|
||||
class Squid extends WaterAnimal{
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::SQUID; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::SQUID; }
|
||||
|
||||
public ?Vector3 $swimDirection = null;
|
||||
public float $swimSpeed = 0.1;
|
||||
|
@ -38,7 +38,7 @@ class Villager extends Living implements Ageable{
|
||||
|
||||
private const TAG_PROFESSION = "Profession"; //TAG_Int
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::VILLAGER; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::VILLAGER; }
|
||||
|
||||
private bool $baby = false;
|
||||
private int $profession = self::PROFESSION_FARMER;
|
||||
|
@ -29,7 +29,7 @@ use function mt_rand;
|
||||
|
||||
class Zombie extends Living{
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::ZOMBIE; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::ZOMBIE; }
|
||||
|
||||
protected function getInitialSizeInfo() : EntitySizeInfo{
|
||||
return new EntitySizeInfo(1.8, 0.6); //TODO: eye height ??
|
||||
|
@ -37,7 +37,7 @@ use function sqrt;
|
||||
|
||||
class ExperienceOrb extends Entity{
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::XP_ORB; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::XP_ORB; }
|
||||
|
||||
public const TAG_VALUE_PC = "Value"; //short
|
||||
public const TAG_VALUE_PE = "experience value"; //int (WTF?)
|
||||
|
@ -55,7 +55,7 @@ class FallingBlock extends Entity{
|
||||
private const TAG_TILE = "Tile"; //TAG_Byte
|
||||
private const TAG_DATA = "Data"; //TAG_Byte
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::FALLING_BLOCK; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::FALLING_BLOCK; }
|
||||
|
||||
protected Block $block;
|
||||
|
||||
|
@ -52,7 +52,7 @@ class ItemEntity extends Entity{
|
||||
private const TAG_THROWER = "Thrower"; //TAG_String
|
||||
public const TAG_ITEM = "Item"; //TAG_Compound
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::ITEM; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::ITEM; }
|
||||
|
||||
public const MERGE_CHECK_PERIOD = 2; //0.1 seconds
|
||||
public const DEFAULT_DESPAWN_DELAY = 6000; //5 minutes
|
||||
|
@ -48,7 +48,7 @@ class Painting extends Entity{
|
||||
public const TAG_DIRECTION_BE = "Direction"; //TAG_Byte
|
||||
public const TAG_MOTIVE = "Motive"; //TAG_String
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::PAINTING; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::PAINTING; }
|
||||
|
||||
public const DATA_TO_FACING = [
|
||||
0 => Facing::SOUTH,
|
||||
|
@ -41,7 +41,7 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
|
||||
private const TAG_FUSE = "Fuse"; //TAG_Short
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::TNT; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::TNT; }
|
||||
|
||||
protected int $fuse;
|
||||
protected bool $worksUnderwater = false;
|
||||
|
@ -46,7 +46,7 @@ use function sqrt;
|
||||
|
||||
class Arrow extends Projectile{
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::ARROW; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::ARROW; }
|
||||
|
||||
public const PICKUP_NONE = 0;
|
||||
public const PICKUP_ANY = 1;
|
||||
|
@ -29,7 +29,7 @@ use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
|
||||
use pocketmine\world\particle\ItemBreakParticle;
|
||||
|
||||
class Egg extends Throwable{
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::EGG; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::EGG; }
|
||||
|
||||
//TODO: spawn chickens on collision
|
||||
|
||||
|
@ -30,7 +30,7 @@ use pocketmine\world\particle\EndermanTeleportParticle;
|
||||
use pocketmine\world\sound\EndermanTeleportSound;
|
||||
|
||||
class EnderPearl extends Throwable{
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::ENDER_PEARL; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::ENDER_PEARL; }
|
||||
|
||||
protected function onHit(ProjectileHitEvent $event) : void{
|
||||
$owner = $this->getOwningEntity();
|
||||
|
@ -30,7 +30,7 @@ use pocketmine\world\sound\PotionSplashSound;
|
||||
use function mt_rand;
|
||||
|
||||
class ExperienceBottle extends Throwable{
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::XP_BOTTLE; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::XP_BOTTLE; }
|
||||
|
||||
protected function getInitialGravity() : float{ return 0.07; }
|
||||
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
|
||||
use pocketmine\world\particle\SnowballPoofParticle;
|
||||
|
||||
class Snowball extends Throwable{
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::SNOWBALL; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::SNOWBALL; }
|
||||
|
||||
protected function onHit(ProjectileHitEvent $event) : void{
|
||||
for($i = 0; $i < 6; ++$i){
|
||||
|
@ -52,7 +52,7 @@ class SplashPotion extends Throwable{
|
||||
|
||||
public const TAG_POTION_ID = "PotionId"; //TAG_Short
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::SPLASH_POTION; }
|
||||
public function getNetworkTypeId() : string{ return EntityIds::SPLASH_POTION; }
|
||||
|
||||
protected bool $linger = false;
|
||||
protected PotionType $potionType;
|
||||
|
@ -44,7 +44,7 @@ class EntityLandSound implements Sound{
|
||||
LevelSoundEvent::LAND,
|
||||
$pos,
|
||||
TypeConverter::getInstance()->getBlockTranslator()->internalIdToNetworkId($this->blockLandedOn->getStateId()),
|
||||
$this->entity::getNetworkTypeId(),
|
||||
$this->entity->getNetworkTypeId(),
|
||||
false, //TODO: does isBaby have any relevance here?
|
||||
false
|
||||
)];
|
||||
|
@ -40,7 +40,7 @@ class EntityLongFallSound implements Sound{
|
||||
LevelSoundEvent::FALL_BIG,
|
||||
$pos,
|
||||
-1,
|
||||
$this->entity::getNetworkTypeId(),
|
||||
$this->entity->getNetworkTypeId(),
|
||||
false, //TODO: is isBaby relevant here?
|
||||
false
|
||||
)];
|
||||
|
@ -39,7 +39,7 @@ class EntityShortFallSound implements Sound{
|
||||
LevelSoundEvent::FALL_SMALL,
|
||||
$pos,
|
||||
-1,
|
||||
$this->entity::getNetworkTypeId(),
|
||||
$this->entity->getNetworkTypeId(),
|
||||
false, //TODO: does isBaby have any relevance here?
|
||||
false
|
||||
)];
|
||||
|
Loading…
x
Reference in New Issue
Block a user