From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic 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 33d7a5da8764c5f6b8e911faecb6b4282443a60b..857ef2377d2e6fd84d70e301860692e670983f0c 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -648,6 +648,21 @@ public class PaperWorldConfig { log("Hopper Move Item Events: " + (disableHopperMoveEvents ? "disabled" : "enabled")); } + 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 027898e97667081840562547653d4adaeae01dda..24c629d5f26bc5aadebcf39a63930b3448525242 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -1133,7 +1133,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 6e3bd5146c687922e7b4680d59a1ae2d1480ad40..bb329e9c1a2295e6433d3728692a1e716c89dcc0 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 @@ -602,7 +602,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 e5679823786f2579f93a93a5ae08ab7ae42b390c..a8162116eb888106e6f48ee836d0cc5d33b72399 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 033d6389e4b7d986fc63abd67e325b68a6132824..f9bc07be70fae9aced51a69bccb5eda309187a47 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 } }