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