Jump to content

Recommended Posts

Posted

Hello!

 

I have recently begun to learn Java and am working on a little mod to test my skills. Whilst I probably won't release this mod to anybody within the community, I wish to polish it off completely and see what I can do with it.

 

Unfortunately, I have encountered a slight hiccup, as my block Mollionite Ore can be mined with any pickaxe.

 

Here is the class file for you coding experts to take a look at, if you please:

 

package com.pxlhub.advancedores.blocks;
import java.util.Random;
import com.pxlhub.advancedores.items.ModItems;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class MollioniteOre extends Block {

public MollioniteOre() {

super(Material.glass);
setBlockName("mollioniteOre");
setCreativeTab(CreativeTabs.tabBlock);
setStepSound(soundTypePiston);
setHardness(3.0F);
setResistance(7.5F);
setHarvestLevel("pickaxe", 2);

}

@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return ModItems.mollioniteCrystal;
}
}

 

I'm not sure how that will look on the forum, so if you like PasteBin, click here!

 

As you can see, I have included the setHarvestLevel (Function is it?), but it can still be mined with any pickaxe and the Mollionite Crystal is still dropped! Is there something key I am missing?

 

Thanks for the help,

PXLForce

Posted

I'm going to be annoying and bump.

 

If anybody has even the slightest information on how I can get this to function correctly, I would really appreciate it!

 

If it is of any use to anybody further, I have started to use GitHub to upload my project to when I am done for the evening. If anybody wants to take a look at it, feel free. https://github.com/PXLForce/AdvancedOres!

Posted

Material.glass can be harvested without any tool.

There are at least two solutions:

-replace this material with an equivalent material, but with setRequiresTool() in its definition [you can make a new Material, if necessary)

-override Block#canHarvestBlock(EntityPlayer, int) to check the tool level instead

Posted

Material.glass can be harvested without any tool.

There are at least two solutions:

-replace this material with an equivalent material, but with setRequiresTool() in its definition [you can make a new Material, if necessary)

-override Block#canHarvestBlock(EntityPlayer, int) to check the tool level instead

 

I can't believe I didn't think of this!

 

Thank you very much! I originally set the material to glass as I didn't want it to drop itself when harvested. Since I have now set what the block will drop, I didn't need it there, but didn't realise! I've now changed it back to the rock material and all seems fine.

 

Thanks! :)

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.