Jump to content

[1.7.10] How to Make a MULTITOOL?


Gine96

Recommended Posts

Since you've already made a few tools, you may have noticed that most or all of the tool classes you've extended from extend from one superclass, ItemTool. All vanilla tools except shears, buckets and swords extend ItemTool (these just extend Item), so looking through that class to see how it works and how the classes that inherit from it work seems like a good place to start.

Link to comment
Share on other sites

Ok looking around classes I've discovered some things that I need but I haven't discovered anythings to add also the sword function at my item... but for now it wasn't very important... Thanks for the good idea of looking throught classes! ;)

 

My code for now is this but I would like to add a sword function

 

import java.util.Set;
import org.apache.http.cookie.SetCookie;
import com.gine.help.Reference;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class GineMTool extends Item {
protected float efficiencyOnProperMaterial;

protected GineMTool(ToolMaterial material){
	super();
	setUnlocalizedName("gineMTool");
	setTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5));
	setCreativeTab(CreativeTabs.tabTools);
	efficiencyOnProperMaterial = 30;
        setMaxDamage(2560);
        setMaxStackSize(1);
        setHarvestLevel("pickaxe", 5);
}

public boolean canHarvestBlock(Block par1Block){
        return true;
    }

public float func_150893_a(ItemStack par1ItemStack, Block par2Block){
                return efficiencyOnProperMaterial;
    }

    
    public int getDamageVsEntity(Entity par1Entity){
        return 100;
    }
    
    public int getItemEnchantability(){
        return 64;
    }

}

 

Link to comment
Share on other sites

I think there are only a few methods that ItemSword has that you'd need to worry about.

 

One is func_150893_a, which I believe is a break-speed function. In vanilla, this allows swords to slice through cobwebs quickly. Another is getItemUseAction, which in vanilla displays block animation using the sword. I don't know whether you would want to override this since you've got a multitool and you may have other uses for right-click. The one you probably care about the most is setting the damage, and as far as I know this is now done using getItemAttributeModifiers. This is also used to generate the damage tooltip I believe.

 

Check out the code in ItemSword for how these work in vanilla, and good luck!

 

PS: I know this is a WIP, but I noticed your constructor receives a tool material but your tool class doesn't use it anywhere. If I might make a design suggestion, put a field that stores the ToolMaterial you pass to the constructor, and then get the statistics like the enchantability and durability from that. This would let you use a single class for as many tools as you like, rather than having to make new ones so you can return different values for getItemEnchantability or getDamageVsEntity. You can use EnumHelper to set up custom ToolMaterials that will store all this info for you!

 

For example:

// Arguments are: Name, Harvest Level, Maximum Durability, Mining Speed, Base Damage and Enchantibility.
public static ToolMaterial SPAM = EnumHelper.addToolMaterial("SPAM", 2, 2000, 7.0F, 3F, ;
public static ToolMaterial NOTSPAM = EnumHelper.addToolMaterial("NotSpam", 1, 1000, 1.0F, 3.0F, 2);

// And now you can just pass your custom material to a tool. You would be able to use the same class for multiple materials, yay!
public static Item spamTool = new ModItemTool(SPAM);
public static Item notSpamTool = new ModItemTool(NOTSPAM);

 

And in your item class, you would do something like:

public int getItemEnchantibility() {
     return this.toolMaterial.getEnchantibility(); // It's all wrapped up in the material you passed to the tool. Tidy!
}

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.



×
×
  • Create New...

Important Information

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