mojira.dev
MC-94978

Throwable items fired from dispenser do not hit mobs for the first two ticks

Dispensers can fire snowballs but they don't hit mobs (hostile and passive).
It is the same problem with eggs, but all is good with arrows.


Code analysis by @unknown in this comment

Linked issues

Comments

ilmango

this is a seperate issue. snowballs don't affect mobs at all, they fly through mobs

Azelef

Yes, MC-44280 says that snowballs don't knockback mobs, while this report says that they don't even hit the mobs. This isn't a duplicate.

marcono1234

Is this still the case in 1.9?

ilmango

confirmed for 1.9

ilmango

further testing showed, that mobs aren't affected, that stand right in front of the dispenser, while those that are a few blocks away get hit. http://imgur.com/istJ6w6

marcono1234

Please change the title to "Throwable items fired from dispenser do not hit mobs for the first two ticks"
And please update the description, the word "irritate" does not fit very well

marcono1234

Please link to this comment in the description

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.

The reason why this happens is because the net.minecraft.entity.projectile.EntityThrowable.onUpdate() method only tests if the thrown entity hits a mob if it existed for more than two ticks. This delay should be only applied if the thrower is an entity.

/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    //...

    Entity entity = null;
    List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).func_186662_g(1.0D));
    double d0 = 0.0D;
    boolean flag = false;

    for (int i = 0; i < list.size(); ++i)
    {
        Entity entity1 = (Entity)list.get(i);

        if (entity1.canBeCollidedWith())
        {
            if (entity1 == this.field_184539_c)
            {
                flag = true;
            }
            // Replaced this
            //else if (this.ticksExisted < 2 && this.field_184539_c == null)
            else if (this.thrower != null && this.ticksExisted < 2 && this.field_184539_c == null)
            {
                this.field_184539_c = entity1;
                flag = true;
            }
            else
            {
                //...
            }
        }
    }

    //...
}
Jens Bergensten

Fixed as suggested by Marcono1234

Bourgeois Bastien

Jens Bergensten

Unconfirmed

Minecraft 15w50a, Minecraft 15w51a, Minecraft 15w51b, Minecraft 1.9

Minecraft 16w32a

Retrieved