mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 17:59:41 +00:00
Set entities on fire if hit by an entity on fire
This commit is contained in:
parent
b33706d427
commit
fb257c16f1
@ -89,6 +89,7 @@ use pocketmine\nbt\tag\Double;
|
|||||||
use pocketmine\nbt\tag\Enum;
|
use pocketmine\nbt\tag\Enum;
|
||||||
use pocketmine\nbt\tag\Float;
|
use pocketmine\nbt\tag\Float;
|
||||||
use pocketmine\nbt\tag\Int;
|
use pocketmine\nbt\tag\Int;
|
||||||
|
use pocketmine\nbt\tag\Short;
|
||||||
use pocketmine\nbt\tag\String;
|
use pocketmine\nbt\tag\String;
|
||||||
use pocketmine\network\Network;
|
use pocketmine\network\Network;
|
||||||
use pocketmine\network\protocol\AdventureSettingsPacket;
|
use pocketmine\network\protocol\AdventureSettingsPacket;
|
||||||
@ -1356,9 +1357,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
$this->processMovement($tickDiff);
|
$this->processMovement($tickDiff);
|
||||||
|
|
||||||
if(!$this->isSpectator()){
|
|
||||||
$this->entityBaseTick($tickDiff);
|
|
||||||
|
|
||||||
|
$this->entityBaseTick($tickDiff);
|
||||||
|
|
||||||
|
if(!$this->isSpectator()){
|
||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
$this->inAirTicks = 0;
|
$this->inAirTicks = 0;
|
||||||
}else{
|
}else{
|
||||||
@ -1388,8 +1390,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$this->sendNextChunk();
|
$this->sendNextChunk();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->checkTeleportPosition();
|
|
||||||
|
|
||||||
if(count($this->moveToSend) > 0){
|
if(count($this->moveToSend) > 0){
|
||||||
$pk = new MoveEntityPacket();
|
$pk = new MoveEntityPacket();
|
||||||
$pk->entities = $this->moveToSend;
|
$pk->entities = $this->moveToSend;
|
||||||
@ -1412,6 +1412,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$this->batchedPackets = [];
|
$this->batchedPackets = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->checkTeleportPosition();
|
||||||
|
|
||||||
$this->lastUpdate = $currentTick;
|
$this->lastUpdate = $currentTick;
|
||||||
|
|
||||||
$this->timings->stopTiming();
|
$this->timings->stopTiming();
|
||||||
@ -1913,6 +1915,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
new Float("", $this->yaw),
|
new Float("", $this->yaw),
|
||||||
new Float("", $this->pitch)
|
new Float("", $this->pitch)
|
||||||
]),
|
]),
|
||||||
|
"Fire" => new Short("Fire", $this->isOnFire() ? 45 * 60 : 0)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$diff = ($this->server->getTick() - $this->startAction);
|
$diff = ($this->server->getTick() - $this->startAction);
|
||||||
|
@ -869,6 +869,10 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
$this->level->updateEntities[$this->id] = $this;
|
$this->level->updateEntities[$this->id] = $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isOnFire(){
|
||||||
|
return $this->fireTicks > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public function setOnFire($seconds){
|
public function setOnFire($seconds){
|
||||||
$ticks = $seconds * 20;
|
$ticks = $seconds * 20;
|
||||||
if($ticks > $this->fireTicks){
|
if($ticks > $this->fireTicks){
|
||||||
|
@ -23,6 +23,7 @@ namespace pocketmine\entity;
|
|||||||
|
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\event\entity\EntityDamageByChildEntityEvent;
|
||||||
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
use pocketmine\event\entity\EntityDeathEvent;
|
use pocketmine\event\entity\EntityDeathEvent;
|
||||||
@ -99,6 +100,15 @@ abstract class Living extends Entity implements Damageable{
|
|||||||
|
|
||||||
if($source instanceof EntityDamageByEntityEvent){
|
if($source instanceof EntityDamageByEntityEvent){
|
||||||
$e = $source->getDamager();
|
$e = $source->getDamager();
|
||||||
|
$t = null;
|
||||||
|
if($source instanceof EntityDamageByChildEntityEvent){
|
||||||
|
$t = $source->getChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($e->isOnFire() > 0 or ($t !== null and $t->isOnFire() > 0)){
|
||||||
|
$this->setOnFire(2 * $this->server->getDifficulty());
|
||||||
|
}
|
||||||
|
|
||||||
$deltaX = $this->x - $e->x;
|
$deltaX = $this->x - $e->x;
|
||||||
$deltaZ = $this->z - $e->z;
|
$deltaZ = $this->z - $e->z;
|
||||||
$yaw = atan2($deltaX, $deltaZ);
|
$yaw = atan2($deltaX, $deltaZ);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user