• 2

    posted a message on [1.4.2] Custom Bow Tutorial
    Quote from xzakosx

    For some reason my bow only has 10 uses!!?!?! can i cant figure out how to fix this... Please Help!

    package net.minecraft.src;
    
    import java.util.Random;
    
    public class ItemIronBow extends ItemBow
    {
    private Random rand = new Random();
    
    public ItemIronBow(int var1)
    {
    super(var1);
    this.maxStackSize = 1;
    this.setMaxDamage(10);
    this.bFull3D = true;
    this.setCreativeTab(CreativeTabs.tabCombat);
    }
    
    /**
    * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
    * update it's contents.
    */
    public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
    {
    EntityPlayer var6 = (EntityPlayer)var3;
    ItemStack var7 = var6.inventory.getCurrentItem();
    
    if (var6.isUsingItem() && var7.itemID == mod_MoreBows.IronBow.shiftedIndex)
    {
    int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
    
    if (var8 >= 18)
    {
    this.iconIndex = mod_MoreBows2.IronBow4;
    }
    else if (var8 > 13)
    {
    this.iconIndex = mod_MoreBows2.IronBow3;
    }
    else if (var8 > 0)
    {
    this.iconIndex = mod_MoreBows2.IronBow2;
    }
    }
    else
    {
    this.iconIndex = mod_MoreBows2.IronBow.iconIndex;
    }
    }
    
    /**
    * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
    */
    public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
    {
    boolean var5 = var3.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
    
    if (var5 || var3.inventory.hasItem(Item.arrow.shiftedIndex))
    {
    int var6 = this.getMaxItemUseDuration(var1) - var4;
    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(var2, var3, var7 * 2.0F);
    
    if (var7 == 1.0F)
    {
    var8.setIsCritical(true);
    }
    
    int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
    
    if (var9 > 0)
    {
    var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
    }
    
    int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
    
    if (var10 > 0)
    {
    var8.setKnockbackStrength(var10);
    }
    
    if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
    {
    var8.setFire(100);
    }
    
    var1.damageItem(1, var3);
    var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
    
    if (!var5)
    {
    var3.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
    }
    else
    {
    var8.canBePickedUp = 2;
    }
    
    if (!var2.isRemote)
    {
    var2.spawnEntityInWorld(var8);
    var8.setDamage(var8.getDamage() * 2.15D);
    this.iconIndex = mod_MoreBows.GoldBow1;
    }
    }
    
    ItemStack var11 = var3.inventory.getCurrentItem();
    
    if (var11.itemID != mod_MoreBows.GoldBow.shiftedIndex)
    {
    this.iconIndex = mod_MoreBows.GoldBow1;
    }
    }
    
    public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
    {
    return var1;
    }
    
    /**
    * How long it takes to use or consume an item
    */
    public int getMaxItemUseDuration(ItemStack var1)
    {
    return 72000;
    }
    
    /**
    * returns the action that specifies what animation to play when the items is being used
    */
    public EnumAction getItemUseAction(ItemStack var1)
    {
    return EnumAction.bow;
    }
    
    /**
    * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
    */
    public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
    {
    if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
    {
    var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
    }
    
    return var1;
    }
    
    /**
    * Return the enchantability factor of the item, most of the time is based on material.
    */
    public int getItemEnchantability()
    {
    return 1;
    }
    }


    public ItemIronBow(int var1)
    {
    super(var1);
    this.maxStackSize = 1;
    this.setMaxDamage(10);
    this.bFull3D = true;
    this.setCreativeTab(CreativeTabs.tabCombat);
    }

    Replace the 10 in...
    this.setMaxDamage(10);


    To whatever you want the damage to be. :)
    (Rep points please? :3)
    Posted in: Tutorials
  • 1

    posted a message on [1.4.2] Custom Bow Tutorial
    Quote from Sigma_Phi

    Thanks, adding another stage did exactly what I needed.

    I'm still having problems getting my custom arrow to render, but that's another issue.

    Thanks again!


    Hm, what do you mean getting it to render?
    No problem :D (I really want some reputation points, could ya help me out? :P)
    Posted in: Tutorials
  • 4

    posted a message on [1.4.2] Custom Bow Tutorial
    This is my first tutorial. Please correct me if I did anything wrong. :)
    (It uses ModLoader)

    I just started modding a few months ago, and now that 1.4.2 has come out, I had to update all my mods. First time I had to do that :) . So, even in 1.3, I couldn't find a very good bow tutorial. They were either broken, or didn't work so well. So, I found how to make it, although it doesn't function exactly as a normal bow. The FOV is not changed, and the animation appears in the hotbar. Anyways, without anymore delay, lets begin the tutorial! :P

    So. First, you want to add the following code to your mod_****.class
    public static final Item yourBowNameHere = (new ItemYourBowNameHere(ItemIDHere)).setItemName("yourBowNameHere");
    public static int yourBowNameHere1 = ModLoader.addOverride("/gui/items.png", "/yourBowNameHere1.png");
    public static int yourBowNameHere2 = ModLoader.addOverride("/gui/items.png", "/yourBowNameHere2.png");
    public static int yourBowNameHere3 = ModLoader.addOverride("/gui/items.png", "/yourBowNameHere3.png");
    public static int yourBowNameHere4 = ModLoader.addOverride("/gui/items.png", "/yourBowNameHere4.png");


    -Remember to rename everything to what you want.
    So what's happening in the code.
    You're creating a new Item, and a new class. You'll get errors at this point, but that's okay. We're not done.
    The new item that is created is ItemYourBowNameHere. You'll want to create a new ItemYourBowNameHere.class, but I'll show you what to put in there later.
    The other 4 items,
    public static int yourBowNameHere1 = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere1.png");
    public static int yourBowNameHere2 = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere2.png");
    public static int yourBowNameHere3 = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere3.png");
    public static int yourBowNameHere4 = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere4.png");

    , are just what I call temporary items, placeholders. They aren't those literally, but you can't actually do anything with them in-game.

    Where it says "/yourBowNameHere(#).png", that sets the image file. So if you set it to "/Textures/bow1.png your texture will be in minecraft.jar/Textures/bow1.png

    Now do the standard procedure for making items, for the main bow item.
    In case you don't know how to do that, put this into your public void load(){}
    codedBowNameHere.iconIndex = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere1.png");
    ModLoader.addName(codedBowNameHere, "In-Game Bow Name Here");
    ModLoader.addRecipe(new ItemStack(codedBowNameHere, 1), new Object[] {" ", " , " "});


    What's happening is you're adding the coded version into the game, declaring it's texture (the previous textures are for the stages of the bow, more explained later), declaring it's in-game name, and creating the recipe. Look up other tutorials for creating recipes.

    The next step, we're going to create the class for the bow. Everything that happens with the bow is coded here.
    Create a new class, and name it ItemYourBowNameHere -Remember to rename it to what you want. Inside the class, paste the following code...
    package net.minecraft.src;
    
    import java.util.Random;
    
    public class ItemYourBowNameHere extends ItemBow
    {
    private Random rand = new Random();
    
    public ItemYourBowNameHere(int var1)
    {
    super(var1);
    this.maxStackSize = 1;
    this.setMaxDamage(UseAmountHere);
    this.bFull3D = true;
    this.setCreativeTab(CreativeTabs.tabCombat);
    }
    
    /**
    * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
    * update it's contents.
    */
    public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
    {
    EntityPlayer var6 = (EntityPlayer)var3;
    ItemStack var7 = var6.inventory.getCurrentItem();
    
    if (var6.isUsingItem() && var7.itemID == mod_****.yourBowNameHere.shiftedIndex)
    {
    int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
    
    if (var8 >= 18)
    {
    this.iconIndex = mod_****.yourBowNameHere4;
    }
    else if (var8 > 13)
    {
    this.iconIndex = mod_****.yourBowNameHere3;
    }
    else if (var8 > 0)
    {
    this.iconIndex = mod_****.yourBowNameHere2;
    }
    }
    else
    {
    this.iconIndex = mod_****.yourBowNameHere.iconIndex;
    }
    }
    
    /**
    * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
    */
    public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
    {
    boolean var5 = var3.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
    
    if (var5 || var3.inventory.hasItem(Item.arrow.shiftedIndex))
    {
    int var6 = this.getMaxItemUseDuration(var1) - var4;
    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(var2, var3, var7 * 2.0F);
    
    if (var7 == 1.0F)
    {
    var8.setIsCritical(true);
    }
    
    int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
    
    if (var9 > 0)
    {
    var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
    }
    
    int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
    
    if (var10 > 0)
    {
    var8.setKnockbackStrength(var10);
    }
    
    if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
    {
    var8.setFire(100);
    }
    
    var1.damageItem(1, var3);
    var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
    
    if (!var5)
    {
    var3.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
    }
    else
    {
    var8.canBePickedUp = 2;
    }
    
    if (!var2.isRemote)
    {
    var2.spawnEntityInWorld(var8);
    var8.setDamage(var8.getDamage() * 1.15D);
    this.iconIndex = mod_****.yourBowNameHere1;
    }
    }
    
    ItemStack var11 = var3.inventory.getCurrentItem();
    
    if (var11.itemID != mod_****.yourBowNameHere.shiftedIndex)
    {
    this.iconIndex = mod_****.yourBowNameHere1;
    }
    }
    
    public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
    {
    return var1;
    }
    
    /**
    * How long it takes to use or consume an item
    */
    public int getMaxItemUseDuration(ItemStack var1)
    {
    return 72000;
    }
    
    /**
    * returns the action that specifies what animation to play when the items is being used
    */
    public EnumAction getItemUseAction(ItemStack var1)
    {
    return EnumAction.bow;
    }
    
    /**
    * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
    */
    public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
    {
    if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
    {
    var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
    }
    
    return var1;
    }
    
    /**
    * Return the enchantability factor of the item, most of the time is based on material.
    */
    public int getItemEnchantability()
    {
    return 1;
    }
    }

    And rename everything to what you called everything in your mod_**** class.

    So what's happening in this class, is...

    public ItemYourBowNameHere(int var1)
    {
    super(var1);
    this.maxStackSize = 1;

    In case you didn't read, it sets the max stack size for you bow. You probably want it to be 1. If you do more than that, when the bow is used, every bow in the stack will be damaged.
    this.setMaxDamage(UseAmountHere);

    Here, you set the amount of uses your bow has. For reference, the default bow has 351 uses.
    this.bFull3D = true;

    I think this just tells minecraft to render the item in your hand 3D. Correct me if I'm wrong.
    this.setCreativeTab(CreativeTabs.tabCombat);
    }

    This sets the creative tab you want the bow to appear on. You probably want to keep it at tabComat.
    Other tab options are:
    tabBlock
    tabDecorations
    tabRedstone
    tabTransport
    tabMisc
    tabFood
    tabTools
    tabCombat
    tabBrewing
    tabMaterials


    Now back to the bow class. In the public void onUpdate part, we're adding the drawback animation.
    if (var6.isUsingItem() && var7.itemID == mod_****.yourBowNameHere.shiftedIndex)
    {
    int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
    
    if (var8 >= 18)
    {
    this.iconIndex = mod_****.yourBowNameHere4;
    }
    else if (var8 > 13)
    {
    this.iconIndex = mod_****.yourBowNameHere3;
    }
    else if (var8 > 0)
    {
    this.iconIndex = mod_****.yourBowNameHere2;
    }
    }
    else
    {
    this.iconIndex = mod_****.yourBowNameHere.iconIndex;
    }

    What's happening, is you're taking those 4 'temporary' items you created in your mod_**** class, and using them. Each tick you draw back the bow, the more your bow will drawback. See the if [(var8 >=18]? That's the first step, yourBowNameHere4. I think I'm about to fail to explain something to you, but what it does is, it starts the drawback animation at 0 ticks, yourBowNameHere2. Then, 5 ticks later, [else if (var8 > 13)], it changes the item to yourBowNameHere3, which is the second step. 5 more ticks later, it switches to yourBowNameHere4, at 18 ticks. I think then, it waits until you release. If you aren't drawing the bow, it'll just be your bow, yourBowNameHere.

    The next part is checking if you have an arrow in your inventory, spawning a new 'EntityArrow', launching it, and deleting the arrow in you inventory. If your bow is enchanted, it calculates what it needs to do, and applies that stuff.

    public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
    {
    return var1;
    }

    That part, I think it's just saying if you try to eat the bow, go to var1, which I think is to start the drawback. Again, correct me if I'm wrong.

    Don't know what
    public int getMaxItemUseDuration(ItemStack var1)
    {
    return 72000;
    }
    
    public EnumAction getItemUseAction(ItemStack var1)
    {
    return EnumAction.bow;
    }
    does.

    This,
    public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
    {
    if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
    {
    var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
    }
    
    return var1;
    }

    Again, I'm pretty sure it just starts the drawback.

    public int getItemEnchantability()
    {
    return 1;
    }

    This part just sets how easy it is to enchant the bow, I think. So if you want it to be easier to get high enchantments, make it a higher number. Again, I'm not 100% sure that's what it is. Correct me if I'm wrong.

    I think that's about it for the coding.
    Your textures will need to be your bow name, and then numbered 1-4, along with another texture of the bow, with no number.

    1 is the first stage, the default bow, 2 is the next drawback phase, 3 and 4 as well. Just so you know, 4 is the last phase, the tightest form of the bow. :)

    Hope this helps. Again, this is my first tutorial. Please correct any of my mistakes, and if this helped, please please please hit that little green up arrow. :D

    -peon. Ah. Now I can stop typing :P
    Posted in: Tutorials
  • 1

    posted a message on Popgalops Beginner-Advanced Modloader Modding Tutorials (Taking requests)
    this.attackStrength


    Errors in 1.4.2 ;)
    Posted in: Mapping and Modding Tutorials
  • 3

    posted a message on how do i make one
    Google is your best friend. If you can't find anything, I have to say you haven't looked very hard. There are hundreds on youtube, and many on these forums. Some good ones are Jbond's tutorials and Techguys. They don't have videos, but a search on youtube could help you.
    Posted in: Modification Development
  • 2

    posted a message on [1.4.7] Jbond98's Beginner/Advanced ModLoader Minecraft Modding Tutorials! -Everything Updated to 1.4.7! [Updated 1/23/2013]
    Quote from Ezio195

    Seeing as you ignored me, I suppose I'm probably being extremely thick. What I have done, it written the above coding into Eclipse as a file, saved it as a java, and after installing modloader correctly, (I know I've done that right because I use it all the time.) I place it in the mods folder, and even the minecraft.jar. In the .jar I placed the raw .java files, and in the mod folder I placed the two files in a .zip.

    Another post mentioned recompiling the MCP, I don't know if I'm suppossed to do that.

    The problem is the blocks do not exist in game, please refer to my earlier posts I have quoted.


    Kai. I`m assuming this is your first try at modding. Well, you're doing the wrong thing with your files. After you have finished coding and are ready to upload/test your mod, you go to your MCP folder, and run the 'recompile.bat'. Wait for it to finish compiling, close it, then run 'reobfuscate.bat.' It will find the classes you have edited/created, and put them in (MCPfolder)\reobf\minecraft
    Those are the CLASSES you need to put inside your minecraft.jar. Do not put .java files in your jar, nothing will happen. And do not put .zips in your .jar. Just put the .class files.

    Hope this helped!
    (If it did, I wouldn't mind a +)
    Posted in: Tutorials
  • 2

    posted a message on Texture Pack Issues
    You selected "Better Grass" While patching. To fix, go back to MC Patcher and click "Unpatch". Then deselect "Better Grass", and then re-patch.

    If this helps, please press the little green + sign
    Posted in: Legacy Support
  • 1

    posted a message on Single Player Commands [V4.9] - Official Download [SPC] [+NoClip]
    Quote from awesome%%%82t69

    when will this mod come out for 1.0 cause i need some food but no animals are near me

    Omg your such a noob. If your gunna play minecraft dont whine for a mod cause your outa food...
    Posted in: Minecraft Mods
  • 1

    posted a message on Any seervers need MOD or Admin?
    Quote from Partian

    I am looking for a server that is INDEED of aan extra Moderator or Admin:

    Requirements:
    24/7 Server
    Decent Plugins
    Wouldn't mind abit of PvP either
    Fly MOD is ENABLED

    Minecraft Name: Chr0ynX


    Um I PLAN to be 24/7, but I'm just starting up my server, it's Hamachi. For the little bit that i am setting it up, it won't be 24/7, but will be soon. Link here
    Posted in: Starting Up / Looking For Server
  • 1

    posted a message on ♛♛EMPIRE-CRAFT♛♛ Relaunch! PvP | Factions | 24/7
    I have a whitelist app. Just so you know I was here before the admins changed.

    In Game Name: peonftw
    Faction:Mercs
    Do you accept the rules:yes
    Why you wish to join:I want my server back... :rolleyes:
    Posted in: PC Servers
  • To post a comment, please .