--- 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;
@@ -26,8 +27,13 @@
 import net.minecraft.world.level.block.state.BlockState;
 import net.minecraft.world.phys.AABB;
 import net.minecraft.world.phys.Vec3;
+// CraftBukkit start
+import org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock;
+import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory;
+// CraftBukkit end
 
 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;
@@ -82,15 +88,16 @@
 
     public static void clientTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) {
         ++blockEntity.tickCount;
-        long l = world.getGameTime();
+        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;
         }
@@ -99,31 +106,34 @@
 
     public static void serverTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) {
         ++blockEntity.tickCount;
-        long l = world.getGameTime();
+        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((Player)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((Player)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((Player)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);
             }
         }
 
@@ -136,30 +146,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);
                             }
                         }
                     }
@@ -175,13 +195,18 @@
         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.0D, (double)world.getHeight(), 0.0D);
-        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));
+        int i1 = pos.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 (pos.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
                 }
             }
 
@@ -189,30 +214,37 @@
     }
 
     private static void updateDestroyTarget(Level world, BlockPos pos, BlockState state, List<BlockPos> activatingBlocks, ConduitBlockEntity blockEntity) {
-        LivingEntity livingEntity = blockEntity.destroyTarget;
+        LivingEntity entityliving = blockEntity.destroyTarget;
         int i = activatingBlocks.size();
+
         if (i < 42) {
             blockEntity.destroyTarget = null;
         } else if (blockEntity.destroyTarget == null && blockEntity.destroyTargetUUID != null) {
-            blockEntity.destroyTarget = findDestroyTarget(world, pos, blockEntity.destroyTargetUUID);
+            blockEntity.destroyTarget = ConduitBlockEntity.findDestroyTarget(world, pos, blockEntity.destroyTargetUUID);
             blockEntity.destroyTargetUUID = null;
         } else if (blockEntity.destroyTarget == null) {
-            List<LivingEntity> list = world.getEntitiesOfClass(LivingEntity.class, getDestroyRangeAABB(pos), (entity) -> {
-                return entity instanceof Enemy && entity.isInWaterOrRain();
+            List<LivingEntity> list1 = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos), (entityliving1) -> {
+                return entityliving1 instanceof Enemy && entityliving1.isInWaterOrRain();
             });
-            if (!list.isEmpty()) {
-                blockEntity.destroyTarget = list.get(world.random.nextInt(list.size()));
+
+            if (!list1.isEmpty()) {
+                blockEntity.destroyTarget = (LivingEntity) list1.get(world.random.nextInt(list1.size()));
             }
         } else if (!blockEntity.destroyTarget.isAlive() || !pos.closerThan(blockEntity.destroyTarget.blockPosition(), 8.0D)) {
             blockEntity.destroyTarget = null;
         }
 
         if (blockEntity.destroyTarget != null) {
-            world.playSound((Player)null, blockEntity.destroyTarget.getX(), blockEntity.destroyTarget.getY(), blockEntity.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F);
-            blockEntity.destroyTarget.hurt(DamageSource.MAGIC, 4.0F);
+            // CraftBukkit start
+            CraftEventFactory.blockDamage = CraftBlock.at(world, pos);
+            if (blockEntity.destroyTarget.hurt(DamageSource.MAGIC, 4.0F)) {
+                world.playSound((Player) null, blockEntity.destroyTarget.getX(), blockEntity.destroyTarget.getY(), blockEntity.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F);
+            }
+            CraftEventFactory.blockDamage = null;
+            // CraftBukkit end
         }
 
-        if (livingEntity != blockEntity.destroyTarget) {
+        if (entityliving != blockEntity.destroyTarget) {
             world.sendBlockUpdated(pos, state, state, 2);
         }
 
@@ -222,7 +254,7 @@
         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;
             }
@@ -234,40 +266,52 @@
         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.0D);
+
+        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) -> {
-            return entity.getUUID().equals(uuid);
+        List<LivingEntity> list = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos), (entityliving) -> {
+            return entityliving.getUUID().equals(uuid);
         });
-        return list.size() == 1 ? list.get(0) : null;
+
+        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) * (double)0.3F;
-        Vec3 vec3 = new Vec3((double)pos.getX() + 0.5D, (double)pos.getY() + 1.5D + d, (double)pos.getZ() + 0.5D);
+        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);
         }
 
     }
