Search in sources :

Example 1 with PlayerVampireBloodChanged

use of com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged 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);
    }
}
Also used : NightVisionStatus(com.bewitchment.common.core.net.messages.NightVisionStatus) EntityInternalBloodChanged(com.bewitchment.common.core.net.messages.EntityInternalBloodChanged) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PlayerVampireBloodChanged(com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged) PlayerTransformationChangedMessage(com.bewitchment.common.core.net.messages.PlayerTransformationChangedMessage) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with PlayerVampireBloodChanged

use of com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged in project Bewitchment by Um-Mitternacht.

the class ApiInstance method addVampireBlood.

/**
 * @param player The player whose blood reserve is being modified
 * @param amount The amount of blood to add (negative values will decrease the total)
 * @return <i>When adding</i> blood this will return true if the value changed and false otherwise: this is <b>true</b> if there was
 * even a little bit of space in the pool, but the blood added was greater than the amount that could be inserted,
 * and <b>false</b> if the pool was maxed.<br>
 * <i>When removing</i> blood this will return true if ALL the blood requested was drained.
 * If the amount drained is greater than the amount available this will return false, and no blood will be drained from the pool
 * @throws UnsupportedOperationException if the player is not a vampire
 */
@Override
public boolean addVampireBlood(EntityPlayer player, int amount) {
    ITransformationData data = player.getCapability(CapabilityTransformationData.CAPABILITY, null);
    boolean flag = data.addVampireBlood(amount);
    if (player instanceof EntityPlayerMP) {
        NetworkHandler.HANDLER.sendTo(new PlayerVampireBloodChanged(player), (EntityPlayerMP) player);
    }
    return flag;
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PlayerVampireBloodChanged(com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged)

Example 3 with PlayerVampireBloodChanged

use of com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged 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));
}
Also used : ITransformationData(com.bewitchment.common.core.capability.transformation.ITransformationData) IBloodReserve(com.bewitchment.api.capability.transformations.IBloodReserve) NightVisionStatus(com.bewitchment.common.core.net.messages.NightVisionStatus) TransformationModifiedEvent(com.bewitchment.api.event.TransformationModifiedEvent) EntityInternalBloodChanged(com.bewitchment.common.core.net.messages.EntityInternalBloodChanged) PlayerVampireBloodChanged(com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged) PlayerTransformationChangedMessage(com.bewitchment.common.core.net.messages.PlayerTransformationChangedMessage)

Example 4 with PlayerVampireBloodChanged

use of com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged 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

PlayerVampireBloodChanged (com.bewitchment.common.core.net.messages.PlayerVampireBloodChanged)4 ITransformationData (com.bewitchment.common.core.capability.transformation.ITransformationData)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 EntityInternalBloodChanged (com.bewitchment.common.core.net.messages.EntityInternalBloodChanged)2 NightVisionStatus (com.bewitchment.common.core.net.messages.NightVisionStatus)2 PlayerTransformationChangedMessage (com.bewitchment.common.core.net.messages.PlayerTransformationChangedMessage)2 IBloodReserve (com.bewitchment.api.capability.transformations.IBloodReserve)1 TransformationModifiedEvent (com.bewitchment.api.event.TransformationModifiedEvent)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1