When the shulker bullet hits the entity does not play an explodes sound and particles.
[media]
Not the same as when they hit the block.
[media]
Also inconsistency with the fireball.
[media]Code analysis by @unknown can be found in this comment.
Linked issues
relates to 3
Attachments
Comments 6
Can confirm.
@unknown, the Bedrock version of the shulker bullet will play an explodes sound when hitting the entity.
I can confirm this in 1.18.1.
Here's a code analysis of this issue. The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.
Code Analysis:
net.minecraft.world.entity.projectile.ShulkerBullet.java
public class ShulkerBullet extends Projectile {
...
protected void onHitEntity(EntityHitResult $ehr) {
super.onHitEntity($ehr);
Entity entity = $ehr.getEntity();
Entity entity1 = this.getOwner();
LivingEntity livingentity = entity1 instanceof LivingEntity ? (LivingEntity)entity1 : null;
boolean flag = entity.hurt(DamageSource.indirectMobAttack(this, livingentity).setProjectile(), 4.0F);
if (flag) {
this.doEnchantDamageEffects(livingentity, entity);
if (entity instanceof LivingEntity) {
((LivingEntity)entity).addEffect(new MobEffectInstance(MobEffects.LEVITATION, 200), MoreObjects.firstNonNull(entity1, this));
}
}
}
...
If we look at the above class, we can see that no sound or particles are produced when a shulker bullet hits an entity, unlike hitting a block.
Potential Fix (tentative):
Simply adding some lines of code that will play a sound and produce some explosion particles when a shulker bullet hits an entity, should resolve this problem. The following lines of code could be used in order to fix this:
((ServerLevel)this.level).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(), this.getZ(), 2, 0.2D, 0.2D, 0.2D, 0.0D);
this.playSound(SoundEvents.SHULKER_BULLET_HIT, 1.0F, 1.0F);
The correct piece of code within its class should look something like the following:
net.minecraft.world.entity.projectile.ShulkerBullet.java
public class ShulkerBullet extends Projectile {
...
protected void onHitEntity(EntityHitResult $ehr) {
super.onHitEntity($ehr);
((ServerLevel)this.level).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(), this.getZ(), 2, 0.2D, 0.2D, 0.2D, 0.0D);
this.playSound(SoundEvents.SHULKER_BULLET_HIT, 1.0F, 1.0F);
Entity entity = $ehr.getEntity();
Entity entity1 = this.getOwner();
LivingEntity livingentity = entity1 instanceof LivingEntity ? (LivingEntity)entity1 : null;
boolean flag = entity.hurt(DamageSource.indirectMobAttack(this, livingentity).setProjectile(), 4.0F);
if (flag) {
this.doEnchantDamageEffects(livingentity, entity);
if (entity instanceof LivingEntity) {
((LivingEntity)entity).addEffect(new MobEffectInstance(MobEffects.LEVITATION, 200), MoreObjects.firstNonNull(entity1, this));
}
}
}
...
Can confirm in 1.18.2.
In 24w37a
I think works as intended becouse normally they don’t explode when hitting an entity, right? I think it normally explodes only when colliding with blocks