Jump to content

Recommended Posts

Posted

I use ordictonary and it fail... Im so sad... Because nothing work. not the source of elorams redpower. not the source out of Forestry. not the source out of universal eletricty...

(I only use the source to get inspiration how to things work)

 

here is the recipe (when i use it it will crash the game at start)

 

      ModLoader.addRecipe(new ItemStack(mod_KingdomAge.copperIngot, 1, 40), new Object[]{ "YX", Character.valueOf('X'), "ingotCoppet", Character.valueOf('Y'), "ingotTin"});

 

(why copper ingot is so high? i use only for normal items one id) i tryed the recipe out of the fore tutorial too and it dont work because i use the modloader style... (of modding but i work with fml)

 

thanks for reading.

 

Moritz

Posted

It crashes because you cannot use Strings as items for the crafting recipe! There must be a method in the OreDictionary which gives you an ItemStack back. This ItemStack can be used then in the recipe.

 

PS: One tip: Don't use ModLoader methods anymore. For recipes use GameRegistry.addRecipe(...). For other ModLoader methods, snoop a bit in the ModLoader class to find the right method.

 

EDIT: Use OreDictionary.getOreID("oreNameHere") to get the ID for the ore.

 

Here's an example code:

GameRegistry.addRecipe(new ItemStack(mod_KingdomAge.copperIngot, 1, 40), "YX", 'X', new ItemStack(OreDictionary.getOreID("ingotCopper"), 1, 0), 'Y', new ItemStack(OreDictionary.getOreID("ingotTin"), 1, 0));

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Please check your code before responding, 1) it's horrible code, 2) Thats not how those functions work, go read the ore dict javadocs, its' there. I've also written samples if you search.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

the code what you gave me is does not work on my mod.. (Errors 5 i think) i tried the code directly out of the mod redpower to test it. this code did not make a error, crash, and now the bad thing no recipe... i do not know how i can fix that.... I poste my codes. maybe this helps out..

Posted

This code Is my modFile...

 

I hope you can help me because i can't make recipes with oredictonary...

 

I deleted all recipe because this comes at my last test when i release a test version

 

 

 

 

package net.minecraft.src;

 

import net.minecraft.src.forge.oredict.*;

import net.minecraft.src.forge.*;

import net.minecraft.src.*;

import java.util.Random;

import net.minecraft.client.Minecraft;

import java.util.Iterator;

 

public class mod_KingdomAge extends BaseMod

{

 

//Blöcke

 

public static Block copperOre;

 

//Items

 

public static Item copperIngot;

//public static Item coinChecker;

public static Item checker;

public static Item oldGun;

public static Item magicSword;

 

//Guis

 

//public static int coinCheckerGUIid = 1;

 

//World Generate

 

public static OreGenerator copperGen;

public static OreGenerator tinGen;

public static OreGenerator silverGen;

 

static

{

 

PropsHelperKingdomAge.initProps();

 

//Item IDs

 

copperIngot = new ItemCopperIngot(PropsHelperKingdomAge.copperIngotID).setItemName("copperIngot");

//coinChecker = new ItemCoinChecker(PropsHelperKingdomAge.coinCheckerID).setItemName("coinChecker");

checker = new ItemChecker(PropsHelperKingdomAge.checkerID).setItemName("checker");

oldGun = new ItemOldGun(PropsHelperKingdomAge.oldGunID).setItemName("oldGun");

magicSword = new ItemMagicSword(PropsHelperKingdomAge.magicSwordID).setItemName("magicSword");

 

//Block IDs

 

copperOre = new BlockCopperOre(PropsHelperKingdomAge.copperOreID).setBlockName("CopperOre");

 

 

//World Generate

 

/* Values for Ore Generator: Block ID, Metadata, Vein Size */         

copperGen = new OreGenerator(copperOre.blockID, 0, 20);

tinGen = new OreGenerator(copperOre.blockID, 1, 15);

silverGen = new OreGenerator(copperOre.blockID, 2, 10);

 

}

 

        @Override

        public void generateSurface(World world, Random random, int chunkX, int chunkZ)

        {

generateVeins(world, random, chunkX, chunkZ, copperGen, 16, 128);

generateVeins(world, random, chunkX, chunkZ, tinGen, 16, 80);

generateVeins(world, random, chunkX, chunkZ, silverGen, 16, 40);

}

 

        public static boolean generateVeins(World world, Random random, int chunkX, int chunkZ, 

                        OreGenerator oregenerator, int rarity, int height) 

