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

The following examples show how to use net.minecraft.util.EnumHandSide#RIGHT . 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: ItemHandUpgrade.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent
public void handleMining(HarvestCheck event)
{
	EntityPlayer p = event.getEntityPlayer();
	ItemStack test = new ItemStack(this, 1, 2);
	boolean rightArm = (p.getPrimaryHand() == EnumHandSide.RIGHT ? 
			(CyberwareAPI.isCyberwareInstalled(p, new ItemStack(CyberwareContent.cyberlimbs, 1, 1))) : 
			(CyberwareAPI.isCyberwareInstalled(p, new ItemStack(CyberwareContent.cyberlimbs, 1, 0))));
	if (rightArm && CyberwareAPI.isCyberwareInstalled(p, test) && p.getHeldItemMainhand() == null)
	{
		ItemStack pick = new ItemStack(Items.STONE_PICKAXE);
		if (pick.canHarvestBlock(event.getTargetBlock()))
		{
			event.setCanHarvest(true);
		}
	}
}
 
Example 2
Source File: RenderCodex.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void renderItemInFirstPerson(AbstractClientPlayer player, EnumHand hand, float swingProgress, ItemStack stack, float equipProgress) {
	// Cherry picked from ItemRenderer.renderItemInFirstPerson
	boolean flag = hand == EnumHand.MAIN_HAND;
	EnumHandSide enumhandside = flag ? player.getPrimaryHand() : player.getPrimaryHand().opposite();
	GlStateManager.pushMatrix();
	boolean flag1 = enumhandside == EnumHandSide.RIGHT;
	float f = -0.4F * MathHelper.sin(MathHelper.sqrt(swingProgress) * (float) Math.PI);
	float f1 = 0.2F * MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float) Math.PI * 2F));
	float f2 = -0.2F * MathHelper.sin(swingProgress * (float) Math.PI);
	int i = flag1 ? 1 : -1;
	GlStateManager.translate(i * f, f1, f2);
	transformSideFirstPerson(enumhandside, equipProgress);
	transformFirstPerson(enumhandside, swingProgress);
	RenderCodex.INSTANCE.doRender(enumhandside, stack);
	GlStateManager.popMatrix();
}
 
Example 3
Source File: LayerTofunianHeldItem.java    From TofuCraftReload with MIT License 6 votes vote down vote up
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    boolean flag = entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT;
    ItemStack itemstack = flag ? entitylivingbaseIn.getHeldItemOffhand() : entitylivingbaseIn.getHeldItemMainhand();
    ItemStack itemstack1 = flag ? entitylivingbaseIn.getHeldItemMainhand() : entitylivingbaseIn.getHeldItemOffhand();

    if (!itemstack.isEmpty() || !itemstack1.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(entitylivingbaseIn, itemstack1, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT);
        this.renderHeldItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT);
        GlStateManager.popMatrix();
    }
}
 
