fix crash mobs

This commit is contained in:
Lemon 2018-07-06 22:06:34 +05:00 committed by GitHub
parent b43a9b6749
commit 12a0b6961b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,29 @@ public class MobBlocker extends FreedomService
{ {
} }
//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) @EventHandler(priority = EventPriority.NORMAL)
public void onCreatureSpawn(CreatureSpawnEvent event) public void onCreatureSpawn(CreatureSpawnEvent event)
{ {