        {

                /* Programming artifact: Array indexes start at 0 */

                for (int i = 0; i < rarity; i++)

                {

                        int hi = random.nextInt(height);

                        int randX = chunkX + random.nextInt(16);

                        int randZ = chunkZ + random.nextInt(16);

                        oregenerator.generate(world, random, randX, hi, randZ);

                }

                return true;

        }

 

 

//public GuiContainer getContainerGUI(EntityClientPlayerMP player, int id, int x, int y, int z)

//{

//switch(id)

//{

//case 0: coinCheckerGUIid : return new GuiCoinChecker(player.inventory, player.worldObj, x, y, z);

//default: return null;

//}

//}

 

 

public mod_KingdomAge()

{

//Register

 

                ModLoader.registerBlock(copperOre, ItemCopperOre.class);

 

//OreDictonary

 

MinecraftForge.registerOre("ingotCopper", new ItemStack(copperIngot, 1, 0));

MinecraftForge.registerOre("ingotTin", new ItemStack(copperIngot, 1, 1));

MinecraftForge.registerOre("ingotBronze", new ItemStack(copperIngot, 1, 3));

MinecraftForge.registerOre("ingotSilver", new ItemStack(copperIngot, 1, 13));

 

//BlockHardness

 

MinecraftForge.setBlockHarvestLevel(copperOre, 0, "pickaxe", 1);

MinecraftForge.setBlockHarvestLevel(copperOre, 1, "pickaxe", 1);

MinecraftForge.setBlockHarvestLevel(copperOre, 2, "pickaxe", 2);

MinecraftForge.setBlockHarvestLevel(copperOre, 3, "pickaxe", 2);

MinecraftForge.setBlockHarvestLevel(copperOre, 4, "pickaxe", 2);

MinecraftForge.setBlockHarvestLevel(copperOre, 5, "pickaxe", 2);

MinecraftForge.setBlockHarvestLevel(copperOre, 0, "miningpickaxe", 0);

MinecraftForge.setBlockHarvestLevel(copperOre, 1, "miningpickaxe", 0);

MinecraftForge.setBlockHarvestLevel(copperOre, 2, "miningpickaxe", 0);

MinecraftForge.setBlockHarvestLevel(copperOre, 3, "miningpickaxe", 0);

MinecraftForge.setBlockHarvestLevel(copperOre, 4, "miningpickaxe", 0);

MinecraftForge.setBlockHarvestLevel(copperOre, 5, "miningpickaxe", 0);

 

//Tools Hardness

 

MinecraftForge.setToolClass(magicSword, "wallbreaker", 3);

 

//ModLoader.setInGameHook(this, true, true);

 

//ModLoader.registerContainerID(this, 10, 160, 5, true);

 

//Textures

 

MinecraftForgeClient.preloadTexture("/Spmod/KingdomAge/items.png");

MinecraftForgeClient.preloadTexture("/Spmod/KingdomAge/armor.png");

MinecraftForgeClient.preloadTexture("/Spmod/KingdomAge/blocks.png");

}

 

//Elorams code for test... did not work

 

public static void initOreDictionary()

