The Bug:
Throwing projectiles at minecarts, boats, item frames, or paintings in creative mode will delete them.
Steps to Reproduce:
Switch into creative mode and obtain any throwable projectile, for example, some snowballs.
Summon either a minecart, boat, item frame, or painting.
Throw the projectile at the entity you just summoned.
Take note as to whether or not throwing projectiles at minecarts, boats, item frames, or paintings in creative mode will delete them.
Observed Behavior:
Throwing projectiles at minecarts, boats, item frames, or paintings in creative mode will delete them.
Expected Behavior:
Throwing projectiles at minecarts, boats, item frames, or paintings in creative mode would not delete them.
Code Analysis:
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 11
relates to 1
Attachments
Comments 31
Confirmed for
1.9
The bug is that normally projectiles like snowballs, eggs and enderpearls deal 0 damage, however when you throw them in Creative mode they destroy boats and minecarts instantaneously.
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 methods net.minecraft.entity.item.EntityMinecart.attackEntityFrom(DamageSource, float)
and net.minecraft.entity.item.EntityBoat.attackEntityFrom(DamageSource, float)
only test if the player damaging the entity is in creative mode however they should make sure that the damage was dealt directly.
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (!this.worldObj.isRemote && !this.isDead)
{
if (this.isEntityInvulnerable(source))
{
return false;
}
else
{
this.setRollingDirection(-this.getRollingDirection());
this.setRollingAmplitude(10);
this.setBeenAttacked();
this.setDamage(this.getDamage() + amount * 10.0F);
// Replaced this
//boolean flag = source.getEntity() instanceof EntityPlayer && ((EntityPlayer)source.getEntity()).capabilities.isCreativeMode;
boolean flag = source.getDamageType().equals("player") && source.isCreativePlayer();
if (flag || this.getDamage() > 40.0F)
{
this.removePassengers();
if (flag && !this.hasCustomName())
{
this.setDead();
}
else
{
this.killMinecart(source);
}
}
return true;
}
}
else
{
return true;
}
}
Relates to MC-78689
Working as intended.
All entities drop nothing when destroyed by snowballs in creative.