mojira.dev
MC-125773

Channeling enchantment doesn't work when mob is in water or lava

The bug

The channeling enchantment doesn't work on a mob whilst it is standing in water or lava.

How to reproduce

  1. Summon an entity in a block of water

  2. Run the command /weather thunder

  3. Obtain a trident with the Channeling enchantment

  4. Strike the entity with the trident

Observed behavior

No lightning strikes the entity and the Channeling enchantment does not affect the entity.

Expected behavior

The Channeling enchantment would be effective even when the entity is in water.

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 23

Still an issue in 1.13pre2

Confirmed for 1.15.1 and 1.15.2pre1

Lightning summoned doesn't go through water unless you are standing in it, perhaps lightning from channeling is supposed to act like it comes from the sky and hits something and not instantly spawned were you point it?

Can confirm in 20w49a.

Can confirm in 20w51a.

13 more comments

Can confirm in 1.18.2 and 22w13a.

Code analysis

Based on yarn mappings in 1.18.2

if (this.world instanceof ServerWorld && this.world.isThundering() && this.hasChanneling()) {
   BlockPos blockPos = entity.getBlockPos();
   if (this.world.isSkyVisible(blockPos)) {
      LightningEntity lightningEntity = EntityType.LIGHTNING_BOLT.create(this.world);
      lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(blockPos));
      lightningEntity.setChanneler(entity2 instanceof ServerPlayerEntity ? (ServerPlayerEntity)entity2 : null);
      this.world.spawnEntity(lightningEntity);
      soundEvent = SoundEvents.ITEM_TRIDENT_THUNDER;
      g = 5.0F;
   }
}

I'm guessing this is the this.world.isSkyVisible(blockPos) which checks if the block's light level is the maximum, which it isn't in water.

Can confirm in 1.19.

Can confirm in 1.19.2.

Can confirm in 23w03a.

archerking1679

(Unassigned)

Confirmed

Platform

Low

Entities

channeling, trident

Minecraft 18w07c, Minecraft 1.13-pre6, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w12b, ..., 1.19.2, 1.19.3, 23w03a, 1.20.1, 1.21.4

Retrieved