     {

         MinecraftForge.registerOreHandler(new IOreHandler()

         {

             public void registerOre(String var1, ItemStack var2)

             {

                 Iterator var3;

                 ItemStack var4;

 

                 if (var1.equals("ingotCopper"))

                 {

                     ModLoader.addRecipe(new ItemStack(mod_KingdomAge.copperIngot, 1, 6), new Object[] {"Y", Character.valueOf('Y'), var2});

                     var3 = MinecraftForge.getOreClass("ingotTin").iterator();

 

                     while (var3.hasNext())

                     {

                         var4 = (ItemStack)var3.next();

                         ModLoader.addRecipe(new ItemStack(mod_KingdomAge.copperIngot, 1, 10), new Object[] {"YX", Character.valueOf('Y'), var2, Character.valueOf('X'), var4});

                     }

                 }

             }

         });

}

 

 

public void load()

{

 

//Coin Checker Recipes

 

//Fake Coins

 

//Im working on a new crafting tabel...

 

//CraftingCoinChecker.getInstance().addSharplessRecipe(new ItemStack(mod_KingdomAge.checker, 1, 0), new Object[]{new ItemStack(mod_KingdomAge.copperIngot, 1, 16), new ItemStack(mod_KingdomAge.copperIngot, 1, 46) });

 

//CraftingCoinChecker.getInstance().addSharplessRecipe(new ItemStack(mod_KingdomAge.checker, 1, 0), new Object[]{new ItemStack(mod_KingdomAge.copperIngot, 1, 17), new ItemStack(mod_KingdomAge.copperIngot, 1, 46) });

 

//Original Coins

 

//CraftingCoinChecker.getInstance().addSharplessRecipe(new ItemStack(mod_KingdomAge.checker, 1, 1), new Object[]{new ItemStack(mod_KingdomAge.copperIngot, 1, 8), new ItemStack(mod_KingdomAge.copperIngot, 1, 46) });

 

//CraftingCoinChecker.getInstance().addSharplessRecipe(new ItemStack(mod_KingdomAge.checker, 1, 1), new Object[]{new ItemStack(mod_KingdomAge.copperIngot, 1, 9), new ItemStack(mod_KingdomAge.copperIngot, 1, 47) });

 

//CraftingCoinChecker.getInstance().addSharplessRecipe(new ItemStack(mod_KingdomAge.checker, 1, 1), new Object[]{new ItemStack(mod_KingdomAge.copperIngot, 1, 10), new ItemStack(mod_KingdomAge.copperIngot, 1, 47) });

 

//CraftingCoinChecker.getInstance().addSharplessRecipe(new ItemStack(mod_KingdomAge.checker, 1, 1), new Object[]{new ItemStack(mod_KingdomAge.copperIngot, 1, 11), new ItemStack(mod_KingdomAge.copperIngot, 1, 48) });

 

 

 

//Furnace Recipes

 

//Ore Smelting

 

FurnaceRecipes.smelting().addSmelting(copperOre.blockID, 0, new ItemStack(mod_KingdomAge.copperIngot, 1, 0));

FurnaceRecipes.smelting().addSmelting(copperOre.blockID, 1, new ItemStack(mod_KingdomAge.copperIngot, 1, 1));

FurnaceRecipes.smelting().addSmelting(copperOre.blockID, 2, new ItemStack(mod_KingdomAge.copperIngot, 1, 14));

 

//Bronze Smelting

 

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 2, new ItemStack(mod_KingdomAge.copperIngot.shiftedIndex, 1, 3));

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 6, new ItemStack(mod_KingdomAge.copperIngot.shiftedIndex, 1, 7));

 

//Iron Smelting

 

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 14, new ItemStack(Item.ingotIron));

 

//Chunk Smelting Recipes

 

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 18, new ItemStack(mod_KingdomAge.copperIngot.shiftedIndex, 3, 0));

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 19, new ItemStack(mod_KingdomAge.copperIngot.shiftedIndex, 3, 4));

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 20, new ItemStack(mod_KingdomAge.copperIngot.shiftedIndex, 3, 12));

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 21, new ItemStack(Item.ingotGold, 3));

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 22, new ItemStack(mod_KingdomAge.copperIngot.shiftedIndex, 1, 0));

FurnaceRecipes.smelting().addSmelting(mod_KingdomAge.copperIngot.shiftedIndex, 23, new ItemStack(mod_KingdomAge.copperIngot.shiftedIndex, 1, 0));

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

}

 

@Override

public String getVersion()

{

return "Test Version 0.7";

}

 

}

 

 

 

 

 

Now the Code of the items ItemCopperIngot.java

 

 

 

 

 

package net.minecraft.src;

 

import net.minecraft.src.forge.*;

import net.minecraft.src.*;

 

public class ItemCopperIngot extends Item implements ITextureProvider

