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

Public Member Functions

 __construct (Level $level, CompoundTag $nbt)
 
 close ()
 
 saveNBT ()
 
 getSize ()
 
 getItem ($index)
 
 setItem ($index, Item $item)
 
 getInventory ()
 
 getName ()
 
 hasName ()
 
 setName ($str)
 
 getMotion ()
 
 getSpawnCompound ()
 
- 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 ()
 

Protected Member Functions

 getSlotIndex ($index)
 
- Protected Member Functions inherited from Spawnable
 onChanged ()
 

Protected Attributes

 $inventory
 
 $nextUpdate = 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)
 
- 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
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Level  $level,
CompoundTag  $nbt 
)

Dropper constructor.

Parameters
Level$level
CompoundTag$nbt
54  {
55  parent::__construct($level, $nbt);
56  $this->inventory = new DropperInventory($this);
57  if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){
58  $this->namedtag->Items = new ListTag("Items", []);
59  $this->namedtag->Items->setTagType(NBT::TAG_Compound);
60  }
61  for($i = 0; $i < $this->getSize(); ++$i){
62  $this->inventory->setItem($i, $this->getItem($i));
63  }
64  $this->scheduleUpdate();
65  }

Member Function Documentation

◆ close()

close ( )
67  {
68  if($this->closed === false){
69  foreach($this->getInventory()->getViewers() as $player){
70  $player->removeWindow($this->getInventory());
71  }
72 
73  foreach($this->getInventory()->getViewers() as $player){
74  $player->removeWindow($this->getInventory());
75  }
76  parent::close();
77  }
78  }

◆ getInventory()

getInventory ( )
Returns
DropperInventory

Implements InventoryHolder.

158  {
159  return $this->inventory;
160  }

◆ getItem()

getItem (   $index)

This method should not be used by plugins, use the Inventory

Parameters
int$index
Returns
Item

Implements Container.

117  {
118  $i = $this->getSlotIndex($index);
119  if($i < 0){
120  return Item::get(Item::AIR, 0, 0);
121  }else{
122  return Item::nbtDeserialize($this->namedtag->Items[$i]);
123  }
124  }

◆ getMotion()

getMotion ( )
Returns
array
191  {
192  $meta = $this->getBlock()->getDamage();
193  switch($meta){
194  case Vector3::SIDE_DOWN:
195  return [0, -1, 0];
196  case Vector3::SIDE_UP:
197  return [0, 1, 0];
198  case Vector3::SIDE_NORTH:
199  return [0, 0, -1];
200  case Vector3::SIDE_SOUTH:
201  return [0, 0, 1];
202  case Vector3::SIDE_WEST:
203  return [-1, 0, 0];
204  case Vector3::SIDE_EAST:
205  return [1, 0, 0];
206  default:
207  return [0, 0, 0];
208  }
209  }

◆ getName()

getName ( )
Returns
string

Implements Nameable.

165  : string{
166  return isset($this->namedtag->CustomName) ? $this->namedtag->CustomName->getValue() : "Dropper";
167  }

◆ getSize()

getSize ( )
Returns
int

Implements Container.

91  {
92  return 9;
93  }

◆ getSlotIndex()

getSlotIndex (   $index)
protected
Parameters
$index
Returns
int
100  {
101  foreach($this->namedtag->Items as $i => $slot){
102  if((int) $slot["Slot"] === (int) $index){
103  return (int) $i;
104  }
105  }
106 
107  return -1;
108  }

◆ getSpawnCompound()

getSpawnCompound ( )
Returns
CompoundTag
283  {
284  $c = new CompoundTag("", [
285  new StringTag("id", Tile::DROPPER),
286  new IntTag("x", (int) $this->x),
287  new IntTag("y", (int) $this->y),
288  new IntTag("z", (int) $this->z)
289  ]);
290 
291  if($this->hasName()){
292  $c->CustomName = $this->namedtag->CustomName;
293  }
294 
295  return $c;
296  }

◆ hasName()

hasName ( )
Returns
bool

Implements Nameable.

172  {
173  return isset($this->namedtag->CustomName);
174  }

◆ saveNBT()

saveNBT ( )
80  {
81  $this->namedtag->Items = new ListTag("Items", []);
82  $this->namedtag->Items->setTagType(NBT::TAG_Compound);
83  for($index = 0; $index < $this->getSize(); ++$index){
84  $this->setItem($index, $this->inventory->getItem($index));
85  }
86  }

◆ setItem()

setItem (   $index,
Item  $item 
)

This method should not be used by plugins, use the Inventory

Parameters
int$index
Item$item
Returns
bool

Implements Container.

134  {
135  $i = $this->getSlotIndex($index);
136 
137  if($item->getId() === Item::AIR or $item->getCount() <= 0){
138  if($i >= 0){
139  unset($this->namedtag->Items[$i]);
140  }
141  }elseif($i < 0){
142  for($i = 0; $i <= $this->getSize(); ++$i){
143  if(!isset($this->namedtag->Items[$i])){
144  break;
145  }
146  }
147  $this->namedtag->Items[$i] = $item->nbtSerialize($index);
148  }else{
149  $this->namedtag->Items[$i] = $item->nbtSerialize($index);
150  }
151 
152  return true;
153  }

◆ setName()

setName (   $str)
Parameters
void$str

Implements Nameable.

179  {
180  if($str === ""){
181  unset($this->namedtag->CustomName);
182  return;
183  }
184 
185  $this->namedtag->CustomName = new StringTag("CustomName", $str);
186  }

Field Documentation

◆ $inventory

$inventory
protected

◆ $nextUpdate

$nextUpdate = 0
protected

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