Skip to content

Commit

Permalink
Fix #309 Use default textures instead of vanilla's with a texture pac…
Browse files Browse the repository at this point in the history
…k applied
  • Loading branch information
mezz committed Jul 16, 2017
1 parent a08d5a0 commit 2a4778a
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 67 deletions.
6 changes: 6 additions & 0 deletions src/main/java/mezz/jei/config/Constants.java
Expand Up @@ -3,6 +3,7 @@
import java.util.Locale;

import mezz.jei.util.Translator;
import net.minecraft.util.ResourceLocation;

public final class Constants {
public static final String minecraftModName = "Minecraft";
Expand All @@ -15,9 +16,14 @@ public final class Constants {
// Textures
public static final String RESOURCE_DOMAIN = MOD_ID.toLowerCase(Locale.ENGLISH);
public static final String TEXTURE_GUI_PATH = "textures/gui/";
public static final String TEXTURE_GUI_VANILLA = Constants.TEXTURE_GUI_PATH + "gui_vanilla.png";
public static final String TEXTURE_RECIPE_BACKGROUND_PATH = Constants.TEXTURE_GUI_PATH + "recipe_background.png";
public static final String TEXTURE_RECIPE_BACKGROUND_TALL_PATH = Constants.TEXTURE_GUI_PATH + "recipe_background_tall.png";

public static final ResourceLocation RECIPE_GUI_VANILLA = new ResourceLocation(RESOURCE_DOMAIN, TEXTURE_GUI_VANILLA);
public static final ResourceLocation RECIPE_BACKGROUND = new ResourceLocation(RESOURCE_DOMAIN, TEXTURE_RECIPE_BACKGROUND_PATH);
public static final ResourceLocation RECIPE_BACKGROUND_TALL = new ResourceLocation(RESOURCE_DOMAIN, TEXTURE_RECIPE_BACKGROUND_TALL_PATH);

public static final int MAX_TOOLTIP_WIDTH = 125;

public static final String RECIPE_TRANSFER_TOOLTIP = Translator.translateToLocal("jei.tooltip.transfer");
Expand Down
32 changes: 9 additions & 23 deletions src/main/java/mezz/jei/gui/GuiHelper.java
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.util.ResourceLocation;

public class GuiHelper implements IGuiHelper {

private final IDrawableStatic slotDrawable;
private final IDrawableStatic tabSelected;
private final IDrawableStatic tabUnselected;
Expand All @@ -22,25 +23,18 @@ public class GuiHelper implements IGuiHelper {
private final IDrawableStatic arrowNext;
private final IDrawableStatic plusSign;

private final ResourceLocation recipeBackgroundResource;
private final ResourceLocation recipeBackgroundTallResource;

public GuiHelper() {
ResourceLocation location = new ResourceLocation("minecraft", "textures/gui/container/furnace.png");
this.slotDrawable = createDrawable(location, 55, 16, 18, 18);
slotDrawable = createDrawable(Constants.RECIPE_BACKGROUND, 196, 93, 18, 18);

recipeBackgroundResource = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH);
recipeBackgroundTallResource = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_TALL_PATH);
tabSelected = createDrawable(Constants.RECIPE_BACKGROUND, 196, 15, 24, 24);
tabUnselected = createDrawable(Constants.RECIPE_BACKGROUND, 220, 15, 24, 22);

tabSelected = createDrawable(recipeBackgroundResource, 196, 15, 24, 24);
tabUnselected = createDrawable(recipeBackgroundResource, 220, 15, 24, 22);
shapelessIcon = createDrawable(Constants.RECIPE_BACKGROUND, 196, 0, 16, 15);
infoIcon = createDrawable(Constants.RECIPE_BACKGROUND, 212, 39, 16, 16);

shapelessIcon = createDrawable(recipeBackgroundResource, 196, 0, 16, 15);
infoIcon = createDrawable(recipeBackgroundResource, 212, 39, 16, 16);

arrowPrevious = createDrawable(recipeBackgroundResource, 196, 55, 5, 8, 1, 0, 0, 0);
arrowNext = createDrawable(recipeBackgroundResource, 204, 55, 5, 8, 1, 0, 1, 0);
plusSign = createDrawable(recipeBackgroundResource, 212, 55, 6, 6, 1, 0, 1, 0);
arrowPrevious = createDrawable(Constants.RECIPE_BACKGROUND, 196, 55, 5, 8, 1, 0, 0, 0);
arrowNext = createDrawable(Constants.RECIPE_BACKGROUND, 204, 55, 5, 8, 1, 0, 1, 0);
plusSign = createDrawable(Constants.RECIPE_BACKGROUND, 212, 55, 6, 6, 1, 0, 1, 0);
}

@Override
Expand Down Expand Up @@ -128,14 +122,6 @@ public IDrawableStatic getInfoIcon() {
return infoIcon;
}

public ResourceLocation getRecipeBackgroundResource() {
return recipeBackgroundResource;
}

public ResourceLocation getRecipeBackgroundTallResource() {
return recipeBackgroundTallResource;
}

public IDrawableStatic getArrowPrevious() {
return arrowPrevious;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/mezz/jei/gui/elements/GuiIconButtonSmall.java
Expand Up @@ -12,7 +12,6 @@
* A small gui button that has an {@link IDrawable} instead of a string label.
*/
public class GuiIconButtonSmall extends GuiButton {
private static final ResourceLocation BUTTON_RESOURCE = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH);
private final IDrawable icon;

public GuiIconButtonSmall(int buttonId, int x, int y, int widthIn, int heightIn, IDrawable icon) {
Expand All @@ -25,7 +24,7 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
if (this.visible) {
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int k = this.getHoverState(this.hovered);
GuiUtils.drawContinuousTexturedBox(BUTTON_RESOURCE, this.x, this.y, 0, 182 + k * 20, this.width, this.height, 95, 20, 2, 2, 2, 2, this.zLevel);
GuiUtils.drawContinuousTexturedBox(Constants.RECIPE_BACKGROUND, this.x, this.y, 0, 182 + k * 20, this.width, this.height, 95, 20, 2, 2, 2, 2, this.zLevel);
this.mouseDragged(mc, mouseX, mouseY);

int color = 14737632;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/gui/overlay/ConfigButton.java
Expand Up @@ -30,7 +30,7 @@ public class ConfigButton {
public ConfigButton(IngredientListOverlay parent) {
this.parent = parent;
this.configButton = new GuiButton(2, 0, 0, 0, 0, "");
ResourceLocation configButtonIconLocation = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH);
ResourceLocation configButtonIconLocation = Constants.RECIPE_BACKGROUND;
GuiHelper guiHelper = Internal.getHelpers().getGuiHelper();
this.configButtonIcon = guiHelper.createDrawable(configButtonIconLocation, 0, 166, 16, 16);
this.configButtonCheatIcon = guiHelper.createDrawable(configButtonIconLocation, 16, 166, 16, 16);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/gui/recipes/RecipeCatalysts.java
Expand Up @@ -37,7 +37,7 @@ public class RecipeCatalysts implements IShowsRecipeFocuses {
public RecipeCatalysts() {
ingredients = new ArrayList<>();

ResourceLocation recipeBackgroundResource = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH);
ResourceLocation recipeBackgroundResource = Constants.RECIPE_BACKGROUND;

IGuiHelper guiHelper = Internal.getHelpers().getGuiHelper();
topDrawable = guiHelper.createDrawable(recipeBackgroundResource, 196, 65, 26, 6);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/mezz/jei/gui/recipes/RecipesGui.java
Expand Up @@ -13,6 +13,7 @@
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.config.Constants;
import mezz.jei.config.KeyBindings;
import mezz.jei.gui.Focus;
import mezz.jei.gui.GuiHelper;
Expand Down Expand Up @@ -56,7 +57,7 @@ public class RecipesGui extends GuiScreen implements IRecipesGui, IShowsRecipeFo

private String pageString = "1/1";
private String title = "";
private ResourceLocation backgroundTexture = Internal.getHelpers().getGuiHelper().getRecipeBackgroundResource();
private ResourceLocation backgroundTexture = Constants.RECIPE_BACKGROUND;

private final RecipeCatalysts recipeCatalysts;
private final RecipeGuiTabs recipeGuiTabs;
Expand Down Expand Up @@ -125,13 +126,12 @@ public void initGui() {

this.xSize = 196;

GuiHelper guiHelper = Internal.getHelpers().getGuiHelper();
if (this.height > 300) {
this.ySize = 256;
this.backgroundTexture = guiHelper.getRecipeBackgroundTallResource();
this.backgroundTexture = Constants.RECIPE_BACKGROUND_TALL;
} else {
this.ySize = 166;
this.backgroundTexture = guiHelper.getRecipeBackgroundResource();
this.backgroundTexture = Constants.RECIPE_BACKGROUND;
}

this.guiLeft = (width - this.xSize) / 2;
Expand Down
Expand Up @@ -37,7 +37,7 @@ public DebugRecipeCategory(IGuiHelper guiHelper) {
this.background = guiHelper.createBlankDrawable(RECIPE_WIDTH, RECIPE_HEIGHT);
this.localizedName = "debug";

ResourceLocation backgroundTexture = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH);
ResourceLocation backgroundTexture = Constants.RECIPE_BACKGROUND;
this.tankBackground = guiHelper.createDrawable(backgroundTexture, 220, 196, 18, 60, -1, -1, -1, -1);
this.tankOverlay = guiHelper.createDrawable(backgroundTexture, 238, 196, 18, 60, -1, -1, -1, -1);
}
Expand Down
Expand Up @@ -23,7 +23,7 @@ public class IngredientInfoRecipeCategory implements IRecipeCategory<IngredientI

public IngredientInfoRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createBlankDrawable(recipeWidth, recipeHeight);
ResourceLocation recipeBackgroundResource = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH);
ResourceLocation recipeBackgroundResource = Constants.RECIPE_BACKGROUND;
icon = guiHelper.createDrawable(recipeBackgroundResource, 196, 39, 16, 16);
slotBackground = guiHelper.getSlotDrawable();
localizedName = Translator.translateToLocal("gui.jei.category.itemInformation");
Expand Down
Expand Up @@ -16,8 +16,7 @@ public class AnvilRecipeCategory implements IRecipeCategory<AnvilRecipeWrapper>
private final IDrawable background;

public AnvilRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation backgroundLocation = new ResourceLocation("textures/gui/container/anvil.png");
background = guiHelper.createDrawable(backgroundLocation, 16, 40, 145, 37);
background = guiHelper.createDrawable(Constants.RECIPE_GUI_VANILLA, 0, 168, 125, 18, 0, 20, 0, 0);
}

@Override
Expand All @@ -44,9 +43,9 @@ public IDrawable getBackground() {
public void setRecipe(IRecipeLayout recipeLayout, AnvilRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();

guiItemStacks.init(0, true, 10, 6);
guiItemStacks.init(1, true, 59, 6);
guiItemStacks.init(2, false, 117, 6);
guiItemStacks.init(0, true, 10-10, 0);
guiItemStacks.init(1, true, 59-10, 0);
guiItemStacks.init(2, false, 117-10, 0);

guiItemStacks.set(ingredients);

Expand Down
Expand Up @@ -30,17 +30,17 @@ public class BrewingRecipeCategory implements IRecipeCategory<BrewingRecipeWrapp
private final IDrawableStatic blazeHeat;

public BrewingRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation location = new ResourceLocation("minecraft", "textures/gui/container/brewing_stand.png");
background = guiHelper.createDrawable(location, 55, 15, 64, 60, 0, 0, 0, 40);
ResourceLocation location = Constants.RECIPE_GUI_VANILLA;
background = guiHelper.createDrawable(location, 0, 0, 64, 60, 0, 0, 0, 40);
localizedName = Translator.translateToLocal("gui.jei.category.brewing");

IDrawableStatic brewArrowDrawable = guiHelper.createDrawable(location, 176, 0, 9, 28);
IDrawableStatic brewArrowDrawable = guiHelper.createDrawable(location, 64, 0, 9, 28);
arrow = guiHelper.createAnimatedDrawable(brewArrowDrawable, 400, IDrawableAnimated.StartDirection.TOP, false);

IDrawableStatic brewBubblesDrawable = guiHelper.createDrawable(location, 185, 1, 12, 28);
IDrawableStatic brewBubblesDrawable = guiHelper.createDrawable(location, 73, 1, 12, 28);
bubbles = guiHelper.createAnimatedDrawable(brewBubblesDrawable, 20, IDrawableAnimated.StartDirection.BOTTOM, false);

blazeHeat = guiHelper.createDrawable(location, 176, 29, 18, 4);
blazeHeat = guiHelper.createDrawable(location, 64, 29, 18, 4);

slotDrawable = guiHelper.getSlotDrawable();
}
Expand Down
Expand Up @@ -31,8 +31,8 @@ public class CraftingRecipeCategory implements IRecipeCategory<IRecipeWrapper> {
private final ICraftingGridHelper craftingGridHelper;

public CraftingRecipeCategory(IGuiHelper guiHelper) {
ResourceLocation location = new ResourceLocation("minecraft", "textures/gui/container/crafting_table.png");
background = guiHelper.createDrawable(location, 29, 16, width, height);
ResourceLocation location = Constants.RECIPE_GUI_VANILLA;
background = guiHelper.createDrawable(location, 0, 60, width, height);
localizedName = Translator.translateToLocal("gui.jei.category.craftingTable");
craftingGridHelper = guiHelper.createCraftingGridHelper(craftInputSlot1, craftOutputSlot);
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.config.Constants;
import mezz.jei.util.Translator;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
Expand All @@ -38,8 +39,7 @@ public FuelRecipe(IGuiHelper guiHelper, Collection<ItemStack> input, int burnTim

this.burnTimeString = Translator.translateToLocalFormatted("gui.jei.category.fuel.burnTime", burnTime);

ResourceLocation furnaceBackgroundLocation = new ResourceLocation("minecraft", "textures/gui/container/furnace.png");
IDrawableStatic flameDrawable = guiHelper.createDrawable(furnaceBackgroundLocation, 176, 0, 14, 14);
IDrawableStatic flameDrawable = guiHelper.createDrawable(Constants.RECIPE_GUI_VANILLA, 176, 114, 14, 14);
this.flame = guiHelper.createAnimatedDrawable(flameDrawable, burnTime, IDrawableAnimated.StartDirection.TOP, true);
}

Expand Down
Expand Up @@ -4,25 +4,24 @@

import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.config.Constants;
import mezz.jei.util.Translator;
import net.minecraft.util.ResourceLocation;

public class FurnaceFuelCategory extends FurnaceRecipeCategory<FuelRecipe> {
private final IDrawable background;
private final IDrawable flame;
private final IDrawableStatic background;
private final IDrawableStatic flameTransparentBackground;
private final String localizedName;

public FurnaceFuelCategory(IGuiHelper guiHelper) {
super(guiHelper);
background = guiHelper.createDrawable(backgroundLocation, 55, 38, 18, 32, 0, 0, 0, 80);
background = guiHelper.createDrawable(Constants.RECIPE_GUI_VANILLA, 0, 135, 18, 33, 0, 0, 0, 80);

ResourceLocation recipeBackgroundResource = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH);
flame = guiHelper.createDrawable(recipeBackgroundResource, 215, 0, 14, 14);
flameTransparentBackground = guiHelper.createDrawable(Constants.RECIPE_BACKGROUND, 215, 0, 14, 14);
localizedName = Translator.translateToLocal("gui.jei.category.fuel");
}

Expand All @@ -49,14 +48,14 @@ public String getModName() {
@Nullable
@Override
public IDrawable getIcon() {
return flame;
return flameTransparentBackground;
}

@Override
public void setRecipe(IRecipeLayout recipeLayout, FuelRecipe recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();

guiItemStacks.init(fuelSlot, true, 0, 14);
guiItemStacks.init(fuelSlot, true, 0, 15);
guiItemStacks.set(ingredients);
}
}
Expand Up @@ -5,24 +5,22 @@
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.util.ResourceLocation;
import mezz.jei.config.Constants;

public abstract class FurnaceRecipeCategory<T extends IRecipeWrapper> implements IRecipeCategory<T> {
protected static final int inputSlot = 0;
protected static final int fuelSlot = 1;
protected static final int outputSlot = 2;

protected final ResourceLocation backgroundLocation;
protected final IDrawableAnimated flame;
protected final IDrawableStatic staticFlame;
protected final IDrawableAnimated animatedFlame;
protected final IDrawableAnimated arrow;

public FurnaceRecipeCategory(IGuiHelper guiHelper) {
backgroundLocation = new ResourceLocation("minecraft", "textures/gui/container/furnace.png");
staticFlame = guiHelper.createDrawable(Constants.RECIPE_GUI_VANILLA, 82, 114, 14, 14);
animatedFlame = guiHelper.createAnimatedDrawable(staticFlame, 300, IDrawableAnimated.StartDirection.TOP, true);

IDrawableStatic flameDrawable = guiHelper.createDrawable(backgroundLocation, 176, 0, 14, 14);
flame = guiHelper.createAnimatedDrawable(flameDrawable, 300, IDrawableAnimated.StartDirection.TOP, true);

IDrawableStatic arrowDrawable = guiHelper.createDrawable(backgroundLocation, 176, 14, 24, 17);
IDrawableStatic arrowDrawable = guiHelper.createDrawable(Constants.RECIPE_GUI_VANILLA, 176, 128, 24, 17);
this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.LEFT, false);
}
}
Expand Up @@ -9,16 +9,14 @@
import mezz.jei.config.Constants;
import mezz.jei.util.Translator;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;

public class FurnaceSmeltingCategory extends FurnaceRecipeCategory<SmeltingRecipe> {
private final IDrawable background;
private final String localizedName;

public FurnaceSmeltingCategory(IGuiHelper guiHelper) {
super(guiHelper);
ResourceLocation location = new ResourceLocation("minecraft", "textures/gui/container/furnace.png");
background = guiHelper.createDrawable(location, 55, 16, 82, 54);
background = guiHelper.createDrawable(Constants.RECIPE_GUI_VANILLA, 0, 114, 82, 54);
localizedName = Translator.translateToLocal("gui.jei.category.smelting");
}

Expand All @@ -29,7 +27,7 @@ public IDrawable getBackground() {

@Override
public void drawExtras(Minecraft minecraft) {
flame.draw(minecraft, 2, 20);
animatedFlame.draw(minecraft, 2, 20);
arrow.draw(minecraft, 24, 18);
}

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/jei/textures/gui/recipe_background.png
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 2a4778a

Please sign in to comment.