use of com.bewitchment.common.core.net.messages.EntityInternalBloodChanged in project Bewitchment by Um-Mitternacht.
the class BloodEvents method onJoin.
@SubscribeEvent
public static void onJoin(EntityJoinWorldEvent evt) {
Entity e = evt.getEntity();
if (!e.world.isRemote && e instanceof EntityLivingBase) {
IBloodReserve br = e.getCapability(CapabilityBloodReserve.CAPABILITY, null);
if (br.getMaxBlood() == 0) {
int maxBlood = 100;
if (e instanceof EntityPlayer) {
maxBlood = 480;
} else if (e instanceof EntityVillager) {
maxBlood = 240;
} else if (e instanceof EntityCow || e instanceof EntityHorse || e instanceof EntityPolarBear) {
maxBlood = 150;
} else if (e instanceof EntityDonkey || e instanceof EntityLlama) {
maxBlood = 130;
} else if (e instanceof EntitySheep) {
maxBlood = 110;
} else if (e instanceof EntityWolf || e instanceof EntityOcelot) {
maxBlood = 80;
} else if (e instanceof EntityChicken || e instanceof EntityParrot) {
maxBlood = 50;
} else {
maxBlood = -1;
}
br.setMaxBlood(maxBlood);
br.setBlood(maxBlood);
EntityLivingBase ent = (EntityLivingBase) e;
NetworkHandler.HANDLER.sendToAllAround(new EntityInternalBloodChanged(ent), new TargetPoint(e.dimension, ent.posX, ent.posY, ent.posZ, 32));
} else {
EntityLivingBase ent = (EntityLivingBase) e;
NetworkHandler.HANDLER.sendToAllAround(new EntityInternalBloodChanged(ent), new TargetPoint(e.dimension, ent.posX, ent.posY, ent.posZ, 32));
}
}
}
use of com.bewitchment.common.core.net.messages.EntityInternalBloodChanged in project Bewitchment by Um-Mitternacht.
the class TransformationEvents method onPlayerJoin.
@SubscribeEvent
public void onPlayerJoin(PlayerLoggedInEvent evt) {
if (evt.player instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) evt.player;
NetworkHandler.HANDLER.sendTo(new PlayerTransformationChangedMessage(player), player);
NetworkHandler.HANDLER.sendTo(new PlayerVampireBloodChanged(player), player);
NetworkHandler.HANDLER.sendTo(new EntityInternalBloodChanged(player), player);
NetworkHandler.HANDLER.sendTo(new NightVisionStatus(player.getCapability(CapabilityTransformationData.CAPABILITY, null).isNightVisionActive()), player);
}
}
use of com.bewitchment.common.core.net.messages.EntityInternalBloodChanged in project Bewitchment by Um-Mitternacht.
the class ApiInstance method setTypeAndLevel.
@Override
public void setTypeAndLevel(EntityPlayer player, ITransformation type, int level, boolean isClient) {
ITransformationData data = player.getCapability(CapabilityTransformationData.CAPABILITY, null);
IBloodReserve ibr = player.getCapability(CapabilityBloodReserve.CAPABILITY, null);
data.setType(type);
data.setLevel(level);
data.setNightVision(data.isNightVisionActive() && (type == ModTransformations.WEREWOLF || type == ModTransformations.VAMPIRE));
if ((type == ModTransformations.SPECTRE || type == ModTransformations.VAMPIRE)) {
ibr.setMaxBlood(-1);
player.removePotionEffect(ModPotions.bloodDrained);
} else if (ibr.getMaxBlood() < 0) {
ibr.setMaxBlood(480);
ibr.setBlood(480);
}
if (isClient) {
HotbarAction.refreshActions(player, player.world);
} else {
NetworkHandler.HANDLER.sendTo(new PlayerTransformationChangedMessage(player), (EntityPlayerMP) player);
NetworkHandler.HANDLER.sendTo(new PlayerVampireBloodChanged(player), (EntityPlayerMP) player);
NetworkHandler.HANDLER.sendTo(new EntityInternalBloodChanged(player), (EntityPlayerMP) player);
NetworkHandler.HANDLER.sendTo(new NightVisionStatus(player.getCapability(CapabilityTransformationData.CAPABILITY, null).isNightVisionActive()), (EntityPlayerMP) player);
}
MinecraftForge.EVENT_BUS.post(new TransformationModifiedEvent(player, type, level));
}
use of com.bewitchment.common.core.net.messages.EntityInternalBloodChanged 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.common.core.net.messages.EntityInternalBloodChanged 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