diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index 68eda4251..ee971a6cd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -25,6 +25,7 @@ import net.minecraft.block.BlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; import java.util.ArrayList; import java.util.HashMap; @@ -41,6 +42,7 @@ public final class ActuallyAdditionsAPI { public static final List BALL_OF_FUR_RETURN_ITEMS = new ArrayList<>(); // public static final List TREASURE_CHEST_LOOT = new ArrayList<>(); public static final List RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<>(); + public static final List EMPOWERER_RECIPES = new ArrayList<>(); public static final Map RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<>(); /** * Farmer behaviors are sorted when first accessed, this will not be done until after loading, but do not add behaviors at runtime. @@ -238,13 +240,8 @@ public final class ActuallyAdditionsAPI { // TREASURE_CHEST_LOOT.add(new TreasureChestLoot(stack, chance, minAmount, maxAmount)); } - @Deprecated - public static void addEmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor) { - EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor)); - } - - public static void addEmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) { - EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor)); + public static void addEmpowererRecipe(ResourceLocation id, Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, int particleColor) { + EMPOWERER_RECIPES.add(new EmpowererRecipe(id, output, input, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor)); } /** diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java b/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java index 4695bd5fe..77e8c1962 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java @@ -31,7 +31,7 @@ public class ActuallyAdditionsData { generator.addProvider(new ItemTagsGenerator(generator, generatorBlockTags, helper)); generator.addProvider(new LaserRecipeGenerator(generator)); - generator.addProvider(new MiscRecipeGenerator(generator)); + generator.addProvider(new EmpoweringRecipeGenerator(generator)); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/MiscRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java similarity index 98% rename from src/main/java/de/ellpeck/actuallyadditions/data/MiscRecipeGenerator.java rename to src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java index 126ef963d..362262c5c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/MiscRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java @@ -26,8 +26,8 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -public class MiscRecipeGenerator extends RecipeProvider { - public MiscRecipeGenerator(DataGenerator p_i48262_1_) { +public class EmpoweringRecipeGenerator extends RecipeProvider { + public EmpoweringRecipeGenerator(DataGenerator p_i48262_1_) { super(p_i48262_1_); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java index 30c414994..cc5b5b714 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java @@ -31,13 +31,14 @@ import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.MethodHandler; import de.ellpeck.actuallyadditions.mod.network.PacketHandler; -import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler; import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler; import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; +import de.ellpeck.actuallyadditions.mod.util.ResourceReloader; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.crafting.CraftingHelper; +import net.minecraftforge.event.AddReloadListenerEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -91,6 +92,7 @@ public class ActuallyAdditions { MinecraftForge.EVENT_BUS.addListener(this::serverStopped); MinecraftForge.EVENT_BUS.register(new CommonEvents()); MinecraftForge.EVENT_BUS.register(new DungeonLoot()); + MinecraftForge.EVENT_BUS.addListener(ActuallyAdditions::reloadEvent); eventBus.addListener(this::setup); eventBus.addListener(this::clientSetup); @@ -116,11 +118,14 @@ public class ActuallyAdditions { CrusherCrafting.init(); HairyBallHandler.init(); LensRecipeHandler.init(); - EmpowererHandler.init(); LensMining.init(); InitBooklet.init(); } + private static void reloadEvent(AddReloadListenerEvent event){ + event.addListener(new ResourceReloader(event.getDataPackRegistries())); + } + private void clientSetup(FMLClientSetupEvent event) { ActuallyAdditionsClient.setup(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index 7cc64df66..2f017f4f5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -35,7 +35,6 @@ import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats; import de.ellpeck.actuallyadditions.mod.items.lens.LensDisenchanting; import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; -import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler; import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; import de.ellpeck.actuallyadditions.mod.util.Util; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EmpowererHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EmpowererHandler.java deleted file mode 100644 index 4ff0e8b16..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EmpowererHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file ("EmpowererHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.recipe; - -// TODO: [port] ADD BACK -public final class EmpowererHandler { - // - // public static final ArrayList MAIN_PAGE_RECIPES = new ArrayList<>(); - // public static EmpowererRecipe recipeEmpoweredCanolaSeed; - // - public static void init() { - // addCrystalEmpowering(TheCrystals.REDSTONE, "dyeRed", Ingredient.fromItems(Items.NETHERBRICK), Ingredient.fromItems(Items.REDSTONE), Ingredient.fromItems(Items.BRICK)); - // addCrystalEmpowering(TheCrystals.LAPIS, "dyeCyan", Ingredient.fromItems(Items.PRISMARINE_SHARD), Ingredient.fromItems(Items.PRISMARINE_SHARD), Ingredient.fromItems(Items.PRISMARINE_SHARD)); - // addCrystalEmpowering(TheCrystals.DIAMOND, "dyeLightBlue", Ingredient.fromItems(Items.CLAY_BALL), Ingredient.fromItems(Items.CLAY_BALL), fromBlock(Blocks.CLAY)); - // addCrystalEmpowering(TheCrystals.IRON, "dyeGray", Ingredient.fromItems(Items.SNOWBALL), fromBlock(Blocks.STONE_BUTTON), fromBlock(Blocks.COBBLESTONE)); - // - // addCrystalEmpowering(TheCrystals.COAL, "dyeBlack", igd(new ItemStack(Items.COAL, 1, 1)), Ingredient.fromItems(Items.FLINT), fromBlock(Blocks.STONE)); - // - // List balls = OreDictionary.getOres("slimeball"); - // for (ItemStack ball : balls) { - // addCrystalEmpowering(TheCrystals.EMERALD, "dyeLime", igd(new ItemStack(Blocks.TALLGRASS, 1, 1)), igd(new ItemStack(Blocks.SAPLING)), igd(ball.copy())); - // } - // - // Ingredient seed = Ingredient.fromItems(InitItems.itemCanolaSeed); - // ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal())), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal()), seed, seed, seed, seed, 1000, 30, new float[]{1F, 91F / 255F, 76F / 255F}); - // recipeEmpoweredCanolaSeed = RecipeUtil.lastEmpowererRecipe(); - } - // - // private static void addCrystalEmpowering(TheCrystals type, String dye, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3) { - // float[] color = type.conversionColorParticles; - // - // ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemCrystal, 1, type.ordinal())), new ItemStack(InitItems.itemCrystalEmpowered, 1, type.ordinal()), new OreIngredient(dye), modifier1, modifier2, modifier3, 5000, 50, color); - // MAIN_PAGE_RECIPES.add(RecipeUtil.lastEmpowererRecipe()); - // ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitBlocks.blockCrystal, 1, type.ordinal())), new ItemStack(InitBlocks.blockCrystalEmpowered, 1, type.ordinal()), new OreIngredient(dye), modifier1, modifier2, modifier3, 50000, 500, color); - // MAIN_PAGE_RECIPES.add(RecipeUtil.lastEmpowererRecipe()); - // } - // - // private static Ingredient igd(ItemStack s) { - // return Ingredient.fromStacks(s); - // } - // - // private static Ingredient fromBlock(Block b) { - // return Ingredient.fromItems(Item.getItemFromBlock(b)); - // } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ResourceReloader.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ResourceReloader.java new file mode 100644 index 000000000..2614ed554 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ResourceReloader.java @@ -0,0 +1,26 @@ +package de.ellpeck.actuallyadditions.mod.util; + + +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; +import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes; +import net.minecraft.item.crafting.RecipeManager; +import net.minecraft.resources.DataPackRegistries; +import net.minecraft.resources.IResourceManager; +import net.minecraftforge.resource.IResourceType; +import net.minecraftforge.resource.ISelectiveResourceReloadListener; + +import java.util.function.Predicate; + +public class ResourceReloader implements ISelectiveResourceReloadListener { + private final DataPackRegistries data; + public ResourceReloader(DataPackRegistries dataPackRegistries) { + data = dataPackRegistries; + } + + @Override + public void onResourceManagerReload(IResourceManager resourceManager, Predicate resourcePredicate) { + RecipeManager recipeManager = data.getRecipeManager(); + ActuallyAdditionsAPI.EMPOWERER_RECIPES.clear(); + ActuallyAdditionsAPI.EMPOWERER_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.EMPOWERING)); + } +}