Search in sources :

Example 11 with ITransformationData

use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.

the class TransformationEvents method onPlayerRespawn.

@SubscribeEvent
public void onPlayerRespawn(PlayerEvent.Clone event) {
    ITransformationData data = event.getOriginal().getCapability(CapabilityTransformationData.CAPABILITY, null);
    BewitchmentAPI.getAPI().setTypeAndLevel(event.getEntityPlayer(), data.getType(), data.getLevel(), false);
    if (event.isWasDeath()) {
        TransformationHelper.setVampireBlood(event.getEntityPlayer(), (int) (data.getMaxBlood() * 0.1));
    } else {
        TransformationHelper.setVampireBlood(event.getEntityPlayer(), data.getMaxBlood());
    }
    HotbarAction.refreshActions(event.getEntityPlayer(), event.getEntityPlayer().world);
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 12 with ITransformationData

use of com.bewitchment.common.core.capability.transformation.ITransformationData 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));
        }
    }
}
Also used : IBloodReserve(com.bewitchment.api.capability.transformations.IBloodReserve) ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) EntityInternalBloodChanged(com.bewitchment.common.core.net.messages.EntityInternalBloodChanged) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)

Example 13 with ITransformationData

use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.

the class TransformationHelper method setVampireBlood.

public static void setVampireBlood(EntityPlayer player, int amount) {
    ITransformationData data = player.getCapability(CapabilityTransformationData.CAPABILITY, null);
    data.setBlood(amount);
    if (player instanceof EntityPlayerMP) {
        NetworkHandler.HANDLER.sendTo(new PlayerVampireBloodChanged(player), (EntityPlayerMP) player);
    }
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PlayerVampireBloodChanged(com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged)

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