Saturation with an AreaEffectCloud
I don't seem to be able to use
{Effect:[{Id:23, [...] }]}
on an AreaEffectCloud - it simply gives no effects and everything else works perfectly.
Exact command I'm using:
/summon area_effect_cloud ~ ~ ~ {Particle:mobSpell,ReapplicationDelay:10,Radius:2.5f,RadiusPerTick:-0.0025f,RadiusOnUse:-0.05f,Duration:1000,DurationOnUse:0f,WaitTime:0,Effects:[{Id:23,Amplifier:2,Duration:600,ShowParticles:0b}],Potion:"minecraft:water"}
What I expected to happen:
Saturation effect applied to player
What actually happened was:
No effect was applied
Steps to Reproduce:
1. Put the command above in a command block
2. Activate the command block
3. Stand in cloud; no effect is applied
Code analysis by [Mod] Pokechu22 can be found in this comment.
Environment
Windows 10 Version 1511
Java 8 Update 66 (build 1.8.0_66-b18)
- Fixed
Lifeofchrome
- 12
- 12
- Confirmed
- area_effect_cloud saturation
1.9-pre4 - 18w14b
1.9-pre4 1.9 1.10.2 16w36a 16w39b 16w39c 16w41a 16w42a 16w43a 16w44a 1.11-pre1 1.11 16w50a 1.11.1 1.11.2 17w06a 17w13a 17w13b 17w14a 17w15a 17w16a 17w17b 17w18a 17w18b 1.12-pre1 1.12-pre2 1.12-pre3 1.12-pre5 1.12-pre6 1.12-pre7 1.12 17w31a 1.12.1-pre1 1.12.1 1.12.2-pre1 1.12.2-pre2 1.12.2 17w43a 17w43b 17w45a 17w46a 17w48a 17w50a 18w01a 18w03b 18w06a 18w09a 18w10d 18w14b- 18w15a
Created Issue:
Saturation with an AreaEffectCloud
I don't seem to be able to use
{Effect:[{Id:23, [...] }]}on an AreaEffectCloud - it simply gives no effects and everything else works perfectly.
Exact command I'm using:
/summon AreaEffectCloud ~ ~ ~ {Particle:mobSpell,ReapplicationDelay:10,Radius:2.5f,RadiusPerTick:-0.0025f,RadiusOnUse:-0.05f,Duration:1000,DurationOnUse:0f,WaitTime:0,Effects:[{Id:23,Amplifier:2,Duration:600,ShowParticles:0b}],Potion:"minecraft:water"}What I expected to happen:
Saturation effect applied to playerWhat actually happened was:
No effect was appliedSteps to Reproduce:
1. Put the command above in a command block
2. Activate the command block
3. Stand in cloud; no effect is appliedEnvironment
Windows 10 Version 1511
Java 8 Update 66 (build 1.8.0_66-b18)
I don't seem to be able to use
{Effect:[{Id:23, [...] }]}on an AreaEffectCloud - it simply gives no effects and everything else works perfectly.
Exact command I'm using:
/summon AreaEffectCloud ~ ~ ~ {Particle:mobSpell,ReapplicationDelay:10,Radius:2.5f,RadiusPerTick:-0.0025f,RadiusOnUse:-0.05f,Duration:1000,DurationOnUse:0f,WaitTime:0,Effects:[{Id:23,Amplifier:2,Duration:600,ShowParticles:0b}],Potion:"minecraft:water"}What I expected to happen:
Saturation effect applied to playerWhat actually happened was:
No effect was appliedSteps to Reproduce:
1. Put the command above in a command block
2. Activate the command block
3. Stand in cloud; no effect is applied
relates to
I don't seem to be able to use
{Effect:[{Id:23, [...] }]}on an AreaEffectCloud - it simply gives no effects and everything else works perfectly.
Exact command I'm using:
/summonAreaEffectCloud ~ ~ ~ {Particle:mobSpell,ReapplicationDelay:10,Radius:2.5f,RadiusPerTick:-0.0025f,RadiusOnUse:-0.05f,Duration:1000,DurationOnUse:0f,WaitTime:0,Effects:[{Id:23,Amplifier:2,Duration:600,ShowParticles:0b}],Potion:"minecraft:water"}What I expected to happen:
Saturation effect applied to playerWhat actually happened was:
No effect was appliedSteps to Reproduce:
1. Put the command above in a command block
2. Activate the command block
3. Stand in cloud; no effect is applied
I don't seem to be able to use
{Effect:[{Id:23, [...] }]}on an AreaEffectCloud - it simply gives no effects and everything else works perfectly.
Exact command I'm using:
/summon area_effect_cloud ~ ~ ~ {Particle:mobSpell,ReapplicationDelay:10,Radius:2.5f,RadiusPerTick:-0.0025f,RadiusOnUse:-0.05f,Duration:1000,DurationOnUse:0f,WaitTime:0,Effects:[{Id:23,Amplifier:2,Duration:600,ShowParticles:0b}],Potion:"minecraft:water"}What I expected to happen:
Saturation effect applied to playerWhat actually happened was:
No effect was appliedSteps to Reproduce:
1. Put the command above in a command block
2. Activate the command block
3. Stand in cloud; no effect is applied
I don't seem to be able to use
{Effect:[{Id:23, [...] }]}on an AreaEffectCloud - it simply gives no effects and everything else works perfectly.
Exact command I'm using:
/summon area_effect_cloud ~ ~ ~ {Particle:mobSpell,ReapplicationDelay:10,Radius:2.5f,RadiusPerTick:-0.0025f,RadiusOnUse:-0.05f,Duration:1000,DurationOnUse:0f,WaitTime:0,Effects:[{Id:23,Amplifier:2,Duration:600,ShowParticles:0b}],Potion:"minecraft:water"}What I expected to happen:
Saturation effect applied to playerWhat actually happened was:
No effect was appliedSteps to Reproduce:
1. Put the command above in a command block
2. Activate the command block
3. Stand in cloud; no effect is applied
I don't seem to be able to use
{Effect:[{Id:23, [...] }]}on an AreaEffectCloud - it simply gives no effects and everything else works perfectly.
Exact command I'm using:
/summon area_effect_cloud ~ ~ ~ {Particle:mobSpell,ReapplicationDelay:10,Radius:2.5f,RadiusPerTick:-0.0025f,RadiusOnUse:-0.05f,Duration:1000,DurationOnUse:0f,WaitTime:0,Effects:[{Id:23,Amplifier:2,Duration:600,ShowParticles:0b}],Potion:"minecraft:water"}What I expected to happen:
Saturation effect applied to playerWhat actually happened was:
No effect was appliedSteps to Reproduce:
1. Put the command above in a command block
2. Activate the command block
3. Stand in cloud; no effect is applied
Code analysis by [Mod] Pokechu22 can be found in this comment.
Confirmed for 17w48a.
Confirmed for 1.10.2.
This is highly related to MC-98123, and most of the code analysis there applies here as well (the same usage of affectEntity is found in EntityPotion).
Method and class names based on 1.11 decompiled using MCP 9.35 rc1
The bug
When a mob is shot with a tipped arrow all effects are applied as if they were no instant effects. This causes instant effects with the Amplifier 0 to not be applied because the method net.minecraft.potion.Potion.performEffect(EntityLivingBase, int) can be considered broken for instant effects because it only shifts with the amplifier but does not add 0.5 at the end.
This can be fixed by having the method net.minecraft.entity.projectile.EntityTippedArrow.arrowHit(EntityLivingBase) test if the effect is instant and in that case call the method net.minecraft.potion.Potion.affectEntity(Entity, Entity, EntityLivingBase, int, double) instead. After this change tipped arrows would be affected by MC-25866 / MC-98123 as well.
Note that changing the Effect id to 1 (Speed) makes this work.
This results in the command:
/summon AreaEffectCloud ~ ~ ~ {Particle:mobSpell,ReapplicationDelay:10,Radius:2.5f,RadiusPerTick:-0.0025f,RadiusOnUse:-0.05f,Duration:1000,DurationOnUse:0f,WaitTime:0,Effects:[
{Id:1,Amplifier:2,Duration:600,ShowParticles:0b}],Potion:"minecraft:water"}
That's the point - it doesn't work with saturation. Of course it works with all other effects, but not for saturation.
Just discovered this bug myself in 1.10.2. Kinda disappointing.
I looked at the relevant code for this.
First off, Saturation is an instant effect, which means that having it apply for 600 units (the game will say seconds, but it's actually ticks) may not be what you want - it's instant, permanent full hunger for 30 seconds effectively (you can see this with /effect @p minecraft:saturation 600 3). But still, the behavior with AreaEffectClouds is a bug.
AreaEffectClouds have some complex logic in their onUpdate to check for entities, render particles, and decrease sizes, but the main potion applying logic is simply this: (MCP names followed by 1.10.2 obfuscated names)
And if you look at Potion.affectEntity, it only is for handling healing of entities:
Since the effect is neither instant health nor instant damage, the first if statement passes but the second one does not, meaning nothing happens. (Normally, the logic for saturation happens in Potion.performEffect(EntityLivingBase, int) (rp.a(sf, int), lines 76 - 100)).
The trivial fix is to manually handle saturation potions in affectEntity, maybe just by copying the logic from performEffect. Of course, if that is done one can't have a duration on saturation potions in area effect clouds (but the same behavior applies to instant health). It doesn't seem like the logic in AreaEffectCloud can be tweaked to always use addPotionEffect (though I'm not entirely sure why), though if it could that would make for cleaner logic. The ideal fix would probably require some larger refactoring of those two potion methods.
One final note - this issue is highly related to
MC-25866(though not a duplicate per se).Confirmed for 17w48a.
Seems to be somehow related to MC-121429 and how Minecraft processes instant effects in potions.