Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (â‹®) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Over some time now, I have been learning java coding and been working on a mod for Minecraft 1.7.10.

Every thing is working find and I understand most of it, but for some reason does my code, which should remove recipes from Minecraft, not work.

Hope anyone can help me :-\

import java.util.Iterator;
import java.util.List;

import com.fantasymod.Item.ItemCreator;
import com.fantasymod.blocks.BlockCreator;

import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import cpw.mods.fml.common.registry.GameRegistry;

public class craftingmanager {
public static void mainRegistry(){
	addCraftingRec();
	addSmeltingRec();
}
public static void addCraftingRec(){
	//shaped
	GameRegistry.addRecipe(new ItemStack(BlockCreator.bronzeblock, 1), new Object[]{"XXX","XXX","XXX", 'X', ItemCreator.bronzeingot});
	GameRegistry.addRecipe(new ItemStack(Blocks.wool, 1), new Object[]{"XX ","XX ","   ", 'X', ItemCreator.cotton});
	GameRegistry.addRecipe(new ItemStack(ItemCreator.bronzehelmet, 1), new Object[]{"XXX","X X","   ", 'X', ItemCreator.bronzeingot});
	GameRegistry.addRecipe(new ItemStack(ItemCreator.bronzechest, 1), new Object[]{"X X","XXX","XXX", 'X', ItemCreator.bronzeingot});
	GameRegistry.addRecipe(new ItemStack(ItemCreator.bronzepants, 1), new Object[]{"XXX","X X","X X", 'X', ItemCreator.bronzeingot});
	GameRegistry.addRecipe(new ItemStack(ItemCreator.bronzeboots, 1), new Object[]{"   ","X X","X X", 'X', ItemCreator.bronzeingot});
	//shapeless

}
public static void addSmeltingRec(){
	GameRegistry.addSmelting(BlockCreator.bronzeore, new ItemStack(ItemCreator.bronzeingot, 1), 0.0f);
}
public static void removeRecipe(){
	Iterator<IRecipe> remover = CraftingManager.getInstance().getRecipeList().iterator();
		while(remover.hasNext()){
			ItemStack itemstack = remover.next().getRecipeOutput();
			if(itemstack.getItem() == Item.getItemFromBlock(Blocks.furnace)){
				remover.remove();
			}else if (itemstack.getItem() == Items.bread){
				remover.remove();
			}
		}
}
}

this package is being called from my main package with

@EventHandler
public static void Load(FMLInitializationEvent event){
	craftingmanager.mainRegistry();
}

It doesn't look like you're calling

craftingmanager.removeRecipe

anywhere.

Because that doesn't exist maybe? :D Removing from the Iterator changes the underlying List, so this should work just fine.

I'm talking about the

removeRecipe

method in the code the OP posted, not the vanilla

CraftingManager

class.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

so it crashed, but after adding "itemstack != null" in my if statement, the problem solved and it is working fine now. Thank you for pointing it out, I can't believe I missed that  ;D

if(itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.furnace)){
				remover.remove();
			}else if (itemstack != null && itemstack.getItem() == Items.bread){
				remover.remove();
			}

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.