Skip to content

Commit

Permalink
- Finalizes JEI compat fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PocketSizedWeeb committed Apr 15, 2024
1 parent 7d0525d commit 6c7c0ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import com.lothrazar.cyclic.ModCyclic;
import com.lothrazar.cyclic.block.crusher.RecipeCrusher;
import com.lothrazar.cyclic.block.solidifier.TileSolidifier;
import com.lothrazar.cyclic.registry.BlockRegistry;
import com.lothrazar.cyclic.registry.TextureRegistry;
import com.lothrazar.library.gui.EnergyBar;
import com.lothrazar.library.gui.TexturedProgress;
import com.lothrazar.library.util.ChatUtil;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
Expand All @@ -14,6 +18,7 @@
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -26,10 +31,17 @@ public class CrusherRecipeCategory implements IRecipeCategory<RecipeCrusher> {
static final RecipeType<RecipeCrusher> TYPE = new RecipeType<>(ID, RecipeCrusher.class);
private IDrawable gui;
private IDrawable icon;
private Font font;
private EnergyBar bar;

public CrusherRecipeCategory(IGuiHelper helper) {
font = Minecraft.getInstance().font;
gui = helper.drawableBuilder(new ResourceLocation(ModCyclic.MODID, "textures/jei/crusher.png"), 0, 0, 155, 49).setTextureSize(155, 49).build();
icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.CRUSHER.get()));
bar = new EnergyBar(font, TileSolidifier.MAX);
bar.setHeight(48);
bar.guiLeft = -16;
bar.guiTop = -8;
}

@Override
Expand All @@ -55,7 +67,6 @@ public RecipeType<RecipeCrusher> getRecipeType() {
@Override
public void draw(RecipeCrusher recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics ms, double mouseX, double mouseY) {
int x = 78;
var font = Minecraft.getInstance().font;
if (recipe.energy.getTicks() < 40) {
ms.drawString(font, recipe.energy.getTicks() + " t", x, 6, FONT);
}
Expand All @@ -68,6 +79,9 @@ public void draw(RecipeCrusher recipe, IRecipeSlotsView recipeSlotsView, GuiGrap
if (!recipe.randOutput.bonus.isEmpty() && recipe.randOutput.percent > 0) {
ms.drawString(font, recipe.randOutput.percent + "%", 56, 36, FONT);
}

bar.draw(ms, recipe.energy.getEnergyTotal());
bar.renderHoveredToolTip(ms, (int) mouseX, (int) mouseY, recipe.energy.getEnergyTotal());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public MelterRecipeCategory(IGuiHelper helper) {
icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.MELTER.get()));
bar = new EnergyBar(font, TileSolidifier.MAX);
progress = new TexturedProgress(font, 80, 19, 24, 17, TextureRegistry.ARROW);
bar.guiTop = -4;
bar.guiLeft = -2;
}

@Override
Expand Down Expand Up @@ -80,6 +82,6 @@ public void setRecipe(IRecipeLayoutBuilder builder, RecipeMelter recipe, IFocusG
builder.addSlot(RecipeIngredientRole.INPUT, 4, 19).addIngredients(recipe.at(0));
builder.addSlot(RecipeIngredientRole.INPUT, 22, 19).addIngredients(recipe.at(1));
List<FluidStack> matchingFluids = List.of(recipe.getRecipeFluid());
builder.addSlot(RecipeIngredientRole.OUTPUT, 136, 19).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids).setFluidRenderer(4000, false, 16, 16);
builder.addSlot(RecipeIngredientRole.OUTPUT, 132, 19).addIngredients(ForgeTypes.FLUID_STACK, matchingFluids).setFluidRenderer(4000, false, 16, 16);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public SolidifierRecipeCategory(IGuiHelper helper) {
icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BlockRegistry.SOLIDIFIER.get()));
bar = new EnergyBar(font, TileSolidifier.MAX);
progress = new TexturedProgress(font, 63, 25, 24, 17, TextureRegistry.ARROW);
bar.guiTop = -4;
bar.guiLeft = -2;
}

@Override
Expand Down

0 comments on commit 6c7c0ec

Please sign in to comment.