当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.getPrimaryHand方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getPrimaryHand方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getPrimaryHand方法的具体用法?Java EntityPlayer.getPrimaryHand怎么用?Java EntityPlayer.getPrimaryHand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.getPrimaryHand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRenderHand

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public static void onRenderHand(RenderSpecificHandEvent ev)
{
	EntityPlayer player = Minecraft.getMinecraft().player;
	if (!player.isSneaking() && ev.getItemStack().getItem() instanceof ItemParchment)
	{

		float f = player.getSwingProgress(ev.getPartialTicks());
		float f1 = player.prevRotationPitch
				+ (player.rotationPitch - player.prevRotationPitch) * ev.getPartialTicks();

		ItemRenderer itemrenderer = Minecraft.getMinecraft().getItemRenderer();

		float prevEquipProgress = ev.getHand() == EnumHand.MAIN_HAND ? itemrenderer.prevEquippedProgressMainHand
				: itemrenderer.prevEquippedProgressOffHand;
		float equipProgress = ev.getHand() == EnumHand.MAIN_HAND ? itemrenderer.equippedProgressMainHand
				: itemrenderer.equippedProgressOffHand;
		float f5 = 1.0F - (prevEquipProgress + (equipProgress - prevEquipProgress) * ev.getPartialTicks());

		GlStateManager.pushMatrix();
		GlStateManager.pushAttrib();

		if (ev.getHand() == EnumHand.MAIN_HAND && player.getHeldItemOffhand().isEmpty())
		{
			GLHelper.renderParchmentFirstPerson(f1, f5, f, ev.getItemStack());
		} else
		{
			EnumHandSide enumhandside = ev.getHand() == EnumHand.MAIN_HAND ? player.getPrimaryHand()
					: player.getPrimaryHand().opposite();
			GLHelper.renderParchmentFirstPersonSide(f5, enumhandside, f, ev.getItemStack());
		}

		GlStateManager.popAttrib();
		GlStateManager.popMatrix();
		ev.setCanceled(true);
	}
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:38,代码来源:ClientEvents.java

示例2: doRenderLayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void doRenderLayer(EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    boolean flag = player.getPrimaryHand() == EnumHandSide.RIGHT;

    if (!Config.showBeltOnPlayers)
        return;

    BeltFinder.BeltGetter getter = BeltFinder.instance.findStack(player);
    if (getter == null)
        return;

    ItemStack stack = getter.getBelt();
    if (stack.getCount() <= 0)
        return;

    ToolBeltInventory cap = ItemToolBelt.getItems(stack);

    ItemStack firstItem = cap.getStackInSlot(0);
    ItemStack secondItem = cap.getStackInSlot(1);

    ItemStack leftItem = flag ? firstItem : secondItem;
    ItemStack rightItem = flag ? secondItem : firstItem;

    GlStateManager.pushMatrix();

    if (player.isSneaking())
    {
        GlStateManager.translate(0.0F, 0.2F, 0.0F);
    }

    this.translateToBody();

    if (!leftItem.isEmpty() || !rightItem.isEmpty())
    {
        GlStateManager.pushMatrix();

        if (this.livingEntityRenderer.getMainModel().isChild)
        {
            GlStateManager.translate(0.0F, 0.75F, 0.0F);
            GlStateManager.scale(0.5F, 0.5F, 0.5F);
        }

        this.renderHeldItem(player, rightItem, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT);
        this.renderHeldItem(player, leftItem, ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT);

        GlStateManager.popMatrix();
    }

    GlStateManager.translate(0.0F, 0.19F, 0.0F);
    GlStateManager.scale(0.85f, 0.6f, 0.78f);

    this.livingEntityRenderer.bindTexture(TEXTURE_BELT);
    this.beltModel.render(player, 0, 0, 0, 0, 0, scale);

    GlStateManager.popMatrix();
}
 
开发者ID:gigaherz,项目名称:ToolBelt,代码行数:58,代码来源:LayerToolBelt.java


注:本文中的net.minecraft.entity.player.EntityPlayer.getPrimaryHand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。