GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
Spawnable Class Reference

Public Member Functions

 spawnTo (Player $player)
 
 __construct (Level $level, CompoundTag $nbt)
 
 spawnToAll ()
 
 getSpawnCompound ()
 
 updateCompoundTag (CompoundTag $nbt, Player $player)
 
- Public Member Functions inherited from Tile
 getSaveId ()
 
 __construct (Level $level, CompoundTag $nbt)
 
 getId ()
 
 saveNBT ()
 
 getBlock ()
 
 onUpdate ()
 
 scheduleUpdate ()
 
 __destruct ()
 
 close ()
 
 getName ()
 
- Public Member Functions inherited from Position
 __construct ($x=0, $y=0, $z=0, Level $level=null)
 
 asPosition ()
 
 add ($x, $y=0, $z=0)
 
 getLevel ()
 
 setLevel (Level $level=null)
 
 isValid ()
 
 getSide ($side, $step=1)
 
 __toString ()
 
 setComponents ($x, $y, $z)
 
 fromObjectAdd (Vector3 $pos, $x, $y, $z)
 
- Public Member Functions inherited from Vector3
 __construct ($x=0, $y=0, $z=0)
 
 getX ()
 
 getY ()
 
 getZ ()
 
 getFloorX ()
 
 getFloorY ()
 
 getFloorZ ()
 
 getRight ()
 
 getUp ()
 
 getForward ()
 
 getSouth ()
 
 getWest ()
 
 add ($x, $y=0, $z=0)
 
 subtract ($x=0, $y=0, $z=0)
 
 multiply ($number)
 
 divide ($number)
 
 ceil ()
 
 floor ()
 
 round ()
 
 abs ()
 
 getSide ($side, $step=1)
 
 asVector3 ()
 
 distance (Vector3 $pos)
 
 distanceSquared (Vector3 $pos)
 
 maxPlainDistance ($x=0, $z=0)
 
 length ()
 
 lengthSquared ()
 
 normalize ()
 
 dot (Vector3 $v)
 
 cross (Vector3 $v)
 
 equals (Vector3 $v)
 
 getIntermediateWithXValue (Vector3 $v, $x)
 
 getIntermediateWithYValue (Vector3 $v, $y)
 
 getIntermediateWithZValue (Vector3 $v, $z)
 
 setComponents ($x, $y, $z)
 
 fromObjectAdd (Vector3 $pos, $x, $y, $z)
 
 __toString ()
 

Protected Member Functions

 onChanged ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Tile
static init ()
 
static createTile ($type, Level $level, CompoundTag $nbt,... $args)
 
static registerTile ($className)
 
- Static Public Member Functions inherited from Position
static fromObject (Vector3 $pos, Level $level=null)
 
- Static Public Member Functions inherited from Vector3
static getOppositeSide ($side)
 
static createRandomDirection (Random $random)
 
- Data Fields inherited from Tile
const BREWING_STAND = "BrewingStand"
 
const CHEST = "Chest"
 
const DL_DETECTOR = "DayLightDetector"
 
const ENCHANT_TABLE = "EnchantTable"
 
const FLOWER_POT = "FlowerPot"
 
const FURNACE = "Furnace"
 
const MOB_SPAWNER = "MobSpawner"
 
const SIGN = "Sign"
 
const SKULL = "Skull"
 
const ITEM_FRAME = "ItemFrame"
 
const DISPENSER = "Dispenser"
 
const DROPPER = "Dropper"
 
const CAULDRON = "Cauldron"
 
const HOPPER = "Hopper"
 
const BEACON = "Beacon"
 
const ENDER_CHEST = "EnderChest"
 
const BED = "Bed"
 
const DAY_LIGHT_DETECTOR = "DLDetector"
 
 $chunk
 
 $name
 
 $id
 
 $x
 
 $y
 
 $z
 
 $attach
 
 $metadata
 
 $closed = false
 
 $namedtag
 
 $tickTimer
 
- Data Fields inherited from Position
 $level = null
 
- Data Fields inherited from Vector3
const SIDE_DOWN = 0
 
const SIDE_UP = 1
 
const SIDE_NORTH = 2
 
const SIDE_SOUTH = 3
 
const SIDE_WEST = 4
 
const SIDE_EAST = 5
 
 $x
 
 $y
 
 $z
 
- Static Public Attributes inherited from Tile
static $tileCount = 1
 
- Protected Attributes inherited from Tile
 $lastUpdate
 
 $server
 
 $timings
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Level  $level,
CompoundTag  $nbt 
)

Spawnable constructor.

Parameters
Level$level
CompoundTag$nbt
60  {
61  parent::__construct($level, $nbt);
62  $this->spawnToAll();
63  }

Member Function Documentation

◆ getSpawnCompound()

getSpawnCompound ( )
abstract
Returns
CompoundTag

◆ onChanged()

onChanged ( )
protected
77  {
78  $this->spawnToAll();
79 
80  if($this->chunk !== null){
81  $this->chunk->setChanged();
82  $this->level->clearChunkCache($this->chunk->getX(), $this->chunk->getZ());
83  }
84  }

◆ spawnTo()

spawnTo ( Player  $player)
Parameters
Player$player
Returns
bool
37  {
38  if($this->closed){
39  return false;
40  }
41 
42  $nbt = new NBT(NBT::LITTLE_ENDIAN);
43  $nbt->setData($this->getSpawnCompound());
44  $pk = new BlockEntityDataPacket();
45  $pk->x = $this->x;
46  $pk->y = $this->y;
47  $pk->z = $this->z;
48  $pk->namedtag = $nbt->write(true);
49  $player->dataPacket($pk);
50 
51  return true;
52  }

◆ spawnToAll()

spawnToAll ( )
65  {
66  if($this->closed){
67  return;
68  }
69 
70  foreach($this->getLevel()->getChunkPlayers($this->chunk->getX(), $this->chunk->getZ()) as $player){
71  if($player->spawned === true){
72  $this->spawnTo($player);
73  }
74  }
75  }

◆ updateCompoundTag()

updateCompoundTag ( CompoundTag  $nbt,
Player  $player 
)

Called when a player updates a block entity's NBT data for example when writing on a sign.

Parameters
CompoundTag$nbt
Player$player
Returns
bool indication of success, will respawn the tile to the player if false.
100  : bool{
101  return false;
102  }

The documentation for this class was generated from the following file: