Jump to content

Recommended Posts

Posted

If by any chance the error could be caused by an id you set for your block and something in minecraft already has that id things will not work. You do not need to set an id for your blocks that can make problems with other mods forge will auto assign an id to blocks an Items. Here is an example of a mod I made I do not give ids forge does that for me. I only posted the code for one of my items but you can get the idea from one. I also posted code for a diffrent mod I made that adds new blocks. Again I only added the code for one block.

 

package net.SandItems.mod;

 

import net.SandItems.mod.items.SandAxe;

import net.SandItems.mod.items.SandHoe;

import net.SandItems.mod.items.SandPickaxe;

import net.SandItems.mod.items.SandShovel;

import net.SandItems.mod.items.SandSword;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.Item.ToolMaterial;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.util.EnumHelper;

import net.minecraftforge.oredict.OreDictionary;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.registry.GameRegistry;

 

 

@Mod(modid = SandItems.modid, version = SandItems.version, name = SandItems.name)

public class SandItems {

 

public static final String modid = "sandItems";

public static final String version = "v1.0";

public static final String name = "SandStoneItems";

 

public static ToolMaterial Sandy = EnumHelper.addToolMaterial("Sandy", 1, 125, 4.0F, 1.0F, 10);

 

public static Item itemSandPickaxe;

 

public static Item itemSandSword;

 

public static Item itemSandShovel;

 

public static Item itemSandAxe;

 

public static Item itemSandHoe;

 

 

@EventHandler

public void PreInit(FMLPreInitializationEvent preEvent){

 

itemSandPickaxe = new SandPickaxe(Sandy).setUnlocalizedName("SandPick");

 

itemSandSword = new SandSword(Sandy).setUnlocalizedName("SandSword");

 

itemSandShovel = new SandShovel(Sandy).setUnlocalizedName("SandShovel");

 

itemSandAxe = new SandAxe(Sandy).setUnlocalizedName("SandAxe");

 

itemSandHoe = new SandHoe(Sandy).setUnlocalizedName("SandHoe");

 

GameRegistry.registerItem(itemSandPickaxe, "SandPickaxe");

GameRegistry.registerItem(itemSandSword, "SandSword");

GameRegistry.registerItem(itemSandShovel, "SandShovel");

GameRegistry.registerItem(itemSandAxe, "SandAxe");

GameRegistry.registerItem(itemSandHoe, "SandHoe");

 

}

 

@EventHandler

public void Init(FMLInitializationEvent event){

 

GameRegistry.addRecipe(new ItemStack(itemSandPickaxe), new Object[]{"ccc", " x ", " x ", 'x', Items.stick, 'c',new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE)});

GameRegistry.addRecipe(new ItemStack(itemSandSword), new Object[]{" c ", " c ", " x ", 'x', Items.stick, 'c',new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE)});

GameRegistry.addRecipe(new ItemStack(itemSandShovel), new Object[]{" c ", " x ", " x ", 'x', Items.stick, 'c',new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE)});

GameRegistry.addRecipe(new ItemStack(itemSandAxe), new Object[]{"cc ", "cx ", " x ", 'x', Items.stick, 'c',new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE)});

GameRegistry.addRecipe(new ItemStack(itemSandHoe), new Object[]{"cc ", " x ", " x ", 'x', Items.stick, 'c',new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE)});

 

}

 

@EventHandler

public void PostInit(FMLPostInitializationEvent PostEvent){

 

}

 

}

 

 

 

package net.SandItems.mod.items;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.SandItems.mod.SandItems;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.item.ItemAxe;

import net.minecraft.creativetab.CreativeTabs;

 

public class SandAxe extends ItemAxe {

 

public SandAxe(ToolMaterial p_i45327_1_) {

super(p_i45327_1_);

this.setCreativeTab(CreativeTabs.tabTools);

}

 

@SideOnly(Side.CLIENT)

public void registerIcons(IIconRegister iconRegister) {

this.itemIcon = iconRegister.registerIcon(SandItems.modid + ":" + this.getUnlocalizedName().substring(5));

}

 

}

 

 

 

package net.classicBlocks.mod;

 

 

import net.classicBlocks.mod.blocks.ClassicBrick;

import net.classicBlocks.mod.blocks.ClassicBrickSlab;

import net.classicBlocks.mod.blocks.ClassicBrickStairs;

import net.classicBlocks.mod.blocks.ClassicCobble;

import net.classicBlocks.mod.blocks.ClassicCobbleSlab;

import net.classicBlocks.mod.blocks.ClassicCobbleStairs;

import net.classicBlocks.mod.blocks.ClassicLeaf;

import net.classicBlocks.mod.blocks.ClassicMossy;

import net.minecraft.init.Blocks;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.Item.ToolMaterial;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.util.EnumHelper;

import net.minecraftforge.oredict.OreDictionary;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.registry.GameRegistry;

 

 

@Mod(modid = classicBlock.modid, version = classicBlock.version, name = classicBlock.name)

