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

The following are Jave code examples for showing how to use getItemInUse() 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: minecraft-quiverbow   File: EnderBow.java   View Source Code Vote up 5 votes
@Override
   public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) 
{
	if(player.getItemInUse() == null) { return this.itemIcon; }
        
        int Pulling = stack.getMaxItemUseDuration() - useRemaining;	// Displaying the bow drawing animation based on the use state
       
        if (Pulling >= 18) { return this.pull_2; }
        else if (Pulling > 13) { return this.pull_1; }
        else if (Pulling > 0) { return this.pull_0; }              
        
        return itemIcon;
   }
 
Example 2
Project: minecraft-quiverbow   File: QuiverBow.java   View Source Code Vote up 5 votes
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) 	// On hand display
{
	if(player.getItemInUse() == null) { return this.itemIcon; }

	int Pulling = stack.getMaxItemUseDuration() - useRemaining;	// Displaying the bow drawing animation based on the use state

	if (Pulling >= 18) { return this.pull_2; }
	else if (Pulling > 13) { return this.pull_1; }
	else if (Pulling > 0) { return this.pull_0; }

	return this.itemIcon;
}
 
Example 3
Project: connor41-etfuturum2   File: ItemBowRenderer.java   View Source Code Vote up 4 votes
@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
	TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
	ResourceLocation resource = textureManager.getResourceLocation(stack.getItemSpriteNumber());

	EntityPlayer player = Minecraft.getMinecraft().thePlayer;
	ItemStack usingItem = player.getItemInUse();
	int useRemaining = player.getItemInUseCount();

	ItemBow bow = (ItemBow) stack.getItem();

	IIcon icon = bow.getIcon(stack, 0);
	if (usingItem != null && usingItem == stack) {
		int charge = stack.getMaxItemUseDuration() - useRemaining;
		if (charge >= 18)
			icon = bow.getItemIconForUseDuration(2);
		else if (charge > 13)
			icon = bow.getItemIconForUseDuration(1);
		else if (charge > 0)
			icon = bow.getItemIconForUseDuration(0);
	}
	if (icon == null)
		icon = ((TextureMap) textureManager.getTexture(resource)).getAtlasSprite("missingno");

	OpenGLHelper.pushMatrix();
	textureManager.bindTexture(resource);

	OpenGLHelper.colour(bow.getColorFromItemStack(stack, 0));

	OpenGLHelper.disableLighting();
	OpenGLHelper.enableAlpha();
	OpenGLHelper.enableBlend();
	OpenGlHelper.glBlendFunc(770, 771, 1, 0);

	renderItem.renderIcon(0, 0, icon, 16, 16);

	OpenGLHelper.enableLighting();
	OpenGLHelper.disableAlpha();
	OpenGLHelper.disableBlend();

	if (stack.hasEffect(0))
		renderItem.renderEffect(textureManager, 0, 0);

	OpenGLHelper.popMatrix();
}