Example 4
Source File: RenderPlayerCyberware.java    From Cyberware with MIT License 6 votes vote down vote up
@Override
public void renderRightArm(AbstractClientPlayer clientPlayer)
{
	Minecraft.getMinecraft().getTextureManager().bindTexture(robo);
	super.renderRightArm(clientPlayer);
	
	if (CyberwareAPI.isCyberwareInstalled(clientPlayer, new ItemStack(CyberwareContent.handUpgrades, 1, 1)) && CyberwareAPI.isCyberwareInstalled(clientPlayer, new ItemStack(CyberwareContent.cyberlimbs, 1, 1)) && Minecraft.getMinecraft().gameSettings.mainHand == EnumHandSide.RIGHT && 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 5
Source File: ItemHandUpgrade.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent
public void handleMineSpeed(BreakSpeed event)
{
	EntityPlayer p = event.getEntityPlayer();
	ItemStack test = new ItemStack(this, 1, 2);
	boolean rightArm = (p.getPrimaryHand() == EnumHandSide.RIGHT ? 
					(CyberwareAPI.isCyberwareInstalled(p, new ItemStack(CyberwareContent.cyberlimbs, 1, 1))) : 
					(CyberwareAPI.isCyberwareInstalled(p, new ItemStack(CyberwareContent.cyberlimbs, 1, 0))));
	if (rightArm && CyberwareAPI.isCyberwareInstalled(p, test) && p.getHeldItemMainhand() == null)
	{
		ItemStack pick = new ItemStack(Items.STONE_PICKAXE);
		event.setNewSpeed(event.getNewSpeed() * pick.getStrVsBlock(p.worldObj.getBlockState(event.getPos())));
	}
}
 
Example 6
Source File: ModelTofuMindCore.java    From TofuCraftReload with MIT License 5 votes vote down vote up
protected EnumHandSide getMainHand(Entity entityIn) {
    if (entityIn instanceof EntityLivingBase) {
        EntityLivingBase entitylivingbase = (EntityLivingBase) entityIn;
        EnumHandSide enumhandside = entitylivingbase.getPrimaryHand();
        return entitylivingbase.swingingHand == EnumHand.MAIN_HAND ? enumhandside : enumhandside.opposite();
    } else {
        return EnumHandSide.RIGHT;
    }
}
 
Example 7
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 8
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 5 votes vote down vote up
private void transformFirstPerson(EnumHandSide p_187453_1_, float p_187453_2_)
{
	int i = p_187453_1_ == EnumHandSide.RIGHT ? 1 : -1;
	float f = MathHelper.sin(p_187453_2_ * p_187453_2_ * (float)Math.PI);
	GlStateManager.rotate((float)i * (45.0F + f * -20.0F), 0.0F, 1.0F, 0.0F);
	float f1 = MathHelper.sin(MathHelper.sqrt_float(p_187453_2_) * (float)Math.PI);
	GlStateManager.rotate((float)i * f1 * -20.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(f1 * -80.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate((float)i * -45.0F, 0.0F, 1.0F, 0.0F);
}
 
Example 9
Source File: ItemHandUpgrade.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent(priority=EventPriority.NORMAL)
public void handleLivingUpdate(CyberwareUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	ItemStack test = new ItemStack(this, 1, 1);
	if (CyberwareAPI.isCyberwareInstalled(e, test))
	{
		boolean last = getLastClaws(e);
		boolean isEquipped = e.getHeldItemMainhand() == null && 
				(e.getPrimaryHand() == EnumHandSide.RIGHT ? 
						(CyberwareAPI.isCyberwareInstalled(e, new ItemStack(CyberwareContent.cyberlimbs, 1, 1))) : 
						(CyberwareAPI.isCyberwareInstalled(e, new ItemStack(CyberwareContent.cyberlimbs, 1, 0))));
		if (isEquipped && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(e, test)))
		{
			this.addUnarmedDamage(e, test);
			lastClaws.put(e.getEntityId(), true);

			if (!last)
			{
				if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
				{
					updateHand(e, true);
				}
			}
		}
		else
		{
			this.removeUnarmedDamage(e, test);
			lastClaws.put(e.getEntityId(), false);
		}
		
	}
	else
	{
		
		lastClaws.put(e.getEntityId(), false);
	}
}
 
Example 10
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 11
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 12
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 4 votes vote down vote up
private void transformSideFirstPerson(EnumHandSide p_187459_1_, float p_187459_2_)
{
	int i = p_187459_1_ == EnumHandSide.RIGHT ? 1 : -1;
	GlStateManager.translate((float)i * 0.56F, -0.52F + p_187459_2_ * -0.6F, -0.72F);
}
 
Example 13
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();
}
 
Example 14
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 15
Source File: HudRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public static void renderHud(Post event) {
	ScaledResolution resolution = event.getResolution();
	int width = resolution.getScaledWidth();
	int height = resolution.getScaledHeight();
	EntityPlayer player = Minecraft.getMinecraft().player;

	ItemStack stack = BaublesSupport.getItem(player, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO);
	if (stack.isEmpty()) return;

	if (event.getType() == ElementType.EXPERIENCE) {

		int barSide = Minecraft.getMinecraft().gameSettings.mainHand == EnumHandSide.RIGHT ? 1 : -1;
		barSide *= Minecraft.getMinecraft().gameSettings.attackIndicator == 2 ? -1 : 1;

		int right = ((width / 2) - (100 / 2)) + 155 * barSide;
		int top = height - 17;

		HUD_TEXTURE.bind();

		GlStateManager.pushMatrix();
		GlStateManager.color(1.0F, 1.0F, 1.0F);
		emptyManaBar.draw(ClientTickHandler.getTicks(), right, top);
		emptyBurnoutBar.draw(ClientTickHandler.getTicks(), right, top + 6);
		GlStateManager.popMatrix();

		try (ManaManager.CapManagerBuilder mgr = ManaManager.forObject(player)) {
			double mana = mgr.getMana();
			double burnout = mgr.getBurnout();
			double maxMana = mgr.getMaxMana();
			double maxBurnout = mgr.getMaxBurnout();

			GlStateManager.pushMatrix();
			GlStateManager.color(1.0F, 1.0F, 1.0F);
			int visualManaLength = 0;
			if (mana > 0)
				visualManaLength = (int) (((mana * 100) / maxMana) % 101);
			fullManaBar.draw(ClientTickHandler.getTicks(), right, top, visualManaLength, 5);

			GlStateManager.color(1.0F, 1.0F, 1.0F);

			int visualBurnoutLength = 0;
			if (burnout > 0)
				visualBurnoutLength = (int) (((burnout * 100) / maxBurnout) % 101);
			fullBurnoutBar.draw(ClientTickHandler.getTicks(), right, top + 6, visualBurnoutLength, 5);

			GlStateManager.popMatrix();
		}
	}
}
 
Example 16
Source File: RenderCodex.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static void transformSideFirstPerson(EnumHandSide p_187459_1_, float p_187459_2_) {
	int i = p_187459_1_ == EnumHandSide.RIGHT ? 1 : -1;
	GlStateManager.translate(i * 0.56F, -0.44F + p_187459_2_ * -0.8F, -0.72F);
}
 
Example 17
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 18
Source File: ModelSamuraiIllager.java    From Sakura_mod with MIT License 4 votes vote down vote up
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.arms.rotationPointY = 3.0F;
    this.arms.rotationPointZ = -1.0F;
    this.arms.rotateAngleX = -0.75F;
    this.leg0.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount * 0.5F;
    this.leg1.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 1.4F * limbSwingAmount * 0.5F;
    this.leg0.rotateAngleY = 0.0F;
    this.leg1.rotateAngleY = 0.0F;
    AbstractIllager.IllagerArmPose abstractillager$illagerarmpose = ((AbstractIllager) entityIn).getArmPose();

    if (abstractillager$illagerarmpose == AbstractIllager.IllagerArmPose.ATTACKING) {
        float f = MathHelper.sin(this.swingProgress * (float) Math.PI);
        float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float) Math.PI);
        this.rightArm.rotateAngleZ = -0.3363323129985824F;
        this.leftArm.rotateAngleZ = 0.3363323129985824F;
        this.rightArm.rotateAngleY = -0.3363323129985824F;
        this.leftArm.rotateAngleY = 0.3363323129985824F;

        if (((EntityLivingBase) entityIn).getPrimaryHand() == EnumHandSide.RIGHT) {
            this.rightArm.rotateAngleX = -1.4849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F;
            this.leftArm.rotateAngleX = -1.4849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F;
            this.rightArm.rotateAngleX += f * 2.2F - f1 * 0.4F;
            this.leftArm.rotateAngleX += f * 2.2F - f1 * 0.4F;
        } else {
            this.rightArm.rotateAngleX = -1.4849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F;
            this.leftArm.rotateAngleX = -1.4849558F + MathHelper.cos(ageInTicks * 0.09F) * 0.15F;
            this.rightArm.rotateAngleX += f * 2.2F - f1 * 0.4F;
            this.leftArm.rotateAngleX += f * 2.2F - f1 * 0.4F;
        }

        this.rightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
        this.leftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
        this.rightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.09F) * 0.05F;
        this.leftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.09F) * 0.05F;
    } else if (abstractillager$illagerarmpose == AbstractIllager.IllagerArmPose.SPELLCASTING) {
        this.rightArm.rotationPointZ = 0.0F;
        this.rightArm.rotationPointX = -5.0F;
        this.leftArm.rotationPointZ = 0.0F;
        this.leftArm.rotationPointX = 5.0F;
        this.rightArm.rotateAngleX = MathHelper.cos(ageInTicks * 0.6662F) * 0.25F;
        this.leftArm.rotateAngleX = MathHelper.cos(ageInTicks * 0.6662F) * 0.25F;
        this.rightArm.rotateAngleZ = 2.3561945F;
        this.leftArm.rotateAngleZ = -2.3561945F;
        this.rightArm.rotateAngleY = 0.0F;
        this.leftArm.rotateAngleY = 0.0F;
    } else if (abstractillager$illagerarmpose == AbstractIllager.IllagerArmPose.BOW_AND_ARROW) {
        this.rightArm.rotateAngleY = -0.1F + this.head.rotateAngleY;
        this.rightArm.rotateAngleX = -((float) Math.PI / 2F) + this.head.rotateAngleX;
        this.leftArm.rotateAngleX = -0.9424779F + this.head.rotateAngleX;
        this.leftArm.rotateAngleY = this.head.rotateAngleY - 0.4F;
        this.leftArm.rotateAngleZ = ((float) Math.PI / 2F);
    }
}
 
