Jump to content

[1.6.5] addSmelting custom blocks to custom ingots?


Recommended Posts

Posted

This is my first time modding and I'm most probably doing something stupid, But I'm trying to make it so my custom ore is able to be smelted into my custom ingot, I'm following the tutorial on the wiki so it is 'genericOre' and 'genericIngot'. Usually you put

 

GameRegistry.addSmelting(Block.dirt.blockID, diamondstack, 0.1f);

 

But I have no idea how to put in my genericOre and genericIngot? This is the class file to my Generic Ingot and Generic Ore:

 

package kamber56.tutorial;

 

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.monster.EntityCreeper;

import net.minecraft.entity.monster.EntityZombie;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

public class GenericItem extends Item {

 

public GenericItem(int id) {

super(id);

 

setMaxStackSize(64);

setCreativeTab(CreativeTabs.tabMisc);

setUnlocalizedName("genericItem");

setTextureName(BasicInfo.NAME.toLowerCase() + ":genericItem");

 

}

 

}

 

 

 

 

 

package kamber56.tutorial;

 

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.monster.EntityCreeper;

import net.minecraft.entity.monster.EntityZombie;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

public class GenericIngot extends Item {

 

public GenericIngot(int id) {

super(id);

 

setMaxStackSize(64);

setCreativeTab(CreativeTabs.tabMaterials);

setUnlocalizedName("genericIngot");

setTextureName("Basic:genericIngot");

 

}

 

 

}

 

I also have in the Load eventhandler this:

 

GameRegistry.registerItem(genericItem, "genericItem");

LanguageRegistry.addName(genericItem, "Generic Item");

 

 

GameRegistry.registerBlock(genericOre, "genericOre");

LanguageRegistry.addName(genericOre, "Generic Ore");

MinecraftForge.setBlockHarvestLevel(genericOre, "pickaxe", 3);

 

 

Any help would be appreciated!

 

[Edit] A Pastebin link to the 3 classes http://pastebin.com/ZWc2LUkv

Posted

First of all, there is no such thing as 1.6.5, lol.

 

It's the same exact thing... look at addSmelting's Declaration its:

 

void addSmelting(int INPUT, ItemStack OUTPUT, float xp)

 

You can place it like this:

GameRegistry.addSmelting(genericOre.itemID, new ItemStack(genericIngot, 1), 0.1F);

 

This should be pretty simple and self explanatory, imo.

 

Posted

LOL, anytime bud, anytime.

 

Block is just getting the class file from Minecraft, to retrieve the dirt block and set it as an ID, it just has to be the ID number of the block.

Try learning more Java before starting to mod, you'll need it.

Posted

I've got a similar problem now, I'm trying to make it so that my genericItem is made when I put 3 genericIngots in a line in the crafting bench. It comes up with no errors in eclipse but when I launch Minecraft it says :

 

java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Character

2014-02-13 17:28:22 [iNFO] [sTDOUT] at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:187)

2014-02-13 17:28:22 [iNFO] [sTDOUT] at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:245)

2014-02-13 17:28:22 [iNFO] [sTDOUT] at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:240)

2014-02-13 17:28:22 [iNFO] [sTDOUT] at kamber56.tutorial.Basic.load(Basic.java:80)

 

Here is the code I'm using. And it's this line which is causing it as when I remove it it launches fine.

GameRegistry.addRecipe(new ItemStack(genericItem, 1), " x ", " x ", " x ",

'x', new ItemStack(genericIngot, 1), 0.1F);

 

(And yeah I sort of went straight into playing around with making a mod because it seemed a lot more fun than following 100 or so YouTube tutorials on learning Java fully :P)

 

[EDIT] Managed to fix it! I Just made the ItemStacks above it; separate from the GameRegistry.addrecipe

 

ItemStack genericItemStack = new ItemStack(genericItem);

ItemStack genericIngotStack = new ItemStack(genericIngot);

 

GameRegistry.addRecipe(genericItemStack, " x ", " x ", " x ",

'x', genericIngotStack);

 

 

It would be cool if someone could explain what I've done wrong and how that's fixed itself?

[EDIT2] Managed to find out, It was the 0.1F making it crash

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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