From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Encode42 Date: Tue, 11 May 2021 21:00:53 -0400 Subject: [PATCH] Configurable mob blindness Ported from https://github.com/raltsmc/mobblindness diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index d161596f42fc7f720436a3d08ad59fe1393433b0..4938c289ea20f9f922e48d9b9f25caadb8c0f5b9 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -1020,6 +1020,17 @@ public abstract class LivingEntity extends Entity implements Attackable { if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) { d0 *= 0.5D; } + + // Purpur start + if (entity instanceof LivingEntity entityliving) { + if (entityliving.hasEffect(MobEffects.BLINDNESS)) { + int amplifier = entityliving.getEffect(MobEffects.BLINDNESS).getAmplifier(); + for (int i = 0; i < amplifier; i++) { + d0 *= this.level.purpurConfig.mobsBlindnessMultiplier; + } + } + } + // Purpur end } return d0; diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index ce92ab1a31c000a66b8bf45651563f2e8c0c5a9b..8c4b7ad4af57e2547b0e01032e8b6a8341cdb2ba 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -134,6 +134,7 @@ public class PurpurWorldConfig { public boolean persistentDroppableEntityDisplayNames = false; public boolean projectilesBypassMobGriefing = false; public boolean tickFluids = true; + public double mobsBlindnessMultiplier = 1; public double tridentLoyaltyVoidReturnHeight = 0.0D; public double voidDamageHeight = -64.0D; public double voidDamageDealt = 4.0D; @@ -154,6 +155,7 @@ public class PurpurWorldConfig { persistentDroppableEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-droppable-entity-display-names", persistentDroppableEntityDisplayNames); projectilesBypassMobGriefing = getBoolean("gameplay-mechanics.projectiles-bypass-mob-griefing", projectilesBypassMobGriefing); tickFluids = getBoolean("gameplay-mechanics.tick-fluids", tickFluids); + mobsBlindnessMultiplier = getDouble("gameplay-mechanics.entity-blindness-multiplier", mobsBlindnessMultiplier); tridentLoyaltyVoidReturnHeight = getDouble("gameplay-mechanics.trident-loyalty-void-return-height", tridentLoyaltyVoidReturnHeight); voidDamageHeight = getDouble("gameplay-mechanics.void-damage-height", voidDamageHeight); voidDamageDealt = getDouble("gameplay-mechanics.void-damage-dealt", voidDamageDealt);