Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

  • Author

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!

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

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.