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

FurnaceRecipes.smelting().getSmeltingList().remove(Blocks.iron_ore);

 

This is how it was in 1.6.4 but then you had to put ".blockID" after iron_ore but now that IDs are not used in code this does not work anymore, if this not how you remove recipes anymore?

[Okay, while I was typing this, deiseiben07 posted.]

 

FurnaceRecipes.smelting().getSmeltingList().remove(new ItemStack(Blocks.iron_ore)) will not work.

 

The reason is simple if you understand hashmaps. The key is looked up in an array of hash buckets indexed by the hashCode() return value. Then, if the key is not equals(Object o) to the one to remove/add/get the object looks down to list or hash bucket and checks equals() again (some do a rehash, but not this implementation).

 

Now to the actual reason it fails. No two new ItemStacks will generate the same hash (under normal circumstances.) So, every ItemStack will not match an existing key, and since ItemStack does not implement either hashCode() or equals(o), the Object (superclass) methods are used (they amount to the address of the instance as hashCode). If you put an ItemStack in the map, it stays but will never match anything but that exact reference, ever.

 

You therefore must iterate through the recipes, check with ItemStack.areItemStacksEqual(s1, s2) -- yes, really slow... but the only way right now.

 

  • Author

This is what I did for removing crafting recipes

static void removeRecipesWithResult(ItemStack resultItem) {
	ArrayList recipes = (ArrayList) CraftingManager.getInstance().getRecipeList();

	for (int scan = 0; scan < recipes.size(); scan++) {
		IRecipe tmpRecipe = (IRecipe) recipes.get(scan);
		if (ItemStack.areItemStacksEqual(resultItem, tmpRecipe.getRecipeOutput())) {
			recipes.remove(scan);
		}//if
	}//for
}//removeRecipesWithResult

 

This is what I am trying to do for removing furnace recipes, is there a furnace equivalent to IRecipe?

 

static void removeFurnaceRecipeWithResult(ItemStack resultItem) {
	java.util.Map recipes = FurnaceRecipes.smelting().getSmeltingList();

	for (int scan = 0; scan < recipes.size(); scan++) {
		if (ItemStack.areItemStacksEqual(resultItem, [b][/b]) {
			recipes.remove(scan);
		}
	}
}//removeFurnaceRecipeWithResult

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.