Jump to content

[1.7.10] Recipe remover mod also causing strange side-effects


Roboguy99

Recommended Posts

My recipe remover mod (all the code can be found here: https://github.com/Roboguy99/Recipe-Remover) is causing strange recipe-related effects to occur. For whatever reason, any recipe (vanilla and some modded recipes) which would normally return an ItemStack of greater than 1 when crafted (e.g. 1 oak wood log -> 4 oak wooden planks) only return 1 whenever my mod is installed. If anybody could take the time to see if there is anything obvious in my code.

 

Apart from two command classes here is all of the code:

 

 

package roboguy99.recipeRemover;

import java.util.List;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;

@Mod(modid="RecipeRemover", name="Recipe Remover", version="1.1.0", acceptableRemoteVersions = "*")
public class RecipeRemover
{
    Configuration config;
    private static final String[] DEFAULT_RECIPE_LIST = {"minecraft:stone", "modid:item"};
    private String[] recipeList;
    public static final Logger logger = LogManager.getLogger("RecipeRemover");
  
    @EventHandler
    public void preInit(FMLPreInitializationEvent e)
    {
    	logger.info("Loading config");
  
    	Configuration config = new Configuration(e.getSuggestedConfigurationFile());
    
    	config.load();
    		Property recipeList = config.get(Configuration.CATEGORY_GENERAL, "disabledRecipes", DEFAULT_RECIPE_LIST);
    		String[] recipeListS = recipeList.getStringList();
    		recipeList.comment = "Place the block ID on each separate line. \n Use the /id command in-game to get the block/item IDs.";
	config.save();
    
	this.recipeList = recipeListS;

	logger.info("Config loaded successfully");
    }
  
    @EventHandler
    public void postInit(FMLPostInitializationEvent e)
    {
    	System.out.println("[RecipeRemover] Removing recipes");
    	
    	for(int i = 0; i < this.recipeList.length; i++)
        {
        	  this.removeRecipes(this.recipeList[i]);
        }
    	
    	logger.info("Recipes removed succesfully");
    }
    
    @EventHandler
    public void serverLoad(FMLServerStartingEvent event)
    {
      event.registerServerCommand(new FindIDCommand());
      event.registerServerCommand(new FindIDFromHandCommand());
    }
  

    @SuppressWarnings("unchecked")
    private void removeRecipes(String toDelete)
    {    
    	ItemStack resultItem = new ItemStack((Item)Item.itemRegistry.getObject(toDelete));
    	if (resultItem != null)
	{
    		resultItem.stackSize = 1;
	}
    	
	List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
       
	for (int i = 0; i < recipes.size(); i++)
        {
            IRecipe tmpRecipe = recipes.get(i);
            ItemStack recipeResult = tmpRecipe.getRecipeOutput();
            if(recipeResult != null) 
            {
            	recipeResult.stackSize = 1;
            }
            
            if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
            {
                recipes.remove(i--);
            }
        }
    }
}

 

 

 

The code for the commands can be seen on the github link above. Thanks.

I have no idea what I'm doing.

Link to comment
Share on other sites

            if(recipeResult != null) 
            {
            	recipeResult.stackSize = 1;
            }

 

Magic.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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.