Skip to content

Commit

Permalink
Fixed hostiles from getting slowness
Browse files Browse the repository at this point in the history
  • Loading branch information
Wurmatron committed Jan 11, 2017
1 parent c1118ef commit b23d272
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/main/java/wurmatron/viral/common/event/ViralEventHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wurmatron.viral.common.event;

import net.minecraft.entity.*;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
Expand Down Expand Up @@ -42,31 +43,28 @@ else if (rand.nextInt(getChancePercentage()) == 0)
public void onLivingUpdate(LivingEvent.LivingUpdateEvent e) {
IViral status = e.getEntityLiving().getCapability(ViralProvider.VIRAL, null);
if (status.status() == 1) {
if (Settings.particles > 0) {
if (Settings.particles > 0)
if (Settings.particles == 1 && counter == 10) {
e.getEntityLiving().worldObj.spawnParticle(EnumParticleTypes.SPELL_MOB, e.getEntityLiving().posX, e.getEntityLiving().posY + e.getEntityLiving().height / 2, e.getEntityLiving().posZ, new Random().nextDouble(), new Random().nextDouble() + 1, new Random().nextDouble());
counter = 0;
} else if (Settings.particles == 2)
e.getEntityLiving().worldObj.spawnParticle(EnumParticleTypes.SPELL_MOB, e.getEntityLiving().posX, e.getEntityLiving().posY + e.getEntityLiving().height / 2, e.getEntityLiving().posZ, new Random().nextDouble(), new Random().nextDouble() + 1, new Random().nextDouble());
else if (Settings.particles != 0 && counter >= 0)
counter++;
}
if (!e.getEntityLiving().worldObj.isRemote && e.getEntityLiving().worldObj.getWorldTime() % Settings.time == 0)
spreadViral(e.getEntityLiving());
if (!(e.getEntityLiving() instanceof IAnimals)) {
if (!(e.getEntityLiving() instanceof EntityAnimal)) {
e.getEntityLiving().getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(e.getEntityLiving().getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue() * 2);
e.getEntityLiving().addPotionEffect(new PotionEffect(Potion.getPotionById(5), 100));
e.getEntityLiving().addPotionEffect(new PotionEffect(Potion.getPotionById(11), 100));
e.getEntityLiving().addPotionEffect(new PotionEffect(Potion.getPotionById(1), 100, 2));
} else if (e.getEntityLiving() instanceof IAnimals) {
if (Settings.infectPassive) {
e.getEntityLiving().addPotionEffect(new PotionEffect(Potion.getPotionById(2), 100, 4));
if (Settings.hurtPassive && e.getEntityLiving().worldObj.getWorldTime() % 1000 == 0)
if (passiveDamage > 0)
e.getEntityLiving().attackEntityFrom(DamageSource.magic, passiveDamage);
} else
status.set(0);
}
} else if (e.getEntityLiving() instanceof EntityAnimal && Settings.infectPassive) {
LogHandler.info("Animal: " + e.getEntityLiving().getClass().getName());
e.getEntityLiving().addPotionEffect(new PotionEffect(Potion.getPotionById(2), 100, 4));
if (Settings.hurtPassive && e.getEntityLiving().worldObj.getWorldTime() % 1000 == 0 && passiveDamage > 0)
e.getEntityLiving().attackEntityFrom(DamageSource.magic, passiveDamage);
} else
status.set(0);
}
}

Expand All @@ -78,13 +76,11 @@ private void spreadViral(EntityLivingBase entity) {
if (e instanceof IAnimals && !Settings.infectPassive)
return;
EntityLivingBase ent = (EntityLivingBase) e;
if (!ent.worldObj.isRemote) {
if (rand.nextInt(getChancePercentage()) == 0) {
IViral status = ent.getCapability(ViralProvider.VIRAL, null);
if (status.status() == 0) {
status.set(1);
LogHandler.debug("Infected " + ent.getDisplayName().getUnformattedComponentText() + " X: " + ent.posX + " , Y: " + ent.posY + " , Z: " + ent.posZ);
}
if (!ent.worldObj.isRemote && rand.nextInt(getChancePercentage()) == 0) {
IViral status = ent.getCapability(ViralProvider.VIRAL, null);
if (status.status() == 0) {
status.set(1);
LogHandler.debug("Infected " + ent.getDisplayName().getUnformattedComponentText() + " X: " + ent.posX + " , Y: " + ent.posY + " , Z: " + ent.posZ);
}
}
}
Expand Down

0 comments on commit b23d272

Please sign in to comment.