Skip to content

Commit

Permalink
Split smelting & energized smelter recipe registration.
Browse files Browse the repository at this point in the history
Fixes #5010
  • Loading branch information
tomelfring committed Apr 27, 2018
1 parent 2b6fafd commit c713b3a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
12 changes: 11 additions & 1 deletion src/main/java/mekanism/client/jei/MekanismJEI.java
Expand Up @@ -18,6 +18,7 @@
import mekanism.client.gui.GuiCombiner;
import mekanism.client.gui.GuiCrusher;
import mekanism.client.gui.GuiElectrolyticSeparator;
import mekanism.client.gui.GuiEnergizedSmelter;
import mekanism.client.gui.GuiEnrichmentChamber;
import mekanism.client.gui.GuiMetallurgicInfuser;
import mekanism.client.gui.GuiOsmiumCompressor;
Expand All @@ -39,6 +40,7 @@
import mekanism.client.jei.machine.advanced.PurificationChamberRecipeWrapper;
import mekanism.client.jei.machine.basic.CrusherRecipeWrapper;
import mekanism.client.jei.machine.basic.EnrichmentRecipeWrapper;
import mekanism.client.jei.machine.basic.SmeltingRecipeWrapper;
import mekanism.client.jei.machine.chance.PrecisionSawmillRecipeWrapper;
import mekanism.client.jei.machine.chemical.ChemicalCrystallizerRecipeCategory;
import mekanism.client.jei.machine.chemical.ChemicalCrystallizerRecipeWrapper;
Expand Down Expand Up @@ -94,6 +96,7 @@
import mekanism.common.recipe.machines.PurificationRecipe;
import mekanism.common.recipe.machines.SawmillRecipe;
import mekanism.common.recipe.machines.SeparatorRecipe;
import mekanism.common.recipe.machines.SmeltingRecipe;
import mekanism.common.recipe.machines.SolarNeutronRecipe;
import mekanism.common.recipe.machines.ThermalEvaporationRecipe;
import mekanism.common.recipe.machines.WasherRecipe;
Expand Down Expand Up @@ -170,6 +173,7 @@ public void registerIngredients(IModIngredientRegistration registry)
@Override
public void registerCategories(IRecipeCategoryRegistration registry)
{

ChemicalCrystallizerRecipeCategory chemicalCrystallizerCategory = new ChemicalCrystallizerRecipeCategory(registry.getJeiHelpers().getGuiHelper());
ChemicalDissolutionChamberRecipeCategory chemicalDissolutionChamberCategory = new ChemicalDissolutionChamberRecipeCategory(registry.getJeiHelpers().getGuiHelper());
ChemicalInfuserRecipeCategory chemicalInfuserCategory = new ChemicalInfuserRecipeCategory(registry.getJeiHelpers().getGuiHelper());
Expand All @@ -194,12 +198,13 @@ public void registerCategories(IRecipeCategoryRegistration registry)

MachineRecipeCategory machineRecipeCategoryEnrichment = new MachineRecipeCategory(registry.getJeiHelpers().getGuiHelper(), Recipe.ENRICHMENT_CHAMBER.name().toLowerCase(Locale.ROOT), "tile.MachineBlock.EnrichmentChamber.name", ProgressBar.BLUE);
MachineRecipeCategory machineRecipeCategoryCrusher = new MachineRecipeCategory(registry.getJeiHelpers().getGuiHelper(), Recipe.CRUSHER.name().toLowerCase(Locale.ROOT), "tile.MachineBlock.Crusher.name", ProgressBar.CRUSH);
MachineRecipeCategory machineRecipeCategoryEnergizedSmelter = new MachineRecipeCategory(registry.getJeiHelpers().getGuiHelper(), Recipe.ENERGIZED_SMELTER.name().toLowerCase(Locale.ROOT), "tile.MachineBlock.EnergizedSmelter.name", ProgressBar.BLUE);

registry.addRecipeCategories(chemicalCrystallizerCategory, chemicalDissolutionChamberCategory, chemicalInfuserCategory, chemicalOxidizerCategory,
chemicalWasherCategory, electrolyticSeparatorCategory, metallurgicInfuserCategory, prcCategory, rotaryCondensentratorCondensentratingCategory, rotaryCondensentratorDecondensentratingCategory, solarNeutronCategory,
thermalEvaporationCategory, doubleMachineRecipeCategoryCombiner, advancedMachineRecipeCategoryPurificationChamber, advancedMachineRecipeCategoryOsmiumCompressor,
advancedMachineRecipeCategoryChemicalInjectionChamber, chanceMachineRecipeCategoryPrecisionSawmill, machineRecipeCategoryEnrichment,
machineRecipeCategoryCrusher
machineRecipeCategoryCrusher, machineRecipeCategoryEnergizedSmelter
);
}

Expand All @@ -217,6 +222,9 @@ public void register(IModRegistry registry)
registry.handleRecipes(CrusherRecipe.class, CrusherRecipeWrapper::new, "mekanism.crusher");
addRecipes(registry, Recipe.CRUSHER, BasicMachineRecipe.class, CrusherRecipeWrapper.class, "mekanism.crusher");

