mojira.dev
MC-92105

Splash and lingering potion ignore Ambient and ShowParticles tag

The bug

When you use splash or lingering potions with CustomPotionEffects that are set to Ambient:1b or ShowParticles:0b, they ignore this tag and set it to 0b respectively 1b.

How to reproduce

Lingering Ambient

/give @p lingering_potion 1 0 {CustomPotionEffects:[{Id:12,Duration:1200,Ambient:1b,Amplifier:1}]}

Splash No particles

/give @p splash_potion 1 0 {CustomPotionEffects:[{Id:12,Duration:1200,Ambient:1b,ShowParticles:0b}]}

The reason

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

Splash potions

The reason why this is happening is because the net.minecraft.entity.projectile.EntityPotion.onImpact(RayTraceResult) method is not copying whether or not the potion effect is ambient or if it is supposed to show particles when creating a new potion effect that gets added to the the mob (the drinkable potion does this).

Lingering potions

The reason why this is happening is because the net.minecraft.entity.projectile.EntityPotion.onImpact(RayTraceResult) method is not copying whether or not the potion effect is ambient or if it is supposed to show particles when creating a new potion effect that gets added to the AreaEffectCloud.

Complete method

/**
     * Called when this EntityThrowable hits a block or entity.
     */
    protected void onImpact(RayTraceResult result)
    {
        if (!this.worldObj.isRemote)
        {
            ItemStack itemstack = this.func_184543_l();
            PotionType potiontype = PotionUtils.func_185191_c(itemstack);
            List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);

            if (result.typeOfHit == RayTraceResult.Type.BLOCK && potiontype == PotionTypes.water && list.isEmpty())
            {
                BlockPos blockpos = result.getBlockPos().offset(result.sideHit);
                this.func_184542_a(blockpos);

                for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
                {
                    this.func_184542_a(blockpos.offset(enumfacing));
                }

                this.worldObj.playAuxSFX(2002, new BlockPos(this), PotionType.getID(potiontype));
                this.setDead();
            }
            else
            {
                if (!list.isEmpty())
                {
                    if (this.func_184544_n())
                    {
                        EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.worldObj, this.posX, this.posY, this.posZ);
                        entityareaeffectcloud.func_184481_a(this.getThrower());
                        entityareaeffectcloud.setRadius(3.0F);
                        entityareaeffectcloud.func_184495_b(-0.5F);
                        entityareaeffectcloud.func_184485_d(10);
                        entityareaeffectcloud.func_184487_c(-entityareaeffectcloud.getRadius() / (float)entityareaeffectcloud.func_184489_o());
                        entityareaeffectcloud.func_184484_a(potiontype);

                        for (PotionEffect potioneffect : PotionUtils.func_185190_b(itemstack))
                        {
                            // Replaced this
                            //entityareaeffectcloud.func_184496_a(new PotionEffect(potioneffect.func_188419_a(), potioneffect.getDuration(), potioneffect.getAmplifier()));
                            entityareaeffectcloud.func_184496_a(new PotionEffect(potioneffect));
                        }

                        this.worldObj.spawnEntityInWorld(entityareaeffectcloud);
                    }
                    else
                    {
                        AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D);
                        List<EntityLivingBase> list1 = this.worldObj.<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);

                        if (!list1.isEmpty())
                        {
                            for (EntityLivingBase entitylivingbase : list1)
                            {
                                if (entitylivingbase.func_184603_cC())
                                {
                                    double d0 = this.getDistanceSqToEntity(entitylivingbase);

                                    if (d0 < 16.0D)
                                    {
                                        double d1 = 1.0D - Math.sqrt(d0) / 4.0D;

                                        if (entitylivingbase == result.entityHit)
                                        {
                                            d1 = 1.0D;
                                        }

                                        for (PotionEffect potioneffect1 : list)
                                        {
                                            Potion potion = potioneffect1.func_188419_a();

                                            if (potion.isInstant())
                                            {
                                                potion.affectEntity(this, this.getThrower(), entitylivingbase, potioneffect1.getAmplifier(), d1);
                                            }
                                            else
                                            {
                                                int i = (int)(d1 * (double)potioneffect1.getDuration() + 0.5D);

                                                if (i > 20)
                                                {
                                                    // Replaced this
                                                    //entitylivingbase.addPotionEffect(new PotionEffect(potion, i, potioneffect1.getAmplifier()));
                                                    entitylivingbase.addPotionEffect(new PotionEffect(potion, i, potioneffect1.getAmplifier(), potioneffect1.getIsAmbient(), potioneffect1.func_188418_e()));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                this.worldObj.playAuxSFX(2002, new BlockPos(this), PotionType.getID(potiontype));
                this.setDead();
            }
        }
    }

Linked issues

Comments 5

Confirmed for 1.9-pre2

Confirmed for 1.9-pre3

Confirmed for 1.9-pre4

Still in 1.9.1-pre3

marcono1234

migrated

Confirmed

ambient, lingering_potion, potion-effect, splash_potion

Minecraft 15w44b, Minecraft 1.9 Pre-Release 2, Minecraft 1.9 Pre-Release 3, Minecraft 1.9 Pre-Release 4, Minecraft 1.9, ..., Minecraft 16w39c, Minecraft 16w40a, Minecraft 16w41a, Minecraft 16w42a, Minecraft 16w43a

Minecraft 16w44a

Retrieved