--- a/net/minecraft/world/entity/monster/Spider.java
+++ b/net/minecraft/world/entity/monster/Spider.java
@@ -43,6 +43,7 @@
 import net.minecraft.world.phys.Vec3;
 
 public class Spider extends Monster {
+
     private static final EntityDataAccessor<Byte> DATA_FLAGS_ID = SynchedEntityData.defineId(Spider.class, EntityDataSerializers.BYTE);
     private static final float SPIDER_SPECIAL_EFFECT_CHANCE = 0.1F;
 
@@ -58,14 +59,14 @@
         this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 0.8D));
         this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F));
         this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
-        this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
+        this.targetSelector.addGoal(1, new HurtByTargetGoal(this, new Class[0]));
         this.targetSelector.addGoal(2, new Spider.SpiderTargetGoal<>(this, Player.class));
         this.targetSelector.addGoal(3, new Spider.SpiderTargetGoal<>(this, IronGolem.class));
     }
 
     @Override
     public double getPassengersRidingOffset() {
-        return (double)(this.getBbHeight() * 0.5F);
+        return (double) (this.getBbHeight() * 0.5F);
     }
 
     @Override
@@ -76,7 +77,7 @@
     @Override
     protected void defineSynchedData() {
         super.defineSynchedData();
-        this.entityData.define(DATA_FLAGS_ID, (byte)0);
+        this.entityData.define(Spider.DATA_FLAGS_ID, (byte) 0);
     }
 
     @Override
@@ -89,7 +90,7 @@
     }
 
     public static AttributeSupplier.Builder createAttributes() {
-        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0D).add(Attributes.MOVEMENT_SPEED, (double)0.3F);
+        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0D).add(Attributes.MOVEMENT_SPEED, 0.30000001192092896D);
     }
 
     @Override
