From 6a0c54f850c263f58e7551257265c6922aeac5d5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 24 Sep 2022 17:24:35 +0100 Subject: [PATCH] Block: Relocate and document addVelocityToEntity() maybe we should consider merging this with onEntityInside(), since they are both called for the same reasons? ... --- src/block/Block.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/block/Block.php b/src/block/Block.php index 266e4c785..41983df64 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -342,10 +342,6 @@ class Block{ return false; } - public function addVelocityToEntity(Entity $entity) : ?Vector3{ - return null; - } - final public function getPosition() : Position{ return $this->position; } @@ -585,6 +581,19 @@ class Block{ return true; } + /** + * Returns a direction vector describing which way an entity intersecting this block should be pushed. + * This is used by liquids to push entities in liquid currents. + * + * The returned vector is summed with vectors from every other block the entity is intersecting, and normalized to + * produce a final direction vector. + * + * WARNING: This will not be called if {@link Block::hasEntityCollision()} does not return true! + */ + public function addVelocityToEntity(Entity $entity) : ?Vector3{ + return null; + } + /** * Called when an entity lands on this block (usually due to falling). * @return float|null The new vertical velocity of the entity, or null if unchanged.