From 55a2d42a291576b35884ba1184ddcfa98fe0f48f Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 3 Jul 2019 21:47:42 -0700 Subject: [PATCH] Make recipes reloadable using an event. Eventually they may move to jsons/files, but this will do for now --- build.gradle | 2 +- .../java/vazkii/botania/api/BotaniaAPI.java | 101 +---------- .../vazkii/botania/api/recipe/RecipeBrew.java | 26 ++- .../botania/api/recipe/RecipeElvenTrade.java | 14 +- .../botania/api/recipe/RecipePetals.java | 10 +- .../botania/api/recipe/RecipePureDaisy.java | 32 +++- .../botania/api/recipe/RecipeRuneAltar.java | 8 +- .../api/recipe/RegisterRecipesEvent.java | 58 ++++++ .../java/vazkii/botania/common/Botania.java | 28 +-- .../botania/common/block/ModSubtiles.java | 5 +- .../common/block/mana/BlockBrewery.java | 6 +- .../block/subtile/SubTilePureDaisy.java | 2 +- .../common/block/tile/TileAlfPortal.java | 6 +- .../botania/common/block/tile/TileAltar.java | 4 +- .../common/block/tile/TileBrewery.java | 4 +- .../common/block/tile/TileRuneAltar.java | 9 +- .../common/core/handler/IMCHandler.java | 9 - .../common/core/handler/IMCSender.java | 4 - .../common/crafting/ModBrewRecipes.java | 69 +++---- .../common/crafting/ModElvenTradeRecipes.java | 37 ++-- .../crafting/ModManaAlchemyRecipes.java | 169 +++++++++--------- .../crafting/ModManaConjurationRecipes.java | 37 ++-- .../crafting/ModManaInfusionRecipes.java | 46 ++--- .../common/crafting/ModPetalRecipes.java | 101 ++++++----- .../common/crafting/ModPureDaisyRecipes.java | 32 ++-- .../common/crafting/ModRuneRecipes.java | 48 ++--- .../common/crafting/ReloadListener.java | 47 +++++ .../common/crafting/recipe/HeadRecipe.java | 5 +- .../botania/common/lexicon/LexiconData.java | 8 +- .../loot_tables/blocks/solid_vine.json | 2 +- 30 files changed, 510 insertions(+), 419 deletions(-) create mode 100644 src/main/java/vazkii/botania/api/recipe/RegisterRecipesEvent.java create mode 100644 src/main/java/vazkii/botania/common/crafting/ReloadListener.java diff --git a/build.gradle b/build.gradle index fa8dd5372..6d20abf33 100644 --- a/build.gradle +++ b/build.gradle @@ -87,7 +87,7 @@ configurations { //End of the SCP config dependencies { - minecraft 'net.minecraftforge:forge:1.14.3-27.0.16' + minecraft 'net.minecraftforge:forge:1.14.3-27.0.23' //deobfCompile "com.mod-buildcraft:buildcraft-api:7.99.17" //deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2" diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index d69c6fd99..f5042986c 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -70,13 +70,15 @@ public final class BotaniaAPI { public static final Map brewMap = new LinkedHashMap<>(); - public static final List petalRecipes = new ArrayList<>(); - public static final List pureDaisyRecipes = new ArrayList<>(); + /* + * These maps are not meant to be mutated! + */ + public static Map petalRecipes = Collections.emptyMap(); + public static Map pureDaisyRecipes = Collections.emptyMap(); public static Map manaInfusionRecipes = Collections.emptyMap(); - public static final List runeAltarRecipes = new ArrayList<>(); - public static final List elvenTradeRecipes = new ArrayList<>(); - public static final List brewRecipes = new ArrayList<>(); - public static final List miniFlowerRecipes = new ArrayList<>(); + public static Map runeAltarRecipes = Collections.emptyMap(); + public static Map elvenTradeRecipes = Collections.emptyMap(); + public static Map brewRecipes = Collections.emptyMap(); public static Map oreWeights = Collections.emptyMap(); public static Map oreWeightsNether = Collections.emptyMap(); @@ -420,93 +422,6 @@ public final class BotaniaAPI { return gravityRodBlacklist.contains(entity); } - /** - * Registers a Petal Recipe. - * @param output The ItemStack to craft. - * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper - * or String (case for Ore Dictionary). The array can't be larger than 16. - * @return The recipe created. - */ - public static RecipePetals registerPetalRecipe(ItemStack output, Ingredient... inputs) { - Preconditions.checkArgument(inputs.length <= 16); - RecipePetals recipe = new RecipePetals(output, inputs); - petalRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Pure Daisy Recipe with the default time - * @param input The input for the recipe. Can be a Block (meta-insensitive), IBlockState (meta-sensitive), or an oredict String. - * @param outputState The blockstate to be placed upon recipe completion. - * @return The recipe created. - */ - public static RecipePureDaisy registerPureDaisyRecipe(Object input, BlockState outputState) { - return registerPureDaisyRecipe(input, outputState, RecipePureDaisy.DEFAULT_TIME); - } - - /** - * Registers a Pure Daisy Recipe. - * @param input The input for the recipe. Can be a Block (meta-insensitive), IBlockState (meta-sensitive), or an oredict String. - * @param outputState The blockstate to be placed upon recipe completion. - * @param time The amount of time in ticks to complete this recipe. Note that this is ticks on your block, not total time. - * The Pure Daisy only ticks one block at a time in a round robin fashion. - * @return The recipe created. - */ - public static RecipePureDaisy registerPureDaisyRecipe(Object input, BlockState outputState, int time) { - RecipePureDaisy recipe = new RecipePureDaisy(input, outputState, time); - pureDaisyRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Rune Altar Recipe. - * @param output The ItemStack to craft. - * @param mana The amount of mana required. Don't go over 100000! - * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper - * or String (case for Ore Dictionary). The array can't be larger than 16. - * @return The recipe created. - */ - public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Ingredient... inputs) { - Preconditions.checkArgument(inputs.length <= 16); - RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs); - runeAltarRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Elven Trade recipe (throw an item in an Alfheim Portal). - * @param outputs The ItemStacks to return. - * @param inputs The items required, can be ItemStack or ore dictionary entry string. - * @return The recipe created. - */ - public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack[] outputs, Ingredient... inputs) { - RecipeElvenTrade recipe = new RecipeElvenTrade(outputs, inputs); - elvenTradeRecipes.add(recipe); - return recipe; - } - - /** - * Registers a Elven Trade recipe (throw an item into an Alfeim Portal). - * @param output The ItemStack to return - * @param inputs The items required, can be an ItemStack or an Ore Dictionary entry string. - * @return The recipe created. - */ - public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Ingredient... inputs) { - return registerElvenTradeRecipe(new ItemStack[]{ output }, inputs); - } - - /** - * Registers a Brew Recipe (for the Botanical Brewery). - * @param brew The brew in to be set in this recipe. - * @param inputs The items used in the recipe, no more than 6. - */ - public static RecipeBrew registerBrewRecipe(Brew brew, Ingredient... inputs) { - Preconditions.checkArgument(inputs.length <= 6); - RecipeBrew recipe = new RecipeBrew(brew, inputs); - brewRecipes.add(recipe); - return recipe; - } - /** * Adds a category to the list of registered categories to appear in the Lexicon. */ diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java index 0726d5d6e..2a89646e5 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java @@ -14,19 +14,22 @@ import com.google.common.collect.ImmutableList; import net.minecraft.item.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.items.IItemHandler; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewContainer; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; public class RecipeBrew { - + private final ResourceLocation id; private final Brew brew; private final ImmutableList inputs; - public RecipeBrew(Brew brew, Ingredient... inputs) { + public RecipeBrew(ResourceLocation id, Brew brew, Ingredient... inputs) { + this.id = id; this.brew = brew; this.inputs = ImmutableList.copyOf(inputs); } @@ -42,24 +45,29 @@ public class RecipeBrew { if(stack.getItem() instanceof IBrewContainer) continue; - int stackIndex = -1; + boolean matchedOne = false; - for(int j = 0; j < inputsMissing.size(); j++) { - Ingredient input = inputsMissing.get(j); + Iterator iter = inputsMissing.iterator(); + while (iter.hasNext()) { + Ingredient input = iter.next(); if(input.test(stack)) { - stackIndex = j; + iter.remove(); + matchedOne = true; break; } } - if(stackIndex != -1) - inputsMissing.remove(stackIndex); - else return false; + if(!matchedOne) + return false; } return inputsMissing.isEmpty(); } + public ResourceLocation getId() { + return id; + } + public List getInputs() { return new ArrayList<>(inputs); } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java index 2116ef591..fbcfaae5b 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java @@ -3,16 +3,22 @@ package vazkii.botania.api.recipe; import com.google.common.collect.ImmutableList; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; import java.util.ArrayList; import java.util.List; public class RecipeElvenTrade { - + private final ResourceLocation id; private final ImmutableList outputs; private final ImmutableList inputs; - public RecipeElvenTrade(ItemStack[] outputs, Ingredient... inputs) { + public RecipeElvenTrade(ResourceLocation id, ItemStack output, Ingredient... inputs) { + this(id, new ItemStack[] { output }, inputs); + } + + public RecipeElvenTrade(ResourceLocation id, ItemStack[] outputs, Ingredient... inputs) { + this.id = id; this.outputs = ImmutableList.copyOf(outputs); this.inputs = ImmutableList.copyOf(inputs); } @@ -51,6 +57,10 @@ public class RecipeElvenTrade { return inputsMissing.isEmpty(); } + public ResourceLocation getId() { + return id; + } + public List getInputs() { return inputs; } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java index 710b123cf..4868a11fb 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java @@ -14,6 +14,7 @@ import com.google.common.collect.ImmutableList; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.items.IItemHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -21,11 +22,12 @@ import java.util.ArrayList; import java.util.List; public class RecipePetals { - + private final ResourceLocation id; private final ItemStack output; private final ImmutableList inputs; - public RecipePetals(ItemStack output, Ingredient... inputs) { + public RecipePetals(ResourceLocation id, ItemStack output, Ingredient... inputs) { + this.id = id; this.output = output; this.inputs = ImmutableList.copyOf(inputs); } @@ -56,6 +58,10 @@ public class RecipePetals { return ingredientsMissing.isEmpty(); } + public ResourceLocation getId() { + return id; + } + public List getInputs() { return inputs; } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java b/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java index ea84e3fb7..de175d83e 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java @@ -14,6 +14,7 @@ import com.google.common.base.Preconditions; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.tags.Tag; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import vazkii.botania.api.subtile.TileEntitySpecialFlower; @@ -22,22 +23,37 @@ public class RecipePureDaisy { public static final int DEFAULT_TIME = 150; + private final ResourceLocation id; private final Object input; private final BlockState outputState; private final int time; - public RecipePureDaisy(Object input, BlockState state) { - this(input, state, DEFAULT_TIME); + public RecipePureDaisy(ResourceLocation id, Object input, BlockState state) { + this(id, input, state, DEFAULT_TIME); } - public RecipePureDaisy(Object input, BlockState state, int time) { + /** + * @param id The ID for this recipe. + * @param input The input for the recipe. Can be a Block, BlockState, or Tag<Block>. + * @param state The blockstate to be placed upon recipe completion. + * @param time The amount of time in ticks to complete this recipe. Note that this is ticks on your block, not total time. + * The Pure Daisy only ticks one block at a time in a round robin fashion. + */ + public RecipePureDaisy(ResourceLocation id, Object input, BlockState state, int time) { Preconditions.checkArgument(time >= 0, "Time must be nonnegative"); + this.id = id; this.input = input; - outputState = state; + this.outputState = state; this.time = time; - if(input != null && !(input instanceof Tag || input instanceof Block || input instanceof BlockState)) + if(input != null + && !(input instanceof Block) + && !(input instanceof BlockState) + && !(input instanceof Tag && checkBlockTag((Tag) input))) throw new IllegalArgumentException("input must be a Tag, Block, or IBlockState"); - // todo 1.13 find way to throw or enforce Tag + } + + private static boolean checkBlockTag(Tag tag) { + return tag.getAllElements().stream().allMatch(o -> o instanceof Block); } /** @@ -76,4 +92,8 @@ public class RecipePureDaisy { return time; } + public ResourceLocation getId() { + return id; + } + } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java b/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java index 99ff446e6..d85420169 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java @@ -10,15 +10,19 @@ */ package vazkii.botania.api.recipe; +import com.google.common.base.Preconditions; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; public class RecipeRuneAltar extends RecipePetals { private final int mana; - public RecipeRuneAltar(ItemStack output, int mana, Ingredient... inputs) { - super(output, inputs); + public RecipeRuneAltar(ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) { + super(id, output, inputs); + Preconditions.checkArgument(inputs.length <= 16); + Preconditions.checkArgument(mana <= 100000); this.mana = mana; } diff --git a/src/main/java/vazkii/botania/api/recipe/RegisterRecipesEvent.java b/src/main/java/vazkii/botania/api/recipe/RegisterRecipesEvent.java new file mode 100644 index 000000000..83af2de6c --- /dev/null +++ b/src/main/java/vazkii/botania/api/recipe/RegisterRecipesEvent.java @@ -0,0 +1,58 @@ +package vazkii.botania.api.recipe; + +import net.minecraftforge.eventbus.api.Event; + +import java.util.function.Consumer; + +/** + * Fired on {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS} + * whenever Botania wants to receive recipe registrations, i.e. on server start and every /reload. + * + * The handles to register recipes are simple {@link Consumer}s that accept the recipe to register it. + * + * This will be fired many times during the lifecycle of the game, it's highly encouraged you keep your event + * handlers as stateless as possible. + */ +public class RegisterRecipesEvent extends Event { + private final Consumer pureDaisy; + private final Consumer manaInfusion; + private final Consumer brew; + private final Consumer elvenTrade; + private final Consumer apothecary; + private final Consumer runeAltar; + + public RegisterRecipesEvent(Consumer pureDaisy, Consumer manaInfusion, + Consumer brew, Consumer elvenTrade, + Consumer apothecary, Consumer runeAltar) { + this.pureDaisy = pureDaisy; + this.manaInfusion = manaInfusion; + this.brew = brew; + this.elvenTrade = elvenTrade; + this.apothecary = apothecary; + this.runeAltar = runeAltar; + } + + public Consumer pureDaisy() { + return pureDaisy; + } + + public Consumer manaInfusion() { + return manaInfusion; + } + + public Consumer brew() { + return brew; + } + + public Consumer elvenTrade() { + return elvenTrade; + } + + public Consumer apothecary() { + return apothecary; + } + + public Consumer runeAltar() { + return runeAltar; + } +} diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index d9d1e69ae..44e45f61c 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -71,29 +71,10 @@ import vazkii.botania.common.core.loot.TrueGuardianKiller; import vazkii.botania.common.core.proxy.IProxy; import vazkii.botania.common.core.proxy.ServerProxy; import vazkii.botania.common.crafting.FluxfieldConditionFactory; -import vazkii.botania.common.crafting.ModBrewRecipes; import vazkii.botania.common.crafting.ModCraftingRecipes; -import vazkii.botania.common.crafting.ModElvenTradeRecipes; import vazkii.botania.common.crafting.ModPetalRecipes; -import vazkii.botania.common.crafting.ModPureDaisyRecipes; import vazkii.botania.common.crafting.ModRuneRecipes; -import vazkii.botania.common.crafting.recipe.AncientWillRecipe; -import vazkii.botania.common.crafting.recipe.ArmorUpgradeRecipe; -import vazkii.botania.common.crafting.recipe.BlackHoleTalismanExtractRecipe; -import vazkii.botania.common.crafting.recipe.CompositeLensRecipe; -import vazkii.botania.common.crafting.recipe.CosmeticAttachRecipe; -import vazkii.botania.common.crafting.recipe.CosmeticRemoveRecipe; -import vazkii.botania.common.crafting.recipe.HelmRevealingRecipe; -import vazkii.botania.common.crafting.recipe.KeepIvyRecipe; -import vazkii.botania.common.crafting.recipe.LensDyeingRecipe; -import vazkii.botania.common.crafting.recipe.ManaGunClipRecipe; -import vazkii.botania.common.crafting.recipe.ManaGunLensRecipe; -import vazkii.botania.common.crafting.recipe.ManaGunRemoveLensRecipe; -import vazkii.botania.common.crafting.recipe.ManaUpgradeRecipe; -import vazkii.botania.common.crafting.recipe.PhantomInkRecipe; -import vazkii.botania.common.crafting.recipe.ShapelessManaUpgradeRecipe; -import vazkii.botania.common.crafting.recipe.SpellClothRecipe; -import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; +import vazkii.botania.common.crafting.ReloadListener; import vazkii.botania.common.entity.EntityCorporeaSpark; import vazkii.botania.common.entity.EntityDoppleganger; import vazkii.botania.common.entity.EntityFlameRing; @@ -154,11 +135,6 @@ public class Botania { PacketHandler.init(); ModBrews.init(); ModMultiblocks.init(); - ModPetalRecipes.init(); - ModPureDaisyRecipes.init(); - ModRuneRecipes.init(); - ModElvenTradeRecipes.init(); - ModBrewRecipes.init(); ModCraftingRecipes.init(); // todo 1.13 LexiconData.init(); @@ -167,7 +143,6 @@ public class Botania { // todo 1.13 MinecraftForge.EVENT_BUS.register(TCAspects.class); } ModBrews.initTC(); - ModBrewRecipes.initTC(); } MinecraftForge.EVENT_BUS.register(ManaNetworkHandler.instance); @@ -253,6 +228,7 @@ public class Botania { + " \"Do not Override\". Whoever had the brilliant idea of overriding it needs to go" + " back to elementary school and learn to read. (Expected classname: " + expect + ", Actual classname: " + clname + ")"); } + event.getServer().getResourceManager().addReloadListener(new ReloadListener()); } private void serverStarting(FMLServerStartingEvent event) { diff --git a/src/main/java/vazkii/botania/common/block/ModSubtiles.java b/src/main/java/vazkii/botania/common/block/ModSubtiles.java index 0b6cbd793..fe3f9e6fe 100644 --- a/src/main/java/vazkii/botania/common/block/ModSubtiles.java +++ b/src/main/java/vazkii/botania/common/block/ModSubtiles.java @@ -237,10 +237,13 @@ public class ModSubtiles { @SubscribeEvent public static void registerTEs(RegistryEvent.Register> evt) { + IForgeRegistry b = ForgeRegistries.BLOCKS; IForgeRegistry> r = evt.getRegistry(); for (Pair, ResourceLocation> type : TYPES) { - register(r, TileEntityType.Builder.create(type.getLeft()).build(null), type.getRight()); + Block block = b.getValue(type.getRight()); + Block floating = b.getValue(floating(type.getRight())); + register(r, TileEntityType.Builder.create(type.getLeft(), block, floating).build(null), type.getRight()); } } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java b/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java index 220d289c1..99d48ed21 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java @@ -78,10 +78,12 @@ public class BlockBrewery extends BlockMod implements ILexiconable, IWandHUD { @Override public void onReplaced(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState newState, boolean isMoving) { - TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos); + if(state.getBlock() != newState.getBlock()) { + TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos); - InventoryHelper.dropInventory(inv, world, state, pos); + InventoryHelper.dropInventory(inv, world, state, pos); + } super.onReplaced(state, world, pos, newState, isMoving); } diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java index dab305ad0..89b192d76 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java @@ -124,7 +124,7 @@ public class SubTilePureDaisy extends TileEntitySpecialFlower { private RecipePureDaisy findRecipe(BlockPos coords) { BlockState state = getWorld().getBlockState(coords); - for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes.values()) { if(recipe.matches(getWorld(), coords, this, state)) { return recipe; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java index fec7b7a55..7fbbd2035 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java @@ -194,7 +194,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { if(inputStack.getItem() == ModItems.lexicon) return true; - for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { + for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) { for(Ingredient o : recipe.getInputs()) { if(o.test(inputStack)) { return true; @@ -263,7 +263,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { i++; } - for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { + for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) { if(recipe.matches(stacksIn, false)) { if(consumeMana(null, 500, false)) { recipe.matches(stacksIn, true); @@ -363,7 +363,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { for(int i = -range; i < range + 1; i++) for(int j = -range; j < range + 1; j++) for(int k = -range; k < range + 1; k++) { - BlockPos pos = new BlockPos(i, j, k); + BlockPos pos = getPos().add(i, j, k); if(world.getBlockState(pos) == pylonState && world.getBlockState(pos.down()).getBlock() instanceof BlockPool) list.add(pos); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java index eb4a0900a..617b09c6c 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java @@ -146,7 +146,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, } if(SEED_PATTERN.matcher(stack.getTranslationKey()).find()) { - for(RecipePetals recipe : BotaniaAPI.petalRecipes) { + for(RecipePetals recipe : BotaniaAPI.petalRecipes.values()) { if(recipe.matches(itemHandler)) { saveLastRecipe(); @@ -377,7 +377,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, if(amt > 0) { float anglePer = 360F / amt; - for(RecipePetals recipe : BotaniaAPI.petalRecipes) + for(RecipePetals recipe : BotaniaAPI.petalRecipes.values()) if(recipe.matches(itemHandler)) { GlStateManager.color4f(1F, 1F, 1F, 1F); mc.textureManager.bindTexture(HUDHandler.manaBar); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java index 018f4b096..d82a9a419 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java @@ -80,7 +80,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I if(did) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) + for(RecipeBrew recipe : BotaniaAPI.brewRecipes.values()) if(recipe.matches(itemHandler) && !recipe.getOutput(itemHandler.getStackInSlot(0)).isEmpty()) { this.recipe = recipe; world.setBlockState(pos, ModBlocks.brewery.getDefaultState().with(BotaniaStateProps.POWERED, true), 1 | 2); @@ -93,7 +93,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I @Override public void tick() { if(mana > 0 && recipe == null) { - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) + for(RecipeBrew recipe : BotaniaAPI.brewRecipes.values()) if(recipe.matches(itemHandler)) { this.recipe = recipe; world.setBlockState(pos, ModBlocks.brewery.getDefaultState().with(BotaniaStateProps.POWERED, true), 1 | 2); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java index dfca753f4..09d25d2d3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java @@ -193,7 +193,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, if(currentRecipe != null) this.manaToGet = currentRecipe.getManaUsage(); else { - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) + for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) if(recipe.matches(itemHandler)) { this.manaToGet = recipe.getManaUsage(); break getMana; @@ -227,7 +227,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, } public boolean hasValidRecipe() { - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) + for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) if(recipe.matches(itemHandler)) return true; @@ -242,7 +242,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, if(currentRecipe != null) recipe = currentRecipe; - else for(RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes) { + else for(RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes.values()) { if(recipe_.matches(itemHandler)) { recipe = recipe_; break; @@ -366,13 +366,12 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, if(amt > 0) { float anglePer = 360F / amt; - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) + for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) if(recipe.matches(itemHandler)) { GlStateManager.enableBlend(); GlStateManager.enableRescaleNormal(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - recipe.getOutput(); float progress = (float) mana / (float) manaToGet; mc.textureManager.bindTexture(HUDHandler.manaBar); diff --git a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java index 67b2029ce..d1924913c 100644 --- a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java @@ -28,7 +28,6 @@ public final class IMCHandler { BotaniaAPI.oreWeightsNether = handleOreWeights(evt.getIMCStream(IMC.REGISTER_NETHER_ORE_WEIGHT::equals)); WikiHooks.modWikis = handleWikis(evt.getIMCStream(IMC.REGISTER_MOD_WIKI::equals)); BotaniaAPI.paintableBlocks = handlePaintable(evt.getIMCStream(IMC.REGISTER_PAINTABLE_BLOCK::equals)); - BotaniaAPI.manaInfusionRecipes = handleManaInfusion(evt.getIMCStream(IMC.REGISTER_MANA_INFUSION::equals)); } private static Map handleWikis(Stream msgs) { @@ -54,12 +53,4 @@ public final class IMCHandler { .collect(Collectors.toMap(PaintableBlockMessage::getBlock, PaintableBlockMessage::getTransformer)); return ImmutableMap.copyOf(map); } - - private static Map handleManaInfusion(Stream msgs) { - Map map = msgs - .filter(msg -> msg.getMessageSupplier().get() instanceof RecipeManaInfusion) - .map(msg -> (RecipeManaInfusion) msg.getMessageSupplier().get()) - .collect(Collectors.toMap(RecipeManaInfusion::getId, r -> r)); - return ImmutableMap.copyOf(map); - } } diff --git a/src/main/java/vazkii/botania/common/core/handler/IMCSender.java b/src/main/java/vazkii/botania/common/core/handler/IMCSender.java index e2c163f49..c2d18181d 100644 --- a/src/main/java/vazkii/botania/common/core/handler/IMCSender.java +++ b/src/main/java/vazkii/botania/common/core/handler/IMCSender.java @@ -133,10 +133,6 @@ public class IMCSender { Blocks.CYAN_CARPET, Blocks.PURPLE_CARPET, Blocks.BLUE_CARPET, Blocks.BROWN_CARPET, Blocks.GREEN_CARPET, Blocks.RED_CARPET, Blocks.BLACK_CARPET }; for(Block b : carpets) send(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(ColorHelper.CARPET_MAP::get, b)); - - ModManaInfusionRecipes.send(); - ModManaAlchemyRecipes.send(); - ModManaConjurationRecipes.send(); } public static void send(String method, Object thing) { diff --git a/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java index e8fa7eac9..e720589e0 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java @@ -20,13 +20,21 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.tags.ItemTags; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ForgeRegistries; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeBrew; +import vazkii.botania.api.recipe.RegisterRecipesEvent; +import vazkii.botania.common.Botania; import vazkii.botania.common.brew.ModBrews; import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.LibOreDict; +import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; + +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class ModBrewRecipes { public static RecipeBrew speedBrew; @@ -53,37 +61,36 @@ public class ModBrewRecipes { public static RecipeBrew warpWardBrew; - public static void init() { - speedBrew = BotaniaAPI.registerBrewRecipe(ModBrews.speed, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.REDSTONE)); - strengthBrew = BotaniaAPI.registerBrewRecipe(ModBrews.strength, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.BLAZE_POWDER), Ingredient.fromItems(Items.GLOWSTONE_DUST)); - hasteBrew = BotaniaAPI.registerBrewRecipe(ModBrews.haste, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.GOLD_NUGGET)); - healingBrew = BotaniaAPI.registerBrewRecipe(ModBrews.healing, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GLISTERING_MELON_SLICE), Ingredient.fromItems(Items.POTATO)); - jumpBoostBrew = BotaniaAPI.registerBrewRecipe(ModBrews.jumpBoost, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.CARROT)); - regenerationBrew = BotaniaAPI.registerBrewRecipe(ModBrews.regen, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GHAST_TEAR), Ingredient.fromItems(Items.GLOWSTONE_DUST)); - weakRegenerationBrew = BotaniaAPI.registerBrewRecipe(ModBrews.regenWeak, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GHAST_TEAR), Ingredient.fromItems(Items.REDSTONE)); - resistanceBrew = BotaniaAPI.registerBrewRecipe(ModBrews.resistance, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.IRON_INGOT), Ingredient.fromItems(Items.LEATHER)); - fireResistanceBrew = BotaniaAPI.registerBrewRecipe(ModBrews.fireResistance, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.MAGMA_CREAM), Ingredient.fromItems(Blocks.NETHERRACK)); - waterBreathingBrew = BotaniaAPI.registerBrewRecipe(ModBrews.waterBreathing, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.GLOWSTONE_DUST)); - invisibilityBrew = BotaniaAPI.registerBrewRecipe(ModBrews.invisibility, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.SNOWBALL), Ingredient.fromItems(Items.GLOWSTONE_DUST)); - nightVisionBrew = BotaniaAPI.registerBrewRecipe(ModBrews.nightVision, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.SPIDER_EYE), Ingredient.fromItems(Items.GOLDEN_CARROT)); - absorptionBrew = BotaniaAPI.registerBrewRecipe(ModBrews.absorption, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GOLDEN_APPLE), Ingredient.fromItems(Items.POTATO)); + @SubscribeEvent + public static void register(RegisterRecipesEvent evt) { + evt.brew().accept(new RecipeBrew(prefix("speed"), ModBrews.speed, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.REDSTONE))); + evt.brew().accept(new RecipeBrew(prefix("strength"), ModBrews.strength, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.BLAZE_POWDER), Ingredient.fromItems(Items.GLOWSTONE_DUST))); + evt.brew().accept(new RecipeBrew(prefix("haste"), ModBrews.haste, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.GOLD_NUGGET))); + evt.brew().accept(new RecipeBrew(prefix("healing"), ModBrews.healing, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GLISTERING_MELON_SLICE), Ingredient.fromItems(Items.POTATO))); + evt.brew().accept(new RecipeBrew(prefix("jump_boost"), ModBrews.jumpBoost, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.CARROT))); + evt.brew().accept(new RecipeBrew(prefix("regeneration"), ModBrews.regen, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GHAST_TEAR), Ingredient.fromItems(Items.GLOWSTONE_DUST))); + evt.brew().accept(new RecipeBrew(prefix("weak_regenreation"), ModBrews.regenWeak, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GHAST_TEAR), Ingredient.fromItems(Items.REDSTONE))); + evt.brew().accept(new RecipeBrew(prefix("resistance"), ModBrews.resistance, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.IRON_INGOT), Ingredient.fromItems(Items.LEATHER))); + evt.brew().accept(new RecipeBrew(prefix("fire_resistance"), ModBrews.fireResistance, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.MAGMA_CREAM), Ingredient.fromItems(Blocks.NETHERRACK))); + evt.brew().accept(new RecipeBrew(prefix("water_breathing"), ModBrews.waterBreathing, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.GLOWSTONE_DUST))); + evt.brew().accept(new RecipeBrew(prefix("invisibility"), ModBrews.invisibility, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.SNOWBALL), Ingredient.fromItems(Items.GLOWSTONE_DUST))); + evt.brew().accept(new RecipeBrew(prefix("night_vision"), ModBrews.nightVision, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.SPIDER_EYE), Ingredient.fromItems(Items.GOLDEN_CARROT))); + evt.brew().accept(new RecipeBrew(prefix("absorption"), ModBrews.absorption, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GOLDEN_APPLE), Ingredient.fromItems(Items.POTATO))); - overloadBrew = BotaniaAPI.registerBrewRecipe(ModBrews.overload, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.BLAZE_POWDER), Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.GLOWSTONE_DUST), Ingredient.fromItems(ModItems.manaSteel), Ingredient.fromItems(Items.SPIDER_EYE)); - soulCrossBrew = BotaniaAPI.registerBrewRecipe(ModBrews.soulCross, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Blocks.SOUL_SAND), Ingredient.fromItems(Items.PAPER), Ingredient.fromItems(Items.APPLE), Ingredient.fromItems(Items.BONE)); - featherFeetBrew = BotaniaAPI.registerBrewRecipe(ModBrews.featherfeet, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.LEATHER), Ingredient.fromTag(ItemTags.WOOL)); - emptinessBrew = BotaniaAPI.registerBrewRecipe(ModBrews.emptiness, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GUNPOWDER), Ingredient.fromItems(Items.ROTTEN_FLESH), Ingredient.fromItems(Items.BONE), Ingredient.fromItems(Items.STRING), Ingredient.fromItems(Items.ENDER_PEARL)); - bloodthirstBrew = BotaniaAPI.registerBrewRecipe(ModBrews.bloodthirst, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.FERMENTED_SPIDER_EYE), Ingredient.fromItems(Items.LAPIS_LAZULI), Ingredient.fromItems(Items.FIRE_CHARGE), Ingredient.fromItems(Items.IRON_INGOT)); - allureBrew = BotaniaAPI.registerBrewRecipe(ModBrews.allure, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.COD), Ingredient.fromItems(Items.QUARTZ), Ingredient.fromItems(Items.GOLDEN_CARROT)); - clearBrew = BotaniaAPI.registerBrewRecipe(ModBrews.clear, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.QUARTZ), Ingredient.fromItems(Items.EMERALD), Ingredient.fromItems(Items.MELON_SLICE)); + evt.brew().accept(new RecipeBrew(prefix("overload"), ModBrews.overload, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.BLAZE_POWDER), Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.GLOWSTONE_DUST), Ingredient.fromItems(ModItems.manaSteel), Ingredient.fromItems(Items.SPIDER_EYE))); + evt.brew().accept(new RecipeBrew(prefix("soul_cross"), ModBrews.soulCross, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Blocks.SOUL_SAND), Ingredient.fromItems(Items.PAPER), Ingredient.fromItems(Items.APPLE), Ingredient.fromItems(Items.BONE))); + evt.brew().accept(new RecipeBrew(prefix("feather_feet"), ModBrews.featherfeet, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.LEATHER), Ingredient.fromTag(ItemTags.WOOL))); + evt.brew().accept(new RecipeBrew(prefix("emptiness"), ModBrews.emptiness, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.GUNPOWDER), Ingredient.fromItems(Items.ROTTEN_FLESH), Ingredient.fromItems(Items.BONE), Ingredient.fromItems(Items.STRING), Ingredient.fromItems(Items.ENDER_PEARL))); + evt.brew().accept(new RecipeBrew(prefix("bloodthirst"), ModBrews.bloodthirst, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.FERMENTED_SPIDER_EYE), Ingredient.fromItems(Items.LAPIS_LAZULI), Ingredient.fromItems(Items.FIRE_CHARGE), Ingredient.fromItems(Items.IRON_INGOT))); + evt.brew().accept(new RecipeBrew(prefix("allure"), ModBrews.allure, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.COD), Ingredient.fromItems(Items.QUARTZ), Ingredient.fromItems(Items.GOLDEN_CARROT))); + evt.brew().accept(new RecipeBrew(prefix("clear"), ModBrews.clear, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.QUARTZ), Ingredient.fromItems(Items.EMERALD), Ingredient.fromItems(Items.MELON_SLICE))); + + if(Botania.thaumcraftLoaded) { + Item salisMundus = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "salis_mundus")); + Item bathSalts = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "bath_salts")); + Item amber = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "amber")); + + evt.brew().accept(new RecipeBrew(prefix("warp_ward"), ModBrews.warpWard, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(salisMundus), Ingredient.fromItems(bathSalts), Ingredient.fromItems(amber))); + } } - - public static void initTC() { - Item salisMundus = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "salis_mundus")); - Item bathSalts = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "bath_salts")); - Item amber = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "amber")); - - warpWardBrew = BotaniaAPI.registerBrewRecipe(ModBrews.warpWard, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(salisMundus), Ingredient.fromItems(bathSalts), Ingredient.fromItems(amber)); - } - - } diff --git a/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java index fce61d267..f3ab9726e 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java @@ -8,8 +8,11 @@ import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.tags.ItemTags; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeElvenTrade; +import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; @@ -18,6 +21,9 @@ import vazkii.botania.common.lib.LibOreDict; import java.util.ArrayList; import java.util.List; +import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; + +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class ModElvenTradeRecipes { public static RecipeElvenTrade dreamwoodRecipe; @@ -27,29 +33,28 @@ public class ModElvenTradeRecipes { public static RecipeElvenTrade elvenQuartzRecipe; public static RecipeElvenTrade alfglassRecipe; - public static void init() { + @SubscribeEvent + public static void register(RegisterRecipesEvent evt) { Ingredient livingwood = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "livingwood"))); - dreamwoodRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.dreamwood), livingwood); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("dreamwood"), new ItemStack(ModBlocks.dreamwood), livingwood)); Ingredient manaDiamond = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation("forge", "gems/mana_diamond"))); Ingredient manaSteel = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation("forge", "ingots/manasteel"))); - elementiumRecipes = new ArrayList<>(); - elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.elementium), manaSteel, manaSteel)); - elementiumRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.elementiumBlock), Ingredient.fromItems(ModBlocks.manasteelBlock), Ingredient.fromItems(ModBlocks.manasteelBlock))); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("elementium"), new ItemStack(ModItems.elementium), manaSteel, manaSteel)); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("elementium_block"), new ItemStack(ModBlocks.elementiumBlock), Ingredient.fromItems(ModBlocks.manasteelBlock), Ingredient.fromItems(ModBlocks.manasteelBlock))); - pixieDustRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.pixieDust), Ingredient.fromItems(ModItems.manaPearl)); - dragonstoneRecipes = new ArrayList<>(); - dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.dragonstone), manaDiamond)); - dragonstoneRecipes.add(BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.dragonstoneBlock), Ingredient.fromItems(ModBlocks.manaDiamondBlock))); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("pixie_dust"), new ItemStack(ModItems.pixieDust), Ingredient.fromItems(ModItems.manaPearl))); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("dragonstone"), new ItemStack(ModItems.dragonstone), manaDiamond)); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("dragonstone_block"), new ItemStack(ModBlocks.dragonstoneBlock), Ingredient.fromItems(ModBlocks.manaDiamondBlock))); - elvenQuartzRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModItems.elfQuartz), Ingredient.fromItems(Items.QUARTZ)); - alfglassRecipe = BotaniaAPI.registerElvenTradeRecipe(new ItemStack(ModBlocks.elfGlass), Ingredient.fromItems(ModBlocks.manaGlass)); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("elf_quartz"), new ItemStack(ModItems.elfQuartz), Ingredient.fromItems(Items.QUARTZ))); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("elf_glass"), new ItemStack(ModBlocks.elfGlass), Ingredient.fromItems(ModBlocks.manaGlass))); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.IRON_INGOT), Ingredient.fromItems(Items.IRON_INGOT)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.IRON_BLOCK), Ingredient.fromItems(Blocks.IRON_BLOCK)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.ENDER_PEARL), Ingredient.fromItems(Items.ENDER_PEARL)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Items.DIAMOND), Ingredient.fromItems(Items.DIAMOND)); - BotaniaAPI.registerElvenTradeRecipe(new ItemStack(Blocks.DIAMOND_BLOCK), Ingredient.fromItems(Blocks.DIAMOND_BLOCK)); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("iron_return"), new ItemStack(Items.IRON_INGOT), Ingredient.fromItems(Items.IRON_INGOT))); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("iron_block_return"), new ItemStack(Blocks.IRON_BLOCK), Ingredient.fromItems(Blocks.IRON_BLOCK))); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("ender_pearl_return"), new ItemStack(Items.ENDER_PEARL), Ingredient.fromItems(Items.ENDER_PEARL))); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("diamond_return"), new ItemStack(Items.DIAMOND), Ingredient.fromItems(Items.DIAMOND))); + evt.elvenTrade().accept(new RecipeElvenTrade(prefix("diamond_block_return"), new ItemStack(Blocks.DIAMOND_BLOCK), Ingredient.fromItems(Blocks.DIAMOND_BLOCK))); } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java index ae99bb450..d0bd5a0a2 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java @@ -20,8 +20,11 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.tags.ItemTags; import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import vazkii.botania.api.imc.IMC; import vazkii.botania.api.recipe.RecipeManaInfusion; +import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.block.ModSubtiles; @@ -33,6 +36,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public final class ModManaAlchemyRecipes { public static RecipeManaInfusion leatherRecipe; @@ -65,119 +69,120 @@ public final class ModManaAlchemyRecipes { // Garden of Glass public static List prismarineRecipes; - public static void send() { - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("rotten_flesh_to_leather"), new ItemStack(Items.LEATHER), Ingredient.fromItems(Items.ROTTEN_FLESH), 600)); + @SubscribeEvent + public static void register(RegisterRecipesEvent evt) { + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("rotten_flesh_to_leather"), new ItemStack(Items.LEATHER), Ingredient.fromItems(Items.ROTTEN_FLESH), 600)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("oak_to_spruce_log"), new ItemStack(Blocks.SPRUCE_LOG), Ingredient.fromItems(Blocks.OAK_LOG), 40)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("spruce_to_birch_log"), new ItemStack(Blocks.BIRCH_LOG), Ingredient.fromItems(Blocks.SPRUCE_LOG), 40)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("birch_to_jungle_log"), new ItemStack(Blocks.JUNGLE_LOG), Ingredient.fromItems(Blocks.BIRCH_LOG), 40)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("jungle_to_acacia_log"), new ItemStack(Blocks.ACACIA_LOG), Ingredient.fromItems(Blocks.JUNGLE_LOG), 40)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("acacia_to_dark_oak_log"), new ItemStack(Blocks.DARK_OAK_LOG), Ingredient.fromItems(Blocks.ACACIA_LOG), 40)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("dark_oak_to_oak_log"), new ItemStack(Blocks.OAK_LOG), Ingredient.fromItems(Blocks.DARK_OAK_LOG), 40)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("oak_to_spruce_log"), new ItemStack(Blocks.SPRUCE_LOG), Ingredient.fromItems(Blocks.OAK_LOG), 40)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("spruce_to_birch_log"), new ItemStack(Blocks.BIRCH_LOG), Ingredient.fromItems(Blocks.SPRUCE_LOG), 40)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("birch_to_jungle_log"), new ItemStack(Blocks.JUNGLE_LOG), Ingredient.fromItems(Blocks.BIRCH_LOG), 40)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("jungle_to_acacia_log"), new ItemStack(Blocks.ACACIA_LOG), Ingredient.fromItems(Blocks.JUNGLE_LOG), 40)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("acacia_to_dark_oak_log"), new ItemStack(Blocks.DARK_OAK_LOG), Ingredient.fromItems(Blocks.ACACIA_LOG), 40)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("dark_oak_to_oak_log"), new ItemStack(Blocks.OAK_LOG), Ingredient.fromItems(Blocks.DARK_OAK_LOG), 40)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("oak_to_spruce_sapling"), new ItemStack(Blocks.SPRUCE_SAPLING), Ingredient.fromItems(Blocks.OAK_SAPLING), 120)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("spruce_to_birch_sapling"), new ItemStack(Blocks.BIRCH_SAPLING), Ingredient.fromItems(Blocks.SPRUCE_SAPLING), 120)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("birch_to_jungle_sapling"), new ItemStack(Blocks.JUNGLE_SAPLING), Ingredient.fromItems(Blocks.BIRCH_SAPLING), 120)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("jungle_to_acacia_sapling"), new ItemStack(Blocks.ACACIA_SAPLING), Ingredient.fromItems(Blocks.JUNGLE_SAPLING), 120)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("acacia_to_dark_oak_sapling"), new ItemStack(Blocks.DARK_OAK_SAPLING), Ingredient.fromItems(Blocks.ACACIA_SAPLING), 120)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("dark_oak_to_oak_sapling"), new ItemStack(Blocks.OAK_SAPLING), Ingredient.fromItems(Blocks.DARK_OAK_SAPLING), 120)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("oak_to_spruce_sapling"), new ItemStack(Blocks.SPRUCE_SAPLING), Ingredient.fromItems(Blocks.OAK_SAPLING), 120)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("spruce_to_birch_sapling"), new ItemStack(Blocks.BIRCH_SAPLING), Ingredient.fromItems(Blocks.SPRUCE_SAPLING), 120)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("birch_to_jungle_sapling"), new ItemStack(Blocks.JUNGLE_SAPLING), Ingredient.fromItems(Blocks.BIRCH_SAPLING), 120)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("jungle_to_acacia_sapling"), new ItemStack(Blocks.ACACIA_SAPLING), Ingredient.fromItems(Blocks.JUNGLE_SAPLING), 120)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("acacia_to_dark_oak_sapling"), new ItemStack(Blocks.DARK_OAK_SAPLING), Ingredient.fromItems(Blocks.ACACIA_SAPLING), 120)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("dark_oak_to_oak_sapling"), new ItemStack(Blocks.OAK_SAPLING), Ingredient.fromItems(Blocks.DARK_OAK_SAPLING), 120)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("glowstone_deconstruct"), new ItemStack(Items.GLOWSTONE_DUST, 4), Ingredient.fromItems(Blocks.GLOWSTONE), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("quartz_deconstruct"), new ItemStack(Items.QUARTZ, 4), Ingredient.fromItems(Blocks.QUARTZ_BLOCK), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("dark_quartz_deconstruct"), new ItemStack(ModItems.darkQuartz, 4), Ingredient.fromItems(ModFluffBlocks.darkQuartz), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("mana_quartz_deconstruct"), new ItemStack(ModItems.manaQuartz, 4), Ingredient.fromItems(ModFluffBlocks.manaQuartz), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("blaze_quartz_deconstruct"), new ItemStack(ModItems.blazeQuartz, 4), Ingredient.fromItems(ModFluffBlocks.blazeQuartz), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("lavender_quartz_deconstruct"), new ItemStack(ModItems.lavenderQuartz, 4), Ingredient.fromItems(ModFluffBlocks.lavenderQuartz), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("red_quartz_deconstruct"), new ItemStack(ModItems.redQuartz, 4), Ingredient.fromItems(ModFluffBlocks.redQuartz), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("elf_quartz_deconstruct"), new ItemStack(ModItems.elfQuartz, 4), Ingredient.fromItems(ModFluffBlocks.elfQuartz), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("glowstone_deconstruct"), new ItemStack(Items.GLOWSTONE_DUST, 4), Ingredient.fromItems(Blocks.GLOWSTONE), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("quartz_deconstruct"), new ItemStack(Items.QUARTZ, 4), Ingredient.fromItems(Blocks.QUARTZ_BLOCK), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("dark_quartz_deconstruct"), new ItemStack(ModItems.darkQuartz, 4), Ingredient.fromItems(ModFluffBlocks.darkQuartz), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("mana_quartz_deconstruct"), new ItemStack(ModItems.manaQuartz, 4), Ingredient.fromItems(ModFluffBlocks.manaQuartz), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("blaze_quartz_deconstruct"), new ItemStack(ModItems.blazeQuartz, 4), Ingredient.fromItems(ModFluffBlocks.blazeQuartz), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("lavender_quartz_deconstruct"), new ItemStack(ModItems.lavenderQuartz, 4), Ingredient.fromItems(ModFluffBlocks.lavenderQuartz), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("red_quartz_deconstruct"), new ItemStack(ModItems.redQuartz, 4), Ingredient.fromItems(ModFluffBlocks.redQuartz), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("elf_quartz_deconstruct"), new ItemStack(ModItems.elfQuartz, 4), Ingredient.fromItems(ModFluffBlocks.elfQuartz), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("chiseled_stone_bricks"), new ItemStack(Blocks.CHISELED_STONE_BRICKS, 1), Ingredient.fromItems(Blocks.STONE_BRICKS), 150)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("ice"), new ItemStack(Blocks.ICE), Ingredient.fromItems(Blocks.SNOW), 2250)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("chiseled_stone_bricks"), new ItemStack(Blocks.CHISELED_STONE_BRICKS, 1), Ingredient.fromItems(Blocks.STONE_BRICKS), 150)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("ice"), new ItemStack(Blocks.ICE), Ingredient.fromItems(Blocks.SNOW), 2250)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("vine_to_lily_pad"), new ItemStack(Blocks.LILY_PAD), Ingredient.fromItems(Blocks.VINE), 320)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("lily_pad_to_vine"), new ItemStack(Blocks.VINE), Ingredient.fromItems(Blocks.LILY_PAD), 320)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("vine_to_lily_pad"), new ItemStack(Blocks.LILY_PAD), Ingredient.fromItems(Blocks.VINE), 320)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("lily_pad_to_vine"), new ItemStack(Blocks.VINE), Ingredient.fromItems(Blocks.LILY_PAD), 320)); Item[] fishes = { Items.COD, Items.SALMON, Items.TROPICAL_FISH, Items.PUFFERFISH }; for(int i = 0; i < fishes.length; i++) { Ingredient in = Ingredient.fromItems(fishes[i]); ItemStack out = new ItemStack(i == fishes.length - 1 ? fishes[0] : fishes[i + 1]); String id = String.format("%s_to_%s", fishes[i].getRegistryName().getPath(), out.getItem().getRegistryName().getPath()); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(new ResourceLocation(LibMisc.MOD_ID, id), out, in, 200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(new ResourceLocation(LibMisc.MOD_ID, id), out, in, 200)); } - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("cocoa_to_wheat"), new ItemStack(Items.WHEAT_SEEDS), Ingredient.fromItems(Items.COCOA_BEANS), 6000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("wheat_to_potato"), new ItemStack(Items.POTATO), Ingredient.fromItems(Items.WHEAT), 6000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("potato_to_carrot"), new ItemStack(Items.CARROT), Ingredient.fromItems(Items.POTATO), 6000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("carrot_to_beetroot"), new ItemStack(Items.BEETROOT_SEEDS), Ingredient.fromItems(Items.CARROT), 6000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("beetroot_to_melon"), new ItemStack(Items.MELON_SEEDS), Ingredient.fromItems(Items.BEETROOT_SEEDS), 6000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("melon_to_pumpkin"), new ItemStack(Items.PUMPKIN_SEEDS), Ingredient.fromItems(Items.MELON_SEEDS), 6000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("pumpkin_to_cocoa"), new ItemStack(Items.COCOA_BEANS), Ingredient.fromItems(Items.PUMPKIN_SEEDS), 6000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("cocoa_to_wheat"), new ItemStack(Items.WHEAT_SEEDS), Ingredient.fromItems(Items.COCOA_BEANS), 6000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("wheat_to_potato"), new ItemStack(Items.POTATO), Ingredient.fromItems(Items.WHEAT), 6000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("potato_to_carrot"), new ItemStack(Items.CARROT), Ingredient.fromItems(Items.POTATO), 6000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("carrot_to_beetroot"), new ItemStack(Items.BEETROOT_SEEDS), Ingredient.fromItems(Items.CARROT), 6000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("beetroot_to_melon"), new ItemStack(Items.MELON_SEEDS), Ingredient.fromItems(Items.BEETROOT_SEEDS), 6000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("melon_to_pumpkin"), new ItemStack(Items.PUMPKIN_SEEDS), Ingredient.fromItems(Items.MELON_SEEDS), 6000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("pumpkin_to_cocoa"), new ItemStack(Items.COCOA_BEANS), Ingredient.fromItems(Items.PUMPKIN_SEEDS), 6000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("potato_unpoison"), new ItemStack(Items.POTATO), Ingredient.fromItems(Items.POISONOUS_POTATO), 1200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("blaze_rod_to_nether_wart"), new ItemStack(Items.NETHER_WART), Ingredient.fromItems(Items.BLAZE_ROD), 4000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("potato_unpoison"), new ItemStack(Items.POTATO), Ingredient.fromItems(Items.POISONOUS_POTATO), 1200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("blaze_rod_to_nether_wart"), new ItemStack(Items.NETHER_WART), Ingredient.fromItems(Items.BLAZE_ROD), 4000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("gunpowder_to_flint"), new ItemStack(Items.FLINT), Ingredient.fromItems(Items.GUNPOWDER), 200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("flint_to_gunpowder"), new ItemStack(Items.GUNPOWDER), Ingredient.fromItems(Items.FLINT), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("gunpowder_to_flint"), new ItemStack(Items.FLINT), Ingredient.fromItems(Items.GUNPOWDER), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("flint_to_gunpowder"), new ItemStack(Items.GUNPOWDER), Ingredient.fromItems(Items.FLINT), 200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("book_to_name_tag"), new ItemStack(Items.NAME_TAG), Ingredient.fromItems(Items.WRITABLE_BOOK), 16000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("book_to_name_tag"), new ItemStack(Items.NAME_TAG), Ingredient.fromItems(Items.WRITABLE_BOOK), 16000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("wool_deconstruct"), new ItemStack(Items.STRING, 3), Ingredient.fromTag(ItemTags.WOOL), 100)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("wool_deconstruct"), new ItemStack(Items.STRING, 3), Ingredient.fromTag(ItemTags.WOOL), 100)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("cactus_to_slime"), new ItemStack(Items.SLIME_BALL), Ingredient.fromItems(Blocks.CACTUS), 1200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("slime_to_cactus"), new ItemStack(Blocks.CACTUS), Ingredient.fromItems(Items.SLIME_BALL), 1200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("cactus_to_slime"), new ItemStack(Items.SLIME_BALL), Ingredient.fromItems(Blocks.CACTUS), 1200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("slime_to_cactus"), new ItemStack(Blocks.CACTUS), Ingredient.fromItems(Items.SLIME_BALL), 1200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("ender_pearl_from_ghast_tear"), new ItemStack(Items.ENDER_PEARL), Ingredient.fromItems(Items.GHAST_TEAR), 28000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("ender_pearl_from_ghast_tear"), new ItemStack(Items.ENDER_PEARL), Ingredient.fromItems(Items.GHAST_TEAR), 28000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("glowstone_to_redstone"), new ItemStack(Items.REDSTONE), Ingredient.fromItems(Items.GLOWSTONE_DUST), 300)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("redstone_to_glowstone"), new ItemStack(Items.GLOWSTONE_DUST), Ingredient.fromItems(Items.REDSTONE), 300)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("glowstone_to_redstone"), new ItemStack(Items.REDSTONE), Ingredient.fromItems(Items.GLOWSTONE_DUST), 300)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("redstone_to_glowstone"), new ItemStack(Items.GLOWSTONE_DUST), Ingredient.fromItems(Items.REDSTONE), 300)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("cobble_to_sand"), new ItemStack(Blocks.SAND), Ingredient.fromItems(Blocks.COBBLESTONE), 50)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("terracotta_to_red_sand"), new ItemStack(Blocks.RED_SAND), Ingredient.fromItems(Blocks.TERRACOTTA), 50)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("cobble_to_sand"), new ItemStack(Blocks.SAND), Ingredient.fromItems(Blocks.COBBLESTONE), 50)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("terracotta_to_red_sand"), new ItemStack(Blocks.RED_SAND), Ingredient.fromItems(Blocks.TERRACOTTA), 50)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("clay_deconstruct"), new ItemStack(Items.CLAY_BALL, 4), Ingredient.fromItems(Blocks.CLAY), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("brick_deconstruct"), new ItemStack(Items.BRICK, 4), Ingredient.fromItems(Blocks.BRICKS), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("clay_deconstruct"), new ItemStack(Items.CLAY_BALL, 4), Ingredient.fromItems(Blocks.CLAY), 25)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("brick_deconstruct"), new ItemStack(Items.BRICK, 4), Ingredient.fromItems(Blocks.BRICKS), 25)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("coarse_dirt"), new ItemStack(Blocks.COARSE_DIRT), Ingredient.fromItems(Blocks.DIRT), 120)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("coarse_dirt"), new ItemStack(Blocks.COARSE_DIRT), Ingredient.fromItems(Blocks.DIRT), 120)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("stone_to_andesite"), new ItemStack(Blocks.ANDESITE), Ingredient.fromItems(Blocks.STONE), 200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("andesite_to_diorite"), new ItemStack(Blocks.DIORITE), Ingredient.fromItems(Blocks.ANDESITE), 200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("diorite_to_granite"), new ItemStack(Blocks.GRANITE), Ingredient.fromItems(Blocks.DIORITE), 200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("granite_to_andesite"), new ItemStack(Blocks.ANDESITE), Ingredient.fromItems(Blocks.GRANITE), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("stone_to_andesite"), new ItemStack(Blocks.ANDESITE), Ingredient.fromItems(Blocks.STONE), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("andesite_to_diorite"), new ItemStack(Blocks.DIORITE), Ingredient.fromItems(Blocks.ANDESITE), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("diorite_to_granite"), new ItemStack(Blocks.GRANITE), Ingredient.fromItems(Blocks.DIORITE), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("granite_to_andesite"), new ItemStack(Blocks.ANDESITE), Ingredient.fromItems(Blocks.GRANITE), 200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("fern_to_dead_bush"), new ItemStack(Blocks.DEAD_BUSH), Ingredient.fromItems(Blocks.FERN), 500)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("dead_bush_to_grass"), new ItemStack(Blocks.GRASS), Ingredient.fromItems(Blocks.DEAD_BUSH), 500)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("grass_to_fern"), new ItemStack(Blocks.FERN), Ingredient.fromItems(Blocks.GRASS), 500)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("fern_to_dead_bush"), new ItemStack(Blocks.DEAD_BUSH), Ingredient.fromItems(Blocks.FERN), 500)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("dead_bush_to_grass"), new ItemStack(Blocks.GRASS), Ingredient.fromItems(Blocks.DEAD_BUSH), 500)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("grass_to_fern"), new ItemStack(Blocks.FERN), Ingredient.fromItems(Blocks.GRASS), 500)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("dandelion_to_poppy"), new ItemStack(Blocks.POPPY), Ingredient.fromItems(Blocks.DANDELION), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("poppy_to_blue_orchid"), new ItemStack(Blocks.BLUE_ORCHID), Ingredient.fromItems(Blocks.POPPY), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("blue_orchid_to_allium"), new ItemStack(Blocks.ALLIUM), Ingredient.fromItems(Blocks.BLUE_ORCHID), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("allium_to_azure_bluet"), new ItemStack(Blocks.AZURE_BLUET), Ingredient.fromItems(Blocks.ALLIUM), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("azure_bluet_to_red_tulip"), new ItemStack(Blocks.RED_TULIP), Ingredient.fromItems(Blocks.AZURE_BLUET), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("red_tulip_to_orange_tulip"), new ItemStack(Blocks.ORANGE_TULIP), Ingredient.fromItems(Blocks.RED_TULIP), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("orange_tulip_to_white_tulip"), new ItemStack(Blocks.WHITE_TULIP), Ingredient.fromItems(Blocks.ORANGE_TULIP), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("white_tulip_to_pink_tulip"), new ItemStack(Blocks.PINK_TULIP), Ingredient.fromItems(Blocks.WHITE_TULIP), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("pink_tulip_to_oxeye_daisy"), new ItemStack(Blocks.OXEYE_DAISY), Ingredient.fromItems(Blocks.PINK_TULIP), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("oxeye_daisy_to_sunflower"), new ItemStack(Blocks.SUNFLOWER), Ingredient.fromItems(Blocks.OXEYE_DAISY), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("sunflower_to_lilac"), new ItemStack(Blocks.LILAC), Ingredient.fromItems(Blocks.SUNFLOWER), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("lilac_to_rose_bush"), new ItemStack(Blocks.ROSE_BUSH), Ingredient.fromItems(Blocks.LILAC), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("rose_bush_to_peony"), new ItemStack(Blocks.PEONY), Ingredient.fromItems(Blocks.ROSE_BUSH), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("peony_to_dandelion"), new ItemStack(Blocks.DANDELION), Ingredient.fromItems(Blocks.PEONY), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("dandelion_to_poppy"), new ItemStack(Blocks.POPPY), Ingredient.fromItems(Blocks.DANDELION), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("poppy_to_blue_orchid"), new ItemStack(Blocks.BLUE_ORCHID), Ingredient.fromItems(Blocks.POPPY), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("blue_orchid_to_allium"), new ItemStack(Blocks.ALLIUM), Ingredient.fromItems(Blocks.BLUE_ORCHID), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("allium_to_azure_bluet"), new ItemStack(Blocks.AZURE_BLUET), Ingredient.fromItems(Blocks.ALLIUM), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("azure_bluet_to_red_tulip"), new ItemStack(Blocks.RED_TULIP), Ingredient.fromItems(Blocks.AZURE_BLUET), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("red_tulip_to_orange_tulip"), new ItemStack(Blocks.ORANGE_TULIP), Ingredient.fromItems(Blocks.RED_TULIP), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("orange_tulip_to_white_tulip"), new ItemStack(Blocks.WHITE_TULIP), Ingredient.fromItems(Blocks.ORANGE_TULIP), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("white_tulip_to_pink_tulip"), new ItemStack(Blocks.PINK_TULIP), Ingredient.fromItems(Blocks.WHITE_TULIP), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("pink_tulip_to_oxeye_daisy"), new ItemStack(Blocks.OXEYE_DAISY), Ingredient.fromItems(Blocks.PINK_TULIP), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("oxeye_daisy_to_sunflower"), new ItemStack(Blocks.SUNFLOWER), Ingredient.fromItems(Blocks.OXEYE_DAISY), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("sunflower_to_lilac"), new ItemStack(Blocks.LILAC), Ingredient.fromItems(Blocks.SUNFLOWER), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("lilac_to_rose_bush"), new ItemStack(Blocks.ROSE_BUSH), Ingredient.fromItems(Blocks.LILAC), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("rose_bush_to_peony"), new ItemStack(Blocks.PEONY), Ingredient.fromItems(Blocks.ROSE_BUSH), 400)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("peony_to_dandelion"), new ItemStack(Blocks.DANDELION), Ingredient.fromItems(Blocks.PEONY), 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("chorus_fruit_to_flower"), new ItemStack(Blocks.CHORUS_FLOWER), Ingredient.fromItems(Items.POPPED_CHORUS_FRUIT), 10000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("chorus_fruit_to_flower"), new ItemStack(Blocks.CHORUS_FLOWER), Ingredient.fromItems(Items.POPPED_CHORUS_FRUIT), 10000)); if(Botania.gardenOfGlassLoaded) { - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("prismarine_shard_gog"), new ItemStack(Items.PRISMARINE_SHARD), Ingredient.fromItems(Items.QUARTZ), 1000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.alchemy(prefix("prismarine_crystals_gog"), new ItemStack(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.PRISMARINE_SHARD), 500)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("prismarine_shard_gog"), new ItemStack(Items.PRISMARINE_SHARD), Ingredient.fromItems(Items.QUARTZ), 1000)); + evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("prismarine_crystals_gog"), new ItemStack(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.PRISMARINE_SHARD), 500)); } - IMCSender.send(IMC.REGISTER_MANA_INFUSION, mini(ModSubtiles.agricarnationChibi, ModSubtiles.agricarnation)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, mini(ModSubtiles.clayconiaChibi, ModSubtiles.clayconia)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, mini(ModSubtiles.bellethornChibi, ModSubtiles.bellethorn)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, mini(ModSubtiles.bubbellChibi, ModSubtiles.bubbell)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, mini(ModSubtiles.hopperhockChibi, ModSubtiles.hopperhock)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, mini(ModSubtiles.marimorphosisChibi, ModSubtiles.marimorphosis)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, mini(ModSubtiles.rannuncarpusChibi, ModSubtiles.rannuncarpus)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, mini(ModSubtiles.solegnoliaChibi, ModSubtiles.solegnolia)); + evt.manaInfusion().accept(mini(ModSubtiles.agricarnationChibi, ModSubtiles.agricarnation)); + evt.manaInfusion().accept(mini(ModSubtiles.clayconiaChibi, ModSubtiles.clayconia)); + evt.manaInfusion().accept(mini(ModSubtiles.bellethornChibi, ModSubtiles.bellethorn)); + evt.manaInfusion().accept(mini(ModSubtiles.bubbellChibi, ModSubtiles.bubbell)); + evt.manaInfusion().accept(mini(ModSubtiles.hopperhockChibi, ModSubtiles.hopperhock)); + evt.manaInfusion().accept(mini(ModSubtiles.marimorphosisChibi, ModSubtiles.marimorphosis)); + evt.manaInfusion().accept(mini(ModSubtiles.rannuncarpusChibi, ModSubtiles.rannuncarpus)); + evt.manaInfusion().accept(mini(ModSubtiles.solegnoliaChibi, ModSubtiles.solegnolia)); } private static RecipeManaInfusion mini(IItemProvider mini, IItemProvider full) { diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java index 39a1af4ef..6b208e553 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java @@ -18,14 +18,18 @@ import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import vazkii.botania.api.imc.IMC; import vazkii.botania.api.recipe.RecipeManaInfusion; +import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.core.handler.IMCSender; import vazkii.botania.common.lib.LibMisc; import java.util.List; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class ModManaConjurationRecipes { public static RecipeManaInfusion redstoneRecipe; @@ -39,24 +43,25 @@ public class ModManaConjurationRecipes { public static List leavesRecipes; public static RecipeManaInfusion grassRecipe; - public static void send() { - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("redstone_dupe"), new ItemStack(Items.REDSTONE, 2), ingr(Items.REDSTONE), 5000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("glowstone_dupe"), new ItemStack(Items.GLOWSTONE_DUST, 2), ingr(Items.GLOWSTONE_DUST), 5000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("quartz_dupe"), new ItemStack(Items.QUARTZ, 2), ingr(Items.QUARTZ), 2500)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("coal_dupe"), new ItemStack(Items.COAL, 2), ingr(Items.COAL), 2100)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("snowball_dupe"), new ItemStack(Items.SNOWBALL, 2), ingr(Items.SNOWBALL), 200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("netherrack_dupe"), new ItemStack(Blocks.NETHERRACK, 2), ingr(Blocks.NETHERRACK), 200)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("soul_sand_dupe"), new ItemStack(Blocks.SOUL_SAND, 2), ingr(Blocks.SOUL_SAND), 1500)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("gravel_dupe"), new ItemStack(Blocks.GRAVEL, 2), ingr(Blocks.GRAVEL), 720)); + @SubscribeEvent + public static void register(RegisterRecipesEvent evt) { + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("redstone_dupe"), new ItemStack(Items.REDSTONE, 2), ingr(Items.REDSTONE), 5000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("glowstone_dupe"), new ItemStack(Items.GLOWSTONE_DUST, 2), ingr(Items.GLOWSTONE_DUST), 5000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("quartz_dupe"), new ItemStack(Items.QUARTZ, 2), ingr(Items.QUARTZ), 2500)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("coal_dupe"), new ItemStack(Items.COAL, 2), ingr(Items.COAL), 2100)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("snowball_dupe"), new ItemStack(Items.SNOWBALL, 2), ingr(Items.SNOWBALL), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("netherrack_dupe"), new ItemStack(Blocks.NETHERRACK, 2), ingr(Blocks.NETHERRACK), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("soul_sand_dupe"), new ItemStack(Blocks.SOUL_SAND, 2), ingr(Blocks.SOUL_SAND), 1500)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("gravel_dupe"), new ItemStack(Blocks.GRAVEL, 2), ingr(Blocks.GRAVEL), 720)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("oak_leaves_dupe"), new ItemStack(Blocks.OAK_LEAVES, 2), ingr(Blocks.OAK_LEAVES), 2000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("birch_leaves_dupe"), new ItemStack(Blocks.BIRCH_LEAVES, 2), ingr(Blocks.BIRCH_LEAVES), 2000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("spruce_leaves_dupe"), new ItemStack(Blocks.SPRUCE_LEAVES, 2), ingr(Blocks.SPRUCE_LEAVES), 2000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("jungle_leaves_dupe"), new ItemStack(Blocks.JUNGLE_LEAVES, 2), ingr(Blocks.JUNGLE_LEAVES), 2000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("acacia_leaves_dupe"), new ItemStack(Blocks.ACACIA_LEAVES, 2), ingr(Blocks.ACACIA_LEAVES), 2000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("dark_oak_leaves_dupe"), new ItemStack(Blocks.DARK_OAK_LEAVES, 2), ingr(Blocks.DARK_OAK_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("oak_leaves_dupe"), new ItemStack(Blocks.OAK_LEAVES, 2), ingr(Blocks.OAK_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("birch_leaves_dupe"), new ItemStack(Blocks.BIRCH_LEAVES, 2), ingr(Blocks.BIRCH_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("spruce_leaves_dupe"), new ItemStack(Blocks.SPRUCE_LEAVES, 2), ingr(Blocks.SPRUCE_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("jungle_leaves_dupe"), new ItemStack(Blocks.JUNGLE_LEAVES, 2), ingr(Blocks.JUNGLE_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("acacia_leaves_dupe"), new ItemStack(Blocks.ACACIA_LEAVES, 2), ingr(Blocks.ACACIA_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("dark_oak_leaves_dupe"), new ItemStack(Blocks.DARK_OAK_LEAVES, 2), ingr(Blocks.DARK_OAK_LEAVES), 2000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, RecipeManaInfusion.conjuration(prefix("grass"), new ItemStack(Blocks.GRASS), ingr(Blocks.GRASS), 800)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("grass"), new ItemStack(Blocks.GRASS), ingr(Blocks.GRASS), 800)); } private static Ingredient ingr(IItemProvider i) { diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java index 827fbb33e..5969192be 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java @@ -21,13 +21,17 @@ import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.Tags; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ForgeRegistries; import vazkii.botania.api.imc.IMC; import vazkii.botania.api.recipe.RecipeManaInfusion; +import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.handler.IMCSender; import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.lib.LibMisc; import java.util.ArrayList; import java.util.Arrays; @@ -35,6 +39,7 @@ import java.util.List; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public final class ModManaInfusionRecipes { public static List manasteelRecipes; @@ -54,42 +59,43 @@ public final class ModManaInfusionRecipes { public static RecipeManaInfusion sugarCaneRecipe; - public static void send() { - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("manasteel"), new ItemStack(ModItems.manaSteel), Ingredient.fromTag(Tags.Items.INGOTS_IRON), 3000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("manasteel_block"), new ItemStack(ModBlocks.manasteelBlock), Ingredient.fromItems(Blocks.IRON_BLOCK), 27000)); + @SubscribeEvent + public static void register(RegisterRecipesEvent evt) { + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("manasteel"), new ItemStack(ModItems.manaSteel), Ingredient.fromTag(Tags.Items.INGOTS_IRON), 3000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("manasteel_block"), new ItemStack(ModBlocks.manasteelBlock), Ingredient.fromItems(Blocks.IRON_BLOCK), 27000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_pearl"), new ItemStack(ModItems.manaPearl), Ingredient.fromItems(Items.ENDER_PEARL), 6000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_pearl"), new ItemStack(ModItems.manaPearl), Ingredient.fromItems(Items.ENDER_PEARL), 6000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_diamond"), new ItemStack(ModItems.manaDiamond), Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), 10000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_diamond_block"), new ItemStack(ModBlocks.manaDiamondBlock), Ingredient.fromItems(Blocks.DIAMOND_BLOCK), 90000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_diamond"), new ItemStack(ModItems.manaDiamond), Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), 10000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_diamond_block"), new ItemStack(ModBlocks.manaDiamondBlock), Ingredient.fromItems(Blocks.DIAMOND_BLOCK), 90000)); Ingredient dust = Ingredient.fromItems(Items.GUNPOWDER, Items.REDSTONE, Items.GLOWSTONE_DUST, Items.SUGAR); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_powder_dust"), new ItemStack(ModItems.manaPowder), dust, 500)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_powder_dust"), new ItemStack(ModItems.manaPowder), dust, 500)); Ingredient dyeIngredient = Ingredient.fromItems(Arrays.stream(DyeColor.values()).map(ModItems::getDye).toArray(Item[]::new)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_powder_dye"), new ItemStack(ModItems.manaPowder), dyeIngredient, 400)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_powder_dye"), new ItemStack(ModItems.manaPowder), dyeIngredient, 400)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("piston_relay"), new ItemStack(ModBlocks.pistonRelay), Ingredient.fromItems(Blocks.PISTON), 15000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_cookie"), new ItemStack(ModItems.manaCookie), Ingredient.fromItems(Items.COOKIE), 20000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("grass_seeds"), new ItemStack(ModItems.grassSeeds), Ingredient.fromItems(Blocks.GRASS), 2500)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("podzol_seeds"), new ItemStack(ModItems.podzolSeeds), Ingredient.fromItems(Blocks.DEAD_BUSH), 2500)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("piston_relay"), new ItemStack(ModBlocks.pistonRelay), Ingredient.fromItems(Blocks.PISTON), 15000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_cookie"), new ItemStack(ModItems.manaCookie), Ingredient.fromItems(Items.COOKIE), 20000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("grass_seeds"), new ItemStack(ModItems.grassSeeds), Ingredient.fromItems(Blocks.GRASS), 2500)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("podzol_seeds"), new ItemStack(ModItems.podzolSeeds), Ingredient.fromItems(Blocks.DEAD_BUSH), 2500)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mycel_seeds"), new ItemStack(ModItems.mycelSeeds), Ingredient.fromItems(Blocks.RED_MUSHROOM, Blocks.BROWN_MUSHROOM), 6500)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mycel_seeds"), new ItemStack(ModItems.mycelSeeds), Ingredient.fromItems(Blocks.RED_MUSHROOM, Blocks.BROWN_MUSHROOM), 6500)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_quartz"), new ItemStack(ModItems.manaQuartz), Ingredient.fromItems(Items.QUARTZ), 250)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("tiny_potato"), new ItemStack(ModBlocks.tinyPotato), Ingredient.fromItems(Items.POTATO), 1337)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_quartz"), new ItemStack(ModItems.manaQuartz), Ingredient.fromItems(Items.QUARTZ), 250)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("tiny_potato"), new ItemStack(ModBlocks.tinyPotato), Ingredient.fromItems(Items.POTATO), 1337)); if(Botania.thaumcraftLoaded) { Item inkwell = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "scribing_tools")); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_inkwell"), new ItemStack(ModItems.manaInkwell), Ingredient.fromItems(inkwell), 35000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_inkwell"), new ItemStack(ModItems.manaInkwell), Ingredient.fromItems(inkwell), 35000)); } - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_glass"), new ItemStack(ModBlocks.manaGlass), Ingredient.fromItems(Blocks.GLASS), 150)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_string"), new ItemStack(ModItems.manaString), Ingredient.fromItems(Items.STRING), 5000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_glass"), new ItemStack(ModBlocks.manaGlass), Ingredient.fromItems(Blocks.GLASS), 150)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_string"), new ItemStack(ModItems.manaString), Ingredient.fromItems(Items.STRING), 5000)); if(Botania.gardenOfGlassLoaded) - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("sugar_cane"), new ItemStack(Blocks.SUGAR_CANE), Ingredient.fromItems(Blocks.HAY_BLOCK), 2000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("sugar_cane"), new ItemStack(Blocks.SUGAR_CANE), Ingredient.fromItems(Blocks.HAY_BLOCK), 2000)); - IMCSender.send(IMC.REGISTER_MANA_INFUSION, new RecipeManaInfusion(prefix("mana_bottle"), new ItemStack(ModItems.manaBottle), Ingredient.fromItems(Items.GLASS_BOTTLE), 5000)); + evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_bottle"), new ItemStack(ModItems.manaBottle), Ingredient.fromItems(Items.GLASS_BOTTLE), 5000)); } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java index 6d9254395..f31755557 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java @@ -10,14 +10,19 @@ */ package vazkii.botania.common.crafting; +import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.tags.ItemTags; +import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePetals; +import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModSubtiles; import vazkii.botania.common.core.handler.ConfigHandler; @@ -29,6 +34,9 @@ import vazkii.botania.common.lib.LibMisc; import java.util.Arrays; +import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; + +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public final class ModPetalRecipes { public static RecipePetals pureDaisyRecipe; public static RecipePetals manastarRecipe; @@ -74,7 +82,8 @@ public final class ModPetalRecipes { public static RecipePetals solegnoliaRecipe; public static RecipePetals bergamuteRecipe; - public static void init() { + @SubscribeEvent + public static void register(RegisterRecipesEvent evt) { Ingredient white = tagIngr("petals/white"); Ingredient orange = tagIngr("petals/orange"); Ingredient magenta = tagIngr("petals/magenta"); @@ -112,63 +121,67 @@ public final class ModPetalRecipes { Ingredient pixieDust = Ingredient.fromItems(ModItems.pixieDust); Ingredient gaiaSpirit = Ingredient.fromItems(ModItems.lifeEssence); - pureDaisyRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.pureDaisy), white, white, white, white); - manastarRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.manastar), lightBlue, green, red, cyan); + evt.apothecary().accept(make(ModSubtiles.pureDaisy, white, white, white, white)); + evt.apothecary().accept(make(ModSubtiles.manastar, lightBlue, green, red, cyan)); - endoflameRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.endoflame), brown, brown, red, lightGray); - hydroangeasRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.hydroangeas), blue, blue, cyan, cyan); - thermalilyRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.thermalily), red, orange, orange, runeEarth, runeFire); - arcaneRoseRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.rosaArcana), pink, pink, purple, purple, lime, runeMana); - munchdewRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.munchdew), lime, lime, red, red, green, runeGluttony); - entropinnyumRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.entropinnyum), red, red, gray, gray, white, white, runeWrath, runeFire); - kekimurusRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.kekimurus), white, white, orange, orange, brown, brown,runeGluttony, pixieDust); - gourmaryllisRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.gourmaryllis), lightGray, lightGray, yellow, yellow, red, runeFire, runeSummer); - narslimmusRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.narslimmus), lime, lime, green, green, black, runeSummer, runeWater); - spectrolusRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.spectrolus), red, red, green, green, blue, blue, white, white, runeWinter, runeAir, pixieDust); - rafflowsiaRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.rafflowsia), purple, purple, green, green, black, runeEarth, runePride, pixieDust); - shulkMeNotRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.shulkMeNot), purple, purple, magenta, magenta, lightGray, gaiaSpirit, runeEnvy, runeWrath); - dandelifeonRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.dandelifeon), purple, purple, lime, green, runeWater, runeFire, runeEarth, runeAir, gaiaSpirit); + evt.apothecary().accept(make(ModSubtiles.endoflame, brown, brown, red, lightGray)); + evt.apothecary().accept(make(ModSubtiles.hydroangeas, blue, blue, cyan, cyan)); + evt.apothecary().accept(make(ModSubtiles.thermalily, red, orange, orange, runeEarth, runeFire)); + evt.apothecary().accept(make(ModSubtiles.rosaArcana, pink, pink, purple, purple, lime, runeMana)); + evt.apothecary().accept(make(ModSubtiles.munchdew, lime, lime, red, red, green, runeGluttony)); + evt.apothecary().accept(make(ModSubtiles.entropinnyum, red, red, gray, gray, white, white, runeWrath, runeFire)); + evt.apothecary().accept(make(ModSubtiles.kekimurus, white, white, orange, orange, brown, brown,runeGluttony, pixieDust)); + evt.apothecary().accept(make(ModSubtiles.gourmaryllis, lightGray, lightGray, yellow, yellow, red, runeFire, runeSummer)); + evt.apothecary().accept(make(ModSubtiles.narslimmus, lime, lime, green, green, black, runeSummer, runeWater)); + evt.apothecary().accept(make(ModSubtiles.spectrolus, red, red, green, green, blue, blue, white, white, runeWinter, runeAir, pixieDust)); + evt.apothecary().accept(make(ModSubtiles.rafflowsia, purple, purple, green, green, black, runeEarth, runePride, pixieDust)); + evt.apothecary().accept(make(ModSubtiles.shulkMeNot, purple, purple, magenta, magenta, lightGray, gaiaSpirit, runeEnvy, runeWrath)); + evt.apothecary().accept(make(ModSubtiles.dandelifeon, purple, purple, lime, green, runeWater, runeFire, runeEarth, runeAir, gaiaSpirit)); - jadedAmaranthusRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.jadedAmaranthus), purple, lime, green, runeSpring, redstoneRoot); - bellethorneRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.bellethorn), red, red, red, cyan, cyan, redstoneRoot); - dreadthorneRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.dreadthorn), black, black, black, cyan, cyan, redstoneRoot); - heiseiDreamRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.heiseiDream), magenta, magenta, purple, pink, runeWrath, pixieDust); - tigerseyeRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.tigerseye), yellow, brown, orange, lime, runeAutumn); + evt.apothecary().accept(make(ModSubtiles.jadedAmaranthus, purple, lime, green, runeSpring, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.bellethorn, red, red, red, cyan, cyan, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.dreadthorn, black, black, black, cyan, cyan, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.heiseiDream, magenta, magenta, purple, pink, runeWrath, pixieDust)); + evt.apothecary().accept(make(ModSubtiles.tigerseye, yellow, brown, orange, lime, runeAutumn)); if(Botania.gardenOfGlassLoaded) - orechidRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.orechid), gray, gray, yellow, yellow, green, green, red, red); - else orechidRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.orechid), gray, gray, yellow, green, red, runePride, runeGreed, redstoneRoot, pixieDust); + evt.apothecary().accept(make(ModSubtiles.orechid, gray, gray, yellow, yellow, green, green, red, red)); + else evt.apothecary().accept(make(ModSubtiles.orechid, gray, gray, yellow, green, red, runePride, runeGreed, redstoneRoot, pixieDust)); - orechidIgnemRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.orechidIgnem), red, red, white, white, pink, runePride, runeGreed, redstoneRoot, pixieDust); + evt.apothecary().accept(make(ModSubtiles.orechidIgnem, red, red, white, white, pink, runePride, runeGreed, redstoneRoot, pixieDust)); if(ConfigHandler.COMMON.fallenKanadeEnabled.get()) - fallenKanadeRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.fallenKanade), white, white, yellow, yellow, orange, runeSpring); - exoflameRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.exoflame), red, red, gray, lightGray, runeFire, runeSummer); - agricarnationRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.agricarnation), lime, lime, green, yellow, runeSpring, redstoneRoot); - hopperhockRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.hopperhock), gray, gray, lightGray, lightGray, runeAir, redstoneRoot); - tangleberrieRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.tangleberrie), cyan, cyan, gray, lightGray, runeAir, runeEarth); - jiyuuliaRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.jiyuulia), pink, pink, purple, lightGray, runeWater, runeAir); - rannuncarpusRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.rannuncarpus), orange, orange, yellow, runeEarth, redstoneRoot); - hyacidusRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.hyacidus), purple, purple, magenta, magenta, green, runeWater, runeAutumn, redstoneRoot); - pollidisiacRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.pollidisiac), red, red, pink, pink, orange, runeLust, runeFire); - clayconiaRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.clayconia), lightGray, lightGray, gray, cyan, runeEarth); - looniumRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.loonium), green, green, green, green, gray, runeSloth, runeGluttony, runeEnvy, redstoneRoot, pixieDust); - daffomillRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.daffomill), white, white, brown, yellow, runeAir, redstoneRoot); - vinculotusRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.vinculotus), black, black, purple, purple, green, runeWater, runeSloth, runeLust, redstoneRoot); - spectranthemumRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.spectranthemum), white, white, lightGray, lightGray, cyan, runeEnvy, runeWater, redstoneRoot, pixieDust); - medumoneRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.medumone), brown, brown, gray, gray, runeEarth, redstoneRoot); - marimorphosisRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.marimorphosis), gray, yellow, green, red, runeEarth, runeFire, redstoneRoot); - bubbellRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.bubbell), cyan, cyan, lightBlue, lightBlue, blue, blue, runeWater, runeSummer, pixieDust); - solegnoliaRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.solegnolia), brown, brown, red, blue, redstoneRoot); - bergamuteRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(ModSubtiles.bergamute), orange, green, green, redstoneRoot); + evt.apothecary().accept(make(ModSubtiles.fallenKanade, white, white, yellow, yellow, orange, runeSpring)); + evt.apothecary().accept(make(ModSubtiles.exoflame, red, red, gray, lightGray, runeFire, runeSummer)); + evt.apothecary().accept(make(ModSubtiles.agricarnation, lime, lime, green, yellow, runeSpring, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.hopperhock, gray, gray, lightGray, lightGray, runeAir, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.tangleberrie, cyan, cyan, gray, lightGray, runeAir, runeEarth)); + evt.apothecary().accept(make(ModSubtiles.jiyuulia, pink, pink, purple, lightGray, runeWater, runeAir)); + evt.apothecary().accept(make(ModSubtiles.rannuncarpus, orange, orange, yellow, runeEarth, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.hyacidus, purple, purple, magenta, magenta, green, runeWater, runeAutumn, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.pollidisiac, red, red, pink, pink, orange, runeLust, runeFire)); + evt.apothecary().accept(make(ModSubtiles.clayconia, lightGray, lightGray, gray, cyan, runeEarth)); + evt.apothecary().accept(make(ModSubtiles.loonium, green, green, green, green, gray, runeSloth, runeGluttony, runeEnvy, redstoneRoot, pixieDust)); + evt.apothecary().accept(make(ModSubtiles.daffomill, white, white, brown, yellow, runeAir, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.vinculotus, black, black, purple, purple, green, runeWater, runeSloth, runeLust, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.spectranthemum, white, white, lightGray, lightGray, cyan, runeEnvy, runeWater, redstoneRoot, pixieDust)); + evt.apothecary().accept(make(ModSubtiles.medumone, brown, brown, gray, gray, runeEarth, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.marimorphosis, gray, yellow, green, red, runeEarth, runeFire, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.bubbell, cyan, cyan, lightBlue, lightBlue, blue, blue, runeWater, runeSummer, pixieDust)); + evt.apothecary().accept(make(ModSubtiles.solegnolia, brown, brown, red, blue, redstoneRoot)); + evt.apothecary().accept(make(ModSubtiles.bergamute, orange, green, green, redstoneRoot)); ItemStack stack = new ItemStack(Items.PLAYER_HEAD); ItemNBTHelper.setString(stack, "SkullOwner", "Vazkii"); Ingredient[] inputs = new Ingredient[16]; Arrays.fill(inputs, pink); - BotaniaAPI.registerPetalRecipe(stack, inputs); + evt.apothecary().accept(new RecipePetals(prefix("vazkii_head"), stack, inputs)); } private static Ingredient tagIngr(String tag) { return Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, tag))); } + + private static RecipePetals make(IItemProvider item, Ingredient... ingredients) { + return new RecipePetals(item.asItem().getRegistryName(), new ItemStack(item), ingredients); + } } diff --git a/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java index 206a12400..c01b7d234 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java @@ -10,26 +10,30 @@ */ package vazkii.botania.common.crafting; -import net.minecraft.block.Blocks; import net.minecraft.block.Blocks; import net.minecraft.tags.BlockTags; import net.minecraftforge.common.Tags; -import vazkii.botania.api.BotaniaAPI; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import vazkii.botania.api.recipe.RecipePureDaisy; +import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.block.ModBlocks; -import vazkii.botania.common.lib.LibOreDict; +import vazkii.botania.common.lib.LibMisc; +import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; + +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public final class ModPureDaisyRecipes { + @SubscribeEvent + public static void register(RegisterRecipesEvent evt) { + evt.pureDaisy().accept(new RecipePureDaisy(prefix("livingrock"), Tags.Blocks.STONE, ModBlocks.livingrock.getDefaultState())); + evt.pureDaisy().accept(new RecipePureDaisy(prefix("livingwood"), BlockTags.LOGS, ModBlocks.livingwood.getDefaultState())); - public static void init() { - BotaniaAPI.registerPureDaisyRecipe(Tags.Blocks.STONE, ModBlocks.livingrock.getDefaultState()); - BotaniaAPI.registerPureDaisyRecipe(BlockTags.LOGS, ModBlocks.livingwood.getDefaultState()); - - BotaniaAPI.registerPureDaisyRecipe(Blocks.NETHERRACK, Blocks.COBBLESTONE.getDefaultState()); - BotaniaAPI.registerPureDaisyRecipe(Blocks.SOUL_SAND, Blocks.SAND.getDefaultState()); - BotaniaAPI.registerPureDaisyRecipe(Blocks.ICE, Blocks.PACKED_ICE.getDefaultState()); - BotaniaAPI.registerPureDaisyRecipe(Blocks.PACKED_ICE, Blocks.BLUE_ICE.getDefaultState()); - BotaniaAPI.registerPureDaisyRecipe(ModBlocks.blazeBlock, Blocks.OBSIDIAN.getDefaultState()); - BotaniaAPI.registerPureDaisyRecipe(Blocks.WATER, Blocks.SNOW.getDefaultState()); + evt.pureDaisy().accept(new RecipePureDaisy(prefix("cobblestone"), Tags.Blocks.STONE, ModBlocks.livingrock.getDefaultState())); + evt.pureDaisy().accept(new RecipePureDaisy(prefix("sand"), Blocks.SOUL_SAND, Blocks.SAND.getDefaultState())); + evt.pureDaisy().accept(new RecipePureDaisy(prefix("packed_ice"), Blocks.ICE, Blocks.PACKED_ICE.getDefaultState())); + evt.pureDaisy().accept(new RecipePureDaisy(prefix("blue_ice"), Blocks.PACKED_ICE, Blocks.BLUE_ICE.getDefaultState())); + evt.pureDaisy().accept(new RecipePureDaisy(prefix("obsidian"), ModBlocks.blazeBlock, Blocks.OBSIDIAN.getDefaultState())); + evt.pureDaisy().accept(new RecipePureDaisy(prefix("snow"), Blocks.WATER, Blocks.SNOW.getDefaultState())); } - } diff --git a/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java index 6b46505e3..2a7897982 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java @@ -19,8 +19,11 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.tags.ItemTags; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.Tags; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeRuneAltar; +import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.crafting.recipe.HeadRecipe; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; @@ -29,6 +32,9 @@ import vazkii.botania.common.lib.LibOreDict; import java.util.ArrayList; import java.util.List; +import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; + +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public final class ModRuneRecipes { public static RecipeRuneAltar recipeWaterRune; @@ -51,7 +57,8 @@ public final class ModRuneRecipes { public static RecipeRuneAltar recipeHead; // todo 1.13 re-tagify these once the community settles down on some names - public static void init() { + @SubscribeEvent + public static void register(RegisterRecipesEvent evt) { final int costTier1 = 5200; final int costTier2 = 8000; final int costTier3 = 12000; @@ -59,16 +66,14 @@ public final class ModRuneRecipes { Ingredient manaSteel = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation("forge", "ingots/manasteel"))); Ingredient manaDiamond = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation("forge", "gems/mana_diamond"))); Ingredient manaPowder = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation("forge", "dusts/mana"))); - recipeWaterRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeWater, 2), costTier1, manaPowder, manaSteel, Ingredient.fromItems(Items.BONE_MEAL), Ingredient.fromItems(Blocks.SUGAR_CANE), Ingredient.fromItems(Items.FISHING_ROD)); - recipeFireRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeFire, 2), costTier1, manaPowder, manaSteel, Ingredient.fromItems(Items.NETHER_BRICK), Ingredient.fromItems(Items.GUNPOWDER), Ingredient.fromItems(Items.NETHER_WART)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("water"), new ItemStack(ModItems.runeWater, 2), costTier1, manaPowder, manaSteel, Ingredient.fromItems(Items.BONE_MEAL), Ingredient.fromItems(Blocks.SUGAR_CANE), Ingredient.fromItems(Items.FISHING_ROD))); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("fire"), new ItemStack(ModItems.runeFire, 2), costTier1, manaPowder, manaSteel, Ingredient.fromItems(Items.NETHER_BRICK), Ingredient.fromItems(Items.GUNPOWDER), Ingredient.fromItems(Items.NETHER_WART))); Ingredient stone = Ingredient.fromTag(Tags.Items.STONE); Ingredient coalBlock = Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_COAL); - recipesEarthRune = new ArrayList<>(); - recipesEarthRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeEarth, 2), costTier1, manaPowder, manaSteel, stone, coalBlock, Ingredient.fromItems(Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM))); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("earth"), new ItemStack(ModItems.runeEarth, 2), costTier1, manaPowder, manaSteel, stone, coalBlock, Ingredient.fromItems(Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM))); - recipesAirRune = new ArrayList<>(); - recipesAirRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeAir, 2), costTier1, manaPowder, manaSteel, Ingredient.fromTag(ItemTags.CARPETS), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.STRING))); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("air"), new ItemStack(ModItems.runeAir, 2), costTier1, manaPowder, manaSteel, Ingredient.fromTag(ItemTags.CARPETS), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.STRING))); Ingredient fire = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "runes/fire"))); Ingredient water = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "runes/water"))); @@ -78,29 +83,28 @@ public final class ModRuneRecipes { Ingredient sapling = Ingredient.fromTag(ItemTags.SAPLINGS); Ingredient leaves = Ingredient.fromTag(ItemTags.LEAVES); Ingredient sand = Ingredient.fromTag(ItemTags.SAND); - recipeSpringRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeSpring), costTier2, water, fire, sapling, sapling, sapling, Ingredient.fromItems(Items.WHEAT)); - recipeSummerRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeSummer), costTier2, earth, air, sand, sand, Ingredient.fromItems(Items.SLIME_BALL), Ingredient.fromItems(Items.MELON_SLICE)); - recipeAutumnRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeAutumn), costTier2, fire, air, leaves, leaves, leaves, Ingredient.fromItems(Items.SPIDER_EYE)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("spring"), new ItemStack(ModItems.runeSpring), costTier2, water, fire, sapling, sapling, sapling, Ingredient.fromItems(Items.WHEAT))); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("summer"), new ItemStack(ModItems.runeSummer), costTier2, earth, air, sand, sand, Ingredient.fromItems(Items.SLIME_BALL), Ingredient.fromItems(Items.MELON_SLICE))); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("autumn"), new ItemStack(ModItems.runeAutumn), costTier2, fire, air, leaves, leaves, leaves, Ingredient.fromItems(Items.SPIDER_EYE))); - recipesWinterRune = new ArrayList<>(); - recipesWinterRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeWinter), costTier2, water, earth, Ingredient.fromItems(Blocks.SNOW), Ingredient.fromItems(Blocks.SNOW), Ingredient.fromTag(ItemTags.WOOL), Ingredient.fromItems(Blocks.CAKE))); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("winter"), new ItemStack(ModItems.runeWinter), costTier2, water, earth, Ingredient.fromItems(Blocks.SNOW), Ingredient.fromItems(Blocks.SNOW), Ingredient.fromTag(ItemTags.WOOL), Ingredient.fromItems(Blocks.CAKE))); Ingredient spring = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "runes/spring"))); Ingredient summer = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "runes/summer"))); Ingredient autumn = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "runes/autumn"))); Ingredient winter = Ingredient.fromTag(new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "runes/winter"))); - recipeManaRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeMana), costTier2, manaSteel, manaSteel, manaSteel, manaSteel, manaSteel, Ingredient.fromItems(ModItems.manaPearl)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("mana"), new ItemStack(ModItems.runeMana), costTier2, manaSteel, manaSteel, manaSteel, manaSteel, manaSteel, Ingredient.fromItems(ModItems.manaPearl))); - recipeLustRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeLust), costTier3, manaDiamond, manaDiamond, summer, air); - recipeGluttonyRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeGluttony), costTier3, manaDiamond, manaDiamond, winter, fire); - recipeGreedRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeGreed), costTier3, manaDiamond, manaDiamond, spring, water); - recipeSlothRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeSloth), costTier3, manaDiamond, manaDiamond, autumn, air); - recipeWrathRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeWrath), costTier3, manaDiamond, manaDiamond, winter, earth); - recipeEnvyRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeEnvy), costTier3, manaDiamond, manaDiamond, winter, water); - recipePrideRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runePride), costTier3, manaDiamond, manaDiamond, summer, fire); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("lust"), new ItemStack(ModItems.runeLust), costTier3, manaDiamond, manaDiamond, summer, air)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("gluttony"), new ItemStack(ModItems.runeGluttony), costTier3, manaDiamond, manaDiamond, winter, fire)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("greed"), new ItemStack(ModItems.runeGreed), costTier3, manaDiamond, manaDiamond, spring, water)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("sloth"), new ItemStack(ModItems.runeSloth), costTier3, manaDiamond, manaDiamond, autumn, air)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("wrath"), new ItemStack(ModItems.runeWrath), costTier3, manaDiamond, manaDiamond, winter, earth)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("envy"), new ItemStack(ModItems.runeEnvy), costTier3, manaDiamond, manaDiamond, winter, water)); + evt.runeAltar().accept(new RecipeRuneAltar(prefix("pride"), new ItemStack(ModItems.runePride), costTier3, manaDiamond, manaDiamond, summer, fire)); - recipeHead = new HeadRecipe(new ItemStack(Items.PLAYER_HEAD), 22500, Ingredient.fromItems(Items.SKELETON_SKULL), Ingredient.fromItems(ModItems.pixieDust), Ingredient.fromItems(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.NAME_TAG), Ingredient.fromItems(Items.GOLDEN_APPLE)); - BotaniaAPI.runeAltarRecipes.add(recipeHead); + recipeHead = new HeadRecipe(prefix("head"), new ItemStack(Items.PLAYER_HEAD), 22500, Ingredient.fromItems(Items.SKELETON_SKULL), Ingredient.fromItems(ModItems.pixieDust), Ingredient.fromItems(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.NAME_TAG), Ingredient.fromItems(Items.GOLDEN_APPLE)); + evt.runeAltar().accept(recipeHead); } } diff --git a/src/main/java/vazkii/botania/common/crafting/ReloadListener.java b/src/main/java/vazkii/botania/common/crafting/ReloadListener.java new file mode 100644 index 000000000..7c2643ecf --- /dev/null +++ b/src/main/java/vazkii/botania/common/crafting/ReloadListener.java @@ -0,0 +1,47 @@ +package vazkii.botania.common.crafting; + +import com.google.common.collect.ImmutableMap; +import net.minecraft.resources.IResourceManager; +import net.minecraft.resources.IResourceManagerReloadListener; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.MinecraftForge; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.recipe.RecipeBrew; +import vazkii.botania.api.recipe.RecipeElvenTrade; +import vazkii.botania.api.recipe.RecipeManaInfusion; +import vazkii.botania.api.recipe.RecipePetals; +import vazkii.botania.api.recipe.RecipePureDaisy; +import vazkii.botania.api.recipe.RecipeRuneAltar; +import vazkii.botania.api.recipe.RegisterRecipesEvent; + +import javax.annotation.Nullable; +import java.util.HashMap; +import java.util.Map; + +public class ReloadListener implements IResourceManagerReloadListener { + @Override + public void onResourceManagerReload(@Nullable IResourceManager manager) { + Map pureDaisy = new HashMap<>(); + Map manaInfusion = new HashMap<>(); + Map brew = new HashMap<>(); + Map elvenTrade = new HashMap<>(); + Map apothecary = new HashMap<>(); + Map runeAltar = new HashMap<>(); + + RegisterRecipesEvent evt = new RegisterRecipesEvent( + r -> pureDaisy.put(r.getId(), r), + r -> manaInfusion.put(r.getId(), r), + r -> brew.put(r.getId(), r), + r -> elvenTrade.put(r.getId(), r), + r -> apothecary.put(r.getId(), r), + r -> runeAltar.put(r.getId(), r) + ); + MinecraftForge.EVENT_BUS.post(evt); + + BotaniaAPI.pureDaisyRecipes = ImmutableMap.copyOf(pureDaisy); + BotaniaAPI.manaInfusionRecipes = ImmutableMap.copyOf(manaInfusion); + BotaniaAPI.brewRecipes = ImmutableMap.copyOf(brew); + BotaniaAPI.elvenTradeRecipes = ImmutableMap.copyOf(elvenTrade); + BotaniaAPI.petalRecipes = ImmutableMap.copyOf(apothecary); + } +} diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java index cfed8f241..0e60ee29c 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java @@ -14,6 +14,7 @@ import net.minecraft.item.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.items.IItemHandler; import vazkii.botania.api.recipe.RecipeRuneAltar; @@ -23,8 +24,8 @@ public class HeadRecipe extends RecipeRuneAltar { private String name = ""; - public HeadRecipe(ItemStack output, int mana, Ingredient... inputs) { - super(output, mana, inputs); + public HeadRecipe(ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) { + super(id, output, mana, inputs); } @Override diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 89ef4e4fc..1242a845f 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -21,6 +21,7 @@ import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.api.lexicon.LexiconRecipeMappings; +import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; @@ -56,6 +57,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public final class LexiconData { @@ -536,9 +538,13 @@ public final class LexiconData { new PageText("3"), new PageCraftingRecipe("4", ModCraftingRecipes.recipeRedstoneRoot)) .setIcon(ItemStack.EMPTY); + // todo 1.14 make this a tag or something instead of this dumb thing + List miniRecipes = BotaniaAPI.manaInfusionRecipes.values().stream() + .filter(r -> r.getOutput().getItem().getRegistryName().getPath().contains("chibi")) + .collect(Collectors.toList()); flowerShrinking = new BasicLexiconEntry(LibLexicon.FFLOWER_SHRINKING, categoryFunctionalFlowers); flowerShrinking.setPriority() - .setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", BotaniaAPI.miniFlowerRecipes)) + .setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", miniRecipes)) .setIcon(new ItemStack(ModSubtiles.bellethornChibi)); flowerSpeed = new BasicLexiconEntry(LibLexicon.FFLOWER_SPEED, categoryFunctionalFlowers); diff --git a/src/main/resources/data/botania/loot_tables/blocks/solid_vine.json b/src/main/resources/data/botania/loot_tables/blocks/solid_vine.json index ca8e7d092..76d454861 100644 --- a/src/main/resources/data/botania/loot_tables/blocks/solid_vine.json +++ b/src/main/resources/data/botania/loot_tables/blocks/solid_vine.json @@ -7,7 +7,7 @@ "entries": [ { "type": "minecraft:loot_table", - "name": "minecraft:vine" + "name": "minecraft:blocks/vine" } ] }