Tutorials Navigation

Tutorials :: New :: Popular :: Top Rated

Tutorials: 18,326 Categories: 12

Total Tutorial Views: 41,458,684

[ Minecraft ] Create Your Own Weapon! [ v1.1 ]

Tutorial Name: [ Minecraft ] Create Your Own Weapon! [ v1.1 ]  

Category: PC Tutorials

Submitted By: Console

Date Added:

Comments: 0

Views: 10,240

Related Forum: PC Building Forum

Share:

Create Your Own Weapon!



Tutorial -
Difficulty - 2/10
Version - v1.1 haven't tried for v1.2




Creating Weapon Physical Damage (for modloader)




Ok, you start of with your mod_**** file

Now Define the item in your mod_**** file.

EXAMPLE: Public static final ItemDagger = (new ItemDagger(100)). *Extra Features of your Item go here*





If it was ItemDagger it would be

package net.minecraft.src;

public class ItemDagger extends Item

    public ItemDagger(int i)
    {
         super(i);





At public ItemDagger(int i) why is there the (int i)?

Because the interface will be defined as i, allowing super(i); Function to work




Now add your flashy epic features of flashy epic

maxStackSize = 1; MAX STACK SIZE
maxDamage = 3124; HOW DURABLE IT IS, IN THIS CASE 3124 USES
field_22047_d = 20; THE AMOUNT OF DAMAGE, 20 HEALTH OR 10 HEARTS.


Finish with a
}





Now we wanna get the item to take damage

so below all we added we should also add


    public void hitEntity(ItemStack itemstack, EntityLiving entityliving)
    {
        itemstack.damageItem(1);
    }

    public void hitBlock(ItemStack itemstack, int i, int j, int k, int l)
    {
        itemstack.damageItem(2);
    }





this code refers to that when the item hits a entity, it takes 1 damage, and when destroys a block, it takes 2, Mess around with that if you want




Now we have to vertify function "field_22047_d;"


Add this below what you have added

    public int getDamageVsEntity(Entity entity)
    {
        return field_22047_d;
    }

    public boolean isFull3D()
    {
        return true;
    }



Finally finish off with this

    private int field_22047_d;
}





So were done, recompile and test your weapon!

if your getting errors, use this base structure !




package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode



public class ItemDagger extends Item
{

    public ItemDagger(int i)
    {
        super(i);
        maxStackSize = 1;
        maxDamage = 500;
        field_22047_d = 5;
    }

    public void hitEntity(ItemStack itemstack, EntityLiving entityliving)
    {
        itemstack.damageItem(1);
    }

    public void hitBlock(ItemStack itemstack, int i, int j, int k, int l)
    {
        itemstack.damageItem(2);
    }

    public int getDamageVsEntity(Entity entity)
    {
        return field_22047_d;
    }

    public boolean isFull3D()
    {
        return true;
    }
       
    private int field_22047_d;
}





Hope you guys like this tutorial there will be more up soon. Thanks for everyone rating and viewing my tutorials.




Last Tutorial (RedstoneWire)


Next Tutorial -
How To Use Infinite Terrain And Sprite Indexes!
Heres a sneak pic of the next,next tutorial...
How To Make Custom Filled Buckets!





Hey guys if you guys need any help message me!

Ratings

Current rating: 6.59 by 17 users
Please take one second and rate this tutorial...

Not a Chance
1
2
3
4
5
6
7
8
9
10
Absolutely

Comments

"[ Minecraft ] Create Your Own Weapon! [ v1.1 ]" :: Login/Create an Account :: 0 comments

If you would like to post a comment please signin to your account or register for an account.