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

Public Member Functions

 __construct (Level $level, CompoundTag $nbt, Entity $shootingEntity=null)
 
 attack ($damage, EntityDamageEvent $source)
 
 canCollideWith (Entity $entity)
 
 saveNBT ()
 
 onUpdate ($currentTick)
 
- Public Member Functions inherited from Entity
 __construct (Level $level, CompoundTag $nbt)
 
 getHeight ()
 
 getWidth ()
 
 getLength ()
 
 setScale ($scale)
 
 getScale ()
 
 getDropExpMin ()
 
 getDropExpMax ()
 
 getNameTag ()
 
 isNameTagVisible ()
 
 isNameTagAlwaysVisible ()
 
 setNameTag ($name)
 
 setNameTagVisible ($value=true)
 
 setNameTagAlwaysVisible ($value=true)
 
 isSneaking ()
 
 setSneaking ($value=true)
 
 isSprinting ()
 
 setSprinting ($value=true)
 
 isGliding ()
 
 setGliding ($value=true)
 
 isImmobile ()
 
 setImmobile ($value=true)
 
 canClimb ()
 
 setCanClimb (bool $value)
 
 canClimbWalls ()
 
 setCanClimbWalls (bool $value=true)
 
 getOwningEntityId ()
 
 getOwningEntity ()
 
 setOwningEntity (Entity $owner)
 
 getEffects ()
 
 removeAllEffects ()
 
 removeEffect ($effectId)
 
 getEffect ($effectId)
 
 hasEffect ($effectId)
 
 addEffect (Effect $effect)
 
 getSaveId ()
 
 saveNBT ()
 
 getViewers ()
 
 spawnTo (Player $player)
 
 sendPotionEffects (Player $player)
 
 sendData ($player, array $data=null)
 
 despawnFrom (Player $player, bool $send=true)
 
 attack ($damage, EntityDamageEvent $source)
 
 heal ($amount, EntityRegainHealthEvent $source)
 
 getHealth ()
 
 isAlive ()
 
 setHealth ($amount)
 
 setLastDamageCause (EntityDamageEvent $type)
 
 getLastDamageCause ()
 
 getAttributeMap ()
 
 getMaxHealth ()
 
 setMaxHealth ($amount)
 
 canCollideWith (Entity $entity)
 
 entityBaseTick ($tickDiff=1)
 
 getDirectionVector ()
 
 getDirectionPlane ()
 
 onUpdate ($currentTick)
 
 scheduleUpdate ()
 
 isOnFire ()
 
 setOnFire ($seconds)
 
 isFireProof ()
 
 getDirection ()
 
 extinguish ()
 
 canTriggerWalking ()
 
 resetFallDistance ()
 
 getBoundingBox ()
 
 fall ($fallDistance)
 
 handleLavaMovement ()
 
 getEyeHeight ()
 
 moveFlying ()
 
 onCollideWithPlayer (Human $entityPlayer)
 
 getPosition ()
 
 getLocation ()
 
 isInsideOfPortal ()
 
 isInsideOfWater ()
 
 isInsideOfSolid ()
 
 isInsideOfFire ()
 
 fastMove ($dx, $dy, $dz)
 
 move ($dx, $dy, $dz)
 
 getBlocksAround ()
 
 setPositionAndRotation (Vector3 $pos, $yaw, $pitch)
 
 setRotation ($yaw, $pitch)
 
 setLocation (Location $pos)
 
 setPosition (Vector3 $pos)
 
 getMotion ()
 
 setMotion (Vector3 $motion)
 
 isOnGround ()
 
 kill ()
 
 teleport (Vector3 $pos, $yaw=null, $pitch=null)
 
 getId ()
 
 respawnToAll ()
 
 spawnToAll ()
 
 despawnFromAll ()
 
 close ()
 
 setDataProperty ($id, $type, $value)
 
 linkEntity (Entity $entity)
 
 sendLinkedData ()
 
 setLinked ($type=0, Entity $entity)
 
 getLinkedEntity ()
 
 getLinkedType ()
 
 getDataProperty ($id)
 
 getDataPropertyType ($id)
 
 setDataFlag ($propertyId, $id, $value=true, $type=self::DATA_TYPE_LONG)
 
 getDataFlag ($propertyId, $id)
 
 __destruct ()
 
 setMetadata ($metadataKey, MetadataValue $metadataValue)
 
 getMetadata ($metadataKey)
 
 hasMetadata ($metadataKey)
 
 removeMetadata ($metadataKey, Plugin $plugin)
 
 __toString ()
 
