minh2908 Posted August 4, 2016 Posted August 4, 2016 My system works fine but i can brew a resistance potion with a resistance potion. Any help? Here is the class that extends IBrewingRecipe: public class PotionRecipe implements IBrewingRecipe{ private ItemStack input; private ItemStack ingredient; private ItemStack output; public PotionRecipe(ItemStack input, ItemStack ingredient, ItemStack output) { this.input = input; this.ingredient = ingredient; this.output = output; } @Override public boolean isInput(ItemStack input2) { if(!input2.hasTagCompound()) return false; return PotionUtils.getPotionFromItem(input2)==PotionUtils.getPotionFromItem(this.input); } @Override public boolean isIngredient(ItemStack ingredient2) { return ingredient2.getItem()==Items.REDSTONE || ingredient2.getItem()==Items.GLOWSTONE_DUST || ingredient2.getItem()==Items.IRON_INGOT||ingredient2.getItem()==Items.FERMENTED_SPIDER_EYE; } @Override public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) { if(ingredient2 != null && input2 != null && isIngredient(ingredient2)) { ItemStack output2 = this.output.copy(); if (input2 != output2) { return output2; } return null; } else return null; } } How I register the recipes: public void postInit(FMLPostInitializationEvent event) {BrewingRecipeRegistry.addRecipe(new PotionRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM,1), CustomPotionTypes.resistance), new ItemStack(Items.FERMENTED_SPIDER_EYE,1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM,1), CustomPotionTypes.weakening))); BrewingRecipeRegistry.addRecipe(new PotionRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM,1), PotionTypes.AWKWARD), new ItemStack(Items.IRON_INGOT,1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM,1), CustomPotionTypes.resistance))); } Quote
Animefan8888 Posted August 4, 2016 Posted August 4, 2016 Why not use BrewingRecipeRegistry.addRecipe(input, ingredient, output); Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
minh2908 Posted August 4, 2016 Author Posted August 4, 2016 It doesn't differentiate between different potions Quote
Animefan8888 Posted August 4, 2016 Posted August 4, 2016 In get output you never check if input2 is input. And honestly forge why would you just check to see if the item is the same when you should be comparing ItemStacks..... Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Animefan8888 Posted August 4, 2016 Posted August 4, 2016 Note these edits work for me. // This @Override public boolean isInput(ItemStack input2) { if(!input2.hasTagCompound()) return false; return PotionType.getPotionTypeForName(input2.getTagCompound().getString("Potion")) == PotionType.getPotionTypeForName(input.getTagCompound().getString("Potion")); } // And this @Override public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) { if(ingredient2 != null && input2 != null && isIngredient(ingredient2)) { ItemStack output2 = this.output.copy(); if (input2 != output2 && isInput(input2)) { return output2; } return null; } else return null; } Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
minh2908 Posted August 4, 2016 Author Posted August 4, 2016 That doesn't seems to solve the problem. I'm pretty sure that the check that you edit didn't change anything.The isInput was my fault ,though . The problem with the system is that even though iron ingot brew the resistance one and fermented spider eye brews the resistance potion to the weakening one, the iron ingot still brew the resistance potion to itself. Quote
Animefan8888 Posted August 4, 2016 Posted August 4, 2016 May I see the code you used to register the potions? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
minh2908 Posted August 4, 2016 Author Posted August 4, 2016 I assume you mean the potiontypes: public class CustomPotionTypes { public static PotionType resistance; public static PotionType weakening; public static void init(){ resistance= GameRegistry.register(new PotionType(new PotionEffect(MobEffects.RESISTANCE, 1800)).setRegistryName("resistance")); weakening= GameRegistry.register(new PotionType(new PotionEffect(CustomPotion.weakening, 1800)).setRegistryName("weakening")); }} In the Mod file: public void preInit(FMLPreInitializationEvent event) { CustomPotionTypes.init(); } Quote
Animefan8888 Posted August 5, 2016 Posted August 5, 2016 Could you post your updated code for PotionRecipes? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
minh2908 Posted August 5, 2016 Author Posted August 5, 2016 package minh2908.ores.init.potion; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionType; import net.minecraftforge.common.brewing.IBrewingRecipe; public class PotionRecipe implements IBrewingRecipe{ private ItemStack input; private ItemStack ingredient; private ItemStack output; public PotionRecipe(ItemStack input, ItemStack ingredient, ItemStack output) { this.input = input; this.ingredient = ingredient; this.output = output; } @Override public boolean isInput(ItemStack input2) { if(!input2.hasTagCompound()) return false; return PotionType.getPotionTypeForName(input2.getTagCompound().getString("Potion")) == PotionType.getPotionTypeForName(input.getTagCompound().getString("Potion")); } @Override public boolean isIngredient(ItemStack ingredient2) { return ingredient2.getItem()==Items.REDSTONE || ingredient2.getItem()==Items.GLOWSTONE_DUST || ingredient2.getItem()==Items.IRON_INGOT||ingredient2.getItem()==Items.FERMENTED_SPIDER_EYE; } @Override public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) { if(ingredient2 != null && input2 != null && isIngredient(ingredient2)) { ItemStack output2 = this.output.copy(); if (input2 != output2 && isInput(input2)) { return output2; } return null; } else return null; } } Quote
Animefan8888 Posted August 5, 2016 Posted August 5, 2016 May I see your entire Main Class? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
minh2908 Posted August 5, 2016 Author Posted August 5, 2016 I've found the solution! Turns out the ingredient check was defective . Thanks for your help, though, especially on reminding me of the ingredient check. Quote
Animefan8888 Posted August 5, 2016 Posted August 5, 2016 Post the change here please for future people that have this problem. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
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.