Search in sources :

Example 6 with IBloodReserve

use of com.bewitchment.api.capability.transformations.IBloodReserve in project Bewitchment by Um-Mitternacht.

the class BloodEvents method fillBloodOverTime.

@SubscribeEvent
public static void fillBloodOverTime(LivingUpdateEvent evt) {
    EntityLivingBase ent = evt.getEntityLiving();
    if (!ent.world.isRemote) {
        boolean ignore = false;
        IBloodReserve br = ent.getCapability(CapabilityBloodReserve.CAPABILITY, null);
        if (br.getMaxBlood() > br.getBlood() && ent.ticksExisted % 80 == 0) {
            int baseIncrease = getBloodRegen(br);
            if (ent instanceof EntityPlayer) {
                ITransformationData data = ent.getCapability(CapabilityTransformationData.CAPABILITY, null);
                if (data.getType() != ModTransformations.VAMPIRE) {
                    ent.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 60, 1));
                }
                if (data.getType() == ModTransformations.VAMPIRE || data.getType() == ModTransformations.SPECTRE)
                    ignore = true;
                br.setBlood(br.getBlood() + baseIncrease);
            } else if (ent instanceof EntityVillager) {
                // TODO check for villagers nearby. Regen rate should be nerfed when many are in the same place
                br.setBlood(br.getBlood() + baseIncrease);
            } else {
                br.setBlood(br.getBlood() + baseIncrease);
            }
            float stored = br.getPercentFilled();
            if (!ignore && stored < PotionBloodDrained.TRESHOLD) {
                ent.addPotionEffect(new PotionEffect(ModPotions.bloodDrained, 200, 0));
            }
            NetworkHandler.HANDLER.sendToAllAround(new EntityInternalBloodChanged(ent), new TargetPoint(ent.dimension, ent.posX, ent.posY, ent.posZ, 32));
        }
    }
}
Also used : IBloodReserve(com.bewitchment.api.capability.transformations.IBloodReserve) ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityInternalBloodChanged(com.bewitchment.common.core.net.messages.EntityInternalBloodChanged) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with IBloodReserve

use of com.bewitchment.api.capability.transformations.IBloodReserve in project Bewitchment by Um-Mitternacht.

the class TransformationHelper method drainBloodFromEntity.

public static void drainBloodFromEntity(EntityPlayer player, EntityLivingBase entity) {
    IBloodReserve br = entity.getCapability(CapabilityBloodReserve.CAPABILITY, null);
    ITransformationData data = player.getCapability(CapabilityTransformationData.CAPABILITY, null);
    if (br.getBlood() > 0 && br.getMaxBlood() > 0) {
        int transferred = (int) Math.min(br.getBlood(), br.getBlood() * 0.05 * data.getLevel());
        if (transferred > 0 && (BewitchmentAPI.getAPI().addVampireBlood(player, transferred) || player.isSneaking())) {
            br.setBlood(br.getBlood() - transferred);
            NetworkHandler.HANDLER.sendToAllAround(new EntityInternalBloodChanged(entity), new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 32));
        }
    }
}
Also used : IBloodReserve(com.bewitchment.api.capability.transformations.IBloodReserve) ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) EntityInternalBloodChanged(com.bewitchment.common.core.net.messages.EntityInternalBloodChanged) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)

Aggregations

IBloodReserve (com.bewitchment.api.capability.transformations.IBloodReserve)7 EntityInternalBloodChanged (com.bewitchment.common.core.net.messages.EntityInternalBloodChanged)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 ITransformationData (com.bewitchment.common.core.capability.transformation.ITransformationData)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 PotionEffect (net.minecraft.potion.PotionEffect)2 TransformationModifiedEvent (com.bewitchment.api.event.TransformationModifiedEvent)1 NightVisionStatus (com.bewitchment.common.core.net.messages.NightVisionStatus)1 PlayerTransformationChangedMessage (com.bewitchment.common.core.net.messages.PlayerTransformationChangedMessage)1 PlayerVampireBloodChanged (com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged)1 Minecraft (net.minecraft.client.Minecraft)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 Entity (net.minecraft.entity.Entity)1 EntityPolarBear (net.minecraft.entity.monster.EntityPolarBear)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1