- Public Member Functions inherited from Location
 __construct ($x=0, $y=0, $z=0, $yaw=0.0, $pitch=0.0, Level $level=null)
 
 asLocation ()
 
 add ($x, $y=0, $z=0, $yaw=0, $pitch=0)
 
 getYaw ()
 
 getPitch ()
 
 fromObjectAdd (Vector3 $pos, $x, $y, $z)
 
 __toString ()
 
- 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 DATA_SHOOTER_ID = 17
 
 $shootingEntity = null
 
 $hadCollision = false
 
- Data Fields inherited from Entity
const NETWORK_ID = -1
 
const DATA_TYPE_BYTE = 0
 
const DATA_TYPE_SHORT = 1
 
const DATA_TYPE_INT = 2
 
const DATA_TYPE_FLOAT = 3
 
const DATA_TYPE_STRING = 4
 
const DATA_TYPE_SLOT = 5
 
const DATA_TYPE_POS = 6
 
const DATA_TYPE_LONG = 7
 
const DATA_TYPE_VECTOR3F = 8
 
const DATA_FLAGS = 0
 
const DATA_HEALTH = 1
 
const DATA_VARIANT = 2
 
const DATA_COLOR = 3
 
const DATA_COLOUR = 3
 
const DATA_NAMETAG = 4
 
const DATA_OWNER_EID = 5
 
const DATA_TARGET_EID = 6
 
const DATA_AIR = 7
 
const DATA_POTION_COLOR = 8
 
const DATA_POTION_AMBIENT = 9
 
const DATA_HURT_TIME = 11
 
const DATA_HURT_DIRECTION = 12
 
const DATA_PADDLE_TIME_LEFT = 13
 
const DATA_PADDLE_TIME_RIGHT = 14
 
const DATA_EXPERIENCE_VALUE = 15
 
const DATA_MINECART_DISPLAY_BLOCK = 16
 
const DATA_MINECART_DISPLAY_OFFSET = 17
 
const DATA_MINECART_HAS_DISPLAY = 18
 
const DATA_ENDERMAN_HELD_ITEM_ID = 23
 
const DATA_ENDERMAN_HELD_ITEM_DAMAGE = 24
 
const DATA_ENTITY_AGE = 25
 
const DATA_FIREBALL_POWER_X = 30
 
const DATA_FIREBALL_POWER_Y = 31
 
const DATA_FIREBALL_POWER_Z = 32
 
const DATA_POTION_AUX_VALUE = 37
 
const DATA_LEAD_HOLDER_EID = 38
 
const DATA_SCALE = 39
 
const DATA_INTERACTIVE_TAG = 40
 
const DATA_NPC_SKIN_ID = 41
 
const DATA_URL_TAG = 42
 
const DATA_MAX_AIR = 43
 
const DATA_MARK_VARIANT = 44
 
const DATA_BLOCK_TARGET = 48
 
const DATA_WITHER_INVULNERABLE_TICKS = 49
 
const DATA_WITHER_TARGET_1 = 50
 
const DATA_WITHER_TARGET_2 = 51
 
const DATA_WITHER_TARGET_3 = 52
 
const DATA_BOUNDING_BOX_WIDTH = 54
 
const DATA_BOUNDING_BOX_HEIGHT = 55
 
const DATA_FUSE_LENGTH = 56
 
const DATA_RIDER_SEAT_POSITION = 57
 
const DATA_RIDER_ROTATION_LOCKED = 58
 
const DATA_RIDER_MAX_ROTATION = 59
 
const DATA_RIDER_MIN_ROTATION = 60
 
