Search in sources :

Example 81 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project ArsMagica2 by Mithion.

the class SpellScrollRenderer method renderEffect.

public void renderEffect(Affinity affinity, boolean includeArm, Object... data) {
    if (!setupIcons) {
        setupAffinityIcons();
        setupIcons = true;
    }
    RenderBlocks renderer = (RenderBlocks) data[0];
    EntityLivingBase entity = (EntityLivingBase) data[1];
    GL11.glPushMatrix();
    GL11.glEnable(32826);
    GL11.glEnable(3042);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    float scale = 3f;
    if (entity == mc.thePlayer && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0) {
        GL11.glPushMatrix();
        if (((EntityPlayer) entity).getItemInUseCount() > 0) {
            GL11.glRotatef(120, 1, 0, 1);
            GL11.glRotatef(-10, 0, 1, 0);
            GL11.glTranslatef(2f, 0f, 0.8f);
        } else {
            GL11.glTranslatef(3f, -1.2f, -2.5f);
            GL11.glScalef(scale, scale, scale);
            GL11.glRotatef(-45, 0, 1, 0);
        }
        RenderHelper.disableStandardItemLighting();
        GL11.glTranslatef(0.6f, 0.0f, -0.4f);
        RenderByAffinity(affinity);
        RenderHelper.enableStandardItemLighting();
        GL11.glPopMatrix();
        if (includeArm) {
            if (entity instanceof EntityPlayer && ((EntityPlayer) entity).getItemInUseCount() > 0) {
                GL11.glRotatef(-130, 0, 1, 0);
                GL11.glTranslatef(-1f, 0.2f, -2.5f);
            }
            GL11.glScalef(scale, scale, scale);
            GL11.glTranslatef(0f, 0.6f, 1.1f);
            Minecraft.getMinecraft().renderEngine.bindTexture(mc.thePlayer.getLocationSkin());
            renderFirstPersonArm(mc.thePlayer);
        }
    } else {
        if (entity instanceof EntityPlayer && ((EntityPlayer) entity).getItemInUseCount() > 0) {
            GL11.glTranslatef(0.0f, 0.0f, 1.0f);
        } else {
            GL11.glTranslatef(0.0f, 0.0f, 1.6f);
        }
        scale = 1.5f;
        GL11.glScalef(scale, scale, scale);
        GL11.glRotatef(45, 0, 1, 0);
        RenderByAffinity(affinity);
    }
    GL11.glDisable(32826);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(3042);
    GL11.glPopMatrix();
}
Also used : RenderBlocks(net.minecraft.client.renderer.RenderBlocks) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 82 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project ArsMagica2 by Mithion.

the class Recall method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase)) {
        return false;
    }
    if (caster.isPotionActive(BuffList.astralDistortion.id) || ((EntityLivingBase) target).isPotionActive(BuffList.astralDistortion.id)) {
        if (caster instanceof EntityPlayer)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.cantTeleport")));
        return false;
    }
    int x = (int) Math.floor(target.posX);
    int y = (int) Math.floor(target.posY);
    int z = (int) Math.floor(target.posZ);
    ItemStack[] ritualRunes = RitualShapeHelper.instance.checkForRitual(this, world, x, y, z, false);
    if (ritualRunes != null) {
        return handleRitualReagents(ritualRunes, world, x, y, z, caster, target);
    }
    ExtendedProperties casterProperties = ExtendedProperties.For(caster);
    if (!casterProperties.getMarkSet()) {
        if (caster instanceof EntityPlayer && !world.isRemote)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.noMark")));
        return false;
    } else if (casterProperties.getMarkDimension() != caster.dimension) {
        if (caster instanceof EntityPlayer && !world.isRemote)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.diffDimMark")));
        return false;
    }
    if (!world.isRemote) {
        ((EntityLivingBase) target).setPositionAndUpdate(casterProperties.getMarkX(), casterProperties.getMarkY(), casterProperties.getMarkZ());
    }
    return true;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) ParticleExpandingCollapsingRingAtPoint(am2.particles.ParticleExpandingCollapsingRingAtPoint) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 83 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project ArsMagica2 by Mithion.

the class ManaDrain method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase))
        return false;
    double manaStolen = 250;
    ExtendedProperties targetProperties = ExtendedProperties.For((EntityLivingBase) target);
    if (manaStolen > targetProperties.getCurrentMana()) {
        manaStolen = targetProperties.getCurrentMana();
    }
    targetProperties.setCurrentMana((float) (targetProperties.getCurrentMana() - manaStolen));
    targetProperties.forceSync();
    ExtendedProperties casterProperties = ExtendedProperties.For(caster);
    casterProperties.setCurrentMana((float) (casterProperties.getCurrentMana() + manaStolen));
    casterProperties.forceSync();
    return true;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 84 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project VoodooCraft by Mod-DevCafeTeam.

