Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Armours and Bows texture.


xXRoboJackXx
 Share

Recommended Posts

Hi, I'm wondering what the new code is for the textures of Armours and bows. I have the old codes but they don't seem to work anymore. If anyone can help please reply, if you want me to add the old codes then just ask.

 

Lastly, if you can answer this one:

 

            par1World.editingBlocks = true;

 

Editing blocks no longer works and I was wondering what the new thing for it was.

 

Thanks for reading.

Link to comment
Share on other sites

The method hasn't changed much, you just need to return an Icon instead of just an int specifying the Icon index.

public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)

Override that method in your Item class, it allows you to make a custom bow.

Link to comment
Share on other sites

So if this is my bow where would I put the icons and what code?

package mods.blueeagle.common.items;

import mods.blueeagle.common.mod.mod_TheGodMod;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
import net.minecraftforge.event.entity.player.ArrowNockEvent;

public class AngelBow extends Item
{
    public AngelBow(int par1)
    {
        super(par1);
        this.maxStackSize = 1;
        this.setMaxDamage(384);
        this.setCreativeTab(CreativeTabs.tabCombat);
    }

    public int getIconIndex(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
    {
    	if (usingItem != null && usingItem.getItem().itemID == mod_TheGodMod.AngelBow.itemID)
    	{
    		int X = usingItem.getMaxItemUseDuration() - useRemaining;
    		if (X >= 18) return 8;
    		if (X >  13) return 7;
    		if (X >   0) return 6;
    	
    	}
    	return getIconIndex(stack);
    }
    /**
     * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
     */
    public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
    {
        int var6 = this.getMaxItemUseDuration(par1ItemStack) - par4;

        ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, var6);
        MinecraftForge.EVENT_BUS.post(event);
        if (event.isCanceled())
        {
            return;
        }
        var6 = event.charge;

        boolean var5 = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;

        if (var5 || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID))
        {
            float var7 = (float)var6 / 20.0F;
            var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;

            if ((double)var7 < 0.1D)
            {
                return;
            }

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

            EntityArrow var8 = new EntityArrow(par2World, par3EntityPlayer, var7 * 2.0F);

            if (var7 == 1.0F)
            {
                var8.setIsCritical(true);
            }

            int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack);

            if (var9 > 0)
            {
                var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
            }

            int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack);

            if (var10 > 0)
            {
                var8.setKnockbackStrength(var10);
            }

            if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0)
            {
                var8.setFire(100);
            }

            par1ItemStack.damageItem(1, par3EntityPlayer);
            par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);

            if (var5)
            {
                var8.canBePickedUp = 2;
            }
            else
            {
                par3EntityPlayer.inventory.consumeInventoryItem(Item.arrow.itemID);
            }

            if (!par2World.isRemote)
            {
                par2World.spawnEntityInWorld(var8);
            }
        }
    }

    public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        return par1ItemStack;
    }

    /**
     * How long it takes to use or consume an item
     */
    public int getMaxItemUseDuration(ItemStack par1ItemStack)
    {
        return 72000;
    }

    /**
     * returns the action that specifies what animation to play when the items is being used
     */
    public EnumAction getItemUseAction(ItemStack par1ItemStack)
    {
        return EnumAction.bow;
    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
        MinecraftForge.EVENT_BUS.post(event);
        if (event.isCanceled())
        {
            return event.result;
        }

        if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID))
        {
            par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
        }

        return par1ItemStack;
    }

    /**
     * Return the enchantability factor of the item, most of the time is based on material.
     */
    public int getItemEnchantability()
    {
        return 1;
    }

@Override
public void func_94581_a(IconRegister iconRegister)
{
         iconIndex = iconRegister.func_94245_a("blueeagle:AngelBow");
}
}

 

And the same for armour:

package blueeagle.common.items;

import blueeagle.common.mod.mod_TheGodMod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraftforge.common.IArmorTextureProvider;

public class AngelArmor extends ItemArmor implements IArmorTextureProvider{

public AngelArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial,
		int par3, int par4) {
	super(par1, par2EnumArmorMaterial, par3, par4);

}
public String getTextureFile() {
return "/Textures/Items.png";
}
@Override
public String getArmorTextureFile(ItemStack itemstack) {
        if (itemstack.itemID == mod_TheGodMod.AngelHelmet.itemID || itemstack.itemID == mod_TheGodMod.AngelPlateBody.itemID || itemstack.itemID == mod_TheGodMod.AngelBoots.itemID) {
        	return "/armor/Angel_1.png";
        }
        if(itemstack.itemID == mod_TheGodMod.AngelPlateLegs.itemID) {
        	return "/armor/Angel_2.png";
        }
	return null;

}
{

}
}

And what code do I delete?

 

Thanks for the help if you do.

Link to comment
Share on other sites

First of all add the @Override annotation wherever you intend to override a method (if you don't know what that means, learn java first).

The methods that give errors are the methods that have changed from 1.4 to 1.5. Then read the following post to learn how textures work in 1.5:

http://www.minecraftforum.net/topic/1722368-15-icons-and-block-textures/

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
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.

 Share



×
×
  • Create New...

Important Information

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