[SPIGOT-6340] AreaEffectCloud getSource() returns null if shooter is dispenser Created: 03/Feb/21  Updated: 03/Feb/21

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Frank Wu Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: PNG File Screenshot 2021-02-02 171339.png     File TestAreaEffectCloud.jar    
Version: CraftBukkit version 2991-Spigot-018b9a0-f3f3094 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

 

It seems like getSource() will return null from the AreaEffectCloud created by lingering potion fired from dispenser. getSource() should return a ProjectileSource, which should lead to the dispenser block.

Test with this code:

List<Entity> nearby = player.getNearbyEntities(32, 32, 32); 
for (Entity entity : nearby) { 
    if (entity instanceof AreaEffectCloud) { 
        AreaEffectCloud area = (AreaEffectCloud) entity; 
        player.sendMessage(entity.getType().name() + "'s source: " + area.getSource()); 
    } 
}

A test plugin is attached. Use command "/taec" to show nearby AreaEffectCloud nearby. The screenshot represents two lingering potions being thrown: One by myself, and one by dispenser.

 

On the other hand: getShooter() from Arrows fired by dispenser works fine.

 



 Comments   
Comment by blablubbabc [ 03/Feb/21 ]

Seems like AreaEffectCloud#getSource() is simply a wrapper around the cloud's 'Owner' currently, which Minecraft expects to always be a LivingEntity. The dispenser is only used as projectile source for projectiles and thrown items. I.e. the thrown potion itself probably has the dispenser as its projectile source. That information is not carried over / preserved when the cloud is spawned by the potion (Minecraft only carries over the 'shooter' entity, which is why this works if you throw the potion yourself).

However, CraftBukkit could probably keep track of the area effect cloud's 'projectile source' when it is spawned by a potion, and then return that instead.

Side note: I wonder if it would also make sense to provide the 'projectile source' (i.e. the dispenser) for primed tnt entities, even though these are not projectiles either (similar to how the AreaEffectCloud is not a projectile). The current TNTPrimed#getSource method always only returns a source entity, if its available.

Generated at Sat Apr 05 09:53:30 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.