Fix TNT flashing, add explosion particles and add DATA_FUSE_LENGTH entity data constant

This commit is contained in:
Dylan K. Taylor 2016-12-09 17:03:15 +00:00
parent ae6e0773ef
commit 5e6d452678
3 changed files with 17 additions and 5 deletions

View File

@ -104,6 +104,7 @@ abstract class Entity extends Location implements Metadatable{
* 52 (short) */ * 52 (short) */
const DATA_BOUNDING_BOX_WIDTH = 53; //float const DATA_BOUNDING_BOX_WIDTH = 53; //float
const DATA_BOUNDING_BOX_HEIGHT = 54; //float const DATA_BOUNDING_BOX_HEIGHT = 54; //float
const DATA_FUSE_LENGTH = 55; //int
/* 56 (vector3f) /* 56 (vector3f)
* 57 (byte) * 57 (byte)
* 58 (float) * 58 (float)

View File

@ -2,11 +2,11 @@
/* /*
* *
* ____ _ _ __ __ _ __ __ ____ * ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
@ -15,7 +15,7 @@
* *
* @author PocketMine Team * @author PocketMine Team
* @link http://www.pocketmine.net/ * @link http://www.pocketmine.net/
* *
* *
*/ */
@ -57,6 +57,9 @@ class PrimedTNT extends Entity implements Explosive{
}else{ }else{
$this->fuse = 80; $this->fuse = 80;
} }
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_IGNITED, true);
$this->setDataProperty(self::DATA_FUSE_LENGTH, self::DATA_TYPE_INT, $this->fuse);
} }
@ -81,6 +84,11 @@ class PrimedTNT extends Entity implements Explosive{
if($tickDiff <= 0 and !$this->justCreated){ if($tickDiff <= 0 and !$this->justCreated){
return true; return true;
} }
if($this->fuse % 5 === 0){ //don't spam it every tick, it's not necessary
$this->setDataProperty(self::DATA_FUSE_LENGTH, self::DATA_TYPE_INT, $this->fuse);
}
$this->lastUpdate = $currentTick; $this->lastUpdate = $currentTick;
$hasUpdate = $this->entityBaseTick($tickDiff); $hasUpdate = $this->entityBaseTick($tickDiff);

View File

@ -29,6 +29,7 @@ use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityExplodeEvent; use pocketmine\event\entity\EntityExplodeEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\particle\HugeExplodeSeedParticle;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Math; use pocketmine\math\Math;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -221,6 +222,8 @@ class Explosion{
$pk->records = $send; $pk->records = $send;
$this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk); $this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk);
$this->level->addParticle(new HugeExplodeSeedParticle($source));
return true; return true;
} }
} }