Java Code Examples for net.minecraft.entity.player.EntityPlayer.getRidingEntity()

The following are Jave code examples for showing how to use getRidingEntity() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CustomWorldGen   File: ItemCarrotOnAStick.java   View Source Code Vote up 6 votes
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.isRiding() && playerIn.getRidingEntity() instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.getRidingEntity();

        if (itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7 && entitypig.boost())
        {
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.FISHING_ROD);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }

            return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
 
Example 2
Project: Backmemed   File: ItemCarrotOnAStick.java   View Source Code Vote up 5 votes
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (itemStackIn.isRemote)
    {
        return new ActionResult(EnumActionResult.PASS, itemstack);
    }
    else
    {
        if (worldIn.isRiding() && worldIn.getRidingEntity() instanceof EntityPig)
        {
            EntityPig entitypig = (EntityPig)worldIn.getRidingEntity();

            if (itemstack.getMaxDamage() - itemstack.getMetadata() >= 7 && entitypig.boost())
            {
                itemstack.damageItem(7, worldIn);

                if (itemstack.func_190926_b())
                {
                    ItemStack itemstack1 = new ItemStack(Items.FISHING_ROD);
                    itemstack1.setTagCompound(itemstack.getTagCompound());
                    return new ActionResult(EnumActionResult.SUCCESS, itemstack1);
                }

                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }
        }

        worldIn.addStat(StatList.getObjectUseStats(this));
        return new ActionResult(EnumActionResult.PASS, itemstack);
    }
}
 
Example 3
Project: Backmemed   File: GuiIngame.java   View Source Code Vote up 4 votes
private void renderMountHealth(ScaledResolution p_184047_1_)
{
    if (this.mc.getRenderViewEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity();
        Entity entity = entityplayer.getRidingEntity();

        if (entity instanceof EntityLivingBase)
        {
            this.mc.mcProfiler.endStartSection("mountHealth");
            EntityLivingBase entitylivingbase = (EntityLivingBase)entity;
            int i = (int)Math.ceil((double)entitylivingbase.getHealth());
            float f = entitylivingbase.getMaxHealth();
            int j = (int)(f + 0.5F) / 2;

            if (j > 30)
            {
                j = 30;
            }

            int k = p_184047_1_.getScaledHeight() - 39;
            int l = p_184047_1_.getScaledWidth() / 2 + 91;
            int i1 = k;
            int j1 = 0;

            for (boolean flag = false; j > 0; j1 += 20)
            {
                int k1 = Math.min(j, 10);
                j -= k1;

                for (int l1 = 0; l1 < k1; ++l1)
                {
                    int i2 = 52;
                    int j2 = 0;
                    int k2 = l - l1 * 8 - 9;
                    this.drawTexturedModalRect(k2, i1, 52 + j2 * 9, 9, 9, 9);

                    if (l1 * 2 + 1 + j1 < i)
                    {
                        this.drawTexturedModalRect(k2, i1, 88, 9, 9, 9);
                    }

                    if (l1 * 2 + 1 + j1 == i)
                    {
                        this.drawTexturedModalRect(k2, i1, 97, 9, 9, 9);
                    }
                }

                i1 -= 10;
            }
        }
    }
}
 
Example 4
Project: CustomWorldGen   File: GuiIngameForge.java   View Source Code Vote up 4 votes
protected void renderHealthMount(int width, int height)
{
    EntityPlayer player = (EntityPlayer)mc.getRenderViewEntity();
    Entity tmp = player.getRidingEntity();
    if (!(tmp instanceof EntityLivingBase)) return;

    bind(ICONS);

    if (pre(HEALTHMOUNT)) return;

    boolean unused = false;
    int left_align = width / 2 + 91;

    mc.mcProfiler.endStartSection("mountHealth");
    GlStateManager.enableBlend();
    EntityLivingBase mount = (EntityLivingBase)tmp;
    int health = (int)Math.ceil((double)mount.getHealth());
    float healthMax = mount.getMaxHealth();
    int hearts = (int)(healthMax + 0.5F) / 2;

    if (hearts > 30) hearts = 30;

    final int MARGIN = 52;
    final int BACKGROUND = MARGIN + (unused ? 1 : 0);
    final int HALF = MARGIN + 45;
    final int FULL = MARGIN + 36;

    for (int heart = 0; hearts > 0; heart += 20)
    {
        int top = height - right_height;

        int rowCount = Math.min(hearts, 10);
        hearts -= rowCount;

        for (int i = 0; i < rowCount; ++i)
        {
            int x = left_align - i * 8 - 9;
            drawTexturedModalRect(x, top, BACKGROUND, 9, 9, 9);

            if (i * 2 + 1 + heart < health)
                drawTexturedModalRect(x, top, FULL, 9, 9, 9);
            else if (i * 2 + 1 + heart == health)
                drawTexturedModalRect(x, top, HALF, 9, 9, 9);
        }

        right_height += 10;
    }
    GlStateManager.disableBlend();
    post(HEALTHMOUNT);
}
 
Example 5
Project: CustomWorldGen   File: GuiIngame.java   View Source Code Vote up 4 votes
protected void renderMountHealth(ScaledResolution p_184047_1_)
{
    if (this.mc.getRenderViewEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity();
        Entity entity = entityplayer.getRidingEntity();

        if (entity instanceof EntityLivingBase)
        {
            this.mc.mcProfiler.endStartSection("mountHealth");
            EntityLivingBase entitylivingbase = (EntityLivingBase)entity;
            int i = (int)Math.ceil((double)entitylivingbase.getHealth());
            float f = entitylivingbase.getMaxHealth();
            int j = (int)(f + 0.5F) / 2;

            if (j > 30)
            {
                j = 30;
            }

            int k = p_184047_1_.getScaledHeight() - 39;
            int l = p_184047_1_.getScaledWidth() / 2 + 91;
            int i1 = k;
            int j1 = 0;

            for (boolean flag = false; j > 0; j1 += 20)
            {
                int k1 = Math.min(j, 10);
                j -= k1;

                for (int l1 = 0; l1 < k1; ++l1)
                {
                    int i2 = 52;
                    int j2 = 0;
                    int k2 = l - l1 * 8 - 9;
                    this.drawTexturedModalRect(k2, i1, 52 + j2 * 9, 9, 9, 9);

                    if (l1 * 2 + 1 + j1 < i)
                    {
                        this.drawTexturedModalRect(k2, i1, 88, 9, 9, 9);
                    }

                    if (l1 * 2 + 1 + j1 == i)
                    {
                        this.drawTexturedModalRect(k2, i1, 97, 9, 9, 9);
                    }
                }

                i1 -= 10;
            }
        }
    }
}