lukas2005 Posted November 4, 2017 Posted November 4, 2017 i have a custom bat wing item and i want to add 2 shapeless crafting recipes that uses it on is bat wing + water bottle = poison potion and another is bat wing + dragon breath = splash levitation potion i have this code: public static void init() { addShapelessRecipe(new ItemStack(Items.POTIONITEM, 1, 8260), ModItems.getItem("bat_wing"), Items.POTIONITEM); NBTTagCompound levitationPotionNbt = new NBTTagCompound(); NBTTagCompound displayNBT = new NBTTagCompound(); NBTTagList customEffectsList = new NBTTagList(); NBTTagCompound potionNbt = new NBTTagCompound(); potionNbt.setInteger("Id", 25); potionNbt.setInteger("Amplifier", 1); potionNbt.setInteger("Duration", 600); // 600 = (0:30) 1800 = (1:30) customEffectsList.set(0, potionNbt); levitationPotionNbt.setTag("CustomPotionEffects", customEffectsList); displayNBT.setString("Name", "Splash Potion of Levitation"); levitationPotionNbt.setTag("display", displayNBT); addShapelessRecipe(new ItemStack(Items.POTIONITEM, 1, 0, levitationPotionNbt), ModItems.getItem("bat_wing"), Items.DRAGON_BREATH); } public static void addShapedRecipe(ItemStack output, Object...shape) { GameRegistry.addShapedRecipe(new ResourceLocation(Reference.MOD_ID, output.getItem().getRegistryName().getResourcePath()+"_recipe"), null, output, shape); } public static void addShapelessRecipe(ItemStack output, Item...items) { Ingredient[] ingredients = new Ingredient[items.length]; for (int i = 0; i < ingredients.length; i++) ingredients[i] = Ingredient.fromItem(items[i]); (init is called in a item register event after registering all the mod items) recipes are not added properly the first one does not works completly and the second one gives me a uncraftable potion with no effects Quote
Draco18s Posted November 5, 2017 Posted November 5, 2017 The NBT constructor is for capability NBT, it is not the same as the ItemStack's stackTagCompound field. Quote 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.
Choonster Posted November 5, 2017 Posted November 5, 2017 (edited) The ItemStack(Item, int, int, NBTTagCompound) constructor doesn't do what you think it does. The NBTTagCompound argument is for the serialised capability data, not the ItemStack's compound tag. Use one of the constructors without an NBTTagCompound argument and then use ItemStack#setTagCompound to set the ItemStack's compound tag. You shouldn't be manually creating the potion NBT anyway. If the effects you want already have a PotionType, use PotionUtils.addPotionToItemStack to add that to the potion ItemStack. If the effects don't have a PotionType (and you don't want to create one for them), use PotionUtils.appendEffects to add them to the potion ItemStack instead. If you want a splash potion, use Items.SPLASH_POTION instead of Items.POTIONITEM. Edited November 5, 2017 by Choonster Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
lukas2005 Posted November 5, 2017 Author Posted November 5, 2017 ok now what about the other one completly not working? Quote
Recommended Posts
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.