Jump to content

Recommended Posts

Posted (edited)

I am having issues getting my custom axe to show up in game, but no problems getting the other tools working. I tried a youtube video but it wasnt much help. Basically im unsure whether to have my class extend ItemTool or ItemAxe and how to set it up. Heres my code for the class. When the game loads the axe just doesnt appear and im not noticing any error messages in my console output. If i try the commented out bit instead, it just crashes.

 

public class ToolAxe extends ItemTool implements IHasModel{
    
        public static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.WOODEN_BUTTON, Blocks.LADDER, Blocks.WOODEN_PRESSURE_PLATE);


        public ToolAxe(String name, ToolMaterial material) {
            
            super(material, EFFECTIVE_ON);
            setUnlocalizedName(name);
            setRegistryName(name);
            setCreativeTab(CreativeTabs.TOOLS);                    
        }
        
        public float getDestroySpeed(ItemStack stack, IBlockState state){
            
            Material material = state.getMaterial();
            return material != Material.WOOD && material != Material.PLANTS && material != Material.VINE ? super.getDestroySpeed(stack, state) : this.efficiency;
        }

//public class ToolAxe extends ItemAxe implements IHasModel{
    
//public ToolAxe(String name, ToolMaterial material, float damage, float speed) {
        
    //    super(material);
    //    setUnlocalizedName(name);
    //    setRegistryName(name);
    //    attackDamage = damage;
    //    attackSpeed = speed;
    //    setCreativeTab(CreativeTabs.TOOLS);
    //    ModItems.ITEMS.add(this);
        
//}
 

Edited by gyro42
Posted

extend ItemAxe? And use the correct constructor (the one with two floats)

You don't need Set<Block> EFFECTIVE_ON, that's handled by setHarvestLevel()

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

extending ItemAxe is the one that caused me to crash in the first place. I tried the constructor both with and without the floats, and attempted to deal with the damage and attack speed in a couple different ways. No Dice. If i could understand the error outputs correctly it was handling the attack damage that caused me to crash, but im not 100% on that. 

 

My solution was the convoluted mess that mimics the ItemAxe class. At least its working now....

 

isn't setHarvestLevel for the pickaxe types?

Posted
10 hours ago, gyro42 said:

If i could understand the error outputs correctly it was handling the attack damage that caused me to crash, but im not 100% on that. 

Did it ever occur to you to post it and let us look at it?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.