const DATA_AREA_EFFECT_CLOUD_RADIUS = 61
 
const DATA_AREA_EFFECT_CLOUD_WAITING = 62
 
const DATA_AREA_EFFECT_CLOUD_PARTICLE_ID = 63
 
const DATA_SHULKER_ATTACH_FACE = 65
 
const DATA_SHULKER_ATTACH_POS = 67
 
const DATA_TRADING_PLAYER_EID = 68
 
const DATA_COMMAND_BLOCK_COMMAND = 71
 
const DATA_COMMAND_BLOCK_LAST_OUTPUT = 72
 
const DATA_COMMAND_BLOCK_TRACK_OUTPUT = 73
 
const DATA_CONTROLLING_RIDER_SEAT_NUMBER = 74
 
const DATA_STRENGTH = 75
 
const DATA_MAX_STRENGTH = 76
 
const DATA_FLAG_ONFIRE = 0
 
const DATA_FLAG_SNEAKING = 1
 
const DATA_FLAG_RIDING = 2
 
const DATA_FLAG_SPRINTING = 3
 
const DATA_FLAG_ACTION = 4
 
const DATA_FLAG_INVISIBLE = 5
 
const DATA_FLAG_TEMPTED = 6
 
const DATA_FLAG_INLOVE = 7
 
const DATA_FLAG_SADDLED = 8
 
const DATA_FLAG_POWERED = 9
 
const DATA_FLAG_IGNITED = 10
 
const DATA_FLAG_BABY = 11
 
const DATA_FLAG_CONVERTING = 12
 
const DATA_FLAG_CRITICAL = 13
 
const DATA_FLAG_CAN_SHOW_NAMETAG = 14
 
const DATA_FLAG_ALWAYS_SHOW_NAMETAG = 15
 
const DATA_FLAG_IMMOBILE = 16
 
const DATA_FLAG_NO_AI = 16
 
const DATA_FLAG_SILENT = 17
 
const DATA_FLAG_WALLCLIMBING = 18
 
const DATA_FLAG_CAN_CLIMB = 19
 
const DATA_FLAG_SWIMMER = 20
 
const DATA_FLAG_CAN_FLY = 21
 
const DATA_FLAG_RESTING = 22
 
const DATA_FLAG_SITTING = 23
 
const DATA_FLAG_ANGRY = 24
 
const DATA_FLAG_INTERESTED = 25
 
const DATA_FLAG_CHARGED = 26
 
const DATA_FLAG_TAMED = 27
 
const DATA_FLAG_LEASHED = 28
 
const DATA_FLAG_SHEARED = 29
 
const DATA_FLAG_GLIDING = 30
 
const DATA_FLAG_ELDER = 31
 
const DATA_FLAG_MOVING = 32
 
const DATA_FLAG_BREATHING = 33
 
const DATA_FLAG_CHESTED = 34
 
const DATA_FLAG_STACKABLE = 35
 
const DATA_FLAG_SHOWBASE = 36
 
const DATA_FLAG_REARING = 37
 
const DATA_FLAG_VIBRATING = 38
 
const DATA_FLAG_IDLING = 39
 
const DATA_FLAG_EVOKER_SPELL = 40
 
const DATA_FLAG_CHARGE_ATTACK = 41
 
const DATA_FLAG_LINGER = 45
 
const SOUTH = 0
 
const WEST = 1
 
const NORTH = 2
 
const EAST = 3
 
 $passenger = null
 
 $vehicle = null
 
 $chunk
 
 $lastX = null
 
 $lastY = null
 
 $lastZ = null
 
 $motionX
 
 $motionY
 
 $motionZ
 
 $temporalVector
 
 $lastMotionX
 
 $lastMotionY
 
 $lastMotionZ
 
 $lastYaw
 
 $lastPitch
 
 $boundingBox
 
 $onGround
 
 $inBlock = false
 
 $positionChanged
 
 $motionChanged
 
 $deadTicks = 0
 
 $height
 
 $eyeHeight = null
 
 $width
 
 $length
 
 $keepMovement = false
 
 $fallDistance = 0
 
 $ticksLived = 0
 
 $lastUpdate
 
 $maxFireTicks
 
 $fireTicks = 0
 
 $namedtag
 
 $canCollide = true
 
 $isCollided = false
 
 $isCollidedHorizontally = false
 
 $isCollidedVertically = false
 
 $noDamageTicks
 
 $closed = false
 
 $dropExp = [0, 0]
 
