Search in sources :

Example 1 with EntitySpirit

use of lumien.randomthings.entitys.EntitySpirit in project Random-Things by lumien231.

the class RTEventHandler method livingDeath.

@SubscribeEvent
public void livingDeath(LivingDeathEvent event) {
    if (!event.getEntityLiving().world.isRemote) {
        if (event.getEntityLiving() instanceof EntityDragon) {
            RTWorldInformation rtInfo = RTWorldInformation.getInstance();
            if (rtInfo != null) {
                rtInfo.setEnderDragonDefeated(true);
            }
        }
        if (event.getSource().getTrueSource() != null && !(event.getSource().getTrueSource() instanceof FakePlayer) && event.getSource().getTrueSource() instanceof EntityPlayer && !(event.getEntity() instanceof EntitySpirit)) {
            double chance = Numbers.SPIRIT_CHANCE_NORMAL;
            RTWorldInformation rtInfo = RTWorldInformation.getInstance();
            if (rtInfo != null) {
                if (rtInfo.isDragonDefeated()) {
                    chance += Numbers.SPIRIT_CHANCE_END_INCREASE;
                }
            }
            if (event.getEntityLiving().world.canBlockSeeSky(event.getEntityLiving().getPosition()) && !event.getEntityLiving().world.isDaytime()) {
                chance += event.getEntityLiving().world.getCurrentMoonPhaseFactor() / 100f * Numbers.SPIRIT_CHANCE_MOON_MULT;
            }
            if (Math.random() < chance) {
                event.getEntityLiving().world.spawnEntity(new EntitySpirit(event.getEntityLiving().world, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ));
            }
        }
        if (event.getEntityLiving() instanceof EntityPlayer) {
            if (!(event.getEntityLiving() instanceof FakePlayer)) {
                EntityPlayer player = (EntityPlayer) event.getEntityLiving();
                if (!event.isCanceled()) {
                    player.world.spawnEntity(new EntitySoul(player.world, player.posX, player.posY, player.posZ, player.getGameProfile().getName()));
                }
            }
        }
    }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntitySpirit(lumien.randomthings.entitys.EntitySpirit) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntitySoul(lumien.randomthings.entitys.EntitySoul) FakePlayer(net.minecraftforge.common.util.FakePlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntitySoul (lumien.randomthings.entitys.EntitySoul)1 EntitySpirit (lumien.randomthings.entitys.EntitySpirit)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1