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

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.

            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.

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.