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

I am working on a mod that adds some Ores and other blocks into the game that have certain harvest requirements to break them, but they don't seem to be working. in game i can punch the blocks and they still drop the items. The code Files in question are below.

 

MyBlocks.java

package com.advancedtunnelbore.blocks;

import com.advancedtunnelbore.lib.RefStrings;
import com.advancedtunnelbore.main.MainRegistry;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.common.registry.GameRegistry;

public class MyBlocks {
public static void mainRegistry(){
	initializeBlock();
	registerItem();
}

public static Block comStone = setHarvestLevel("pickaxe",0);
public static Block sandTOre = setHarvestLevel("shovel",1);
public static Block sandStoneTOre = setHarvestLevel("pickaxe",2);
public static Block stoneTOre = setHarvestLevel("pickaxe",3);

public static void initializeBlock(){
	comStone = new ComStone(Material.rock).setBlockName("comStone").setCreativeTab(MainRegistry.tabTunnelB).setBlockTextureName(RefStrings.MODID + ":com_stone_1").setStepSound(Block.soundTypePiston).setHardness(3F);
	sandTOre = new sandT0re(Material.sand).setBlockName("sandTOre").setCreativeTab(MainRegistry.tabTunnelB).setBlockTextureName(RefStrings.MODID + ":sand_titanium_ore").setStepSound(Block.soundTypeSand).setHardness(1.5F);
	sandStoneTOre = new sandStoneTOre(Material.rock).setBlockName("sandStoneTOre").setCreativeTab(MainRegistry.tabTunnelB).setBlockTextureName(RefStrings.MODID + ":sandstone_titanium_ore").setStepSound(Block.soundTypePiston).setHardness(3F);
	stoneTOre = new stoneTOre(Material.rock).setBlockName("stoneTOre").setCreativeTab(MainRegistry.tabTunnelB).setBlockTextureName(RefStrings.MODID + ":stone_titanium_ore").setStepSound(Block.soundTypePiston).setHardness(3F);


}

private static Block setHarvestLevel(String string, int i) {
	// TODO Auto-generated method stub
	return null;
}

public static void registerItem(){
	GameRegistry.registerBlock(comStone, comStone.getUnlocalizedName());
	GameRegistry.registerBlock(sandTOre, sandTOre.getUnlocalizedName());
	GameRegistry.registerBlock(sandStoneTOre, sandStoneTOre.getUnlocalizedName());
	GameRegistry.registerBlock(stoneTOre, stoneTOre.getUnlocalizedName());

}
}

 

sandTOre.java

package com.advancedtunnelbore.blocks;

import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;

public class sandT0re extends Block {

protected sandT0re(Material p_i45394_1_) {
	super(p_i45394_1_);


}

@Override
    public Item getItemDropped(int metadata, Random random, int fortune) {
        return Item.getItemFromBlock(MyBlocks.sandTOre);
    }

}

 

sandStoneTOre.java

package com.advancedtunnelbore.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;

public class sandStoneTOre extends Block {

protected sandStoneTOre(Material p_i45394_1_) {
	super(p_i45394_1_);

}
@Override
    public Item getItemDropped(int metadata, Random random, int fortune) {
        return Item.getItemFromBlock(MyBlocks.sandStoneTOre);
    }

}

 

stoneTOre.java

package com.advancedtunnelbore.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;

public class stoneTOre extends Block {

protected stoneTOre(Material p_i45394_1_) {
	super(p_i45394_1_);

}
@Override
    public Item getItemDropped(int metadata, Random random, int fortune) {
        return Item.getItemFromBlock(MyBlocks.stoneTOre);
    }

}

 

please help me out

You are setting the block's harest level, before you initlize the block, so you set the harvest level of

null

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.