-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
481 additions
and
14 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
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
34 changes: 34 additions & 0 deletions
34
src/main/java/owmii/powah/compat/jei/AbstractCategory.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,34 @@ | ||
package owmii.powah.compat.jei; | ||
|
||
import mezz.jei.api.gui.drawable.IDrawable; | ||
import mezz.jei.api.helpers.IGuiHelper; | ||
import mezz.jei.api.recipe.category.IRecipeCategory; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.level.ItemLike; | ||
|
||
public abstract class AbstractCategory<T> implements IRecipeCategory<T> { | ||
private final Component title; | ||
private final IDrawable background; | ||
private final IDrawable icon; | ||
|
||
public AbstractCategory(IGuiHelper guiHelper, ItemLike iconItemLike, Component title, IDrawable background) { | ||
this.title = title; | ||
this.background = background; | ||
this.icon = guiHelper.createDrawableItemLike(iconItemLike); | ||
} | ||
|
||
@Override | ||
public final Component getTitle() { | ||
return title; | ||
} | ||
|
||
@Override | ||
public final IDrawable getBackground() { | ||
return background; | ||
} | ||
|
||
@Override | ||
public final IDrawable getIcon() { | ||
return icon; | ||
} | ||
} |
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,9 @@ | ||
package owmii.powah.compat.jei; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import owmii.powah.Powah; | ||
|
||
public class Assets { | ||
public static final ResourceLocation ENERGIZING = ResourceLocation.fromNamespaceAndPath(Powah.MOD_ID, "textures/gui/jei/energizing.png"); | ||
public static final ResourceLocation MISC = ResourceLocation.fromNamespaceAndPath(Powah.MOD_ID, "textures/gui/jei/misc.png"); | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/owmii/powah/compat/jei/JeiEnergizingCategory.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,64 @@ | ||
package owmii.powah.compat.jei; | ||
|
||
import java.util.List; | ||
import java.util.function.Supplier; | ||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; | ||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView; | ||
import mezz.jei.api.helpers.IGuiHelper; | ||
import mezz.jei.api.recipe.IFocusGroup; | ||
import mezz.jei.api.recipe.RecipeIngredientRole; | ||
import mezz.jei.api.recipe.RecipeType; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.resources.language.I18n; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.item.crafting.RecipeHolder; | ||
import owmii.powah.block.Blcks; | ||
import owmii.powah.block.energizing.EnergizingRecipe; | ||
import owmii.powah.recipe.Recipes; | ||
import owmii.powah.util.Util; | ||
|
||
public class JeiEnergizingCategory extends AbstractCategory<RecipeHolder<EnergizingRecipe>> { | ||
public static final Supplier<RecipeType<RecipeHolder<EnergizingRecipe>>> TYPE = RecipeType.createFromDeferredVanilla(Recipes.ENERGIZING); | ||
|
||
public JeiEnergizingCategory(IGuiHelper guiHelper) { | ||
super(guiHelper, Blcks.ENERGIZING_ORB.get(), Component.translatable("gui.powah.jei.category.energizing"), | ||
guiHelper.drawableBuilder(Assets.ENERGIZING, 0, 0, 160, 38).addPadding(1, 0, 0, 0).build()); | ||
} | ||
|
||
@Override | ||
public RecipeType<RecipeHolder<EnergizingRecipe>> getRecipeType() { | ||
return TYPE.get(); | ||
} | ||
|
||
@Override | ||
public void setRecipe(IRecipeLayoutBuilder builder, RecipeHolder<EnergizingRecipe> recipeHolder, IFocusGroup focuses) { | ||
var recipe = recipeHolder.value(); | ||
var ingredients = recipe.getIngredients(); | ||
int size = ingredients.size(); | ||
for (int i = 0; i < size; i++) { | ||
builder.addSlot(RecipeIngredientRole.INPUT, (i * 20) + 4, 5) | ||
.addIngredients(ingredients.get(i)); | ||
} | ||
|
||
builder.addSlot(RecipeIngredientRole.OUTPUT, 137, 5) | ||
.addItemStack(recipe.getResultItem()); | ||
} | ||
|
||
@Override | ||
public void draw(RecipeHolder<EnergizingRecipe> recipeHolder, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, | ||
double mouseY) { | ||
var recipe = recipeHolder.value(); | ||
var minecraft = Minecraft.getInstance(); | ||
guiGraphics.drawString(minecraft.font, I18n.get("info.lollipop.fe", Util.addCommas(recipe.getEnergy())), 2, 29, 0x444444, false); | ||
} | ||
|
||
public static List<RecipeHolder<EnergizingRecipe>> getAllRecipes() { | ||
var minecraft = Minecraft.getInstance(); | ||
var level = minecraft.level; | ||
assert level != null; | ||
var recipeManager = level.getRecipeManager(); | ||
|
||
return recipeManager.getAllRecipesFor(Recipes.ENERGIZING.get()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/owmii/powah/compat/jei/JeiFluidCoolantCategory.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,43 @@ | ||
package owmii.powah.compat.jei; | ||
|
||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; | ||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView; | ||
import mezz.jei.api.helpers.IGuiHelper; | ||
import mezz.jei.api.recipe.IFocusGroup; | ||
import mezz.jei.api.recipe.RecipeIngredientRole; | ||
import mezz.jei.api.recipe.RecipeType; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.resources.language.I18n; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.item.Items; | ||
import owmii.powah.Powah; | ||
import owmii.powah.compat.common.FluidCoolant; | ||
|
||
public class JeiFluidCoolantCategory extends AbstractCategory<FluidCoolant> { | ||
public static final RecipeType<FluidCoolant> TYPE = RecipeType.create(Powah.MOD_ID, "coolant", FluidCoolant.class); | ||
|
||
public JeiFluidCoolantCategory(IGuiHelper guiHelper) { | ||
super(guiHelper, Items.WATER_BUCKET, Component.translatable("gui.powah.jei.category.coolant"), | ||
guiHelper.drawableBuilder(Assets.MISC, 0, 0, 160, 24).addPadding(1, 0, 0, 0).build()); | ||
} | ||
|
||
@Override | ||
public RecipeType<FluidCoolant> getRecipeType() { | ||
return TYPE; | ||
} | ||
|
||
@Override | ||
public void setRecipe(IRecipeLayoutBuilder builder, FluidCoolant recipe, IFocusGroup focuses) { | ||
builder.addSlot(RecipeIngredientRole.INPUT, 4, 5) | ||
.addFluidStack(recipe.fluid()); | ||
} | ||
|
||
@Override | ||
public void draw(FluidCoolant recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { | ||
var minecraft = Minecraft.getInstance(); | ||
guiGraphics.drawString(minecraft.font, I18n.get("info.lollipop.temperature") + ": " | ||
+ I18n.get("info.lollipop.temperature.c", "" + ChatFormatting.DARK_AQUA + recipe.coldness()), 30, 9, 0x444444, false); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/owmii/powah/compat/jei/JeiHeatSourceCategory.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,49 @@ | ||
package owmii.powah.compat.jei; | ||
|
||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; | ||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView; | ||
import mezz.jei.api.helpers.IGuiHelper; | ||
import mezz.jei.api.recipe.IFocusGroup; | ||
import mezz.jei.api.recipe.RecipeIngredientRole; | ||
import mezz.jei.api.recipe.RecipeType; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.resources.language.I18n; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.level.block.Blocks; | ||
import owmii.powah.Powah; | ||
import owmii.powah.compat.common.PassiveHeatSource; | ||
|
||
public class JeiHeatSourceCategory extends AbstractCategory<PassiveHeatSource> { | ||
public static final RecipeType<PassiveHeatSource> TYPE = RecipeType.create(Powah.MOD_ID, "heat_source", PassiveHeatSource.class); | ||
|
||
public JeiHeatSourceCategory(IGuiHelper guiHelper) { | ||
super(guiHelper, Blocks.MAGMA_BLOCK, Component.translatable("gui.powah.jei.category.heat.sources"), | ||
guiHelper.drawableBuilder(Assets.MISC, 0, 0, 160, 24).addPadding(1, 0, 0, 0).build()); | ||
} | ||
|
||
@Override | ||
public RecipeType<PassiveHeatSource> getRecipeType() { | ||
return TYPE; | ||
} | ||
|
||
@Override | ||
public void setRecipe(IRecipeLayoutBuilder builder, PassiveHeatSource recipe, IFocusGroup focuses) { | ||
var input = builder.addSlot(RecipeIngredientRole.INPUT, 4, 5); | ||
|
||
if (recipe.block() != null) { | ||
input.addItemLike(recipe.block()); | ||
} | ||
if (recipe.fluid() != null) { | ||
input.addFluidStack(recipe.fluid()); | ||
} | ||
} | ||
|
||
@Override | ||
public void draw(PassiveHeatSource recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { | ||
var minecraft = Minecraft.getInstance(); | ||
guiGraphics.drawString(minecraft.font, ChatFormatting.DARK_GRAY + I18n.get("info.lollipop.temperature") + ": " | ||
+ ChatFormatting.RESET + I18n.get("info.lollipop.temperature.c", recipe.heat()), 30, 9, 0xc43400, false); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/owmii/powah/compat/jei/JeiMagmatorCategory.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,41 @@ | ||
package owmii.powah.compat.jei; | ||
|
||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; | ||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView; | ||
import mezz.jei.api.helpers.IGuiHelper; | ||
import mezz.jei.api.recipe.IFocusGroup; | ||
import mezz.jei.api.recipe.RecipeIngredientRole; | ||
import mezz.jei.api.recipe.RecipeType; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.network.chat.Component; | ||
import owmii.powah.Powah; | ||
import owmii.powah.block.Blcks; | ||
import owmii.powah.block.Tier; | ||
import owmii.powah.compat.common.MagmatorFuel; | ||
|
||
public class JeiMagmatorCategory extends AbstractCategory<MagmatorFuel> { | ||
public static final RecipeType<MagmatorFuel> TYPE = RecipeType.create(Powah.MOD_ID, "magmatic", MagmatorFuel.class); | ||
|
||
public JeiMagmatorCategory(IGuiHelper guiHelper) { | ||
super(guiHelper, Blcks.MAGMATOR.get(Tier.BASIC), Component.translatable("gui.powah.jei.category.magmatic"), | ||
guiHelper.drawableBuilder(Assets.MISC, 0, 0, 160, 24).addPadding(1, 0, 0, 0).build()); | ||
} | ||
|
||
@Override | ||
public RecipeType<MagmatorFuel> getRecipeType() { | ||
return TYPE; | ||
} | ||
|
||
@Override | ||
public void setRecipe(IRecipeLayoutBuilder builder, MagmatorFuel recipe, IFocusGroup focuses) { | ||
builder.addSlot(RecipeIngredientRole.INPUT, 4, 5) | ||
.addFluidStack(recipe.fluid()); | ||
} | ||
|
||
@Override | ||
public void draw(MagmatorFuel recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { | ||
var minecraft = Minecraft.getInstance(); | ||
guiGraphics.drawString(minecraft.font, recipe.heat() + " FE/100 mb", 27, 9, 0x444444, false); | ||
} | ||
} |
Oops, something went wrong.