Jump to content

[1.7.2] Render a custom bow as a vanilla bow


SackCastellon

Recommended Posts

I want my custom bow to render as the vanilla one do:

 

width=800 height=413https://dl.dropboxusercontent.com/u/184200482/img/bow_vanilla.png[/img]

 

Instead of the way it renders now:

 

width=800 height=413https://dl.dropboxusercontent.com/u/184200482/img/bow_custom.png[/img]

 

Here's the code:

package SackCastellon.betterwood.items;

import java.util.List;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import SackCastellon.betterwood.api.Tabs;
import SackCastellon.betterwood.loader.LoreLoader;
import SackCastellon.betterwood.reference.Reference;

public class ItemBow extends net.minecraft.item.ItemBow {

private final IIcon[] iconArray = new IIcon[3];

    private final String material;
    
private final String materialLore;

private final String lore = LoreLoader.Material;

public ItemBow(ItemPartMaterial material)
    {
	this.setCreativeTab(Tabs.tabBW);
	this.setMaxStackSize(1);
	this.setUnlocalizedName("Bow");
	this.setMaxDamage(384);

	this.material = material.getMaterial();
	this.materialLore = material.getLore();
    }

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
{
	list.add(this.lore + ": " + this.materialLore);

	if (itemStack.isItemEnchanted())
	{
		list.add("");
	}
}

    @Override
    public String getUnlocalizedName(ItemStack itemStack)
    {
        return super.getUnlocalizedName() + "." + this.material;
    }
    
    private String getPathForPull(int pull)
    {
    	return Reference.TexturePath + "bow/" + pull + "/" + this.material;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister iconRegister)
    {
        this.itemIcon = iconRegister.registerIcon(this.getPathForPull(0));

        for (int i = 0; i < 3; ++i)
        {
            this.iconArray[i] = iconRegister.registerIcon(this.getPathForPull(i + 1));
        }
    }

    @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;
    		
    	if (Pulling >= 18)
    	{
    		return iconArray[2];
    	}

    	else if (Pulling > 13)
    	{
    		return iconArray[1];
    	}

    	else if (Pulling > 0)
    	{
    		return iconArray[0];
    	}       
    	
    	return this.itemIcon;
    }
}

 

Thanks for helping  :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.