Java Code Examples for net.minecraft.item.ItemStack#getItemUseAction()

The following examples show how to use net.minecraft.item.ItemStack#getItemUseAction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemKimono.java    From Sakura_mod with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public static ModelBiped getKimonoModel(EntityLivingBase entityLiving, ItemStack itemStack,ModelBiped model)
{
  if (model != null)
  {
    model.setVisible(true);
    
    model.isSneak = entityLiving.isSneaking();
    
    model.isRiding = entityLiving.isRiding();
    model.isChild = entityLiving.isChild();
    ItemStack itemstack = entityLiving.getHeldItemMainhand();
    ItemStack itemstack1 = entityLiving.getHeldItemOffhand();
    ModelBiped.ArmPose modelbiped$armpose = ModelBiped.ArmPose.EMPTY;
    ModelBiped.ArmPose modelbiped$armpose1 = ModelBiped.ArmPose.EMPTY;
    if ((itemstack != null) && (!itemstack.isEmpty()))
    {
      modelbiped$armpose = ModelBiped.ArmPose.ITEM;
      if (entityLiving.getItemInUseCount() > 0)
      {
        EnumAction enumaction = itemstack.getItemUseAction();
        if (enumaction == EnumAction.BLOCK) {
          modelbiped$armpose = ModelBiped.ArmPose.BLOCK;
        } else if (enumaction == EnumAction.BOW) {
          modelbiped$armpose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
      }
    }
    if ((itemstack1 != null) && (!itemstack1.isEmpty()))
    {
      modelbiped$armpose1 = ModelBiped.ArmPose.ITEM;
      if (entityLiving.getItemInUseCount() > 0)
      {
        EnumAction enumaction1 = itemstack1.getItemUseAction();
        if (enumaction1 == EnumAction.BLOCK) {
          modelbiped$armpose1 = ModelBiped.ArmPose.BLOCK;
        }
      }
    }
    if (entityLiving.getPrimaryHand() == EnumHandSide.RIGHT)
    {
      model.rightArmPose = modelbiped$armpose;
      model.leftArmPose = modelbiped$armpose1;
    }
    else
    {
      model.rightArmPose = modelbiped$armpose1;
      model.leftArmPose = modelbiped$armpose;
    }
  }
  return model;
}
 
Example 2
Source File: HyperiumItemRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void renderItemInFirstPerson(float partialTicks, float prevEquippedProgress, float equippedProgress, ItemStack itemToRender) {
    float f = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * partialTicks);
    EntityPlayerSP entityPlayerSP = mc.thePlayer;
    float f1 = entityPlayerSP.getSwingProgress(partialTicks);
    float f2 = entityPlayerSP.prevRotationPitch + (entityPlayerSP.rotationPitch - entityPlayerSP.prevRotationPitch) * partialTicks;
    float f3 = entityPlayerSP.prevRotationYaw + (entityPlayerSP.rotationYaw - entityPlayerSP.prevRotationYaw) * partialTicks;
    ((IMixinItemRenderer) parent).callRotateArroundXAndY(f2, f3);
    ((IMixinItemRenderer) parent).callSetLightMapFromPlayer(entityPlayerSP);
    ((IMixinItemRenderer) parent).callRotateWithPlayerRotations(entityPlayerSP, partialTicks);
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();

    if (itemToRender != null) {
        if (itemToRender.getItem() == Items.filled_map) {
            ((IMixinItemRenderer) parent).callRenderItemMap(entityPlayerSP, f2, f, f1);
        } else if ((itemToRender.getItem() instanceof ItemSword) && !mc.thePlayer.isBlocking() && Settings.CUSTOM_SWORD_ANIMATION) {
            transformFirstPersonItem(f, f1);
        } else if (entityPlayerSP.getItemInUseCount() > 0) {
            EnumAction enumaction = itemToRender.getItemUseAction();

            switch (enumaction) {
                case NONE:
                    transformFirstPersonItem(f, 0.0F);
                    break;
                case EAT:
                case DRINK:
                    ((IMixinItemRenderer) parent).callPerformDrinking(entityPlayerSP, partialTicks);
                    if (Settings.OLD_EATING) {
                        transformFirstPersonItem(f, f1);
                    } else {
                        transformFirstPersonItem(f, 0.0F);
                    }
                    break;
                case BLOCK:
                    if (Settings.OLD_BLOCKHIT) {
                        transformFirstPersonItem(f, f1);
                        ((IMixinItemRenderer) parent).callDoBlockTransformations();
                        GlStateManager.scale(0.83f, 0.88f, 0.85f);
                        GlStateManager.translate(-0.3f, 0.1f, 0.0f);
                    } else {
                        transformFirstPersonItem(f, 0f);
                        ((IMixinItemRenderer) parent).callDoBlockTransformations();
                    }
                    break;

                case BOW:
                    if (Settings.OLD_BOW) {
                        transformFirstPersonItem(f, f1);
                        ((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP);
                        GlStateManager.translate(0.0F, 0.1F, -0.15F);
                    } else {
                        transformFirstPersonItem(f, 0.0F);
                        ((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP);
                    }
            }
        } else {
            ((IMixinItemRenderer) parent).callDoItemUsedTransformations(f1);
            transformFirstPersonItem(f, f1);
        }

        parent.renderItem(entityPlayerSP, itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON);
    } else if (!entityPlayerSP.isInvisible()) {
        ((IMixinItemRenderer) parent).callRenderPlayerArm(entityPlayerSP, f, f1);
    }

    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
}
 
Example 3
Source File: BloodRenderLayer.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void setModelVisibilities(AbstractClientPlayer clientPlayer) {
	ModelPlayer modelplayer = render.getMainModel();

	if (clientPlayer.isSpectator()) {
		modelplayer.setVisible(true);
		modelplayer.bipedHead.showModel = true;
		modelplayer.bipedHeadwear.showModel = true;
	} else {
		ItemStack stackMain = clientPlayer.getHeldItemMainhand();
		ItemStack stackOff = clientPlayer.getHeldItemOffhand();
		modelplayer.setVisible(false);
		modelplayer.bipedHeadwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.HAT);
		modelplayer.bipedBodyWear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.JACKET);
		modelplayer.bipedLeftLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_PANTS_LEG);
		modelplayer.bipedRightLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_PANTS_LEG);
		modelplayer.bipedLeftArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_SLEEVE);
		modelplayer.bipedRightArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE);
		modelplayer.isSneak = clientPlayer.isSneaking();
		ArmPose poseMain = ArmPose.EMPTY;

		if (!stackMain.isEmpty()) {
			poseMain = ArmPose.ITEM;

			if (clientPlayer.getItemInUseCount() > 0) {
				EnumAction enumaction = stackMain.getItemUseAction();

				if (enumaction == EnumAction.BLOCK) {
					poseMain = ArmPose.BLOCK;
				} else if (enumaction == EnumAction.BOW) {
					poseMain = ArmPose.BOW_AND_ARROW;
				}
			}
		}

		ArmPose poseOff = ArmPose.EMPTY;
		if (!stackOff.isEmpty()) {
			poseOff = ArmPose.ITEM;

			if (clientPlayer.getItemInUseCount() > 0) {
				EnumAction enumaction1 = stackOff.getItemUseAction();

				if (enumaction1 == EnumAction.BLOCK) {
					poseOff = ArmPose.BLOCK;
				}
			}
		}

		if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) {
			modelplayer.rightArmPose = poseMain;
			modelplayer.leftArmPose = poseOff;
		} else {
			modelplayer.rightArmPose = poseOff;
			modelplayer.leftArmPose = poseMain;
		}
	}
}
 
Example 4
Source File: RenderGuard.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private void setModelVisibilities(EntityGuard clientPlayer) {
	ModelGuard modelplayer = (ModelGuard) this.getMainModel();

	ItemStack itemstack = clientPlayer.getHeldItemMainhand();
	ItemStack itemstack1 = clientPlayer.getHeldItemOffhand();
	modelplayer.setVisible(true);

	modelplayer.isSneak = clientPlayer.isSneaking();
	ModelBiped.ArmPose modelbiped$armpose = ModelBiped.ArmPose.EMPTY;
	ModelBiped.ArmPose modelbiped$armpose1 = ModelBiped.ArmPose.EMPTY;

	if (itemstack != null) {
		modelbiped$armpose = ModelBiped.ArmPose.ITEM;

		if (clientPlayer.getItemInUseCount() > 0) {
			EnumAction enumaction = itemstack.getItemUseAction();

			if (enumaction == EnumAction.BLOCK) {
				modelbiped$armpose = ModelBiped.ArmPose.BLOCK;
			} else if (enumaction == EnumAction.BOW) {
				modelbiped$armpose = ModelBiped.ArmPose.BOW_AND_ARROW;
			}
		}
	}

	if (itemstack1 != null) {
		modelbiped$armpose1 = ModelBiped.ArmPose.ITEM;

		if (clientPlayer.getItemInUseCount() > 0) {
			EnumAction enumaction1 = itemstack1.getItemUseAction();

			if (enumaction1 == EnumAction.BLOCK) {
				modelbiped$armpose1 = ModelBiped.ArmPose.BLOCK;
			}
		}
	}

	if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) {
		modelplayer.rightArmPose = modelbiped$armpose;
		modelplayer.leftArmPose = modelbiped$armpose1;
	} else {
		modelplayer.rightArmPose = modelbiped$armpose1;
		modelplayer.leftArmPose = modelbiped$armpose;
	}

}
 
Example 5
Source File: RenderPlayerCyberware.java    From Cyberware with MIT License 4 votes vote down vote up
private void setModelVisibilities(AbstractClientPlayer clientPlayer)
{
	ModelPlayer modelplayer = this.getMainModel();

	if (clientPlayer.isSpectator())
	{
		modelplayer.setInvisible(false);
		modelplayer.bipedHead.showModel = true;
		modelplayer.bipedHeadwear.showModel = true;
	}
	else
	{
		ItemStack itemstack = clientPlayer.getHeldItemMainhand();
		ItemStack itemstack1 = clientPlayer.getHeldItemOffhand();
		modelplayer.setInvisible(true);
		modelplayer.bipedHeadwear.showModel = modelplayer.bipedHead.isHidden ? false : clientPlayer.isWearing(EnumPlayerModelParts.HAT);
		modelplayer.bipedBodyWear.showModel = modelplayer.bipedBody.isHidden ? false : clientPlayer.isWearing(EnumPlayerModelParts.JACKET);
		modelplayer.bipedLeftLegwear.showModel = modelplayer.bipedLeftLeg.isHidden ? false : clientPlayer.isWearing(EnumPlayerModelParts.LEFT_PANTS_LEG);
		modelplayer.bipedRightLegwear.showModel = modelplayer.bipedRightLeg.isHidden ? false : clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_PANTS_LEG);
		modelplayer.bipedLeftArmwear.showModel = modelplayer.bipedLeftArm.isHidden ? false : clientPlayer.isWearing(EnumPlayerModelParts.LEFT_SLEEVE);
		modelplayer.bipedRightArmwear.showModel = modelplayer.bipedRightArm.isHidden ? false :clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE);
		modelplayer.isSneak = clientPlayer.isSneaking();
		ModelBiped.ArmPose modelbiped$armpose = ModelBiped.ArmPose.EMPTY;
		ModelBiped.ArmPose modelbiped$armpose1 = ModelBiped.ArmPose.EMPTY;

		if (itemstack != null)
		{
			modelbiped$armpose = ModelBiped.ArmPose.ITEM;

			if (clientPlayer.getItemInUseCount() > 0)
			{
				EnumAction enumaction = itemstack.getItemUseAction();

				if (enumaction == EnumAction.BLOCK)
				{
					modelbiped$armpose = ModelBiped.ArmPose.BLOCK;
				}
				else if (enumaction == EnumAction.BOW)
				{
					modelbiped$armpose = ModelBiped.ArmPose.BOW_AND_ARROW;
				}
			}
		}

		if (itemstack1 != null)
		{
			modelbiped$armpose1 = ModelBiped.ArmPose.ITEM;

			if (clientPlayer.getItemInUseCount() > 0)
			{
				EnumAction enumaction1 = itemstack1.getItemUseAction();

				if (enumaction1 == EnumAction.BLOCK)
				{
					modelbiped$armpose1 = ModelBiped.ArmPose.BLOCK;
				}
			}
		}

		if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT)
		{
			modelplayer.rightArmPose = modelbiped$armpose;
			modelplayer.leftArmPose = modelbiped$armpose1;
		}
		else
		{
			modelplayer.rightArmPose = modelbiped$armpose1;
			modelplayer.leftArmPose = modelbiped$armpose;
		}
	}
}
 
Example 6
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 4 votes vote down vote up
public void renderItemInFirstPerson(AbstractClientPlayer p_187457_1_, float p_187457_2_, float p_187457_3_, EnumHand p_187457_4_, float p_187457_5_, @Nullable ItemStack p_187457_6_, float p_187457_7_)
{
	boolean flag = p_187457_4_ == EnumHand.MAIN_HAND;
	EnumHandSide enumhandside = flag ? p_187457_1_.getPrimaryHand() : p_187457_1_.getPrimaryHand().opposite();
	GlStateManager.pushMatrix();

	if (p_187457_6_ == null)
	{
		if (flag && !p_187457_1_.isInvisible())
		{
			
			this.renderArmFirstPerson(p_187457_7_, p_187457_5_, enumhandside);
		}
	}
	else if (p_187457_6_.getItem() instanceof net.minecraft.item.ItemMap)
	{
		if (flag && itemStackOffHand == null)
		{
			this.renderMapFirstPerson(p_187457_3_, p_187457_7_, p_187457_5_);
		}
		else
		{
			this.renderMapFirstPersonSide(p_187457_7_, enumhandside, p_187457_5_, p_187457_6_);
		}
	}
	else
	{
		boolean flag1 = enumhandside == EnumHandSide.RIGHT;

		if (p_187457_1_.isHandActive() && p_187457_1_.getItemInUseCount() > 0 && p_187457_1_.getActiveHand() == p_187457_4_)
		{
			int j = flag1 ? 1 : -1;

			switch (p_187457_6_.getItemUseAction())
			{
				case NONE:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case EAT:
				case DRINK:
					this.transformEatFirstPerson(p_187457_2_, enumhandside, p_187457_6_);
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case BLOCK:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case BOW:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					GlStateManager.translate((float)j * -0.2785682F, 0.18344387F, 0.15731531F);
					GlStateManager.rotate(-13.935F, 1.0F, 0.0F, 0.0F);
					GlStateManager.rotate((float)j * 35.3F, 0.0F, 1.0F, 0.0F);
					GlStateManager.rotate((float)j * -9.785F, 0.0F, 0.0F, 1.0F);
					float f5 = (float)p_187457_6_.getMaxItemUseDuration() - ((float)this.mc.thePlayer.getItemInUseCount() - p_187457_2_ + 1.0F);
					float f6 = f5 / 20.0F;
					f6 = (f6 * f6 + f6 * 2.0F) / 3.0F;

					if (f6 > 1.0F)
					{
						f6 = 1.0F;
					}

					if (f6 > 0.1F)
					{
						float f7 = MathHelper.sin((f5 - 0.1F) * 1.3F);
						float f3 = f6 - 0.1F;
						float f4 = f7 * f3;
						GlStateManager.translate(f4 * 0.0F, f4 * 0.004F, f4 * 0.0F);
					}

					GlStateManager.translate(f6 * 0.0F, f6 * 0.0F, f6 * 0.04F);
					GlStateManager.scale(1.0F, 1.0F, 1.0F + f6 * 0.2F);
					GlStateManager.rotate((float)j * 45.0F, 0.0F, -1.0F, 0.0F);
			}
		}
		else
		{
			float f = -0.4F * MathHelper.sin(MathHelper.sqrt_float(p_187457_5_) * (float)Math.PI);
			float f1 = 0.2F * MathHelper.sin(MathHelper.sqrt_float(p_187457_5_) * ((float)Math.PI * 2F));
			float f2 = -0.2F * MathHelper.sin(p_187457_5_ * (float)Math.PI);
			int i = flag1 ? 1 : -1;
			GlStateManager.translate((float)i * f, f1, f2);
			this.transformSideFirstPerson(enumhandside, p_187457_7_);
			this.transformFirstPerson(enumhandside, p_187457_5_);
		}

		this.renderItemSide(p_187457_1_, p_187457_6_, flag1 ? ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !flag1);
	}

	GlStateManager.popMatrix();
}