Search in sources :

Example 1 with EntityGhastling

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);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EntityGoblin(com.lying.variousoddities.entity.hostile.EntityGoblin) EntityGhastling(com.lying.variousoddities.entity.passive.EntityGhastling) DamageSource(net.minecraft.util.DamageSource) VODamageSource(com.lying.variousoddities.init.VODamageSource) EntityDamageSource(net.minecraft.util.EntityDamageSource) Random(java.util.Random) ServerWorld(net.minecraft.world.server.ServerWorld) World(net.minecraft.world.World) EntityDamageSource(net.minecraft.util.EntityDamageSource) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) FireballEntity(net.minecraft.entity.projectile.FireballEntity) AbstractGoblinWolf(com.lying.variousoddities.entity.AbstractGoblinWolf) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

AbstractGoblinWolf (com.lying.variousoddities.entity.AbstractGoblinWolf)1 EntityGoblin (com.lying.variousoddities.entity.hostile.EntityGoblin)1 EntityGhastling (com.lying.variousoddities.entity.passive.EntityGhastling)1 VODamageSource (com.lying.variousoddities.init.VODamageSource)1 Random (java.util.Random)1 LivingEntity (net.minecraft.entity.LivingEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 FireballEntity (net.minecraft.entity.projectile.FireballEntity)1 DamageSource (net.minecraft.util.DamageSource)1 EntityDamageSource (net.minecraft.util.EntityDamageSource)1 World (net.minecraft.world.World)1 ServerWorld (net.minecraft.world.server.ServerWorld)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1