Jump to content

Recommended Posts

Posted

Hi,

Sorry for asking such a silly question, but how can I dynamically set the "mining speed" and "mining level" for my custom pickaxe ?

What are the methods for setting them ?

 

Thanks.

Posted

Thanks for the reply.

However, I can't seem to find any methods that sets the 'material' of an item.

 

I figured out the setHarvestLevel, but that only sets if the block broken will drop an item...

How do I set the actual mining speed of the pickaxe ?

Posted

Alright, so after digging through the minecraft source code, I found out you can modify the tool's mining speed by overriding the function func_150893_a and returning a float value. That does work if I hard-code a value into the return line. Seems like minecraft only checks the function once so even if I'm doing some logic checking and returning a different value during runtime doesn't affect the mining speed....

 

Anyone have any idea on how to change the mining speed during runtime ? Thanks in advance.

Posted

just add in yours main mod class:

public static ToolMaterial material = EnumHelper.addToolMaterial("materialName", harvestLevel, maxUses, digSpeed, damage, enchantability);

and in registering pickaxe

= new MyPickaxe(material)

in MyPickaxe

public MyPickaxe(ToolMaterial material) {
	super(material);
}

and if you haven't, add after class MyPickaxe

extends ItemPickaxe

 

so total code:

main mod class

@Mod(modid = "mymod" ,name="My mod",version = "alpha 1.1", )
public class BaseMyMod
{   
public static Item pickaxe;
@EventHandler
public void init(FMLInitializationEvent event)
{ 
	pickaxe = new Pickaxe(material);
GameRegistry.registerItem(pickaxe, "pickaxe");
}
public static ToolMaterial material = EnumHelper.addToolMaterial("material", 2, 500, 20, 15, ;
}

pickaxe class:

public class MyPickaxe extends ItemPickaxe{

public MyPickaxe(ToolMaterial material) {
	super(material);
}
}

after in this class you can register more pickaxe with different tool materials and not whoring about creating more classes and fixing dig speed...

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



×
×
  • Create New...

Important Information

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