@@ -132,51 +133,55 @@
 
     @Override
     public boolean canBeAffected(MobEffectInstance effect) {
-        return effect.getEffect() == MobEffects.POISON ? false : super.canBeAffected(effect);
+        return effect.getEffect() == MobEffects.POISON && this.level.paperConfig().entities.mobEffects.spidersImmuneToPoisonEffect ? false : super.canBeAffected(effect); // Paper
     }
 
     public boolean isClimbing() {
-        return (this.entityData.get(DATA_FLAGS_ID) & 1) != 0;
+        return ((Byte) this.entityData.get(Spider.DATA_FLAGS_ID) & 1) != 0;
     }
 
     public void setClimbing(boolean climbing) {
-        byte b = this.entityData.get(DATA_FLAGS_ID);
+        byte b0 = (Byte) this.entityData.get(Spider.DATA_FLAGS_ID);
+
         if (climbing) {
-            b = (byte)(b | 1);
+            b0 = (byte) (b0 | 1);
         } else {
-            b = (byte)(b & -2);
+            b0 &= -2;
         }
 
-        this.entityData.set(DATA_FLAGS_ID, b);
+        this.entityData.set(Spider.DATA_FLAGS_ID, b0);
     }
 
     @Nullable
     @Override
     public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable SpawnGroupData entityData, @Nullable CompoundTag entityNbt) {
-        entityData = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
-        RandomSource randomSource = world.getRandom();
-        if (randomSource.nextInt(100) == 0) {
-            Skeleton skeleton = EntityType.SKELETON.create(this.level);
-            skeleton.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
-            skeleton.finalizeSpawn(world, difficulty, spawnReason, (SpawnGroupData)null, (CompoundTag)null);
-            skeleton.startRiding(this);
+        Object object = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
+        RandomSource randomsource = world.getRandom();
+
+        if (randomsource.nextInt(100) == 0) {
+            Skeleton entityskeleton = (Skeleton) EntityType.SKELETON.create(this.level);
+
+            entityskeleton.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
+            entityskeleton.finalizeSpawn(world, difficulty, spawnReason, (SpawnGroupData) null, (CompoundTag) null);
+            entityskeleton.startRiding(this);
         }
 
-        if (entityData == null) {
-            entityData = new Spider.SpiderEffectsGroupData();
-            if (world.getDifficulty() == Difficulty.HARD && randomSource.nextFloat() < 0.1F * difficulty.getSpecialMultiplier()) {
-                ((Spider.SpiderEffectsGroupData)entityData).setRandomEffect(randomSource);
+        if (object == null) {
+            object = new Spider.SpiderEffectsGroupData();
+            if (world.getDifficulty() == Difficulty.HARD && randomsource.nextFloat() < 0.1F * difficulty.getSpecialMultiplier()) {
+                ((Spider.SpiderEffectsGroupData) object).setRandomEffect(randomsource);
             }
         }
 
-        if (entityData instanceof Spider.SpiderEffectsGroupData) {
-            MobEffect mobEffect = ((Spider.SpiderEffectsGroupData)entityData).effect;
-            if (mobEffect != null) {
-                this.addEffect(new MobEffectInstance(mobEffect, Integer.MAX_VALUE));
+        if (object instanceof Spider.SpiderEffectsGroupData) {
+            MobEffect mobeffectlist = ((Spider.SpiderEffectsGroupData) object).effect;
+
+            if (mobeffectlist != null) {
+                this.addEffect(new MobEffectInstance(mobeffectlist, Integer.MAX_VALUE), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit
             }
         }
 
-        return entityData;
+        return (SpawnGroupData) object;
     }
 
     @Override
@@ -184,7 +189,8 @@
         return 0.65F;
     }
 
-    static class SpiderAttackGoal extends MeleeAttackGoal {
+    private static class SpiderAttackGoal extends MeleeAttackGoal {
+
         public SpiderAttackGoal(Spider spider) {
             super(spider, 1.0D, true);
         }
@@ -197,8 +203,9 @@
         @Override
         public boolean canContinueToUse() {
             float f = this.mob.getLightLevelDependentMagicValue();
+
             if (f >= 0.5F && this.mob.getRandom().nextInt(100) == 0) {
-                this.mob.setTarget((LivingEntity)null);
+                this.mob.setTarget((LivingEntity) null);
                 return false;
             } else {
                 return super.canContinueToUse();
@@ -207,16 +214,34 @@
 
         @Override
         protected double getAttackReachSqr(LivingEntity entity) {
-            return (double)(4.0F + entity.getBbWidth());
+            return (double) (4.0F + entity.getBbWidth());
+        }
+    }
+
+    private static class SpiderTargetGoal<T extends LivingEntity> extends NearestAttackableTargetGoal<T> {
+
+        public SpiderTargetGoal(Spider spider, Class<T> targetEntityClass) {
+            super(spider, targetEntityClass, true);
+        }
+
+        @Override
+        public boolean canUse() {
+            float f = this.mob.getLightLevelDependentMagicValue();
+
+            return f >= 0.5F ? false : super.canUse();
         }
     }
 
     public static class SpiderEffectsGroupData implements SpawnGroupData {
+
         @Nullable
         public MobEffect effect;
 
+        public SpiderEffectsGroupData() {}
+
         public void setRandomEffect(RandomSource random) {
             int i = random.nextInt(5);
+
             if (i <= 1) {
                 this.effect = MobEffects.MOVEMENT_SPEED;
             } else if (i <= 2) {
@@ -229,16 +254,4 @@
 
         }
     }
-
-    static class SpiderTargetGoal<T extends LivingEntity> extends NearestAttackableTargetGoal<T> {
-        public SpiderTargetGoal(Spider spider, Class<T> targetEntityClass) {
-            super(spider, targetEntityClass, true);
-        }
-
-        @Override
-        public boolean canUse() {
-            float f = this.mob.getLightLevelDependentMagicValue();
-            return f >= 0.5F ? false : super.canUse();
-        }
-    }
 }
