The bug
The channeling enchantment doesn't work on a mob whilst it is standing in water or lava.
How to reproduce
Summon an entity in a block of water
Run the command
/weather thunder
Obtain a trident with the Channeling enchantment
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
relates to 1
Attachments
Comments 23
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?
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.
Still an issue in 1.13pre2