- Data Fields inherited from Location
 $yaw
 
 $pitch
 
- 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

 initEntity ()
 
- Protected Member Functions inherited from Entity
 recalculateEffectColor ()
 
 initEntity ()
 
 addAttributes ()
 
 checkObstruction ($x, $y, $z)
 
 updateMovement ()
 
 updateFallState ($distanceThisTick, $onGround)
 
 switchLevel (Level $targetLevel)
 
 checkGroundState ($movX, $movY, $movZ, $dx, $dy, $dz)
 
 checkBlockCollision ()
 
 checkChunks ()
 

Protected Attributes

 $damage = 0
 
- Protected Attributes inherited from Entity
 $hasSpawned = []
 
 $effects = []
 
 $id
 
 $dataFlags = 0
 
 $dataProperties
 
 $lastDamageCause = null
 
 $age = 0
 
 $ySize = 0
 
 $stepHeight = 0
 
 $isStatic = false
 
 $justCreated
 
 $attributeMap
 
 $gravity
 
 $drag
 
 $server
 
 $timings
 
 $isPlayer = false
 
 $linkedEntity = null
 
 $linkedType = null
 
 $riding = null
 
 $activatedPressurePlates = []
 

Additional Inherited Members

- Static Public Member Functions inherited from Entity
static init ()
 
static createEntity ($type, Level $level, CompoundTag $nbt,... $args)
 
static registerEntity ($className, $force=false)
 
- Static Public Member Functions inherited from Location
static fromObject (Vector3 $pos, Level $level=null, $yaw=0.0, $pitch=0.0)
 
- 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 Entity
static $entityCount = 1
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Level  $level,
CompoundTag  $nbt,
Entity  $shootingEntity = null 
)

Projectile constructor.

Parameters
Level$level
CompoundTag$nbt
Entity | null$shootingEntity
54  {
55  $this->shootingEntity = $shootingEntity;
56  if($shootingEntity !== null){
57  $this->setDataProperty(self::DATA_SHOOTER_ID, self::DATA_TYPE_LONG, $shootingEntity->getId());
58  }
59  parent::__construct($level, $nbt);
60  }

Member Function Documentation

◆ attack()

attack (   $damage,
EntityDamageEvent  $source 
)
Parameters
float$damage
EntityDamageEvent$source
Returns
bool|void
68  {
69  if($source->getCause() === EntityDamageEvent::CAUSE_VOID){
70  parent::attack($damage, $source);
71  }
72  }

◆ canCollideWith()

canCollideWith ( Entity  $entity)
Parameters
Entity$entity
Returns
bool
90  {
91  return $entity instanceof Living and !$this->onGround;
92  }

◆ initEntity()

initEntity ( )
protected
74  {
75  parent::initEntity();
76 
77  $this->setMaxHealth(1);
78  $this->setHealth(1);
79  if(isset($this->namedtag->Age)){
80  $this->age = $this->namedtag["Age"];
81  }
82 
83  }

◆ onUpdate()

onUpdate (   $currentTick)
Parameters
$currentTick
Returns
bool

$entity->canCollideWith($this) or

