Hi there, I be on working for a Hardcore Plugin. And now i have no Plan how i can check how the Recipe is exactly. First i make a new Recipe for Golden Apple with Ingot PHP: ShapedRecipe goldenApple = new ShapedRecipe( new ItemStack(Material.GOLDEN_APPLE, 1)).shape(new String[] { "ggg", "gag", "ggg" }).setIngredient('g', Material.GOLD_INGOT).setIngredient('a', Material.APPLE);plugin.getServer().addRecipe(goldenApple); And now i will check on CraftItemEvent is the Recipe from Golden Apple with Nuggets ore Ingot. Any Idea how i can do this? From the Event i can get the Recipe but not the Shapes
check whether the recipe is instanceof ShapedRecipe, and if it is, you can safely cast it: Code:java if (event.getRecipe() instanceof ShapedRecipe) {ShapedRecipe s = (ShapedRecipe) event.getRecipe();// check the shape here and do whatever you want}
Ah thank you so mutch than can i get the shapes Hm okey not so nice... the Shapes are Strings and every time when i have a Recipe that need all rows i get the same... PHP: if ( event.getRecipe() instanceof ShapedRecipe ) { ShapedRecipe recipe = (ShapedRecipe) event.getRecipe(); String[] shapes = recipe.getShape(); for ( String shape : shapes ) { Helper.log("Shape : " + shape ); } } 14:21:11 [INFO] [Hardcore] Shape : abc 14:21:11 [INFO] [Hardcore] Shape : def 14:21:11 [INFO] [Hardcore] Shape : ghi What can i do that i know witch it is? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
This is good practice, but why are you making a golden apple when there is already a recipe for it in vanilla?
dsmyth1915 : I make this for Hardcore Mode normally you need one Gold Ingot for a Golden Apple but for the Hard mode you need 9 Golden Ingot for it
Looks like I need to play more O.O last I checked it was 9 gold blocks... That might have been before 1.8 beta lol. First off, you were using a for loop, with no actually loop. How that works I have no clue. Second, instead of using the logger to check the shape (why it printed abcdefghi) try checking for the player who is trying to use the recipe. And print his name along with the recipe name. I'm not entirely familiar with recipes, but ill look around and get back to you.
@dsmyth : I look throw the String[] he has three Strings for each Row in the Recipe. I be alone on the Server so i dont need tho log the Player Name i know where it is. And the Helper.log() is Loggin on the Server Console.