the class HexHandler method hurtEvent.

/**
     * Protection Hex
     */
@SubscribeEvent
public static void hurtEvent(LivingHurtEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    ItemStack stack;
    //Protection - Absorbs some damage, with a 10s cooldown
    if (event.getSource().getSourceOfDamage() != null && (stack = getDollWithHex(entity, "protection")) != null) {
        UUID uuid = entity.getUniqueID();
        Long cooldownStart = protectionCooldowns.get(uuid);
        long worldTime = entity.world.getTotalWorldTime();
        //Check if hex is ready to protect
        if (//200 ticks == 10 seconds
        cooldownStart == null || (worldTime - cooldownStart) >= 200) {
            //Protect from up to 5 hearts of damage
            float protection = 10f;
            float damage = event.getAmount();
            event.setAmount(damage <= protection ? 0 : damage - protection);
            //Sets the new cooldown start
            protectionCooldowns.put(uuid, worldTime);
            //Damage the doll
            stack.damageItem(1, entity);
        }
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 85 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project ImmersiveEngineering by BluSunrize.

the class TileEntityConveyorVertical method onEntityCollision.

@Override
public void onEntityCollision(World world, Entity entity) {
    if (entity != null && !entity.isDead) {
        if (world.isBlockIndirectlyGettingPowered(pos) > 0)
            return;
        double vBase = entity instanceof EntityLivingBase ? 1.5 : 1.15;
        double distY = Math.abs(getPos().add(0, 1, 0).getY() + .5 - entity.posY);
        double treshold = .9;
        boolean contact = distY < treshold;
        double vX = entity.motionX;
        double vY = 0.1 * vBase;
        double vZ = entity.motionZ;
        if (entity.motionY < 0)
            vY += entity.motionY * .9;
        if (!(entity instanceof EntityPlayer)) {
            vX = 0.05 * this.facing.getFrontOffsetX();
            vZ = 0.05 * this.facing.getFrontOffsetZ();
            if (facing == EnumFacing.WEST || facing == EnumFacing.EAST) {
                if (entity.posZ > getPos().getZ() + 0.65D)
                    vZ = -0.1D * vBase;
                else if (entity.posZ < getPos().getZ() + 0.35D)
                    vZ = 0.1D * vBase;
            } else if (facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) {
                if (entity.posX > getPos().getX() + 0.65D)
                    vX = -0.1D * vBase;
                else if (entity.posX < getPos().getX() + 0.35D)
                    vX = 0.1D * vBase;
            }
        }
        //Little boost at the top of a conveyor to help players and minecarts to get off
        if (contact && !(world.getTileEntity(getPos().add(0, 1, 0)) instanceof TileEntityConveyorVertical))
            vY *= 2.25;
        entity.onGround = false;
        if (entity.fallDistance < 3)
            entity.fallDistance = 0;
        else
            entity.fallDistance *= .9;
        entity.motionX = vX;
        entity.motionY = vY;
        entity.motionZ = vZ;
        if (entity instanceof EntityItem) {
            ((EntityItem) entity).setNoDespawn();
            TileEntity inventoryTile;
            inventoryTile = world.getTileEntity(getPos().add(0, 1, 0));
            if (!world.isRemote) {
                if (contact && inventoryTile != null && !(inventoryTile instanceof TileEntityConveyorBelt)) {
                    ItemStack stack = ((EntityItem) entity).getEntityItem();
                    if (stack != null) {
                        ItemStack ret = Utils.insertStackIntoInventory(inventoryTile, stack, EnumFacing.DOWN);
                        if (ret == null)
                            entity.setDead();
                        else if (ret.stackSize < stack.stackSize)
                            ((EntityItem) entity).setEntityItemStack(ret);
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)270 EntityPlayer (net.minecraft.entity.player.EntityPlayer)100 Entity (net.minecraft.entity.Entity)72 PotionEffect (net.minecraft.potion.PotionEffect)43 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)39 ItemStack (net.minecraft.item.ItemStack)36 Vec3d (net.minecraft.util.math.Vec3d)25 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)25 BlockPos (net.minecraft.util.math.BlockPos)24 TileEntity (net.minecraft.tileentity.TileEntity)23 World (net.minecraft.world.World)20 IBlockState (net.minecraft.block.state.IBlockState)19 AMVector3 (am2.api.math.AMVector3)15 IArsMagicaBoss (am2.bosses.IArsMagicaBoss)15 ArrayList (java.util.ArrayList)15 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)15 Block (net.minecraft.block.Block)12 EntityItem (net.minecraft.entity.item.EntityItem)11 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)11 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10