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

Public Member Functions

 __construct (Level $level, CompoundTag $nbt)
 
 saveNBT ()
 
 getSpawnCompound ()
 
 getName ()
 
 hasName ()
 
 setName ($str)
 
 getInventory ()
 
 updateCompoundTag (CompoundTag $nbt, Player $player)
 
 onUpdate ()
 
- Public Member Functions inherited from Spawnable
 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 ()
 

Data Fields

const POWER_LEVEL_MAX = 4
 
- 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
 

Protected Member Functions

 calculatePowerLevel ()
 
- Protected Member Functions inherited from Spawnable
 onChanged ()
 

Protected Attributes

 $currentTick = 0
 
- Protected Attributes inherited from Tile
 $lastUpdate
 
 $server
 
 $timings
 

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)
 
- Static Public Attributes inherited from Tile
static $tileCount = 1
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Level  $level,
CompoundTag  $nbt 
)

Beacon constructor.

Parameters
Level$level
CompoundTag$nbt
50  {
51  if(!isset($nbt->primary)){
52  $nbt->primary = new IntTag("primary", 0);
53  }
54  if(!isset($nbt->secondary)){
55  $nbt->secondary = new IntTag("secondary", 0);
56  }
57  $this->inventory = new BeaconInventory($this);
58  parent::__construct($level, $nbt);
59  $this->scheduleUpdate();
60  }

Member Function Documentation

◆ calculatePowerLevel()

calculatePowerLevel ( )
protected
Returns
int
178  {
179  $tileX = $this->getFloorX();
180  $tileY = $this->getFloorY();
181  $tileZ = $this->getFloorZ();
182  for($powerLevel = 1; $powerLevel <= self::POWER_LEVEL_MAX; $powerLevel++){
183  $queryY = $tileY - $powerLevel;
184  for($queryX = $tileX - $powerLevel; $queryX <= $tileX + $powerLevel; $queryX++){
185  for($queryZ = $tileZ - $powerLevel; $queryZ <= $tileZ + $powerLevel; $queryZ++){
186  $testBlockId = $this->level->getBlockIdAt($queryX, $queryY, $queryZ);
187  if(
188  $testBlockId != Block::IRON_BLOCK &&
189  $testBlockId != Block::GOLD_BLOCK &&
190  $testBlockId != Block::EMERALD_BLOCK &&
191  $testBlockId != Block::DIAMOND_BLOCK
192  ){
193  return $powerLevel - 1;
194  }
195  }
196  }
197  }
198  return self::POWER_LEVEL_MAX;
199  }

◆ getInventory()

getInventory ( )
Returns
BeaconInventory

Implements InventoryHolder.

113  {
114  return $this->inventory;
115  }

◆ getName()

getName ( )
Returns
string

Implements Nameable.

88  : string{
89  return $this->hasName() ? $this->namedtag->CustomName->getValue() : "Beacon";
90  }

◆ getSpawnCompound()

getSpawnCompound ( )
Returns
CompoundTag
69  {
70  $c = new CompoundTag("", [
71  new StringTag("id", Tile::BEACON),
72  new ByteTag("isMovable", (bool) true),
73  new IntTag("x", (int) $this->x),
74  new IntTag("y", (int) $this->y),
75  new IntTag("z", (int) $this->z),
76  new IntTag("primary", $this->namedtag["primary"]),
77  new IntTag("secondary", $this->namedtag["secondary"])
78  ]);
79  if($this->hasName()){
80  $c->CustomName = $this->namedtag->CustomName;
81  }
82  return $c;
83  }

◆ hasName()

hasName ( )
Returns
bool

Implements Nameable.

95  {
96  return isset($this->namedtag->CustomName);
97  }

◆ onUpdate()

onUpdate ( )
Returns
bool
135  {
136  if($this->closed === true){
137  return false;
138  }
139  if($this->currentTick++ % 100 != 0){
140  return true;
141  }
142 
143  $level = $this->calculatePowerLevel();
144 
145  $this->timings->startTiming();
146 
147  $id = 0;
148 
149  if($level > 0){
150  if(isset($this->namedtag->secondary) && $this->namedtag["primary"] != 0){
151  $id = $this->namedtag["primary"];
152  }else if(isset($this->namedtag->secondary) && $this->namedtag["secondary"] != 0){
153  $id = $this->namedtag["secondary"];
154  }
155  if($id != 0){
156  $range = ($level + 1) * 10;
157  $effect = Effect::getEffect($id);
158  $effect->setDuration(10 * 30);
159  $effect->setAmplifier(0);
160  foreach($this->level->getPlayers() as $player){
161  if($this->distance($player) <= $range){
162  $player->addEffect($effect);
163  }
164  }
165  }
166  }
167 
168  $this->lastUpdate = microtime(true);
169 
170  $this->timings->stopTiming();
171 
172  return true;
173  }

◆ saveNBT()

saveNBT ( )
62  {
63  parent::saveNBT();
64  }

◆ setName()

setName (   $str)
Parameters
void$str

Implements Nameable.

102  {
103  if($str === ""){
104  unset($this->namedtag->CustomName);
105  return;
106  }
107  $this->namedtag->CustomName = new StringTag("CustomName", $str);
108  }

◆ updateCompoundTag()

updateCompoundTag ( CompoundTag  $nbt,
Player  $player 
)
Parameters
CompoundTag$nbt
Player$player
Returns
bool
123  : bool{
124  if($nbt["id"] !== Tile::BEACON){
125  return false;
126  }
127  $this->namedtag->primary = new IntTag("primary", $nbt["primary"]);
128  $this->namedtag->secondary = new IntTag("secondary", $nbt["secondary"]);
129  return true;
130  }

Field Documentation

◆ $currentTick

$currentTick = 0
protected

◆ POWER_LEVEL_MAX

const POWER_LEVEL_MAX = 4

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