From 12a0b6961ba19ff45930ada69113c90bc6f8fb6a Mon Sep 17 00:00:00 2001 From: Lemon Date: Fri, 6 Jul 2018 22:06:34 +0500 Subject: [PATCH] fix crash mobs --- .../totalfreedommod/blocking/MobBlocker.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java index 0c0a2a0c..bdaa7301 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java @@ -32,6 +32,29 @@ public class MobBlocker extends FreedomService protected void onStop() { } + + //fixes crash mobs, credit to Mafrans + @EventHandler(priority = EventPriority.NORMAL) + public void onEntitySpawn(EntitySpawnEvent e) + { + if (!(e instanceof LivingEntity)) + { + return; + } + + Entity entity = e.getEntity(); + if (entity instanceof Attributable) + { + if (((Attributable) entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue() > 255.0) + { + ((Attributable) entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(255.0); + } + if (((Attributable) entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() > 10.0) + { + ((Attributable) entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(10.0); + } + } + } @EventHandler(priority = EventPriority.NORMAL) public void onCreatureSpawn(CreatureSpawnEvent event)