Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show melter recipes in their own JEI tab by default
This makes the overrides and blacklist more clear to the end user, which should help with #31. Also, it makes it more clear when solid fuel can be used for a recipe. This feature can be disabled if desired, as most times its redundant.
- Loading branch information
1 parent
df3f288
commit 223f44b
Showing
8 changed files
with
259 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/main/java/knightminer/tcomplement/plugin/jei/melter/MeltingRecipeCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package knightminer.tcomplement.plugin.jei.melter; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
import knightminer.tcomplement.TinkersComplement; | ||
import knightminer.tcomplement.library.Util; | ||
import mezz.jei.api.IGuiHelper; | ||
import mezz.jei.api.gui.IDrawable; | ||
import mezz.jei.api.gui.IDrawableAnimated; | ||
import mezz.jei.api.gui.IDrawableStatic; | ||
import mezz.jei.api.gui.IGuiFluidStackGroup; | ||
import mezz.jei.api.gui.IGuiItemStackGroup; | ||
import mezz.jei.api.gui.IRecipeLayout; | ||
import mezz.jei.api.ingredients.IIngredients; | ||
import mezz.jei.api.recipe.IRecipeCategory; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.init.Items; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import slimeknights.tconstruct.library.client.GuiUtil; | ||
import slimeknights.tconstruct.library.materials.Material; | ||
|
||
public class MeltingRecipeCategory implements IRecipeCategory<MeltingRecipeWrapper> { | ||
|
||
public static final String CATEGORY = Util.resource("melter"); | ||
public static final ResourceLocation BACKGROUND = Util.getResource("textures/gui/jei/melter.png"); | ||
private static List<ItemStack> furnaceFuels; | ||
|
||
private final IDrawable background; | ||
protected final IDrawable solidCover; | ||
protected final IDrawableAnimated flame; | ||
private final IDrawableAnimated progress; | ||
|
||
public MeltingRecipeCategory(IGuiHelper guiHelper) { | ||
background = guiHelper.createDrawable(BACKGROUND, 0, 0, 160, 46, 0, 0, 0, 0); | ||
solidCover = guiHelper.createDrawable(BACKGROUND, 174, 0, 18, 33); | ||
|
||
IDrawableStatic flameDrawable = guiHelper.createDrawable(BACKGROUND, 160, 0, 14, 14); | ||
flame = guiHelper.createAnimatedDrawable(flameDrawable, 200, IDrawableAnimated.StartDirection.TOP, true); | ||
IDrawableStatic progressDrawable = guiHelper.createDrawable(BACKGROUND, 160, 14, 3, 16); | ||
progress = guiHelper.createAnimatedDrawable(progressDrawable, 200, IDrawableAnimated.StartDirection.BOTTOM, false); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getUid() { | ||
return CATEGORY; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getTitle() { | ||
return Util.translate("gui.jei.melter.title"); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public IDrawable getBackground() { | ||
return background; | ||
} | ||
|
||
@Override | ||
public void drawExtras(Minecraft minecraft) { | ||
progress.draw(minecraft, 49, 21); | ||
} | ||
|
||
@Override | ||
public void setRecipe(IRecipeLayout recipeLayout, MeltingRecipeWrapper recipe, IIngredients ingredients) { | ||
IGuiItemStackGroup items = recipeLayout.getItemStacks(); | ||
items.init(0, true, 52, 20); | ||
items.set(ingredients); | ||
|
||
// if solid fuels are available, add a standard subset | ||
if(recipe.isSolid) { | ||
items.init(1, true, 6, 22); | ||
items.set(1, getFurnaceFuels()); | ||
} | ||
|
||
IGuiFluidStackGroup fluids = recipeLayout.getFluidStacks(); | ||
fluids.addTooltipCallback(GuiUtil::onFluidTooltip); | ||
|
||
fluids.init(0, false, 121, 7, 32, 32, Material.VALUE_Block, false, null); | ||
fluids.set(ingredients); | ||
|
||
fluids.init(1, true, 29, 7, 12, 32, 1000, false, null); | ||
fluids.set(1, recipe.getLiquidFuels()); | ||
} | ||
|
||
@Override | ||
public String getModName() { | ||
return TinkersComplement.modName; | ||
} | ||
|
||
private static List<ItemStack> getFurnaceFuels() { | ||
if (furnaceFuels != null) { | ||
return furnaceFuels; | ||
} | ||
return furnaceFuels = ImmutableList.of(new ItemStack(Items.COAL), new ItemStack(Items.COAL, 1, 1), new ItemStack(Blocks.LOG), new ItemStack(Blocks.PLANKS), new ItemStack(Blocks.COAL_BLOCK)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/knightminer/tcomplement/plugin/jei/melter/MeltingRecipeChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package knightminer.tcomplement.plugin.jei.melter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import knightminer.tcomplement.library.TCompRegistry; | ||
import slimeknights.tconstruct.library.smeltery.MeltingRecipe; | ||
import slimeknights.tconstruct.plugin.jei.smelting.SmeltingRecipeChecker; | ||
|
||
public class MeltingRecipeChecker { | ||
public static List<MeltingRecipe> getMeltingRecipes() { | ||
List<MeltingRecipe> recipes = new ArrayList<>(); | ||
|
||
// first, add all overrides | ||
for(MeltingRecipe recipe : TCompRegistry.getAllMeltingOverrides()) { | ||
if(recipe.output != null && recipe.input != null && recipe.input.getInputs() != null && recipe.input.getInputs().size() > 0) { | ||
recipes.add(recipe); | ||
} | ||
} | ||
|
||
// next, add all normal melting recipes if not hidden by the blacklist or overrides | ||
for(MeltingRecipe recipe : SmeltingRecipeChecker.getSmeltingRecipes()) { | ||
if (!TCompRegistry.isSmeltingHidden(recipe)) { | ||
recipes.add(recipe); | ||
} | ||
} | ||
|
||
return recipes;//recipes.stream().map(MeltingRecipeWrapper::new).collect(Collectors.toList()); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/knightminer/tcomplement/plugin/jei/melter/MeltingRecipeWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package knightminer.tcomplement.plugin.jei.melter; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import knightminer.tcomplement.plugin.jei.JEIPlugin; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import slimeknights.tconstruct.library.smeltery.MeltingRecipe; | ||
import slimeknights.tconstruct.plugin.jei.smelting.SmeltingRecipeWrapper; | ||
|
||
public class MeltingRecipeWrapper extends SmeltingRecipeWrapper { | ||
|
||
protected boolean isSolid; | ||
public MeltingRecipeWrapper(MeltingRecipe recipe) { | ||
super(recipe); | ||
// if true, we can use solid fuels | ||
isSolid = recipe.getTemperature() <= 500; | ||
} | ||
|
||
public List<FluidStack> getLiquidFuels() { | ||
return fuels; | ||
} | ||
|
||
|
||
@Override | ||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { | ||
// if solid fuel is available, draw the flame icon, otherwise cover the slot | ||
if(isSolid) { | ||
JEIPlugin.meltingCategory.flame.draw(minecraft, 8, 7); | ||
} else { | ||
JEIPlugin.meltingCategory.solidCover.draw(minecraft, 6, 7); | ||
} | ||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.