104  {
105  if($this->closed){
106  return false;
107  }
108 
109 
110  $tickDiff = $currentTick - $this->lastUpdate;
111  if($tickDiff <= 0 and !$this->justCreated){
112  return true;
113  }
114  $this->lastUpdate = $currentTick;
115 
116  $hasUpdate = $this->entityBaseTick($tickDiff);
117 
118  if($this->isAlive()){
119 
120  $movingObjectPosition = null;
121 
122  if(!$this->isCollided){
123  $this->motionY -= $this->gravity;
124  }
125 
126  $moveVector = new Vector3($this->x + $this->motionX, $this->y + $this->motionY, $this->z + $this->motionZ);
127 
128  $list = $this->getLevel()->getCollidingEntities($this->boundingBox->addCoord($this->motionX, $this->motionY, $this->motionZ)->expand(1, 1, 1), $this);
129 
130  $nearDistance = PHP_INT_MAX;
131  $nearEntity = null;
132 
133  foreach($list as $entity){
134  if(
135  ($entity === $this->shootingEntity and $this->ticksLived < 5)
136  ){
137  continue;
138  }
139 
140  $axisalignedbb = $entity->boundingBox->grow(0.3, 0.3, 0.3);
141  $ob = $axisalignedbb->calculateIntercept($this, $moveVector);
142 
143  if($ob === null){
144  continue;
145  }
146 
147  $distance = $this->distanceSquared($ob->hitVector);
148 
149  if($distance < $nearDistance){
150  $nearDistance = $distance;
151  $nearEntity = $entity;
152  }
153  }
154 
155  if($nearEntity !== null){
156  $movingObjectPosition = MovingObjectPosition::fromEntity($nearEntity);
157  }
158 
159  if($movingObjectPosition !== null){
160  if($movingObjectPosition->entityHit !== null){
161 
162  $this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
163 
164  $motion = sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2);
165  $damage = ceil($motion * $this->damage);
166 
167  if($this instanceof Arrow and $this->isCritical()){
168  $damage += mt_rand(0, (int) ($damage / 2) + 1);
169  }
170 
171  if($this->shootingEntity === null){
172  $ev = new EntityDamageByEntityEvent($this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
173  }else{
174  $ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
175  }
176 
177  if($movingObjectPosition->entityHit->attack($ev->getFinalDamage(), $ev) === true){
178  if($this instanceof Arrow and $this->getPotionId() != 0){
179  foreach(Potion::getEffectsById($this->getPotionId() - 1) as $effect){
180  $movingObjectPosition->entityHit->addEffect($effect->setDuration($effect->getDuration() / 8));
181  }
182  }
183  $ev->useArmors();
184  }
185 
186  $this->hadCollision = true;
187 
188  if($this->fireTicks > 0){
189  $ev = new EntityCombustByEntityEvent($this, $movingObjectPosition->entityHit, 5);
190  $this->server->getPluginManager()->callEvent($ev);
191  if(!$ev->isCancelled()){
192  $movingObjectPosition->entityHit->setOnFire($ev->getDuration());
193  }
194  }
195 
196  $this->kill();
197  return true;
198  }
199  }
200 
201  $this->move($this->motionX, $this->motionY, $this->motionZ);
202 
203  if($this->isCollided and !$this->hadCollision){
204  $this->hadCollision = true;
205 
206  $this->motionX = 0;
207  $this->motionY = 0;
208  $this->motionZ = 0;
209 
210  $this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
211  }elseif(!$this->isCollided and $this->hadCollision){
212  $this->hadCollision = false;
213  }
214 
215  if(!$this->onGround or abs($this->motionX) > 0.00001 or abs($this->motionY) > 0.00001 or abs($this->motionZ) > 0.00001){
216  $f = sqrt(($this->motionX ** 2) + ($this->motionZ ** 2));
217  $this->yaw = (atan2($this->motionX, $this->motionZ) * 180 / M_PI);
218  $this->pitch = (atan2($this->motionY, $f) * 180 / M_PI);
219  $hasUpdate = true;
220  }
221 
222  $this->updateMovement();
223 
224  }
225 
226  return $hasUpdate;
227  }

◆ saveNBT()

saveNBT ( )
94  {
95  parent::saveNBT();
96  $this->namedtag->Age = new ShortTag("Age", $this->age);
97  }

Field Documentation

◆ $damage

$damage = 0
protected

◆ $hadCollision

$hadCollision = false

◆ $shootingEntity

$shootingEntity = null

◆ DATA_SHOOTER_ID

const DATA_SHOOTER_ID = 17

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