Jump to content

Recommended Posts

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

Posted

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

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