public class classicBlock {

 

public static final String modid = "classicBlocks";

public static final String version = "v1.0";

public static final String name = "ClassicBlocks";

 

public static Block blockClassicBrick;

public static Block blockClassicCobble;

public static Block blockClassicMossy;

public static Block blockClassicBrickSlab;

public static Block blockClassicBrickStairs;

public static Block blockClassicCobbleSlab;

public static Block blockClassicCobbleStairs;

public static Block blockClassicLeaf;

 

 

 

 

@EventHandler

public void PreInit(FMLPreInitializationEvent preEvent){

 

blockClassicBrick = new ClassicBrick(Material.rock).setBlockName("classicBrick");

blockClassicCobble = new ClassicCobble(Material.rock).setBlockName("ClassicStoneCobble");

blockClassicMossy = new ClassicMossy(Material.rock).setBlockName("ClassicStoneMossy");

blockClassicLeaf = new ClassicLeaf(Material.grass).setBlockName("ClassicLeaf");

 

blockClassicBrickSlab = new ClassicBrickSlab(false, Material.rock).setBlockName("classicBrickSlab");

blockClassicCobbleSlab = new ClassicCobbleSlab(false, Material.rock).setBlockName("ClassicCobbleSlab");

 

blockClassicBrickStairs = new ClassicBrickStairs(blockClassicBrick, 0).setBlockName("classicBrickStairs");

blockClassicCobbleStairs = new ClassicCobbleStairs(blockClassicCobble, 0).setBlockName("classicCobbleStairs");

 

 

 

GameRegistry.registerBlock(blockClassicBrick, "ClassicBrick");

GameRegistry.registerBlock(blockClassicCobble, "ClassicCobbleStone");

GameRegistry.registerBlock(blockClassicMossy, "ClassicMossyStone");

 

GameRegistry.registerBlock(blockClassicBrickSlab, "ClassicBrickSlab");

GameRegistry.registerBlock(blockClassicCobbleSlab, "ClassicCobbleSlab");

 

GameRegistry.registerBlock(blockClassicBrickStairs, "ClassicBrickStairs");

GameRegistry.registerBlock(blockClassicCobbleStairs, "ClassicCobbleStairs");

 

 

}

 

@EventHandler

public void Init(FMLInitializationEvent event){

 

GameRegistry.addShapelessRecipe(new ItemStack(blockClassicBrick), Blocks.brick_block);

GameRegistry.addShapelessRecipe(new ItemStack(blockClassicCobble), Blocks.cobblestone);

GameRegistry.addShapelessRecipe(new ItemStack(blockClassicMossy), Blocks.mossy_cobblestone);

 

GameRegistry.addRecipe(new ItemStack(blockClassicBrickSlab, 6), new Object[]{"xxx", "  ", "  ", 'x',new ItemStack(blockClassicBrick, 1, OreDictionary.WILDCARD_VALUE)});

GameRegistry.addRecipe(new ItemStack(blockClassicBrickSlab, 6), new Object[]{"  ", "xxx", "  ", 'x',new ItemStack(blockClassicBrick, 1, OreDictionary.WILDCARD_VALUE)});

GameRegistry.addRecipe(new ItemStack(blockClassicBrickSlab, 6), new Object[]{"  ", "  ", "xxx", 'x',new ItemStack(blockClassicBrick, 1, OreDictionary.WILDCARD_VALUE)});

 

GameRegistry.addRecipe(new ItemStack(blockClassicCobbleSlab, 6), new Object[]{"xxx", "  ", "  ", 'x',new ItemStack(blockClassicCobble, 1, OreDictionary.WILDCARD_VALUE)});

GameRegistry.addRecipe(new ItemStack(blockClassicCobbleSlab, 6), new Object[]{"  ", "xxx", "  ", 'x',new ItemStack(blockClassicCobble, 1, OreDictionary.WILDCARD_VALUE)});

GameRegistry.addRecipe(new ItemStack(blockClassicCobbleSlab, 6), new Object[]{"  ", "  ", "xxx", 'x',new ItemStack(blockClassicCobble, 1, OreDictionary.WILDCARD_VALUE)});

 

GameRegistry.addRecipe(new ItemStack(blockClassicCobbleStairs, 4), new Object[]{"x  ", "xx ", "xxx", 'x',new ItemStack(blockClassicCobble, 1, OreDictionary.WILDCARD_VALUE)});

 

GameRegistry.addRecipe(new ItemStack(blockClassicBrickStairs, 4), new Object[]{"x  ", "xx ", "xxx", 'x',new ItemStack(blockClassicBrick, 1, OreDictionary.WILDCARD_VALUE)});

 

}

 

@EventHandler

public void PostInit(FMLPostInitializationEvent PostEvent){

 

}

 

}

 

 

 

package net.classicBlocks.mod.blocks;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.SandItems.mod.SandItems;

import net.classicBlocks.mod.classicBlock;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.creativetab.CreativeTabs;

 

public class ClassicBrick extends Block {

 

public ClassicBrick(Material material) {

super(material);

 

this.setHardness(2.0F);

this.setResistance(10.0F);

this.setStepSound(soundTypePiston);

this.setCreativeTab(CreativeTabs.tabBlock);

 

 

}

 

@SideOnly(Side.CLIENT)

public void registerBlockIcons(IIconRegister iconRegister){

this.blockIcon = iconRegister.registerIcon(classicBlock.modid + ":" + this.getUnlocalizedName().substring(5));

}

 

}

 

  • 1 month later...
Posted

Does anyone knows an answer yet?

Dude!

 

[Gosaints said]:

> "The object net.sciencecraft.machines.Grinder@7c1f7ea has been registered twice for the same name ScienceCraft:GrinderIdle"

 

The error log says:

> java.lang.IllegalStateException: Can't free registry slot 165 occupied by net.minecraft.item.ItemBlock@4f7b27a0

....

> at net.sciencecraft.main.ScienceCraft.Load(ScienceCraft.java:362) [scienceCraft.class:?]

 

ScienceCraft line 362:

362:      GameRegistry.registerBlock(GrinderIdle, "GrinderIdle");

 

Search code for "GrinderIdle" gives, like I said in my previous post,

[TGG said]:

207:      GameRegistry.registerBlock(GrinderIdle, "GrinderIdle");

 

-TGG

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.