Jump to content

Bow animations? [Solved & Explained by me][page 2]


xXRoboJackXx

Recommended Posts

so did his code work? if not you might want to show him your effort at using his suggested code and then he can help you, he is a smart guy dont argue you will lose.

 

As I said I probably typed it wrong so I'm going to keep going till I found it out, also I'm not arguing I know he's a smart guy so if he says that's probably the code I'm going to keep trying with that code.

Link to comment
Share on other sites

so did his code work? if not you might want to show him your effort at using his suggested code and then he can help you, he is a smart guy dont argue you will lose.

 

As I said I probably typed it wrong so I'm going to keep going till I found it out, also I'm not arguing I know he's a smart guy so if he says that's probably the code I'm going to keep trying with that code.

Link to comment
Share on other sites

so did his code work? if not you might want to show him your effort at using his suggested code and then he can help you, he is a smart guy dont argue you will lose.

 

As I said I probably typed it wrong so I'm going to keep going till I found it out, also I'm not arguing I know he's a smart guy so if he says that's probably the code I'm going to keep trying with that code.

 

would be much easier if you just posted the code where you tried his solution and then you can get help to what you typed wrongly? :P

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

so did his code work? if not you might want to show him your effort at using his suggested code and then he can help you, he is a smart guy dont argue you will lose.

 

As I said I probably typed it wrong so I'm going to keep going till I found it out, also I'm not arguing I know he's a smart guy so if he says that's probably the code I'm going to keep trying with that code.

 

would be much easier if you just posted the code where you tried his solution and then you can get help to what you typed wrongly? :P

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

so did his code work? if not you might want to show him your effort at using his suggested code and then he can help you, he is a smart guy dont argue you will lose.

 

As I said I probably typed it wrong so I'm going to keep going till I found it out, also I'm not arguing I know he's a smart guy so if he says that's probably the code I'm going to keep trying with that code.

 

would be much easier if you just posted the code where you tried his solution and then you can get help to what you typed wrongly? :P

 

 

Kk Here is my tries from today:

Try one:

 

 