Example 19
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 20
Source File: ModelTofuGandlem.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.handR2.rotateAngleX = -0.9560913642424937F;
    this.handL2.rotateAngleX = -0.9560913642424937F;

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

    float f = ageInTicks - (float) entityIn.ticksExisted;

    float f1 = ((EntityTofuGandlem) entityIn).getAttackingAnimationScale(f);

    f1 = f1 * f1;

    float f2 = ((EntityTofuGandlem) entityIn).getSpellCastingAnimationScale(f);

    f2 = f2 * f2;

    float f3 = ((EntityTofuGandlem) entityIn).getSoyShotAnimationScale(f);

    f3 = f3 * f3;

    if (f2 > 0) {
        this.handR.rotateAngleX = (MathHelper.cos(ageInTicks * 0.6662F) * 0.2F) * f2;
        this.handL.rotateAngleX = (MathHelper.cos(ageInTicks * 0.6662F) * 0.2F) * f2;
        this.handR.rotateAngleZ = 2.3561945F * f2;
        this.handL.rotateAngleZ = -2.3561945F * f2;
        this.handR.rotateAngleY = 0.0F;
        this.handL.rotateAngleY = 0.0F;
        this.handR2.rotateAngleX = 0.0F;
        this.handL2.rotateAngleX = 0.0F;
    } else if (f3 > 0) {

        if (((EntityLivingBase) entityIn).getPrimaryHand() == EnumHandSide.RIGHT) {
            this.handR2.rotateAngleX = -0.6F + MathHelper.cos(ageInTicks * 0.04F) * 0.15F;
            this.handR.rotateAngleX = -1.2F + MathHelper.cos(ageInTicks * 0.04F) * 0.15F;
        } else {
            this.handL2.rotateAngleX = -0.6F + MathHelper.cos(ageInTicks * 0.04F) * 0.15F;
            this.handL.rotateAngleX = -1.2F + MathHelper.cos(ageInTicks * 0.04F) * 0.15F;
        }
    } else if (f1 > 0) {
        this.handR.rotateAngleZ = 0.0F;
        this.handL.rotateAngleZ = 0.0F;
        this.handR.rotateAngleY = 0.15707964F * f1;
        this.handL.rotateAngleY = -0.15707964F * f1;

        if (((EntityLivingBase) entityIn).getPrimaryHand() == EnumHandSide.RIGHT) {
            this.handR.rotateAngleX = -1.6F + MathHelper.cos(ageInTicks * 0.04F) * 0.15F;
        } else {
            this.handL.rotateAngleX = -1.6F + MathHelper.cos(ageInTicks * 0.04F) * 0.15F;
        }

        this.handR.rotateAngleZ += (MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F) * f1;
        this.handL.rotateAngleZ -= (MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F) * f1;
        this.handR.rotateAngleX += (MathHelper.cos(ageInTicks * 0.09F) * 0.05F) * f1;
        this.handL.rotateAngleX -= (MathHelper.cos(ageInTicks * 0.09F) * 0.05F) * f1;
    }
}