Skip to content

Commit

Permalink
improved readability of JEI recipes when using resource packs that al…
Browse files Browse the repository at this point in the history
…ter the background texture
  • Loading branch information
codetaylor committed Feb 1, 2018
1 parent 823a0a9 commit a114860
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 3 deletions.
Binary file modified assets/jei.xcf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
Expand All @@ -18,6 +19,11 @@
public class JEIRecipeWrapperMortar
implements IRecipeWrapper {

private static final ResourceLocation TEXTURE_PRIMARY_OVERLAY = new ResourceLocation(
ModuleMortar.MOD_ID,
"textures/gui/jei_primary.png"
);

private static final ResourceLocation TEXTURE_SECONDARY_OVERLAY = new ResourceLocation(
ModuleMortar.MOD_ID,
"textures/gui/jei_secondary.png"
Expand Down Expand Up @@ -59,11 +65,18 @@ public void drawInfo(
Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY
) {

GlStateManager.enableBlend();

if (this.outputs.size() > 1) {
GuiHelper.drawTexturedRect(minecraft, TEXTURE_SECONDARY_OVERLAY, recipeWidth - 26, 0, 26, 54, 0, 0, 0, 26, 54);

String text = Math.round(this.secondaryOutputChance * 100) + "%";
minecraft.fontRenderer.drawStringWithShadow(text, recipeWidth - 2, 32, 0xFFFFFF);

} else {
GuiHelper.drawTexturedRect(minecraft, TEXTURE_PRIMARY_OVERLAY, recipeWidth - 26, 0, 26, 54, 0, 0, 0, 26, 54);
}

GlStateManager.disableBlend();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
import com.codetaylor.mc.advancedmortars.modules.mortar.recipe.IRecipeMortar;
import com.codetaylor.mc.advancedmortars.modules.mortar.recipe.RecipeMortar;
import com.codetaylor.mc.advancedmortars.modules.mortar.reference.EnumMortarType;
import mezz.jei.api.*;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.gui.elements.DrawableResource;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

Expand Down Expand Up @@ -63,12 +69,20 @@ private JEICategoryMortar createCategory(EnumMortarType type) {

private IDrawable createBackground() {

IGuiHelper guiHelper = this.jeiHelpers.getGuiHelper();
ResourceLocation resourceLocation = new ResourceLocation(
ModuleMortar.MOD_ID,
TEXTURE_BACKGROUND
);
return guiHelper.createDrawable(resourceLocation, 0, 0, 116, 54, 116, 54);
return new DrawableResource(resourceLocation, 0, 0, 116, 54, 0, 0, 0, 0, 116, 54) {

@Override
public void draw(Minecraft minecraft) {

GlStateManager.enableBlend();
super.draw(minecraft);
GlStateManager.disableBlend();
}
};
}

private String createTitleTranslateKey(EnumMortarType type) {
Expand Down
Binary file modified src/main/resources/assets/advancedmortars/textures/gui/jei.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a114860

Please sign in to comment.