From 5e6d4526783041fbbcbf6e445d5bbeae93577b18 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 9 Dec 2016 17:03:15 +0000 Subject: [PATCH] Fix TNT flashing, add explosion particles and add DATA_FUSE_LENGTH entity data constant --- src/pocketmine/entity/Entity.php | 1 + src/pocketmine/entity/PrimedTNT.php | 18 +++++++++++++----- src/pocketmine/level/Explosion.php | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 813f8ee34..6e6ce9ab9 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -104,6 +104,7 @@ abstract class Entity extends Location implements Metadatable{ * 52 (short) */ const DATA_BOUNDING_BOX_WIDTH = 53; //float const DATA_BOUNDING_BOX_HEIGHT = 54; //float + const DATA_FUSE_LENGTH = 55; //int /* 56 (vector3f) * 57 (byte) * 58 (float) diff --git a/src/pocketmine/entity/PrimedTNT.php b/src/pocketmine/entity/PrimedTNT.php index a93e43a11..a098909c4 100644 --- a/src/pocketmine/entity/PrimedTNT.php +++ b/src/pocketmine/entity/PrimedTNT.php @@ -2,11 +2,11 @@ /* * - * ____ _ _ __ __ _ __ __ ____ - * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ + * ____ _ _ __ __ _ __ __ ____ + * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | - * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ - * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| + * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ + * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * * 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 @@ -15,7 +15,7 @@ * * @author PocketMine Team * @link http://www.pocketmine.net/ - * + * * */ @@ -57,6 +57,9 @@ class PrimedTNT extends Entity implements Explosive{ }else{ $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){ 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; $hasUpdate = $this->entityBaseTick($tickDiff); diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index 4499e4bcb..dd73938e1 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -29,6 +29,7 @@ use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityExplodeEvent; use pocketmine\item\Item; +use pocketmine\level\particle\HugeExplodeSeedParticle; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Math; use pocketmine\math\Vector3; @@ -221,6 +222,8 @@ class Explosion{ $pk->records = $send; $this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk); + $this->level->addParticle(new HugeExplodeSeedParticle($source)); + return true; } }