use of com.bewitchment.api.capability.transformations.IBloodReserve 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.api.capability.transformations.IBloodReserve in project Bewitchment by Um-Mitternacht.
the class EntityInternalBloodChanged method handleMessage.
@SideOnly(Side.CLIENT)
@Override
public IMessage handleMessage(MessageContext context) {
Minecraft.getMinecraft().addScheduledTask(() -> {
if (Minecraft.getMinecraft().world != null) {
EntityLivingBase ent = (EntityLivingBase) Minecraft.getMinecraft().world.getEntityByID(entity_id);
if (ent != null) {
IBloodReserve br = ent.getCapability(CapabilityBloodReserve.CAPABILITY, null);
br.setBlood(amount);
br.setMaxBlood(max);
br.setDrinker(id_drainer);
}
}
});
return null;
}
use of com.bewitchment.api.capability.transformations.IBloodReserve in project Bewitchment by Um-Mitternacht.
the class BloodViewerHUD method renderOverlay.
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR && ExtraBarButtonsHUD.INSTANCE.actionScroller[0] == ModAbilities.DRAIN_BLOOD && ExtraBarButtonsHUD.INSTANCE.isInExtraBar && Minecraft.getMinecraft().pointedEntity instanceof EntityLivingBase) {
IBloodReserve ibr = Minecraft.getMinecraft().pointedEntity.getCapability(CapabilityBloodReserve.CAPABILITY, null);
float filled = ibr.getPercentFilled();
if (ibr.getMaxBlood() > 0) {
GlStateManager.pushMatrix();
GlStateManager.color(filled, filled, filled);
GlStateManager.enableAlpha();
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
mc.getTextureManager().bindTexture(TEXTURE);
renderTextureAtIndex((sr.getScaledWidth() / 2) - 5d, (sr.getScaledHeight() / 2) - 30d);
GlStateManager.popMatrix();
}
}
}
use of com.bewitchment.api.capability.transformations.IBloodReserve in project Bewitchment by Um-Mitternacht.
the class PotionBloodDrained method performEffect.
@Override
public void performEffect(EntityLivingBase entity, int amplifier) {
IBloodReserve br = entity.getCapability(CapabilityBloodReserve.CAPABILITY, null);
float amount = br.getPercentFilled();
if (amount > 0 && amount < TRESHOLD) {
if (br.getDrinkerUUID() != null)
entity.attackEntityFrom(new DamageSourceDrain(entity.world.getPlayerEntityByUUID(br.getDrinkerUUID())), 0.5f);
if (br.getDrinkerUUID() != null)
entity.setRevengeTarget(entity.world.getPlayerEntityByUUID(br.getDrinkerUUID()));
entity.addPotionEffect(new PotionEffect(this, 200, amplifier));
} else {
entity.removePotionEffect(this);
br.setDrinker(null);
}
}
use of com.bewitchment.api.capability.transformations.IBloodReserve 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));
}
Aggregations