registry.handleRecipes(SmeltingRecipe.class, SmeltingRecipeWrapper::new, "mekanism.energized_smelter");
addRecipes(registry, Recipe.ENERGIZED_SMELTER, BasicMachineRecipe.class, SmeltingRecipeWrapper.class, "mekanism.energized_smelter");

registry.handleRecipes(CombinerRecipe.class, CombinerRecipeWrapper::new, "mekanism.combiner");
addRecipes(registry, Recipe.COMBINER, DoubleMachineRecipe.class, CombinerRecipeWrapper.class, "mekanism.combiner");

Expand Down Expand Up @@ -278,6 +286,7 @@ public void register(IModRegistry registry)

registry.addRecipeClickArea(GuiEnrichmentChamber.class, 79, 40, 24, 7, "mekanism.enrichment_chamber");
registry.addRecipeClickArea(GuiCrusher.class, 79, 40, 24, 7, "mekanism.crusher");
registry.addRecipeClickArea(GuiEnergizedSmelter.class, 79, 40, 24, 7, "mekanism.energized_smelter", VanillaRecipeCategoryUid.SMELTING);
registry.addRecipeClickArea(GuiCombiner.class, 79, 40, 24, 7, "mekanism.combiner");
registry.addRecipeClickArea(GuiPurificationChamber.class, 79, 40, 24, 7, "mekanism.purification_chamber");
registry.addRecipeClickArea(GuiOsmiumCompressor.class, 79, 40, 24, 7, "mekanism.osmium_compressor");
Expand All @@ -298,6 +307,7 @@ public void register(IModRegistry registry)

registerRecipeItem(registry, MachineType.ENRICHMENT_CHAMBER);
registerRecipeItem(registry, MachineType.CRUSHER);
registerRecipeItem(registry, MachineType.ENERGIZED_SMELTER);
registerRecipeItem(registry, MachineType.COMBINER);
registerRecipeItem(registry, MachineType.PURIFICATION_CHAMBER);
registerRecipeItem(registry, MachineType.OSMIUM_COMPRESSOR);
Expand Down
@@ -0,0 +1,12 @@
package mekanism.client.jei.machine.basic;

import mekanism.client.jei.machine.MachineRecipeWrapper;
import mekanism.common.recipe.machines.BasicMachineRecipe;

public class SmeltingRecipeWrapper extends MachineRecipeWrapper
{
public SmeltingRecipeWrapper(BasicMachineRecipe r)
{
super(r);
}
}
9 changes: 0 additions & 9 deletions src/main/java/mekanism/common/Mekanism.java
Expand Up @@ -647,15 +647,6 @@ public void serverStarting(FMLServerStartingEvent event)
voiceManager.start();
}

//Load cached furnace recipes
Recipe.ENERGIZED_SMELTER.get().clear();

for(Map.Entry<ItemStack, ItemStack> entry : FurnaceRecipes.instance().getSmeltingList().entrySet())
{
SmeltingRecipe recipe = new SmeltingRecipe(new ItemStackInput(entry.getKey()), new ItemStackOutput(entry.getValue()));
Recipe.ENERGIZED_SMELTER.put(recipe);
}

event.registerServerCommand(new CommandMekanism());
}

Expand Down
20 changes: 18 additions & 2 deletions src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java
@@ -1,24 +1,40 @@
package mekanism.common.tile;

import java.util.HashMap;
import java.util.Map;

import mekanism.common.block.states.BlockStateMachine;
import mekanism.common.config.MekanismConfig.usage;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.machines.SmeltingRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import mekanism.common.tile.prefab.TileEntityElectricMachine;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;

public class TileEntityEnergizedSmelter extends TileEntityElectricMachine<SmeltingRecipe>
{
private static Map<ItemStackInput, SmeltingRecipe> cachedRecipes;

public TileEntityEnergizedSmelter()
{
super("smelter", "EnergizedSmelter", BlockStateMachine.MachineType.ENERGIZED_SMELTER.baseEnergy, usage.energizedSmelterUsage, 200);
}

@Override
public Map<ItemStackInput, SmeltingRecipe> getRecipes()
public synchronized Map<ItemStackInput, SmeltingRecipe> getRecipes()
{
return Recipe.ENERGIZED_SMELTER.get();
if(cachedRecipes == null)

This comment has been minimized.

Copy link
@thiakil

thiakil Apr 27, 2018

Member

why not just do this in postinit?, so that you could theoretically remove normal smelting recipes from the ES with CT

This comment has been minimized.

Copy link
@tomelfring

tomelfring Apr 27, 2018

Author Collaborator

That was an option I considered. I don't know which one of hoe two is better to be honest.

In this implementation it can do anything a furnace can do and everything added though ct/IMC. And it has two categories in JEI, one for smelting and one for all additions.

{
cachedRecipes = new HashMap<>();
cachedRecipes.putAll(Recipe.ENERGIZED_SMELTER.get());
for(Map.Entry<ItemStack, ItemStack> entry : FurnaceRecipes.instance().getSmeltingList().entrySet())
{
SmeltingRecipe recipe = new SmeltingRecipe(new ItemStackInput(entry.getKey()), new ItemStackOutput(entry.getValue()));
cachedRecipes.put(recipe.getInput(), recipe);
}
}
return cachedRecipes;
}
}

0 comments on commit c713b3a

Please sign in to comment.