mojira.dev
MC-93824

Feeding golden carrot to breed horse works if InLove is greater than 0

The bug

When you try to breed a horse you can still feed it golden carrots even if the InLove value is greater than 0. This is different compared to other animals which can only be fed once and to golden apples which can only be used if the horse is not in love.

The reason

The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.

The reason for this is that the method net.minecraft.entity.passive.EntityHorse.func_184645_a(EntityPlayer, EnumHand, ItemStack) tests for golden carrots only if the horse is tamed and an adult horse.

public boolean func_184645_a(EntityPlayer p_184645_1_, EnumHand p_184645_2_, ItemStack p_184645_3_)
{
    if (p_184645_3_ != null && p_184645_3_.getItem() == Items.spawn_egg)
    //...
    else
    {
        if (p_184645_3_ != null)
        {
            //...

            boolean flag = false;

            if (!this.getType().func_188602_h())
            {
                float f = 0.0F;
                int i = 0;
                int j = 0;

                if (p_184645_3_.getItem() == Items.wheat)
                //...
                else if (p_184645_3_.getItem() == Items.golden_carrot)
                {
                    f = 4.0F;
                    i = 60;
                    j = 5;

                    // Should test as well if the horse is not in love (see golden apple test)
                    if (this.isTame() && this.getGrowingAge() == 0)
                    {
                        flag = true;
                        this.setInLove(p_184645_1_);
                    }
                }
                else if (p_184645_3_.getItem() == Items.golden_apple)
                {
                    f = 10.0F;
                    i = 240;
                    j = 10;

                    if (this.isTame() && this.getGrowingAge() == 0 && !this.isInLove())
                    {
                        flag = true;
                        this.setInLove(p_184645_1_);
                    }
                }

                //...
            }

            //...
        }
        
        //...
    }
}

Comments 0

No comments.

marcono1234

Agnes Larsson

Unconfirmed

breeding, golden-apple, golden-carrot, horse

Minecraft 15w49b, Minecraft 16w21b

Minecraft 16w38a

Retrieved