Search in sources :

Example 1 with EntityPolarBear

use of net.minecraft.entity.monster.EntityPolarBear 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));
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityInternalBloodChanged(com.bewitchment.common.core.net.messages.EntityInternalBloodChanged) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) IBloodReserve(com.bewitchment.api.capability.transformations.IBloodReserve) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPolarBear(net.minecraft.entity.monster.EntityPolarBear) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IBloodReserve (com.bewitchment.api.capability.transformations.IBloodReserve)1 EntityInternalBloodChanged (com.bewitchment.common.core.net.messages.EntityInternalBloodChanged)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPolarBear (net.minecraft.entity.monster.EntityPolarBear)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)1