{

public ItemCopperIngot(int id)

{

super(id);

setHasSubtypes(true);

setMaxDamage(0);

setMaxStackSize(64);

}

 

public String getItemDisplayName(ItemStack var1)

{

String var2 = "Ingot";

 

switch(var1.getItemDamage())

{

case 0:

var2 = "Copper" + var2;

break;

case 1:

var2 = "Tin" + var2;

break;

case 2:

var2 = "Mixed" + var2;

break;

case 3:

var2 = "Bronze" + var2;

break;

case 4:

var2 = "Copper Nugget";

break;

case 5:

var2 = "Tin Nugget";

break;

case 6:

var2 = "Mixed Nugget";

break;

case 7:

var2 = "Bronze Nugget";

break;

case 8:

var2 = "Copper Coin";

break;

case 9:

var2 = "Bronze Coin";

break;

case 10:

var2 = "Silver Coin";

break;

case 11:

var2 = "Gold Coin";

break;

case 12:

var2 = "Silver" + var2;

break;

case 13:

var2 = "Silver Nugget";

break;

case 14:

var2 = "Mixed" + var2;

break;

case 15:

var2 = "Mixed Nugget";

break;

case 16:

var2 = "Silver Coin";  // Fake Coin

break;

case 17:

var2 = "Gold Coin"; //Fake Coin

break;

case 18:

var2 = "Copper Chunk";

break;

case 19:

var2 = "Bronze Chunk";

break;

case 20:

var2 = "Silver Chunk";

break;

case 21:

var2 = "Gold Chunk";

break;

case 22:

var2 = "Silver Chunk"; //Faked Coin

break;

case 23:

var2 = "Gold Chunk"; //Faked Coin

break;

case 24:

var2 = "Chain Part";

break;

case 25:

var2 = "Chain Cloth";

break;

case 26:

var2 = "Mixed Metal Plate";

break;

case 27:

var2 = "Iron Plate";

break;

case 28:

var2 = "Iron Plate Team 1";

break;

case 29:

var2 = "Iron Plate Team 2";

break;

case 30:

var2 = "Iron Plate Team 3";

break;

case 31:

var2 = "Iron Plate Team 4";

break;

case 32:

var2 = "Iron Plate Team 5";

break;

case 33:

var2 = "Iron Plate Team 6";

break;

case 34:

var2 = "Iron Plate Team 7";

break;

case 35:

var2 = "Iron Plate Team 8";

break;

case 36:

var2 = "Iron Plate Team 9";

break;

case 37:

var2 = "Iron Plate Team 10";

break;

case 38:

var2 = "Iron Plate Team 11";

break;

case 39:

var2 = "Iron Plate Team 12";

break;

case 40:

var2 = "Iron Plate Team 13";

break;

case 41:

var2 = "Iron Plate Team 14";

break;

case 42:

var2 = "Iron Plate Team 15";

break;

case 43:

var2 = "Iron Plate Team 16";

break;

case 44:

var2 = "Iron Plate Söldner";

break;

case 45:

var2 = "Chain";

break;

case 46:

var2 = "Low weight";

break;

case 47:

var2 = "Medium weight";

break;

case 48:

var2 = "High weight";

break;

default:

var2 = "Tutorial Item";

}

return var2;

}

 

public int getIconFromDamage(int var1)

{

switch(var1)

{

case 0: return 0;

case 1: return 1;

case 2: return 2;

case 3: return 3;

case 4: return 4;

case 5: return 5;

case 6: return 6;

case 7: return 7;

case 8: return 8;

case 9: return 9;

case 10: return 10;

case 11: return 11;

case 12: return 12;

case 13: return 13;

case 14: return 14;

case 15: return 15;

case 16: return 16;

case 17: return 17;

case 18: return 18;

case 19: return 19;

case 20: return 20;

case 21: return 21;

case 22: return 22;

case 23: return 23;

case 24: return 24;

case 25: return 25;

case 26: return 26;

case 27: return 27;

case 28: return 28;

case 29: return 29;

case 30: return 30;

case 31: return 31;

case 32: return 32;

case 33: return 33;

case 34: return 34;

case 35: return 35;

case 36: return 36;

case 37: return 37;

case 38: return 38;

case 39: return 39;

case 40: return 40;

case 41: return 41;

case 42: return 42;

case 43: return 43;

case 44: return 44;

case 45: return 45;

case 46: return 46;

case 47: return 47;

case 48: return 48;

default: return 200;

}

}

 

@Override

public String getTextureFile()

{

return "/Spmod/KingdomAge/items.png";

}

}

 

 

[/spoilet]

 

 

i hope you can read the spoiler.

Posted

So yeah, I searched a bit and found this on the wiki:

http://www.minecraftforge.net/wiki/How_to_use_the_ore_dictionary

 

You should read through this. I tested it myself and it works.

 

 

@Lex: Sorry for that, It was waay to late for me xP

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

What failed? Please give more info about this.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Your mod_ file would be enough.

 

EDIT: Nvm, I used that one posted above. Here's a more or less cleaned mod_ file:

https://gist.github.com/dc7f29572c8bcab492c0

 

PS: You should really check out this tutorial:

http://www.minecraftforge.net/wiki/Tutorials/Upgrading_To_Forge_for_1.3.1

 

It will teach you how to make your mods right and throw out any ModLoader stuff.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Thanks. My modfile will be for only 3 days on the next post downloadfile... sry i can not post with my ipod touch(G2) on github... I use dropbox to share my code.. and why i do not use minecraft 1.3.1 because i make some of my mods for friends an they use 1.2.5. And i have to read the changes and that does need more time for mod which is at a testing phase... When its at the realease Time i update the mod... Thanks to the answer

Posted

Ok i understand it right now i try gameRegistry... If it make fail i change back to modloader... the only thing what i use on

modloader is RegisterBlock and AddRecipe

Posted

Ok First of All the item Checker is only to check item is a fake or is an original... Secend one i already Importet all OreDictonary Classes. Third one i do not Need Sharpless Recipes. I need only Sharped Recipes. forth one. The public void Load is only for recipes and the public mod_KingdomAge for the rest (kinda sorting). but at all thanks now im testing it and tomorow you get an other answer...

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.