Jump to content

Recommended Posts

Posted

Hello Guys,

 

I got a big problem with my mod. I want to smelt down my own created Ore but it won't work don't know why :(

 

MainClass:

package crystalrevolution;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
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 cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.registry.GameRegistry;
import crystalrevolution.blocks.OreCrystal;
import crystalrevolution.items.Crystal;
import crystalrevolution.proxies.ServerProxy;


@Mod(modid = crystalrevolution.MODID, version = crystalrevolution.VERSION)
public class crystalrevolution {

@SidedProxy(clientSide = "crystalrevolution.proxies.ClientProxy", serverSide = "crystalrevolution.proxies.ServerProxy")
public static ServerProxy proxy;

public static final String MODID = "crevolution";
public static final String VERSION = "1.0.0a";

// --Blocks
public static Block OreCrystal = new OreCrystal(Material.rock);

// --Items
public static Item Crystal = new Crystal();

public crystalrevolution() {
	// smelting
	GameRegistry.addSmelting(OreCrystal, new ItemStack(Crystal), 5.0F);

	// Blocks
	GameRegistry.registerBlock(OreCrystal, "OreCrystal");

	// Items
	GameRegistry.registerItem(Crystal, "Crystal");

}
}

 

OreCrystal Class:

package crystalrevolution.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import crystalrevolution.crystalrevolution;

public class OreCrystal extends Block{

private String texture = "CrystalRevolution:crystal_ore";

public OreCrystal(Material mat) {
	super(mat);
	this.setBlockName("OreCrystal");
	this.setHardness(5);
	this.setResistance(;
	this.setCreativeTab(crystalrevolution.tabCrystal);
	this.setBlockTextureName(texture);
	this.setHarvestLevel("pickaxe", 2);
}

public Item getItemDropped(int par1, Random rand, int par3){
	return crystalrevolution.Crystal;

}

public int quantityDropped(Random rand){
	return 1 + rand.nextInt(4);

}

}

Posted

You're overthinking it. Your mod's constuctor is not the place to register anything or create anything or add recipes for anything. Also, do not use your mod's static initializers for new blocks, or items.

 

Learn about and use the FML events for your Mod preinitialization, initialization, and post-initialization. That is where your block, items, recipes, etc. are set up.

Posted

@Casual did u looked at the Code ? I have registered them already my only problem is the Smelting i used the same structure as in 1.6.2

ffdsaklfj. How do you not understand what he's trying to tell you to do?

You are suppose to "register" your items BEFORE you call your addSmelting() method, or the game will not recognize the items because they are even created yet!

Posted

Try this

 

GameRegistry.addSmelting(<MainClassName>.OreCrystal.blockID, new ItemStack (<MainClassName>.Crystal), 5.0F);

 

<MainClassName> is your main class name

Developer of MechanicalCraft.

 

Sadly not available to public yet :(

Posted

Smelting needs to go after the registration of the blocks/items!

And inside load events.

 

You really need to learn Java and thoroughly read beginner tutorials, it's worth doing.

 

I havent checked the syntax, so you may need to import some things if they aren't already. But this is how your main class should look roughly

 

 

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
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 cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
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;
import crystalrevolution.blocks.OreCrystal;
import crystalrevolution.items.Crystal;
import crystalrevolution.proxies.ServerProxy;


@Mod(modid = crystalrevolution.MODID, version = crystalrevolution.VERSION)
public class crystalrevolution {

@SidedProxy(clientSide = "crystalrevolution.proxies.ClientProxy", serverSide = "crystalrevolution.proxies.ServerProxy")
public static ServerProxy proxy;

public static final String MODID = "crevolution";
public static final String VERSION = "1.0.0a";

// --Blocks
public static Block OreCrystal = new OreCrystal(Material.rock);

// --Items
public static Item Crystal = new Crystal();

/**
 * Called from FML during the pre initialisation phase
 * @param event Pre-Init event
 */
    @EventHandler
    public void preInitialise(FMLPreInitializationEvent event) {
    	
    	//Blocks and items are registered here
    	
	// Blocks
	GameRegistry.registerBlock(OreCrystal, "OreCrystal");

	// Items
	GameRegistry.registerItem(Crystal, "Crystal");
    	
    }
    
/**
 * Called from FML during the initialisation phase
 * @param event Init event
 */
    @EventHandler 
public void initialise(FMLInitializationEvent event) {
    	
    	//Smelting happens here
    	
    	GameRegistry.addSmelting(OreCrystal, new ItemStack(Crystal), 5.0F);
}

/**
 * Called from FML during the post initialisation phase
 * @param event Post-Init event
 */
    @EventHandler
public void postInitialise(FMLPostInitializationEvent event) {
    	
    	//Communication between mods goes here, if you choose to do that in the future
    	
}
}

 

I'm Sparkst3r, that kid who makes Sphax textures.

Well hi there. :D

Posted

Smelting needs to go after the registration of the blocks/items!

And inside load events.

 

You really need to learn Java and thoroughly read beginner tutorials, it's worth doing.

 

I havent checked the syntax, so you may need to import some things if they aren't already. But this is how your main class should look roughly

 

 

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
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 cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
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;
import crystalrevolution.blocks.OreCrystal;
import crystalrevolution.items.Crystal;
import crystalrevolution.proxies.ServerProxy;


@Mod(modid = crystalrevolution.MODID, version = crystalrevolution.VERSION)
public class crystalrevolution {

@SidedProxy(clientSide = "crystalrevolution.proxies.ClientProxy", serverSide = "crystalrevolution.proxies.ServerProxy")
public static ServerProxy proxy;

public static final String MODID = "crevolution";
public static final String VERSION = "1.0.0a";

// --Blocks
public static Block OreCrystal = new OreCrystal(Material.rock);

// --Items
public static Item Crystal = new Crystal();

/**
 * Called from FML during the pre initialisation phase
 * @param event Pre-Init event
 */
    @EventHandler
    public void preInitialise(FMLPreInitializationEvent event) {
    	
    	//Blocks and items are registered here
    	
	// Blocks
	GameRegistry.registerBlock(OreCrystal, "OreCrystal");

	// Items
	GameRegistry.registerItem(Crystal, "Crystal");
    	
    }
    
/**
 * Called from FML during the initialisation phase
 * @param event Init event
 */
    @EventHandler 
public void initialise(FMLInitializationEvent event) {
    	
    	//Smelting happens here
    	
    	GameRegistry.addSmelting(OreCrystal, new ItemStack(Crystal), 5.0F);
}

/**
 * Called from FML during the post initialisation phase
 * @param event Post-Init event
 */
    @EventHandler
public void postInitialise(FMLPostInitializationEvent event) {
    	
    	//Communication between mods goes here, if you choose to do that in the future
    	
}
}

 

 

The smelting code is wrong. You need to define if it's a block or not by going to the end of the block your smelting and put .blockID .

Developer of MechanicalCraft.

 

Sadly not available to public yet :(

Posted

Smelting needs to go after the registration of the blocks/items!

And inside load events.

 

You really need to learn Java and thoroughly read beginner tutorials, it's worth doing.

 

I havent checked the syntax, so you may need to import some things if they aren't already. But this is how your main class should look roughly

 

 

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
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 cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
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;
import crystalrevolution.blocks.OreCrystal;
import crystalrevolution.items.Crystal;
import crystalrevolution.proxies.ServerProxy;


@Mod(modid = crystalrevolution.MODID, version = crystalrevolution.VERSION)
public class crystalrevolution {

@SidedProxy(clientSide = "crystalrevolution.proxies.ClientProxy", serverSide = "crystalrevolution.proxies.ServerProxy")
public static ServerProxy proxy;

public static final String MODID = "crevolution";
public static final String VERSION = "1.0.0a";

// --Blocks
public static Block OreCrystal = new OreCrystal(Material.rock);

// --Items
public static Item Crystal = new Crystal();

/**
 * Called from FML during the pre initialisation phase
 * @param event Pre-Init event
 */
    @EventHandler
    public void preInitialise(FMLPreInitializationEvent event) {
    	
    	//Blocks and items are registered here
    	
	// Blocks
	GameRegistry.registerBlock(OreCrystal, "OreCrystal");

	// Items
	GameRegistry.registerItem(Crystal, "Crystal");
    	
    }
    
/**
 * Called from FML during the initialisation phase
 * @param event Init event
 */
    @EventHandler 
public void initialise(FMLInitializationEvent event) {
    	
    	//Smelting happens here
    	
    	GameRegistry.addSmelting(OreCrystal, new ItemStack(Crystal), 5.0F);
}

/**
 * Called from FML during the post initialisation phase
 * @param event Post-Init event
 */
    @EventHandler
public void postInitialise(FMLPostInitializationEvent event) {
    	
    	//Communication between mods goes here, if you choose to do that in the future
    	
}
}

 

 

The smelting code is wrong. You need to define if it's a block or not by going to the end of the block your smelting and put .blockID .

For 1.6 you do, but this is 1.7, you don't need to do that anymore. You now only need to pass in the Item or block to the method and the appropriate method is inferred

I'm Sparkst3r, that kid who makes Sphax textures.

Well hi there. :D

Posted

@Casual did u looked at the Code ? I have registered them already my only problem is the Smelting i used the same structure as in 1.6.2

Yes I did!

 

First take a look at your code:

public crystalrevolution() {
	// smelting
	GameRegistry.addSmelting(OreCrystal, new ItemStack(Crystal), 5.0F);

	// Blocks
	GameRegistry.registerBlock(OreCrystal, "OreCrystal");

	// Items
	GameRegistry.registerItem(Crystal, "Crystal");

}

 

Take a look at the modified code

public crystalrevolution() {
// Blocks
	GameRegistry.registerBlock(OreCrystal, "OreCrystal");

	// Items
	GameRegistry.registerItem(Crystal, "Crystal");

	// smelting
	GameRegistry.addSmelting(OreCrystal, new ItemStack(Crystal), 5.0F);

}

 

The Crystal and the OreCrystal are first registered by the GameRegistry and then it can be used by other methodes like the addSmelting(). you can't do a addRecipe() before registerItem / Block either.

 

Coding, Testing, Smiling, Publishing!

Posted

Ahhh now i understand what u want to tell me  ::) thanks for ur help :)

You still shouldn't be putting it in the constructor.

 

That was the first thing I said. The OP seems to want to ignore the sage advice about that, since it works so far. The fun will come when he has to play nice with other mods and the emails and complaints he will get!!! Well, live and learn.

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.