mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
snowballs and eggs
This commit is contained in:
parent
105b09e28f
commit
3df03ae96b
10 changed files with 304 additions and 34 deletions
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
class Arrow extends Projectile{
|
||||
class Arrow extends Entity{
|
||||
const TYPE = OBJECT_ARROW;
|
||||
|
||||
const CLASS_TYPE = ENTITY_OBJECT;
|
||||
|
||||
public $shooterEID = 0;
|
||||
public $shotByEntity;
|
||||
|
|
@ -65,6 +65,9 @@ class Arrow extends Projectile{
|
|||
$this->lastZ = $this->z;
|
||||
$this->lastPitch = $this->pitch;
|
||||
$this->lastYaw = $this->yaw;
|
||||
$this->lastSpeedX = $this->speedX;
|
||||
$this->lastSpeedY = $this->speedY;
|
||||
$this->lastSpeedZ = $this->speedZ;
|
||||
$this->needsUpdate = true;
|
||||
$this->handleWaterMovement(); //TODO: maybe just call parent::update(); ?
|
||||
if($this->fire > 0){
|
||||
|
|
|
|||
32
src/entity/object/ThrownEgg.php
Normal file
32
src/entity/object/ThrownEgg.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
class ThrownEgg extends Projectile{
|
||||
const TYPE = OBJECT_EGG;
|
||||
|
||||
public function onHit(MovingObjectPosition $hitResult){
|
||||
if($hitResult->typeOfHit == 1){
|
||||
$hitResult->entityHit->harm(0, $this->eid);
|
||||
}
|
||||
|
||||
$rand = mt_rand(0, 7);
|
||||
if($rand == 0){
|
||||
$count = mt_rand(0, 31) == 0 ? 4 : 1;
|
||||
$data = [
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
"z" => $this->z,
|
||||
"yaw" => $this->yaw,
|
||||
"pitch" => 0,
|
||||
"IsBaby" => true
|
||||
];
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$chicken = $this->server->api->entity->add($this->level, ENTITY_MOB, MOB_CHICKEN, $data);
|
||||
|
||||
$this->server->api->entity->spawnToAll($chicken);
|
||||
}
|
||||
}
|
||||
|
||||
$this->close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
src/entity/object/ThrownSnowball.php
Normal file
11
src/entity/object/ThrownSnowball.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
class ThrownSnowball extends Projectile{
|
||||
const TYPE = OBJECT_SNOWBALL;
|
||||
public function onHit(MovingObjectPosition $hitResult){
|
||||
if($hitResult->typeOfHit == 1){
|
||||
$hitResult->entityHit->harm(0, $this->eid);
|
||||
}
|
||||
|
||||
$this->close();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue