Java Code Examples for net.minecraft.util.EnumHandSide#LEFT

The following examples show how to use net.minecraft.util.EnumHandSide#LEFT . 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: LayerTofunianHeldItem.java    From TofuCraftReload with MIT License 6 votes vote down vote up
private void renderHeldItem(EntityLivingBase p_188358_1_, ItemStack p_188358_2_, ItemCameraTransforms.TransformType p_188358_3_, EnumHandSide handSide)
{
    if (!p_188358_2_.isEmpty())
    {
        GlStateManager.pushMatrix();

        if (p_188358_1_.isSneaking())
        {
            GlStateManager.translate(0.0F, 0.2F, 0.0F);
        }
        // Forge: moved this call down, fixes incorrect offset while sneaking.
        this.translateToHand(handSide);
        GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
        boolean flag = handSide == EnumHandSide.LEFT;
        GlStateManager.translate((float)(flag ? -1 : 1) / 60.0F, 0.125F, -0.25F);
        Minecraft.getMinecraft().getItemRenderer().renderItemSide(p_188358_1_, p_188358_2_, p_188358_3_, flag);
        GlStateManager.popMatrix();
    }
}
 
Example 2
Source File: RenderPlayerCyberware.java    From Cyberware with MIT License 6 votes vote down vote up
@Override
public void renderLeftArm(AbstractClientPlayer clientPlayer)
{
	Minecraft.getMinecraft().getTextureManager().bindTexture(robo);
	super.renderLeftArm(clientPlayer);
	
	if (CyberwareAPI.isCyberwareInstalled(clientPlayer, new ItemStack(CyberwareContent.handUpgrades, 1, 1))
		&& CyberwareAPI.isCyberwareInstalled(clientPlayer, new ItemStack(CyberwareContent.cyberlimbs, 1, 0))
		&& Minecraft.getMinecraft().gameSettings.mainHand == EnumHandSide.LEFT && clientPlayer.getHeldItemMainhand() == null
		&& EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(clientPlayer, new ItemStack(CyberwareContent.handUpgrades, 1, 1))))
	{
		GL11.glPushMatrix();

		float percent = ((Minecraft.getMinecraft().thePlayer.ticksExisted + Minecraft.getMinecraft().getRenderPartialTicks() - ItemHandUpgrade.clawsTime) / 4F);
		percent = Math.min(1.0F, percent);
		percent = Math.max(0F, percent);
		percent = (float) Math.sin(percent * Math.PI / 2F);
		claws.claw1.rotateAngleY = 0.00F;
		claws.claw1.rotateAngleZ = 0.07F;
		claws.claw1.rotateAngleX = 0.00F;
		claws.claw1.setRotationPoint(-5.0F, -5.0F + (7F * percent), 0.0F);
		claws.claw1.render(0.0625F);
		GL11.glPopMatrix();
	}
}
 
Example 3
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 5 votes vote down vote up
private void renderArmFirstPerson(float p_187456_1_, float p_187456_2_, EnumHandSide p_187456_3_)
{
	boolean flag = p_187456_3_ != EnumHandSide.LEFT;
	float f = flag ? 1.0F : -1.0F;
	float f1 = MathHelper.sqrt_float(p_187456_2_);
	float f2 = -0.3F * MathHelper.sin(f1 * (float)Math.PI);
	float f3 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F));
	float f4 = -0.4F * MathHelper.sin(p_187456_2_ * (float)Math.PI);
	GlStateManager.translate(f * (f2 + 0.64000005F), f3 + -0.6F + p_187456_1_ * -0.6F, f4 + -0.71999997F);
	GlStateManager.rotate(f * 45.0F, 0.0F, 1.0F, 0.0F);
	float f5 = MathHelper.sin(p_187456_2_ * p_187456_2_ * (float)Math.PI);
	float f6 = MathHelper.sin(f1 * (float)Math.PI);
	GlStateManager.rotate(f * f6 * 70.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(f * f5 * -20.0F, 0.0F, 0.0F, 1.0F);
	AbstractClientPlayer abstractclientplayer = this.mc.thePlayer;
	this.mc.getTextureManager().bindTexture(abstractclientplayer.getLocationSkin());
	GlStateManager.translate(f * -1.0F, 3.6F, 3.5F);
	GlStateManager.rotate(f * 120.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(200.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(f * -135.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.translate(f * 5.6F, 0.0F, 0.0F);
	RenderPlayer renderplayer = getEntityRenderObject(this.mc.thePlayer, p_187456_3_);
	GlStateManager.disableCull();

	if (flag)
	{
		renderplayer.renderRightArm(abstractclientplayer);
	}
	else
	{
		renderplayer.renderLeftArm(abstractclientplayer);
	}

	GlStateManager.enableCull();
}
 
Example 4
Source File: EssentialsMissingHandler.java    From Cyberware with MIT License 5 votes vote down vote up
private void processEvent(Event event, EnumHand hand, EntityPlayer p, ICyberwareUserData cyberware)
{
	EnumHandSide mainHand = p.getPrimaryHand();
	EnumHandSide offHand = ((mainHand == EnumHandSide.LEFT) ? EnumHandSide.RIGHT : EnumHandSide.LEFT);
	EnumSide correspondingMainHand = ((mainHand == EnumHandSide.RIGHT) ? EnumSide.RIGHT : EnumSide.LEFT);
	EnumSide correspondingOffHand = ((offHand == EnumHandSide.RIGHT) ? EnumSide.RIGHT : EnumSide.LEFT);
	
	boolean leftUnpowered = false;
	ItemStack armLeft = cyberware.getCyberware(new ItemStack(CyberwareContent.cyberlimbs, 1, 0));
	if (armLeft != null && !ItemCyberlimb.isPowered(armLeft))
	{
		leftUnpowered = true;
	}
	
	boolean rightUnpowered = false;
	ItemStack armRight = cyberware.getCyberware(new ItemStack(CyberwareContent.cyberlimbs, 1, 1));
	if (armRight != null && !ItemCyberlimb.isPowered(armRight))
	{
		rightUnpowered = true;
	}

	if (hand == EnumHand.MAIN_HAND && (!cyberware.hasEssential(EnumSlot.ARM, correspondingMainHand) || leftUnpowered))
	{
		event.setCanceled(true);
	}
	else if (hand == EnumHand.OFF_HAND && (!cyberware.hasEssential(EnumSlot.ARM, correspondingOffHand) || rightUnpowered))
	{
		event.setCanceled(true);
	}
}
 
Example 5
Source File: ModelTofunian.java    From TofuCraftReload with MIT License 4 votes vote down vote up
protected ModelRenderer getArmForSide(EnumHandSide side)
{
    return side == EnumHandSide.LEFT ? this.bipedLeftArm : this.bipedRightArm;
}
 
Example 6
Source File: ModelTofuMindCore.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
    this.head.rotateAngleY = netHeadYaw * 0.017453292F;

    this.head.rotateAngleX = headPitch * 0.017453292F;


    this.body.rotateAngleY = 0.0F;
    float f = 1.0F;


    this.handR.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbSwingAmount * 0.5F / f;
    this.handL.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2.0F * limbSwingAmount * 0.5F / f;
    this.handR.rotateAngleZ = 0.0F;
    this.handL.rotateAngleY = 0.0F;
    this.handL.rotateAngleZ = 0.0F;


    this.handR.rotateAngleY = 0.0F;
    this.handR.rotateAngleZ = 0.0F;


    if (this.swingProgress > 0.0F) {
        EnumHandSide enumhandside = this.getMainHand(entityIn);
        ModelRenderer modelrenderer = this.getArmForSide(enumhandside);
        float f1 = this.swingProgress;
        this.body.rotateAngleY = MathHelper.sin(MathHelper.sqrt(f1) * ((float) Math.PI * 2F)) * 0.2F;

        if (enumhandside == EnumHandSide.LEFT) {
            this.body.rotateAngleY *= -1.0F;
        }

        this.handR.rotationPointZ = MathHelper.sin(this.body.rotateAngleY) * 5.0F;
        this.handR.rotationPointX = -MathHelper.cos(this.body.rotateAngleY) * 5.0F;
        this.handL.rotationPointZ = -MathHelper.sin(this.body.rotateAngleY) * 5.0F;
        this.handL.rotationPointX = MathHelper.cos(this.body.rotateAngleY) * 5.0F;
        this.handR.rotateAngleY += this.body.rotateAngleY;
        this.handL.rotateAngleY += this.body.rotateAngleY;
        this.handL.rotateAngleX += this.body.rotateAngleY;
        f1 = 1.0F - this.swingProgress;
        f1 = f1 * f1;
        f1 = f1 * f1;
        f1 = 1.0F - f1;
        float f2 = MathHelper.sin(f1 * (float) Math.PI);
        float f3 = MathHelper.sin(this.swingProgress * (float) Math.PI) * -(this.head.rotateAngleX - 0.7F) * 0.75F;
        modelrenderer.rotateAngleX = (float) ((double) modelrenderer.rotateAngleX - ((double) f2 * 1.2D + (double) f3));
        modelrenderer.rotateAngleY += this.body.rotateAngleY * 2.0F;
        modelrenderer.rotateAngleZ += MathHelper.sin(this.swingProgress * (float) Math.PI) * -0.4F;
    }

    this.body.rotateAngleX = 0.0F;

    this.handR.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
    this.handL.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
    this.handR.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
    this.handL.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
}
 
Example 7
Source File: ModelTofuMindCore.java    From TofuCraftReload with MIT License 4 votes vote down vote up
protected ModelRenderer getArmForSide(EnumHandSide side) {
    return side == EnumHandSide.LEFT ? this.handL : handR;
}
 
Example 8
Source File: CraftHumanEntity.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public MainHand getMainHand() {
    return getHandle().getPrimaryHand() == EnumHandSide.LEFT ? MainHand.LEFT : MainHand.RIGHT;
}
 
Example 9
Source File: EssentialsMissingHandlerClient.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent(priority=EventPriority.LOWEST)
public void handleMissingEssentials(LivingUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (e != null && e == Minecraft.getMinecraft().thePlayer)
	{
		ICyberwareUserData cyberware = CyberwareAPI.getCapability(e);
		GameSettings settings = Minecraft.getMinecraft().gameSettings;
		boolean stillMissingArm = false;
		boolean stillMissingSecondArm = false;
		
		boolean leftUnpowered = false;
		ItemStack armLeft = cyberware.getCyberware(new ItemStack(CyberwareContent.cyberlimbs, 1, 0));
		if (armLeft != null && !ItemCyberlimb.isPowered(armLeft))
		{
			leftUnpowered = true;
		}
		
		boolean rightUnpowered = false;
		ItemStack armRight = cyberware.getCyberware(new ItemStack(CyberwareContent.cyberlimbs, 1, 1));
		if (armRight != null && !ItemCyberlimb.isPowered(armRight))
		{
			rightUnpowered = true;
		}
		
		
		boolean hasSkin = cyberware.isCyberwareInstalled(new ItemStack(CyberwareContent.skinUpgrades, 1, 2));
		hasRoboLeft = armLeft != null && !hasSkin;
		hasRoboRight = armRight != null && !hasSkin;
		boolean hasRightArm = cyberware.hasEssential(EnumSlot.ARM, EnumSide.RIGHT) && !rightUnpowered;
		boolean hasLeftArm = cyberware.hasEssential(EnumSlot.ARM, EnumSide.LEFT) && !leftUnpowered;
		
		if (!hasRightArm)
		{
			if (settings.mainHand != EnumHandSide.LEFT)
			{
				oldHand = settings.mainHand;
				settings.mainHand = EnumHandSide.LEFT;
				settings.sendSettingsToServer();
			}

			if (!missingArm)
			{
				missingArm = true;
			}
			stillMissingArm = true;


			if (!hasLeftArm)
			{
				if (!missingSecondArm)
				{
					missingSecondArm = true;
				}
				stillMissingSecondArm = true;
			}

		}
		else if (!hasLeftArm)
		{
			if (settings.mainHand != EnumHandSide.RIGHT)
			{
				oldHand = settings.mainHand;
				settings.mainHand = EnumHandSide.RIGHT;
				settings.sendSettingsToServer();
			}

			if (!missingArm)
			{
				missingArm = true;
			}
			stillMissingArm = true;
		

			if (!hasRightArm)
			{
				if (!missingSecondArm)
				{
					missingSecondArm = true;
				}
				stillMissingSecondArm = true;
			}

		}

		if (!stillMissingArm && oldHand != null)
		{
			missingArm = false;
			settings.mainHand = oldHand;
			settings.sendSettingsToServer();
		
		}

		if (!stillMissingSecondArm)
		{
			missingSecondArm = false;
		}
	}
}
 
Example 10
Source File: RendererBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount,
                          float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
	
	IBackpack backpack;
	RenderOptions renderOptions;
	if (_overrideBackpack != null) {
		backpack = _overrideBackpack;
		renderOptions = _overrideRenderOptions;
	} else {
		backpack = BackpackHelper.getBackpack(entity);
		BackpackEntityEntry entry = BackpackRegistry.getEntityEntry(entity.getClass());
		renderOptions = (entry != null) ? entry.renderOptions : null;
	}
	if ((backpack == null) || (renderOptions == null)) return;
	
	GlStateManager.pushMatrix();
	
	if (entity.isChild()) {
		GlStateManager.scale(0.5F, 0.5F, 0.5F);
		GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
	}
	
	ModelBase modelBase = this.livingEntityRenderer.getMainModel();
	if (modelBase instanceof ModelBiped) {
		ModelRenderer bipedBody = ((ModelBiped) modelBase).bipedBody;
		
		if (entity.isSneaking()) {
			// FIXME: Can be sneaking while flying with the elytra, then backpack is misaligned..?
			GlStateManager.translate(0.0F, 0.2F, 0.0F);
		}
		
		bipedBody.postRender(scale);
	} else {
		// Fallback to the custom way of transforming the backpack.
		// Make backpack swing with body as players swing their arms.
		float swingProgress = entity.getSwingProgress(partialTicks);
		float swingAngle = MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float)Math.PI * 2.0F)) * 0.2F;
		if ((entity.swingingHand == EnumHand.OFF_HAND) ^
		    (entity.getPrimaryHand() == EnumHandSide.LEFT)) swingAngle *= -1;
		if (swingAngle != 0) GlStateManager.rotate((float)Math.toDegrees(swingAngle), 0.0F, 1.0F, 0.0F);
		
		// Rotate backpack if entity is sneaking.
		if (entity.isSneaking()) {
			// FIXME: Can be sneaking while flying with the elytra, then backpack is misaligned..?
			GlStateManager.translate(0.0F, 0.2F, 0.0F);
			GlStateManager.rotate(90.0F / (float)Math.PI, 1.0F, 0.0F, 0.0F);
		}
	}
	
	GlStateManager.scale(renderOptions.scale, renderOptions.scale, renderOptions.scale);
	GlStateManager.translate(8.0F * scale, renderOptions.y * scale, renderOptions.z * scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate((float)renderOptions.rotate, 1.0F, 0.0F, 0.0F);
	GlStateManager.translate(0, ProxyClient.MODEL_BACKPACK_BOX.maxY * scale * -16,
	                            ProxyClient.MODEL_BACKPACK_BOX.minZ * scale * -16);
	
	renderBackpack(backpack, entity.ticksExisted + partialTicks, false);
	
	GlStateManager.popMatrix();
	
}