--- 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;
 
@@ -53,13 +54,15 @@
     @Override
     protected void registerGoals() {
         this.goalSelector.addGoal(1, new FloatGoal(this));
-        this.goalSelector.addGoal(2, new AvoidEntityGoal<>(this, Armadillo.class, 6.0F, 1.0, 1.2, entity -> !((Armadillo)entity).isScared()));
+        this.goalSelector.addGoal(2, new AvoidEntityGoal<>(this, Armadillo.class, 6.0F, 1.0D, 1.2D, (entityliving) -> {
+            return !((Armadillo) entityliving).isScared();
+        }));
         this.goalSelector.addGoal(3, new LeapAtTargetGoal(this, 0.4F));
         this.goalSelector.addGoal(4, new Spider.SpiderAttackGoal(this));
-        this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 0.8));
+        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));
     }
@@ -72,19 +75,20 @@
     @Override
     protected void defineSynchedData(SynchedEntityData.Builder builder) {
         super.defineSynchedData(builder);
-        builder.define(DATA_FLAGS_ID, (byte)0);
+        builder.define(Spider.DATA_FLAGS_ID, (byte) 0);
     }
 
     @Override
     public void tick() {
         super.tick();
         if (!this.level().isClientSide) {
-            this.setClimbing(this.horizontalCollision);
+            this.setClimbing(this.horizontalCollision && (this.level().paperConfig().entities.behavior.allowSpiderWorldBorderClimbing || !(ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(this.level().getWorldBorder(), this.getBoundingBox().inflate(ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_EPSILON)) && this.level().getWorldBorder().isInsideCloseToBorder(this, this.getBoundingBox())))); // Paper - Add config option for spider worldborder climbing (Inflate by +EPSILON as collision will just barely place us outside border)
         }
+
     }
 
     public static AttributeSupplier.Builder createAttributes() {
-        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0).add(Attributes.MOVEMENT_SPEED, 0.3F);
+        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0D).add(Attributes.MOVEMENT_SPEED, 0.30000001192092896D);
     }
 
     @Override
@@ -117,67 +121,73 @@
         if (!state.is(Blocks.COBWEB)) {
             super.makeStuckInBlock(state, multiplier);
         }
+
     }
 
     @Override
     public boolean canBeAffected(MobEffectInstance effect) {
-        return !effect.is(MobEffects.POISON) && super.canBeAffected(effect);
+        return effect.is(MobEffects.POISON) && this.level().paperConfig().entities.mobEffects.spidersImmuneToPoisonEffect ? false : super.canBeAffected(effect); // Paper - Add config for mobs immune to default effects
     }
 
     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) {
-        entityData = super.finalizeSpawn(world, difficulty, spawnReason, entityData);
-        RandomSource randomSource = world.getRandom();
-        if (randomSource.nextInt(100) == 0) {
-            Skeleton skeleton = EntityType.SKELETON.create(this.level());
-            if (skeleton != null) {
-                skeleton.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
-                skeleton.finalizeSpawn(world, difficulty, spawnReason, null);
-                skeleton.startRiding(this);
+        Object object = super.finalizeSpawn(world, difficulty, spawnReason, entityData);
+        RandomSource randomsource = world.getRandom();
+
+        if (randomsource.nextInt(100) == 0) {
+            Skeleton entityskeleton = (Skeleton) EntityType.SKELETON.create(this.level());
+
+            if (entityskeleton != null) {
+                entityskeleton.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
+                entityskeleton.finalizeSpawn(world, difficulty, spawnReason, (SpawnGroupData) 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 spiderEffectsGroupData) {
-            Holder<MobEffect> holder = spiderEffectsGroupData.effect;
+        if (object instanceof Spider.SpiderEffectsGroupData entityspider_groupdataspider) {
+            Holder<MobEffect> holder = entityspider_groupdataspider.effect;
+
             if (holder != null) {
-                this.addEffect(new MobEffectInstance(holder, -1));
+                this.addEffect(new MobEffectInstance(holder, -1), null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN, world instanceof net.minecraft.server.level.ServerLevel); // CraftBukkit
             }
         }
 
-        return entityData;
+        return (SpawnGroupData) object;
     }
 
     @Override
     public Vec3 getVehicleAttachmentPoint(Entity vehicle) {
-        return vehicle.getBbWidth() <= this.getBbWidth() ? new Vec3(0.0, 0.3125 * (double)this.getScale(), 0.0) : super.getVehicleAttachmentPoint(vehicle);
+        return vehicle.getBbWidth() <= this.getBbWidth() ? new Vec3(0.0D, 0.3125D * (double) this.getScale(), 0.0D) : super.getVehicleAttachmentPoint(vehicle);
     }
 
-    static class SpiderAttackGoal extends MeleeAttackGoal {
+    private static class SpiderAttackGoal extends MeleeAttackGoal {
+
         public SpiderAttackGoal(Spider spider) {
-            super(spider, 1.0, true);
+            super(spider, 1.0D, true);
         }
 
         @Override
@@ -188,8 +198,9 @@
         @Override
         public boolean canContinueToUse() {
             float f = this.mob.getLightLevelDependentMagicValue();
+
             if (f >= 0.5F && this.mob.getRandom().nextInt(100) == 0) {
-                this.mob.setTarget(null);
+                this.mob.setTarget((LivingEntity) null);
                 return false;
             } else {
                 return super.canContinueToUse();
@@ -197,12 +208,30 @@
         }
     }
 
+    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 Holder<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) {
@@ -212,18 +241,7 @@
             } else if (i <= 4) {
                 this.effect = MobEffects.INVISIBILITY;
             }
-        }
-    }
 
-    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) && super.canUse();
         }
     }
 }
