mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 01:39:52 +00:00
Add a hook to enable blocks to react to projectiles colliding with them
this enables implementing blocks such as the target block.
This commit is contained in:
parent
3e4f01d85e
commit
c67e42a723
@ -32,6 +32,7 @@ use pocketmine\block\utils\SupportType;
|
|||||||
use pocketmine\data\runtime\RuntimeDataReader;
|
use pocketmine\data\runtime\RuntimeDataReader;
|
||||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
|
use pocketmine\entity\projectile\Projectile;
|
||||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\ItemBlock;
|
use pocketmine\item\ItemBlock;
|
||||||
@ -626,6 +627,13 @@ class Block{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a projectile collides with one of this block's collision boxes.
|
||||||
|
*/
|
||||||
|
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
|
||||||
|
//NOOP
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return AxisAlignedBB[]
|
* @return AxisAlignedBB[]
|
||||||
*/
|
*/
|
||||||
|
@ -306,5 +306,6 @@ abstract class Projectile extends Entity{
|
|||||||
*/
|
*/
|
||||||
protected function onHitBlock(Block $blockHit, RayTraceResult $hitResult) : void{
|
protected function onHitBlock(Block $blockHit, RayTraceResult $hitResult) : void{
|
||||||
$this->blockHit = $blockHit->getPosition()->asVector3();
|
$this->blockHit = $blockHit->getPosition()->asVector3();
|
||||||
|
$blockHit->onProjectileHit($this, $hitResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user