--- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
@@ -1,6 +1,7 @@
 package net.minecraft.world.level.block.entity;
 
 import com.google.common.collect.Lists;
+import java.util.Iterator;
 import java.util.List;
 import java.util.UUID;
 import javax.annotation.Nullable;
@@ -28,6 +29,7 @@
 import net.minecraft.world.phys.Vec3;
 
 public class ConduitBlockEntity extends BlockEntity {
+
     private static final int BLOCK_REFRESH_RATE = 2;
     private static final int EFFECT_DURATION = 13;
     private static final float ROTATION_SPEED = -0.0375F;
@@ -58,6 +60,7 @@
         } else {
             this.destroyTargetUUID = null;
         }
+
     }
 
     @Override
@@ -66,6 +69,7 @@
         if (this.destroyTarget != null) {
             nbt.putUUID("Target", this.destroyTarget.getUUID());
         }
+
     }
 
     @Override
@@ -79,50 +83,56 @@
     }
 
     public static void clientTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) {
-        blockEntity.tickCount++;
-        long l = world.getGameTime();
+        ++blockEntity.tickCount;
+        long i = world.getGameTime();
         List<BlockPos> list = blockEntity.effectBlocks;
-        if (l % 40L == 0L) {
-            blockEntity.isActive = updateShape(world, pos, list);
-            updateHunting(blockEntity, list);
+
+        if (i % 40L == 0L) {
+            blockEntity.isActive = ConduitBlockEntity.updateShape(world, pos, list);
+            ConduitBlockEntity.updateHunting(blockEntity, list);
         }
 
-        updateClientTarget(world, pos, blockEntity);
-        animationTick(world, pos, list, blockEntity.destroyTarget, blockEntity.tickCount);
+        ConduitBlockEntity.updateClientTarget(world, pos, blockEntity);
+        ConduitBlockEntity.animationTick(world, pos, list, blockEntity.destroyTarget, blockEntity.tickCount);
         if (blockEntity.isActive()) {
-            blockEntity.activeRotation++;
+            ++blockEntity.activeRotation;
         }
+
     }
 
     public static void serverTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) {
-        blockEntity.tickCount++;
-        long l = world.getGameTime();
+        ++blockEntity.tickCount;
+        long i = world.getGameTime();
         List<BlockPos> list = blockEntity.effectBlocks;
-        if (l % 40L == 0L) {
-            boolean bl = updateShape(world, pos, list);
-            if (bl != blockEntity.isActive) {
-                SoundEvent soundEvent = bl ? SoundEvents.CONDUIT_ACTIVATE : SoundEvents.CONDUIT_DEACTIVATE;
-                world.playSound(null, pos, soundEvent, SoundSource.BLOCKS, 1.0F, 1.0F);
+
+        if (i % 40L == 0L) {
+            boolean flag = ConduitBlockEntity.updateShape(world, pos, list);
+
+            if (flag != blockEntity.isActive) {
+                SoundEvent soundeffect = flag ? SoundEvents.CONDUIT_ACTIVATE : SoundEvents.CONDUIT_DEACTIVATE;
+
+                world.playSound((Player) null, pos, soundeffect, SoundSource.BLOCKS, 1.0F, 1.0F);
             }
 
-            blockEntity.isActive = bl;
-            updateHunting(blockEntity, list);
-            if (bl) {
-                applyEffects(world, pos, list);
-                updateDestroyTarget(world, pos, state, list, blockEntity);
+            blockEntity.isActive = flag;
+            ConduitBlockEntity.updateHunting(blockEntity, list);
+            if (flag) {
+                ConduitBlockEntity.applyEffects(world, pos, list);
+                ConduitBlockEntity.updateDestroyTarget(world, pos, state, list, blockEntity);
             }
         }
 
         if (blockEntity.isActive()) {
-            if (l % 80L == 0L) {
-                world.playSound(null, pos, SoundEvents.CONDUIT_AMBIENT, SoundSource.BLOCKS, 1.0F, 1.0F);
+            if (i % 80L == 0L) {
+                world.playSound((Player) null, pos, SoundEvents.CONDUIT_AMBIENT, SoundSource.BLOCKS, 1.0F, 1.0F);
             }
 
-            if (l > blockEntity.nextAmbientSoundActivation) {
-                blockEntity.nextAmbientSoundActivation = l + 60L + (long)world.getRandom().nextInt(40);
-                world.playSound(null, pos, SoundEvents.CONDUIT_AMBIENT_SHORT, SoundSource.BLOCKS, 1.0F, 1.0F);
+            if (i > blockEntity.nextAmbientSoundActivation) {
+                blockEntity.nextAmbientSoundActivation = i + 60L + (long) world.getRandom().nextInt(40);
+                world.playSound((Player) null, pos, SoundEvents.CONDUIT_AMBIENT_SHORT, SoundSource.BLOCKS, 1.0F, 1.0F);
             }
         }
+
     }
 
     private static void updateHunting(ConduitBlockEntity blockEntity, List<BlockPos> activatingBlocks) {
@@ -132,30 +142,40 @@
     private static boolean updateShape(Level world, BlockPos pos, List<BlockPos> activatingBlocks) {
         activatingBlocks.clear();
 
-        for (int i = -1; i <= 1; i++) {
-            for (int j = -1; j <= 1; j++) {
-                for (int k = -1; k <= 1; k++) {
-                    BlockPos blockPos = pos.offset(i, j, k);
-                    if (!world.isWaterAt(blockPos)) {
+        int i;
+        int j;
+        int k;
+
+        for (i = -1; i <= 1; ++i) {
+            for (j = -1; j <= 1; ++j) {
+                for (k = -1; k <= 1; ++k) {
+                    BlockPos blockposition1 = pos.offset(i, j, k);
+
+                    if (!world.isWaterAt(blockposition1)) {
                         return false;
                     }
                 }
             }
         }
 
-        for (int l = -2; l <= 2; l++) {
-            for (int m = -2; m <= 2; m++) {
-                for (int n = -2; n <= 2; n++) {
-                    int o = Math.abs(l);
-                    int p = Math.abs(m);
-                    int q = Math.abs(n);
-                    if ((o > 1 || p > 1 || q > 1) && (l == 0 && (p == 2 || q == 2) || m == 0 && (o == 2 || q == 2) || n == 0 && (o == 2 || p == 2))) {
-                        BlockPos blockPos2 = pos.offset(l, m, n);
-                        BlockState blockState = world.getBlockState(blockPos2);
+        for (i = -2; i <= 2; ++i) {
+            for (j = -2; j <= 2; ++j) {
+                for (k = -2; k <= 2; ++k) {
+                    int l = Math.abs(i);
+                    int i1 = Math.abs(j);
+                    int j1 = Math.abs(k);
 
-                        for (Block block : VALID_BLOCKS) {
-                            if (blockState.is(block)) {
-                                activatingBlocks.add(blockPos2);
+                    if ((l > 1 || i1 > 1 || j1 > 1) && (i == 0 && (i1 == 2 || j1 == 2) || j == 0 && (l == 2 || j1 == 2) || k == 0 && (l == 2 || i1 == 2))) {
+                        BlockPos blockposition2 = pos.offset(i, j, k);
+                        BlockState iblockdata = world.getBlockState(blockposition2);
+                        Block[] ablock = ConduitBlockEntity.VALID_BLOCKS;
+                        int k1 = ablock.length;
+
+                        for (int l1 = 0; l1 < k1; ++l1) {
+                            Block block = ablock[l1];
+
+                            if (iblockdata.is(block)) {
+                                activatingBlocks.add(blockposition2);
                             }
                         }
                     }
@@ -167,110 +187,145 @@
     }
 
     private static void applyEffects(Level world, BlockPos pos, List<BlockPos> activatingBlocks) {
-        int i = activatingBlocks.size();
+        // CraftBukkit start
+        ConduitBlockEntity.applyEffects(world, pos, ConduitBlockEntity.getRange(activatingBlocks));
+    }
+
+    public static int getRange(List<BlockPos> list) {
+        // CraftBukkit end
+        int i = list.size();
         int j = i / 7 * 16;
-        int k = pos.getX();
-        int l = pos.getY();
-        int m = pos.getZ();
-        AABB aABB = new AABB((double)k, (double)l, (double)m, (double)(k + 1), (double)(l + 1), (double)(m + 1))
-            .inflate((double)j)
-            .expandTowards(0.0, (double)world.getHeight(), 0.0);
-        List<Player> list = world.getEntitiesOfClass(Player.class, aABB);
-        if (!list.isEmpty()) {
-            for (Player player : list) {
-                if (pos.closerThan(player.blockPosition(), (double)j) && player.isInWaterOrRain()) {
-                    player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true));
+        // CraftBukkit start
+        return j;
+    }
+
+    private static void applyEffects(Level world, BlockPos blockposition, int j) { // j = effect range in blocks
+        // CraftBukkit end
+        int k = blockposition.getX();
+        int l = blockposition.getY();
+        int i1 = blockposition.getZ();
+        AABB axisalignedbb = (new AABB((double) k, (double) l, (double) i1, (double) (k + 1), (double) (l + 1), (double) (i1 + 1))).inflate((double) j).expandTowards(0.0D, (double) world.getHeight(), 0.0D);
+        List<Player> list1 = world.getEntitiesOfClass(Player.class, axisalignedbb);
+
+        if (!list1.isEmpty()) {
+            Iterator iterator = list1.iterator();
+
+            while (iterator.hasNext()) {
+                Player entityhuman = (Player) iterator.next();
+
+                if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) {
+                    entityhuman.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit
                 }
             }
+
         }
     }
 
     private static void updateDestroyTarget(Level world, BlockPos pos, BlockState state, List<BlockPos> activatingBlocks, ConduitBlockEntity blockEntity) {
-        LivingEntity livingEntity = blockEntity.destroyTarget;
-        int i = activatingBlocks.size();
+        // CraftBukkit start - add "damageTarget" boolean
+        ConduitBlockEntity.updateDestroyTarget(world, pos, state, activatingBlocks, blockEntity, true);
+    }
+
+    public static void updateDestroyTarget(Level world, BlockPos blockposition, BlockState iblockdata, List<BlockPos> list, ConduitBlockEntity tileentityconduit, boolean damageTarget) {
+        // CraftBukkit end
+        LivingEntity entityliving = tileentityconduit.destroyTarget;
+        int i = list.size();
+
         if (i < 42) {
-            blockEntity.destroyTarget = null;
-        } else if (blockEntity.destroyTarget == null && blockEntity.destroyTargetUUID != null) {
-            blockEntity.destroyTarget = findDestroyTarget(world, pos, blockEntity.destroyTargetUUID);
-            blockEntity.destroyTargetUUID = null;
-        } else if (blockEntity.destroyTarget == null) {
-            List<LivingEntity> list = world.getEntitiesOfClass(
-                LivingEntity.class, getDestroyRangeAABB(pos), entity -> entity instanceof Enemy && entity.isInWaterOrRain()
-            );
-            if (!list.isEmpty()) {
-                blockEntity.destroyTarget = list.get(world.random.nextInt(list.size()));
+            tileentityconduit.destroyTarget = null;
+        } else if (tileentityconduit.destroyTarget == null && tileentityconduit.destroyTargetUUID != null) {
+            tileentityconduit.destroyTarget = ConduitBlockEntity.findDestroyTarget(world, blockposition, tileentityconduit.destroyTargetUUID);
+            tileentityconduit.destroyTargetUUID = null;
+        } else if (tileentityconduit.destroyTarget == null) {
+            List<LivingEntity> list1 = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(blockposition), (entityliving1) -> {
+                return entityliving1 instanceof Enemy && entityliving1.isInWaterOrRain();
+            });
+
+            if (!list1.isEmpty()) {
+                tileentityconduit.destroyTarget = (LivingEntity) list1.get(world.random.nextInt(list1.size()));
             }
-        } else if (!blockEntity.destroyTarget.isAlive() || !pos.closerThan(blockEntity.destroyTarget.blockPosition(), 8.0)) {
-            blockEntity.destroyTarget = null;
+        } else if (!tileentityconduit.destroyTarget.isAlive() || !blockposition.closerThan(tileentityconduit.destroyTarget.blockPosition(), 8.0D)) {
+            tileentityconduit.destroyTarget = null;
         }
 
-        if (blockEntity.destroyTarget != null) {
-            world.playSound(
-                null,
-                blockEntity.destroyTarget.getX(),
-                blockEntity.destroyTarget.getY(),
-                blockEntity.destroyTarget.getZ(),
-                SoundEvents.CONDUIT_ATTACK_TARGET,
-                SoundSource.BLOCKS,
-                1.0F,
-                1.0F
-            );
-            blockEntity.destroyTarget.hurt(world.damageSources().magic(), 4.0F);
+        // CraftBukkit start
+        if (damageTarget && tileentityconduit.destroyTarget != null) {
+            if (tileentityconduit.destroyTarget.hurt(world.damageSources().magic().directBlock(world, blockposition), 4.0F)) {
+                world.playSound(null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F);
+            }
+            // CraftBukkit end
         }
 
-        if (livingEntity != blockEntity.destroyTarget) {
-            world.sendBlockUpdated(pos, state, state, 2);
+        if (entityliving != tileentityconduit.destroyTarget) {
+            world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 2);
         }
+
     }
 
     private static void updateClientTarget(Level world, BlockPos pos, ConduitBlockEntity blockEntity) {
         if (blockEntity.destroyTargetUUID == null) {
             blockEntity.destroyTarget = null;
         } else if (blockEntity.destroyTarget == null || !blockEntity.destroyTarget.getUUID().equals(blockEntity.destroyTargetUUID)) {
-            blockEntity.destroyTarget = findDestroyTarget(world, pos, blockEntity.destroyTargetUUID);
+            blockEntity.destroyTarget = ConduitBlockEntity.findDestroyTarget(world, pos, blockEntity.destroyTargetUUID);
             if (blockEntity.destroyTarget == null) {
                 blockEntity.destroyTargetUUID = null;
             }
         }
+
     }
 
     public static AABB getDestroyRangeAABB(BlockPos pos) {
         int i = pos.getX();
         int j = pos.getY();
         int k = pos.getZ();
-        return new AABB((double)i, (double)j, (double)k, (double)(i + 1), (double)(j + 1), (double)(k + 1)).inflate(8.0);
+
+        return (new AABB((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1))).inflate(8.0D);
     }
 
     @Nullable
     private static LivingEntity findDestroyTarget(Level world, BlockPos pos, UUID uuid) {
-        List<LivingEntity> list = world.getEntitiesOfClass(LivingEntity.class, getDestroyRangeAABB(pos), entity -> entity.getUUID().equals(uuid));
-        return list.size() == 1 ? list.get(0) : null;
+        List<LivingEntity> list = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos), (entityliving) -> {
+            return entityliving.getUUID().equals(uuid);
+        });
+
+        return list.size() == 1 ? (LivingEntity) list.get(0) : null;
     }
 
     private static void animationTick(Level world, BlockPos pos, List<BlockPos> activatingBlocks, @Nullable Entity entity, int ticks) {
-        RandomSource randomSource = world.random;
-        double d = (double)(Mth.sin((float)(ticks + 35) * 0.1F) / 2.0F + 0.5F);
-        d = (d * d + d) * 0.3F;
-        Vec3 vec3 = new Vec3((double)pos.getX() + 0.5, (double)pos.getY() + 1.5 + d, (double)pos.getZ() + 0.5);
+        RandomSource randomsource = world.random;
+        double d0 = (double) (Mth.sin((float) (ticks + 35) * 0.1F) / 2.0F + 0.5F);
 
-        for (BlockPos blockPos : activatingBlocks) {
-            if (randomSource.nextInt(50) == 0) {
-                BlockPos blockPos2 = blockPos.subtract(pos);
-                float f = -0.5F + randomSource.nextFloat() + (float)blockPos2.getX();
-                float g = -2.0F + randomSource.nextFloat() + (float)blockPos2.getY();
-                float h = -0.5F + randomSource.nextFloat() + (float)blockPos2.getZ();
-                world.addParticle(ParticleTypes.NAUTILUS, vec3.x, vec3.y, vec3.z, (double)f, (double)g, (double)h);
+        d0 = (d0 * d0 + d0) * 0.30000001192092896D;
+        Vec3 vec3d = new Vec3((double) pos.getX() + 0.5D, (double) pos.getY() + 1.5D + d0, (double) pos.getZ() + 0.5D);
+        Iterator iterator = activatingBlocks.iterator();
+
+        float f;
+
+        while (iterator.hasNext()) {
+            BlockPos blockposition1 = (BlockPos) iterator.next();
+
+            if (randomsource.nextInt(50) == 0) {
+                BlockPos blockposition2 = blockposition1.subtract(pos);
+
+                f = -0.5F + randomsource.nextFloat() + (float) blockposition2.getX();
+                float f1 = -2.0F + randomsource.nextFloat() + (float) blockposition2.getY();
+                float f2 = -0.5F + randomsource.nextFloat() + (float) blockposition2.getZ();
+
+                world.addParticle(ParticleTypes.NAUTILUS, vec3d.x, vec3d.y, vec3d.z, (double) f, (double) f1, (double) f2);
             }
         }
 
         if (entity != null) {
-            Vec3 vec32 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
-            float i = (-0.5F + randomSource.nextFloat()) * (3.0F + entity.getBbWidth());
-            float j = -1.0F + randomSource.nextFloat() * entity.getBbHeight();
-            float k = (-0.5F + randomSource.nextFloat()) * (3.0F + entity.getBbWidth());
-            Vec3 vec33 = new Vec3((double)i, (double)j, (double)k);
-            world.addParticle(ParticleTypes.NAUTILUS, vec32.x, vec32.y, vec32.z, vec33.x, vec33.y, vec33.z);
+            Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
+            float f3 = (-0.5F + randomsource.nextFloat()) * (3.0F + entity.getBbWidth());
+            float f4 = -1.0F + randomsource.nextFloat() * entity.getBbHeight();
+
+            f = (-0.5F + randomsource.nextFloat()) * (3.0F + entity.getBbWidth());
+            Vec3 vec3d2 = new Vec3((double) f3, (double) f4, (double) f);
+
+            world.addParticle(ParticleTypes.NAUTILUS, vec3d1.x, vec3d1.y, vec3d1.z, vec3d2.x, vec3d2.y, vec3d2.z);
         }
+
     }
 
     public boolean isActive() {
