use of com.lying.variousoddities.entity.passive.EntityGhastling in project VariousOddities by Lyinginbedmon.
the class VOBusServer method onDeathNearGoblinEvent.
@SubscribeEvent
public static void onDeathNearGoblinEvent(LivingDeathEvent event) {
LivingEntity victim = event.getEntityLiving();
DamageSource cause = event.getSource();
World world = victim.getEntityWorld();
// Reduce refractory period of nearby goblins when a. goblin is slain or b. goblin slays any mob (esp. players)
if (victim instanceof EntityGoblin)
reduceRefractory(victim, 1000);
else if (cause instanceof EntityDamageSource && ((EntityDamageSource) cause).getTrueSource() instanceof EntityGoblin)
reduceRefractory(victim, victim instanceof PlayerEntity ? 4000 : 500);
// Occasionally spawn ghastlings when a ghast dies to a reflected fireball
if (victim.getType() == EntityType.GHAST)
if (cause.getImmediateSource() instanceof FireballEntity && cause.getTrueSource() instanceof PlayerEntity) {
Random rand = victim.getRNG();
if (rand.nextInt(15) == 0)
for (int i = 0; i < rand.nextInt(3); i++) {
EntityGhastling ghastling = VOEntities.GHASTLING.create(world);
ghastling.setLocationAndAngles(victim.getPosX(), victim.getPosY(), victim.getPosZ(), rand.nextFloat() * 360F, 0F);
world.addEntity(ghastling);
}
}
// Heal worgs and wargs when they kill something
if (cause instanceof EntityDamageSource && ((EntityDamageSource) cause).getTrueSource() instanceof AbstractGoblinWolf)
((AbstractGoblinWolf) cause.getTrueSource()).heal(2F + victim.getRNG().nextFloat() * 3F);
}
Aggregations