Skip to content

Commit

Permalink
Potion Recipes to Vanilla addMix
Browse files Browse the repository at this point in the history
Moved potion recipes to vanilla addMix to allow for CraftTweaker support.

Also switched around the non-vanilla handling to use individual items instead of lists, even though it'll no longer be in use.
  • Loading branch information
Charles445 committed Nov 12, 2020
1 parent 9cb18ae commit a92a4bd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.PotionHelper;
import net.minecraft.potion.PotionType;
import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
Expand All @@ -23,6 +24,8 @@

public class RegisterRecipes
{
public static boolean POTION_RECIPES_AS_VANILLA = true;

@Mod.EventBusSubscriber
public static class Registrar
{
Expand All @@ -43,23 +46,38 @@ public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
FluidUtil.getFilledBucket(new FluidStack(SDFluids.purifiedWater, Fluid.BUCKET_VOLUME)),
0.0f);


//Potions
//Avoiding using PotionHelper.addMix

//Awkward to normal
registerSameItemPotionRecipes(PotionTypes.AWKWARD, SDItems.ice_chunk, SDPotions.cold_resist_type);
registerSameItemPotionRecipes(PotionTypes.AWKWARD, SDItems.magma_chunk, SDPotions.heat_resist_type);

//Normal to long
registerSameItemPotionRecipes(SDPotions.cold_resist_type, Items.REDSTONE, SDPotions.long_cold_resist_type);
registerSameItemPotionRecipes(SDPotions.heat_resist_type, Items.REDSTONE, SDPotions.long_heat_resist_type);

//Item to Item
registerConversionPotionRecipes(SDPotions.cold_resist_type);
registerConversionPotionRecipes(SDPotions.heat_resist_type);
registerConversionPotionRecipes(SDPotions.long_cold_resist_type);
registerConversionPotionRecipes(SDPotions.long_heat_resist_type);
if(POTION_RECIPES_AS_VANILLA)
{
//This is done to allow for CraftTweaker support

//Awkward to normal
PotionHelper.addMix(PotionTypes.AWKWARD, SDItems.ice_chunk, SDPotions.cold_resist_type);
PotionHelper.addMix(PotionTypes.AWKWARD, SDItems.magma_chunk, SDPotions.heat_resist_type);

PotionHelper.addMix(SDPotions.cold_resist_type, Items.REDSTONE, SDPotions.long_cold_resist_type);
PotionHelper.addMix(SDPotions.heat_resist_type, Items.REDSTONE, SDPotions.long_heat_resist_type);
}
else
{
//Avoiding using PotionHelper.addMix
//This is the "proper" way to do this, but it does not allow CraftTweaker to remove them

//Awkward to normal
registerSameItemPotionRecipes(PotionTypes.AWKWARD, SDItems.ice_chunk, SDPotions.cold_resist_type);
registerSameItemPotionRecipes(PotionTypes.AWKWARD, SDItems.magma_chunk, SDPotions.heat_resist_type);

//Normal to long
registerSameItemPotionRecipes(SDPotions.cold_resist_type, Items.REDSTONE, SDPotions.long_cold_resist_type);
registerSameItemPotionRecipes(SDPotions.heat_resist_type, Items.REDSTONE, SDPotions.long_heat_resist_type);

//Item to Item
registerConversionPotionRecipes(SDPotions.cold_resist_type);
registerConversionPotionRecipes(SDPotions.heat_resist_type);
registerConversionPotionRecipes(SDPotions.long_cold_resist_type);
registerConversionPotionRecipes(SDPotions.long_heat_resist_type);
}
}

private static void registerConversionPotionRecipes(PotionType potionType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,16 @@
import javax.annotation.Nonnull;

import net.minecraft.item.ItemStack;
import net.minecraftforge.common.brewing.AbstractBrewingRecipe;
import net.minecraftforge.common.brewing.BrewingOreRecipe;
import net.minecraftforge.oredict.OreDictionary;

public class FixedBrewingOreRecipe extends BrewingOreRecipe
public class FixedBrewingOreRecipe extends AbstractBrewingRecipe<ItemStack>
{
//I wasn't expecting this to actually be a problem but it is
//BrewingRecipe and BrewingOreRecipe are set up to handle OreDict items well, but not anything NBT related

public FixedBrewingOreRecipe(@Nonnull ItemStack input, @Nonnull String ingredient, @Nonnull ItemStack output)
{
super(input, ingredient, output);
}

public FixedBrewingOreRecipe(@Nonnull ItemStack input, @Nonnull ItemStack ingredient, @Nonnull ItemStack output)
{
super(input, Arrays.asList(new ItemStack[]{ingredient}), output);
}

public FixedBrewingOreRecipe(@Nonnull ItemStack input, @Nonnull List<ItemStack> ingredient, @Nonnull ItemStack output)
public FixedBrewingOreRecipe(ItemStack input, ItemStack ingredient, ItemStack output)
{
super(input, ingredient, output);
}
Expand All @@ -34,4 +25,10 @@ public boolean isInput(@Nonnull ItemStack stack)
{
return super.isInput(stack) && ItemStack.areItemStackTagsEqual(getInput(), stack);
}

@Override
public boolean isIngredient(ItemStack ingredient)
{
return OreDictionary.itemMatches(this.getIngredient(), ingredient, false);
}
}

0 comments on commit a92a4bd

Please sign in to comment.