aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0692-Add-config-for-mobs-immune-to-default-effects.patch
blob: 4ce15709925bed5b1d00824b40c285b18b645995 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 2 Dec 2020 21:03:02 -0800
Subject: [PATCH] Add config for mobs immune to default effects


diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 3a83320bae86ba1acb189b9b2cf934ad0393c353..be7b7f9345a42007d6ccea6a31c93a4c874647b6 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -683,6 +683,21 @@ public class PaperWorldConfig {
         log("Hopper Ignore Occluding Blocks: " + (hoppersIgnoreOccludingBlocks ? "enabled" : "disabled"));
     }
 
+    public boolean undeadImmuneToCertainEffects = true;
+    public boolean spidersImmuneToPoisonEffect = true;
+    public boolean witherImmuneToWitherEffect = true;
+    public boolean witherSkeletonImmuneToWitherEffect = true;
+    private void mobEffectChanges() {
+        undeadImmuneToCertainEffects = getBoolean("mob-effects.undead-immune-to-certain-effects", undeadImmuneToCertainEffects);
+        log("Undead immune to harmful effects: " + undeadImmuneToCertainEffects);
+        spidersImmuneToPoisonEffect = getBoolean("mob-effects.spiders-immune-to-poison-effect", spidersImmuneToPoisonEffect);
+        log("Spiders immune to poison effect: " + spidersImmuneToPoisonEffect);
+        witherImmuneToWitherEffect = getBoolean("mob-effects.immune-to-wither-effect.wither", witherImmuneToWitherEffect);
+        log("Wither immune to wither effect: " + witherImmuneToWitherEffect);
+        witherSkeletonImmuneToWitherEffect = getBoolean("mob-effects.immune-to-wither-effect.wither-skeleton", witherSkeletonImmuneToWitherEffect);
+        log("Wither skeleton immune to wither effect: " + witherSkeletonImmuneToWitherEffect);
+    }
+
     public boolean nerfNetherPortalPigmen = false;
     private void nerfNetherPortalPigmen() {
         nerfNetherPortalPigmen = getBoolean("game-mechanics.nerf-pigmen-from-nether-portals", nerfNetherPortalPigmen);
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 1879271ef55e07cd93ebab2d01bfeb7e7b247883..2b0ba27fbded68270421f31037f71bb81f98d139 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1128,7 +1128,7 @@ public abstract class LivingEntity extends Entity {
         if (this.getMobType() == MobType.UNDEAD) {
             MobEffect mobeffectlist = effect.getEffect();
 
-            if (mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) {
+            if ((mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) && this.level.paperConfig.undeadImmuneToCertainEffects) { // Paper
                 return false;
             }
         }
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
index 3657b7021d8b505653fadbdfbd515c112cd11177..ede0ced64d74d71547d1b8bb6853c5aacc1b486a 100644
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -613,7 +613,7 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
 
     @Override
     public boolean canBeAffected(MobEffectInstance effect) {
-        return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
+        return effect.getEffect() == MobEffects.WITHER && this.level.paperConfig.witherImmuneToWitherEffect ? false : super.canBeAffected(effect); // Paper
     }
 
     private class WitherDoNothingGoal extends Goal {
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
index a3cb44914ef7d8636e743baa361a1a09ceeb2207..05b6c07c0705c7d8741c77baa87982e8e278dc97 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java
@@ -133,7 +133,7 @@ public class Spider extends Monster {
 
     @Override
     public boolean canBeAffected(MobEffectInstance effect) {
-        return effect.getEffect() == MobEffects.POISON ? false : super.canBeAffected(effect);
+        return effect.getEffect() == MobEffects.POISON && this.level.paperConfig.spidersImmuneToPoisonEffect ? false : super.canBeAffected(effect); // Paper
     }
 
     public boolean isClimbing() {
diff --git a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
index c727bbf7de71213fba410625c4a7ad90315b608a..6acc46c3a6fe7648d2cc4d0aaef063633c74c20d 100644
--- a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
@@ -122,6 +122,6 @@ public class WitherSkeleton extends AbstractSkeleton {
 
     @Override
     public boolean canBeAffected(MobEffectInstance effect) {
-        return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
+        return effect.getEffect() == MobEffects.WITHER && this.level.paperConfig.witherSkeletonImmuneToWitherEffect ? false : super.canBeAffected(effect); // Paper
     }
 }