package mods.blueeagle.common.items;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.util.Icon;
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 static final String[] bowPullIconNameArray = new String[] {"blueeagle:angelbow_pull_0", "blueeagle:angelbow_pull_1", "blueeagle:angelbow_pull_2"};
    @SideOnly(Side.CLIENT)
    private Icon[] iconArray;

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

    /**
     * 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 j = this.getMaxItemUseDuration(par1ItemStack) - par4;

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

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

        if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID))
        {
            float f = (float)j / 20.0F;
            f = (f * f + f * 2.0F) / 3.0F;

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

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

            EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);

            if (f == 1.0F)
            {
                entityarrow.setIsCritical(true);
            }

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

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

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

            if (l > 0)
            {
                entityarrow.setKnockbackStrength(l);
            }

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

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

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

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

    public ItemStack onEaten(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 updateIcons(IconRegister reg)
    {
             this.iconIndex = reg.registerIcon("blueeagle:AngelBow");
    }
             public Icon getIconIndex(IconRegister reg, 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) this.iconIndex = reg.registerIcon("blueeagle:AngelBow1");
          if (X >  13) this.iconIndex = reg.registerIcon("blueeagle:AngelBow2");
          if (X >   0) this.iconIndex = reg.registerIcon("blueeagle:AngelBow3");
       
       
}
return iconIndex;
}
}

 

 

Try 2:

 

package mods.blueeagle.common.items;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.util.Icon;
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 static final String[] bowPullIconNameArray = new String[] {"blueeagle:angelbow_pull_0", "blueeagle:angelbow_pull_1", "blueeagle:angelbow_pull_2"};
    @SideOnly(Side.CLIENT)
    private Icon[] iconArray;

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

    /**
     * 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 j = this.getMaxItemUseDuration(par1ItemStack) - par4;

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

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

        if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID))
        {
            float f = (float)j / 20.0F;
            f = (f * f + f * 2.0F) / 3.0F;

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

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

            EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);

            if (f == 1.0F)
            {
                entityarrow.setIsCritical(true);
            }

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

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

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

            if (l > 0)
            {
                entityarrow.setKnockbackStrength(l);
            }

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

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

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

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

    public ItemStack onEaten(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;
    }
    


    @SideOnly(Side.CLIENT)
    public void updateIcons(IconRegister par1IconRegister)
    {
        super.updateIcons(par1IconRegister);
        this.iconArray = new Icon[bowPullIconNameArray.length];

        for (int i = 0; i < this.iconArray.length; ++i)
        {
            this.iconArray[i] = par1IconRegister.registerIcon(bowPullIconNameArray[i]);
            this.iconIndex = par1IconRegister.registerIcon("blueeagle:AngelBow");

        }
    }

    @SideOnly(Side.CLIENT)
    public Icon func_94599_c(int par1)
    {
        return this.iconArray[par1];
    }
    
}

 

Link to comment
Share on other sites

so did his code work? if not you might want to show him your effort at using his suggested code and then he can help you, he is a smart guy dont argue you will lose.

 

As I said I probably typed it wrong so I'm going to keep going till I found it out, also I'm not arguing I know he's a smart guy so if he says that's probably the code I'm going to keep trying with that code.

 

would be much easier if you just posted the code where you tried his solution and then you can get help to what you typed wrongly? :P

 

 

Kk Here is my tries from today:

Try one:

 

 

package mods.blueeagle.common.items;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.util.Icon;
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 static final String[] bowPullIconNameArray = new String[] {"blueeagle:angelbow_pull_0", "blueeagle:angelbow_pull_1", "blueeagle:angelbow_pull_2"};
    @SideOnly(Side.CLIENT)
    private Icon[] iconArray;

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

    /**
     * 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 j = this.getMaxItemUseDuration(par1ItemStack) - par4;

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

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

        if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID))
        {
            float f = (float)j / 20.0F;
            f = (f * f + f * 2.0F) / 3.0F;

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

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

            EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);

            if (f == 1.0F)
            {
                entityarrow.setIsCritical(true);
            }

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

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

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

            if (l > 0)
            {
                entityarrow.setKnockbackStrength(l);
            }

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

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

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

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

    public ItemStack onEaten(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 updateIcons(IconRegister reg)
    {
             this.iconIndex = reg.registerIcon("blueeagle:AngelBow");
    }
             public Icon getIconIndex(IconRegister reg, 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) this.iconIndex = reg.registerIcon("blueeagle:AngelBow1");
          if (X >  13) this.iconIndex = reg.registerIcon("blueeagle:AngelBow2");
          if (X >   0) this.iconIndex = reg.registerIcon("blueeagle:AngelBow3");
       
       
}
return iconIndex;
}
}

 

 

Try 2:

 

package mods.blueeagle.common.items;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.util.Icon;
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 static final String[] bowPullIconNameArray = new String[] {"blueeagle:angelbow_pull_0", "blueeagle:angelbow_pull_1", "blueeagle:angelbow_pull_2"};
    @SideOnly(Side.CLIENT)
    private Icon[] iconArray;

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

    /**
     * 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 j = this.getMaxItemUseDuration(par1ItemStack) - par4;

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

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

        if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID))
        {
            float f = (float)j / 20.0F;
            f = (f * f + f * 2.0F) / 3.0F;

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

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

            EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);

            if (f == 1.0F)
            {
                entityarrow.setIsCritical(true);
            }

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

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

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

            if (l > 0)
            {
                entityarrow.setKnockbackStrength(l);
            }

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

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

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

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

    public ItemStack onEaten(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;
    }
    


    @SideOnly(Side.CLIENT)
    public void updateIcons(IconRegister par1IconRegister)
    {
        super.updateIcons(par1IconRegister);
        this.iconArray = new Icon[bowPullIconNameArray.length];

        for (int i = 0; i < this.iconArray.length; ++i)
        {
            this.iconArray[i] = par1IconRegister.registerIcon(bowPullIconNameArray[i]);
            this.iconIndex = par1IconRegister.registerIcon("blueeagle:AngelBow");

        }
    }

    @SideOnly(Side.CLIENT)
    public Icon func_94599_c(int par1)
    {
        return this.iconArray[par1];
    }
    
}

 

Link to comment
Share on other sites

Did you even read my post? You have NOT done anything that looks anywhere near what I have suggested. If you are just copy-pasting code (your code looks like that!) you need to go and learn java first. making a copy-paste mod is not a good idea.

 

Fixed it thanks for the help. Topic locked.

Link to comment
Share on other sites

Did you even read my post? You have NOT done anything that looks anywhere near what I have suggested. If you are just copy-pasting code (your code looks like that!) you need to go and learn java first. making a copy-paste mod is not a good idea.

 

Fixed it thanks for the help. Topic locked.

Link to comment
Share on other sites

Topic Unlocked.

 

Well let me give the code and explain a bit of it.

 

Just a note the "Texture" from the code (a name I use) Can be anything like wibbly wobbaly or anything it's just a name that you give it, but if you call it something like bow then you'll need to write bow for all of them. Same with N and Time.

  @SideOnly(Side.CLIENT)
    
    private Icon[] Texture = new Icon[4];
    public void updateIcons(IconRegister iconRegister)
    
    {
    	
             iconIndex = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_0");
             for (int N = 0; N < 4; N++)
             {
                     this.Texture[N] = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_" + N);
                     
             }
    }
    public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
    {
             if(player.getItemInUse() == null) return this.iconIndex;
             int time = stack.getMaxItemUseDuration() - useRemaining;
             if (time >= 18)
             {
                     return Texture[3];
             }
             else if (time > 13)
             {
                     return Texture[2];
             }
             else if (time > 0)
             {
                     return Texture[1];
             }             
             return Texture[0];
             }
    }

What this:

    private Icon[] Texture= new Icon[4];

Is doing is registering what the Texture does so that code works.

 

This:

    public void updateIcons(IconRegister iconRegister)

Is the method.

 

This:

             iconIndex = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_0");

Is saying that the mod folder location is at blueeagle and the : is saying that it's going to find a texture in there.

The + getUnlocalizedName() is saying that the unlocalized name for this item is the first part of the texture (the name)

The .substring(5) gets rid of the "item." from the beginning of the string.

The +_0 is adding on a "_0" to the code of the texture. And then the for (int N = 0 < 4; N++) is saying that the number 0 = N and the can only be less then 4.

                     this.Texture[N] = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_" + N);

Which is saying this Icon[number] = the method iconRegisterIcon("Foldername:" and then it gets the name, takes off the item and adds on the _ and number of the image.

 

This:

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

Is the method that will be needed for the rest of the code.

 

This:

             if(player.getItemInUse() == null) return this.iconIndex;
             int time = stack.getMaxItemUseDuration() - useRemaining;

Is when the player is using the bow and int time is: stack.getMaxItemUseDuration() - useRemaining;

 

this:

  if (time >= 18)
             {
                     return Texture[3];
             }
             else if (time > 13)
             {
                     return Texture[2];
             }
             else if (time > 0)
             {
                     return Texture[1];
             }             
             return Texture[0];
             }
    }

This is saying that if time is greater then 18 (The time)

then it will = the return Texture[3]

which is the texture.

So this is going back to the method we write for the Texture which is the unlocalized name and the foldername with the _ and remember that the [N] will be a number so you write [3] in there which will make the code know that inside the [] is a number and this will make the code know now that the texture is located somewhere in the folder blueeagle (and my unlocalized name is AngelBow) it'll add a _ and the number which in this case is 3 so it's looking for the texture which is called

AngelBow_3

then I'm pretty sure you can work out what the else ifs mean.

 

and the return Texture[0] is the bow when not in use.

 

Hope I explained that well :)

Link to comment
Share on other sites

Topic Unlocked.

 

Well let me give the code and explain a bit of it.

 

Just a note the "Texture" from the code (a name I use) Can be anything like wibbly wobbaly or anything it's just a name that you give it, but if you call it something like bow then you'll need to write bow for all of them. Same with N and Time.

  @SideOnly(Side.CLIENT)
    
    private Icon[] Texture = new Icon[4];
    public void updateIcons(IconRegister iconRegister)
    
    {
    	
             iconIndex = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_0");
             for (int N = 0; N < 4; N++)
             {
                     this.Texture[N] = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_" + N);
                     
             }
    }
    public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
    {
             if(player.getItemInUse() == null) return this.iconIndex;
             int time = stack.getMaxItemUseDuration() - useRemaining;
             if (time >= 18)
             {
                     return Texture[3];
             }
             else if (time > 13)
             {
                     return Texture[2];
             }
             else if (time > 0)
             {
                     return Texture[1];
             }             
             return Texture[0];
             }
    }

What this:

    private Icon[] Texture= new Icon[4];

Is doing is registering what the Texture does so that code works.

 

This:

    public void updateIcons(IconRegister iconRegister)

Is the method.

 

This:

             iconIndex = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_0");

Is saying that the mod folder location is at blueeagle and the : is saying that it's going to find a texture in there.

The + getUnlocalizedName() is saying that the unlocalized name for this item is the first part of the texture (the name)

The .substring(5) gets rid of the "item." from the beginning of the string.

The +_0 is adding on a "_0" to the code of the texture. And then the for (int N = 0 < 4; N++) is saying that the number 0 = N and the can only be less then 4.

                     this.Texture[N] = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_" + N);

Which is saying this Icon[number] = the method iconRegisterIcon("Foldername:" and then it gets the name, takes off the item and adds on the _ and number of the image.

 

This:

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

Is the method that will be needed for the rest of the code.

 

This:

             if(player.getItemInUse() == null) return this.iconIndex;
             int time = stack.getMaxItemUseDuration() - useRemaining;

Is when the player is using the bow and int time is: stack.getMaxItemUseDuration() - useRemaining;

 

this:

  if (time >= 18)
             {
                     return Texture[3];
             }
             else if (time > 13)
             {
                     return Texture[2];
             }
             else if (time > 0)
             {
                     return Texture[1];
             }             
             return Texture[0];
             }
    }

This is saying that if time is greater then 18 (The time)

then it will = the return Texture[3]

which is the texture.

So this is going back to the method we write for the Texture which is the unlocalized name and the foldername with the _ and remember that the [N] will be a number so you write [3] in there which will make the code know that inside the [] is a number and this will make the code know now that the texture is located somewhere in the folder blueeagle (and my unlocalized name is AngelBow) it'll add a _ and the number which in this case is 3 so it's looking for the texture which is called

AngelBow_3

then I'm pretty sure you can work out what the else ifs mean.

 

and the return Texture[0] is the bow when not in use.

 

Hope I explained that well :)

Link to comment
Share on other sites

RoboJack, thanks for posting your solution once you figured it out. I've been struggling with the same thing, and that was really helpful.

 

Why did you pick the numbers 13 and 18 for the times? Is that the same timing for regular bows or your own timing?

Link to comment
Share on other sites

RoboJack, thanks for posting your solution once you figured it out. I've been struggling with the same thing, and that was really helpful.

 

Why did you pick the numbers 13 and 18 for the times? Is that the same timing for regular bows or your own timing?

 

It's the same timing as regular bows, glad I could help :)

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
  • Topics

×
×
  • Create New...

Important Information

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