would this code work

Started by NACH0NACH0S on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
would this code work

would this codework for minecraft 1.20:

import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import java.util.ArrayList;
import java.util.List;


List<IRecipe<?>> recipes = new ArrayList<>();


List<IRecipe<?>> craftingRecipes = CraftingManager.getInstance().getRecipeList();
recipes.addAll(craftingRecipes);


for (IRecipe<?> recipe : recipes) {
   System.out.println(recipe.getId());
}

 

and this code in the same procedure:

import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


List<IRecipe<?>> recipes = new ArrayList<>();


List<IRecipe<?>> craftingRecipes = CraftingManager.getInstance().getRecipeList();
recipes.addAll(craftingRecipes);


Collections.shuffle(recipes);


for (IRecipe<?> recipe : recipes) {
   System.out.println(recipe.getId());
}

 

Please help!!!!!!

Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
All of the code will need to…
Wed, 06/28/2023 - 18:13

All of the code will need to be put into a class for this to work.

Updated code:

import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class RecipeListProcedure {
	List<IRecipe<?>> recipes = new ArrayList<>();
	List<IRecipe<?>> craftingRecipes = CraftingManager.getInstance().getRecipeList();
	public static void execute() {
		recipes.addAll(craftingRecipes);
		Collections.shuffle(recipes); // you can remove this line if you want
		for (IRecipe<?> recipe : recipes) {
			System.out.println(recipe.getId());
		}
	}
}
Joined May 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Just want to say, if you…
Wed, 07/12/2023 - 11:48

Just want to say, if you want to know if it works, just *try it out*.