use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.
the class VampireAbilityHandler method sleepBed.
@SubscribeEvent
public void sleepBed(RightClickBlock evt) {
ITransformationData data = evt.getEntityPlayer().getCapability(CapabilityTransformationData.CAPABILITY, null);
if (data.getType() == ModTransformations.VAMPIRE && evt.getEntityPlayer().world.getBlockState(evt.getPos()).getBlock() == Blocks.BED) {
evt.setCancellationResult(EnumActionResult.FAIL);
evt.setCanceled(true);
evt.getEntityPlayer().sendStatusMessage(new TextComponentTranslation("vampire.bed_blocked"), true);
}
}
use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.
the class VampireAbilityHandler method getMultiplier.
// NO-SUBSCRIBE
private float getMultiplier(LivingHurtEvent evt) {
float mult = 1;
if (evt.getSource().getTrueSource() instanceof EntityPlayer) {
EntityPlayer source = (EntityPlayer) evt.getSource().getTrueSource();
ITransformationData data = source.getCapability(CapabilityTransformationData.CAPABILITY, null);
if (data.getType() == ModTransformations.HUNTER) {
mult += 0.8;
} else if (data.getType() != ModTransformations.NONE) {
// All transformations basically (except hunter)
mult += 0.1;
}
if (WOOD_WEAPON.apply(source.getHeldItemMainhand())) {
mult += 0.1;
} else if (SILVER_WEAPON.apply(source.getHeldItemMainhand())) {
mult += 0.3;
}
}
if (evt.getSource().isFireDamage() || evt.getSource().isExplosion() || evt.getSource().canHarmInCreative()) {
mult += 0.5;
if (evt.isCanceled()) {
// Attempts to prevent damage are bad
mult += 1;
}
}
return mult;
}
use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.
the class VampireAbilityHandler method incomingDamageModifier.
/**
* Modifies damage depending on the type. Fire and explosion make it 150%of the original,
* all the other types make it 10% of the original provided there's blood in the pool
*/
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void incomingDamageModifier(LivingHurtEvent evt) {
if (!evt.getEntity().world.isRemote && evt.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) evt.getEntityLiving();
ITransformationData data = player.getCapability(CapabilityTransformationData.CAPABILITY, null);
if (data.getType() == ModTransformations.VAMPIRE) {
if (evt.getSource() == SUN_DAMAGE) {
// No immunity for you
evt.setCanceled(false);
return;
}
// A multiplier greater 1 makes the damage not be reduced
float multiplier = getMultiplier(evt);
// No immunity for vampires
evt.setCanceled(false);
if (multiplier > 1) {
evt.setAmount(evt.getAmount() * multiplier);
} else if (data.getBlood() > 0) {
// Don't mitigate damage when there is no blood in the pool
evt.setAmount(evt.getAmount() * 0.1f);
}
}
}
}
use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.
the class VampireAbilityHandler method refreshModifiers.
@SubscribeEvent
public void refreshModifiers(TransformationModifiedEvent evt) {
ITransformationData data = evt.getEntityPlayer().getCapability(CapabilityTransformationData.CAPABILITY, null);
IAttributeInstance attack_speed = evt.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED);
AttributeModifier modifier = attack_speed.getModifier(ATTACK_SPEED_MODIFIER_UUID);
if (modifier != null) {
attack_speed.removeModifier(modifier);
}
if (data.getType() == ModTransformations.VAMPIRE) {
attack_speed.applyModifier(new AttributeModifier(ATTACK_SPEED_MODIFIER_UUID, "Vampire Atk Speed", evt.level / 10, 0));
}
}
use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.
the class VampireBloodBarHUD method renderOverlay.
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
ITransformationData td = Minecraft.getMinecraft().player.getCapability(CapabilityTransformationData.CAPABILITY, null);
if (!Minecraft.getMinecraft().player.isCreative() && event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR && td.getType() == ModTransformations.VAMPIRE) {
GlStateManager.pushMatrix();
GlStateManager.color(1, 1, 1, 1);
GlStateManager.enableAlpha();
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
mc.getTextureManager().bindTexture(TEXTURE);
int totalHearts = td.getMaxBlood() / 160;
int fullHearts = td.getBlood() / 160;
double halfHeart = (td.getBlood() % 160) / 160;
double halfTotalHeart = (td.getMaxBlood() % 160) / 160;
if (ConfigHandler.CLIENT.roundVampireBlood) {
halfHeart = roundToThirds(halfHeart);
halfTotalHeart = roundToThirds(halfTotalHeart);
}
renderTextureAtTile((sr.getScaledWidth() / 2) + 9d, sr.getScaledHeight() - 39d, fullHearts, totalHearts, halfHeart, halfTotalHeart);
GlStateManager.popMatrix();
}
}
Aggregations