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()));
}
}
}
}
}
Aggregations