Search in sources :

Example 1 with ITransformationData

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);
    }
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with ITransformationData

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;
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 3 with ITransformationData

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);
            }
        }
    }
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with ITransformationData

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));
    }
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with ITransformationData

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();
    }
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) ScaledResolution(net.minecraft.client.gui.ScaledResolution) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ITransformationData (com.bewitchment.common.core.capability.transformation.ITransformationData)13 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 IBloodReserve (com.bewitchment.api.capability.transformations.IBloodReserve)3 EntityInternalBloodChanged (com.bewitchment.common.core.net.messages.EntityInternalBloodChanged)3 PlayerVampireBloodChanged (com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 NightVisionStatus (com.bewitchment.common.core.net.messages.NightVisionStatus)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 PotionEffect (net.minecraft.potion.PotionEffect)2 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)2 TransformationModifiedEvent (com.bewitchment.api.event.TransformationModifiedEvent)1 PlayerTransformationChangedMessage (com.bewitchment.common.core.net.messages.PlayerTransformationChangedMessage)1 EntityBatSwarm (com.bewitchment.common.entity.EntityBatSwarm)1 Minecraft (net.minecraft.client.Minecraft)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1 IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1