Just wanna say thanks for all the help I've received so far as I'm trying to crash-course learn this stuff. Another thing I'd like to learn how to do is to disable and/or modify certain features/functions/recipes in the base game using Forge (presumably meaning I wouldn't have to edit the Base Class files?)
(Is that the best practice? Create a mod to override a base class instead of editing the base class?)
A couple examples would be to:
-disable all diamond recipes. I'm creating my own diamond gem and I don't want vanilla diamond appearing in the world (in chests, for example). I'll be disabling vanilla diamond generation using a Gen Mod.
-make TNT stronger
-I want to diversify the base block hardnesses (I think there should be greater disparity between Wood, Brick, Stone, Cobble, etc).
-Rename Lapis Dye to "Blue Dye" and disable "Lapis Blocks" recipe.
Is this just a matter of creating some kind of Base Class "override"? I'd love to get my hands on some Tutorials about it, if any of you guys know anything. As much as it's great to have somebody hand you the code with the solution to your problem, I'd also like to understand the what, why and how of it.
Basically what this does is read through the recipe list generated. It'll go through each one, and store the resulting item in a variable. Once it's done checking everything, it checks to see if the ItemStack you supplied matches any of the output items. If it does, it will remove the recipe from the array, and from the game.
Basically what this does is read through the recipe list generated. It'll go through each one, and store the resulting item in a variable. Once it's done checking everything, it checks to see if the ItemStack you supplied matches any of the output items. If it does, it will remove the recipe from the array, and from the game.
Thanks dude. I'm only a week old in Java, and I really needed the explanation. I think it will benefit others too, as I've seen a few threads on the subject where all the newbies like me where begging for an explanation, that went unanswered.
Now that I'm trying to work with it, it may not be what I need. I'm trying to disable Diamond Weapons, Tools and Armour creation in-game... but not all of the weapons, tools, and armour recipes. I could solve this by disabling "Diamond" all-together. Since I'm using a Custom Ore Generation mod, I'll be able to stop Diamond Ore from generating... but how can I disable Item.diamond from appearing at all in the game (ie. in Dungeon Chests)?
Don't quite get what you're having trouble with. Disabling specific armor and tools?
Yeah I do want to disable specific armour and tools (diamond in particular)... but if just disable the "Item.diamond" all-together (because I don't want it to appear in a dungeon chest or whereever else it may show up)... it will also render the diamond tools/weapons/armour recipes moot.
-I'm already able to stop Diamond Ore from generating... that's no problem.
-Diamonds still appear in the game in chests (etc) and I don't want them in the game.I'm adding my own Diamond (via Forge Mod) to the game, and it will have a completely different function (and look).
Yeah I do want to disable specific armour and tools (diamond in particular)... but if just disable the "Item.diamond" all-together (because I don't want it to appear in a dungeon chest or whereever else it may show up)... it will also render the diamond tools/weapons/armour recipes moot.
-I'm already able to stop Diamond Ore from generating... that's no problem.
-Diamonds still appear in the game in chests (etc) and I don't want them in the game.
I'm adding my own Diamond (via Forge Mod) to the game, and it will have a completely different function (and look).
Out of curiosity how did you stop diamond generating? I haven't tried that yet and you have me curious. Thanks.
In exchange (and I haven't tested this yet as I'm working on generation of my materials in different ways than vanilla) So I did some digging for the output items for armor
There is a file called RecipesArmor and this section is in there.
So you should be able to use it the reference to say helmetDiamond something like this:
ItemStack ItemStackTest = new ItemStack(Item.helmetDiamond);
Feed that into the ItemStackTest or whatever you call it as an input into the function he gave you and see what happens... you'll have to do it for all the armor parts like boots etc....
If I get this to work, and want to change the recipe rather than remove it, would I just create a new recipe for the item after deleting the vanilla one?
Thanks,
Halfwhit
As far as I understand it, yep, that's what you would do.
I suggest to rewrite RemoveRecipe method as follows:
private static void RemoveRecipe(ItemStack resultItem)
{
ItemStack recipeResult = null;
ArrayList recipes = (ArrayList) CraftingManager.getInstance().getRecipeList();
for (int scan = 0; scan < recipes.size(); scan++)
{
IRecipe tmpRecipe = (IRecipe) recipes.get(scan);
recipeResult = tmpRecipe.getRecipeOutput();
if (recipeResult.itemID == resultItem.itemID && recipeResult.getItemDamage() == resultItem.getItemDamage())
{
System.out.println("Removed Recipe: " + recipes.get(scan) + " -> " + recipeResult);
recipes.remove(scan);
scan--; //list is shifted after remove! Adjust index, so next time we will check this value again.
}
}
}
So problems fixed:
1. We remove all repecies, not just ShapedRecipies or ShapelessRecipies. Note that Forge add two new recipie types: ShapedOreRecipe and ShapelessOreRecipe. Also Forge replace some of the vanilla recipies with new ones.
2. Ignore items count in stacks when comparing.
3. Method should correctly remove near recipies.
Actually i didn't test it, but i guess it should work fine.
Thank you for your help
Though I did get an error with a line of that code:
recipeResult = recipe.getRecipeOutput();
It gives me the error that recipe cannot be resolved, but if i change it to recipes.getRecipeOutput() instead then it says that getRecipeOutput() is undefined.
You right! That should be tmpRecipe. Not just recipe. My fault! I've changed my post above with that fix.
(Is that the best practice? Create a mod to override a base class instead of editing the base class?)
A couple examples would be to:
-disable all diamond recipes. I'm creating my own diamond gem and I don't want vanilla diamond appearing in the world (in chests, for example). I'll be disabling vanilla diamond generation using a Gen Mod.
-make TNT stronger
-I want to diversify the base block hardnesses (I think there should be greater disparity between Wood, Brick, Stone, Cobble, etc).
-Rename Lapis Dye to "Blue Dye" and disable "Lapis Blocks" recipe.
Is this just a matter of creating some kind of Base Class "override"? I'd love to get my hands on some Tutorials about it, if any of you guys know anything. As much as it's great to have somebody hand you the code with the solution to your problem, I'd also like to understand the what, why and how of it.
Thanks guys!!
-Pitch
Thanks for the reply! I've never used "reflection" before, so I'll look into it. If you know a good tutorial about it, I'd love to look at it.
Thanks again!
Does anybody understand any of this code? I'm kinda hoping to learn something here, not just blindly copy and paste stuff into my mod.
V
V
Thanks dude. I'm only a week old in Java, and I really needed the explanation. I think it will benefit others too, as I've seen a few threads on the subject where all the newbies like me where begging for an explanation, that went unanswered.
Yeah I do want to disable specific armour and tools (diamond in particular)... but if just disable the "Item.diamond" all-together (because I don't want it to appear in a dungeon chest or whereever else it may show up)... it will also render the diamond tools/weapons/armour recipes moot.
-I'm already able to stop Diamond Ore from generating... that's no problem.
-Diamonds still appear in the game in chests (etc) and I don't want them in the game.I'm adding my own Diamond (via Forge Mod) to the game, and it will have a completely different function (and look).
* cries *
Finally, someone who realizes that mods aren't cookbook recipes!
Out of curiosity how did you stop diamond generating? I haven't tried that yet and you have me curious. Thanks.
In exchange (and I haven't tested this yet as I'm working on generation of my materials in different ways than vanilla) So I did some digging for the output items for armor
this.recipeItems = new Object[][] {{Item.leather, Block.fire, Item.ingotIron, Item.diamond, Item.ingotGold}, {Item.helmetLeather, Item.helmetChain, Item.helmetSteel, Item.helmetDiamond, Item.helmetGold}, {Item.plateLeather, Item.plateChain, Item.plateSteel, Item.plateDiamond, Item.plateGold}, {Item.legsLeather, Item.legsChain, Item.legsSteel, Item.legsDiamond, Item.legsGold}, {Item.bootsLeather, Item.bootsChain, Item.bootsSteel, Item.bootsDiamond, Item.bootsGold}};
There is a file called RecipesArmor and this section is in there.
So you should be able to use it the reference to say helmetDiamond something like this:
ItemStack ItemStackTest = new ItemStack(Item.helmetDiamond);
Feed that into the ItemStackTest or whatever you call it as an input into the function he gave you and see what happens... you'll have to do it for all the armor parts like boots etc....
Custom Ore Generation mod:
http://www.minecraftforum.net/topic/1107057-132v1-custom-ore-generation-updated-sep-27th/
It's awesome, and quite powerful. I can disable Diamond Ore using it.
ahs I thought you had coded it to do so, no worries I may look at it but mostly trying to figure things out for the fun of it
As far as I understand it, yep, that's what you would do.
So problems fixed:
1. We remove all repecies, not just ShapedRecipies or ShapelessRecipies. Note that Forge add two new recipie types: ShapedOreRecipe and ShapelessOreRecipe. Also Forge replace some of the vanilla recipies with new ones.
2. Ignore items count in stacks when comparing.
3. Method should correctly remove near recipies.
Actually i didn't test it, but i guess it should work fine.
You right! That should be tmpRecipe. Not just recipe. My fault! I've changed my post above with that fix.