diff --git a/src/main/java/me/justahuman/slimefun_essentials/api/ManualRecipeRenderer.java b/src/main/java/me/justahuman/slimefun_essentials/api/ManualRecipeRenderer.java index cfd42c6..98f0e28 100644 --- a/src/main/java/me/justahuman/slimefun_essentials/api/ManualRecipeRenderer.java +++ b/src/main/java/me/justahuman/slimefun_essentials/api/ManualRecipeRenderer.java @@ -7,6 +7,19 @@ import net.minecraft.text.Text; public interface ManualRecipeRenderer extends RecipeRenderer { + default SlimefunLabel.DrawMode getDrawMode() { + return SlimefunLabel.DrawMode.LIGHT; + } + + default void addLabels(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { + if (recipe.hasLabels()) { + for (SlimefunLabel slimefunLabel : recipe.labels()) { + slimefunLabel.draw(graphics, offsets.getX(), offsets.label()); + offsets.x().addLabel(); + } + } + } + default void addEnergyWithCheck(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { if (recipe.hasEnergy() && recipe.hasOutputs()) { addEnergy(graphics, offsets, recipe.energy() < 0); @@ -19,7 +32,7 @@ default void addEnergy(DrawContext graphics, OffsetBuilder offsets, boolean nega } default void addEnergy(DrawContext graphics, int x, int y, boolean negative) { - TextureUtils.ENERGY.draw(graphics, x, y); + TextureUtils.ENERGY.draw(graphics, x, y, getDrawMode()); drawEnergyFill(graphics, x, y, negative); } @@ -39,7 +52,7 @@ default void addArrow(DrawContext graphics, SlimefunRecipe recipe, int x, int y, } default void addArrow(DrawContext graphics, int x, int y, boolean backwards) { - (backwards ? TextureUtils.BACKWARDS_ARROW : TextureUtils.ARROW).draw(graphics, x, y); + (backwards ? TextureUtils.BACKWARDS_ARROW : TextureUtils.ARROW).draw(graphics, x, y, getDrawMode()); } default void addFillingArrow(DrawContext graphics, int x, int y, int sfTicks, boolean backwards) { @@ -49,6 +62,24 @@ default void addFillingArrow(DrawContext graphics, int x, int y, int sfTicks, bo void drawArrowFill(DrawContext graphics, int x, int y, int sfTicks, boolean backwards); + default void addInputsOrCatalyst(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { + if (recipe.hasInputs()) { + addInputs(graphics, offsets, recipe); + } else { + addCatalyst(graphics, offsets, recipe); + } + } + + default void addInputs(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { + for (int i = 0; i < recipe.inputs().size(); i++) { + addSlot(graphics, offsets, false); + } + } + + default void addCatalyst(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { + addSlot(graphics, offsets, false); + } + default void addOutputsOrEnergy(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { if (recipe.hasOutputs()) { addOutputs(graphics, offsets, recipe); @@ -59,11 +90,19 @@ default void addOutputsOrEnergy(DrawContext graphics, OffsetBuilder offsets, Sli default void addOutputs(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { for (int i = 0; i < recipe.outputs().size(); i++) { - TextureUtils.OUTPUT.draw(graphics, offsets.getX(), offsets.output()); - offsets.x().addOutput(); + addSlot(graphics, offsets, true); } } + default void addSlot(DrawContext graphics, OffsetBuilder offsets, boolean output) { + addSlot(graphics, offsets.getX(), output ? offsets.output() : offsets.slot(), output); + offsets.x().add((output ? TextureUtils.OUTPUT_SIZE : TextureUtils.SLOT_SIZE) + TextureUtils.PADDING); + } + + default void addSlot(DrawContext graphics, int x, int y, boolean output) { + (output ? TextureUtils.OUTPUT : TextureUtils.SLOT).draw(graphics, x, y, getDrawMode()); + } + default boolean tooltipActive(double mouseX, double mouseY, OffsetBuilder offsets, SlimefunLabel label) { return tooltipActive(mouseX, mouseY, offsets.getX(), offsets.getY(), label); } diff --git a/src/main/java/me/justahuman/slimefun_essentials/client/SlimefunLabel.java b/src/main/java/me/justahuman/slimefun_essentials/client/SlimefunLabel.java index 4218b03..4e39131 100644 --- a/src/main/java/me/justahuman/slimefun_essentials/client/SlimefunLabel.java +++ b/src/main/java/me/justahuman/slimefun_essentials/client/SlimefunLabel.java @@ -13,11 +13,15 @@ import java.util.LinkedHashMap; import java.util.Map; -public record SlimefunLabel(String id, Identifier light, Identifier dark, int u, int v, int width, int height) { +public record SlimefunLabel(String id, Identifier light, Identifier dark, Identifier book, int u, int v, int width, int height) { private static final Map slimefunLabels = new LinkedHashMap<>(); - public SlimefunLabel(String id, Identifier light, Identifier dark, int u, int v) { - this(id, light, dark, u, v, TextureUtils.LABEL_SIZE, TextureUtils.LABEL_SIZE); + public SlimefunLabel(String id, int u, int v, int width, int height) { + this(id, TextureUtils.WIDGETS, TextureUtils.WIDGETS_DARK, TextureUtils.WIDGETS_BOOK, u, v, width, height); + } + + public SlimefunLabel(String id, Identifier light, Identifier dark, Identifier book, int u, int v) { + this(id, light, dark, book, u, v, TextureUtils.LABEL_SIZE, TextureUtils.LABEL_SIZE); } public static void deserialize(String id, JsonObject labelObject) { @@ -25,6 +29,7 @@ public static void deserialize(String id, JsonObject labelObject) { id, new Identifier(JsonUtils.getStringOrDefault(labelObject, "light", "slimefun_essentials:textures/gui/widgets.png")), new Identifier(JsonUtils.getStringOrDefault(labelObject, "dark", "slimefun_essentials:textures/gui/widgets_dark.png")), + new Identifier(JsonUtils.getStringOrDefault(labelObject, "dark", "slimefun_essentials:textures/gui/widgets_book.png")), JsonUtils.getIntegerOrDefault(labelObject, "u", 0), JsonUtils.getIntegerOrDefault(labelObject, "v", 0) )); @@ -44,20 +49,31 @@ public static void clear() { slimefunLabels.clear(); } - public void draw(DrawContext graphics, int x, int y, int width, int height, int u, int v, int regionWidth, int regionHeight, boolean dark) { + public void draw(DrawContext graphics, int x, int y, int width, int height, int u, int v, int regionWidth, int regionHeight, DrawMode drawMode) { RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); - graphics.drawTexture(dark ? this.dark : this.light, x, y, width, height, u, v, regionWidth, regionHeight, 256, 256); + graphics.drawTexture(drawMode.get(this), x, y, width, height, u, v, regionWidth, regionHeight, 256, 256); } - public void draw(DrawContext graphics, int x, int y, boolean dark) { - draw(graphics, x, y, this.width, this.height, this.u, this.v, this.width, this.height, dark); + public void draw(DrawContext graphics, int x, int y, DrawMode drawMode) { + draw(graphics, x, y, this.width, this.height, this.u, this.v, this.width, this.height, drawMode); } public void draw(DrawContext graphics, int x, int y) { - draw(graphics, x, y, false); + draw(graphics, x, y, DrawMode.LIGHT); } public Text text() { return Text.translatable("slimefun_essentials.recipes.label." + this.id); } + + public enum DrawMode { + LIGHT, DARK, BOOK; + public Identifier get(SlimefunLabel slimefunLabel) { + return switch (this) { + case LIGHT -> slimefunLabel.light(); + case DARK -> slimefunLabel.dark(); + case BOOK -> slimefunLabel.book(); + }; + } + } } diff --git a/src/main/java/me/justahuman/slimefun_essentials/compat/jei/categories/ProcessCategory.java b/src/main/java/me/justahuman/slimefun_essentials/compat/jei/categories/ProcessCategory.java index 3a18525..7c14ff7 100644 --- a/src/main/java/me/justahuman/slimefun_essentials/compat/jei/categories/ProcessCategory.java +++ b/src/main/java/me/justahuman/slimefun_essentials/compat/jei/categories/ProcessCategory.java @@ -147,33 +147,10 @@ public void setRecipe(IRecipeLayoutBuilder builder, SlimefunRecipe recipe, IFocu @Override public void draw(SlimefunRecipe recipe, IRecipeSlotsView recipeSlotsView, DrawContext graphics, double mouseX, double mouseY) { final OffsetBuilder offsets = new OffsetBuilder(this, recipe, calculateXOffset(this.slimefunRecipeCategory, recipe)); - - // Display Labels - if (recipe.hasLabels()) { - for (SlimefunLabel slimefunLabel : recipe.labels()) { - slimefunLabel.draw(graphics, offsets.getX(), offsets.label()); - offsets.x().addLabel(); - } - } - - // Display Energy + addLabels(graphics, offsets, recipe); addEnergyWithCheck(graphics, offsets, recipe); - - // Display Inputs, only the slot icon - if (recipe.hasInputs()) { - for (int i = 0; i < recipe.inputs().size(); i++) { - TextureUtils.SLOT.draw(graphics, offsets.getX(), offsets.slot()); - offsets.x().addSlot(); - } - } else { - TextureUtils.SLOT.draw(graphics, offsets.getX(), offsets.slot()); - offsets.x().addSlot(); - } - - // Display Arrow + addInputsOrCatalyst(graphics, offsets, recipe); addArrow(graphics, offsets, recipe); - - // Display Outputs addOutputsOrEnergy(graphics, offsets, recipe); } diff --git a/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/PatchouliIntegration.java b/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/PatchouliIntegration.java index a4eb5c3..c7019cd 100644 --- a/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/PatchouliIntegration.java +++ b/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/PatchouliIntegration.java @@ -21,6 +21,8 @@ import vazkii.patchouli.client.book.BookCategory; import vazkii.patchouli.client.book.ClientBookRegistry; +import java.util.List; + public class PatchouliIntegration { public static final Identifier BOOK_IDENTIFIER = Utils.newIdentifier("slimefun"); public static final PatchouliIdInterpreter INTERPRETER = new PatchouliIdInterpreter(); @@ -64,18 +66,22 @@ public static JsonObject getRecipeEntry(BookCategory category, SlimefunRecipeCat entry.addProperty("sortnum", sortnum); final JsonArray pages = new JsonArray(); - for (SlimefunRecipe recipe : recipeCategory.recipesFor()) { - pages.add(getPage(recipe)); + List recipesFor = recipeCategory.recipesFor(); + for (int i = 0; i < recipesFor.size(); i++) { + SlimefunRecipe recipe = recipesFor.get(i); + pages.add(getPage(recipeCategory, recipe, i)); } entry.add("pages", pages); return entry; } - public static JsonObject getPage(SlimefunRecipe recipe) { + public static JsonObject getPage(SlimefunRecipeCategory category, SlimefunRecipe recipe, int recipeIndex) { final String type = recipe.parent().type(); final JsonObject page = new JsonObject(); - page.addProperty("id", recipe.parent().id()); + + page.addProperty("id", category.id()); + page.addProperty("recipe_index", recipeIndex); if (type.contains("grid")) { page.addProperty("type", "slimefun_essentials:grid_recipe"); @@ -84,38 +90,6 @@ public static JsonObject getPage(SlimefunRecipe recipe) { page.addProperty("type", "slimefun_essentials:" + type); } - if (recipe.hasTime()) { - page.addProperty("sfTicks", recipe.sfTicks()); - } - - if (recipe.hasEnergy()) { - page.addProperty("energy", recipe.energy()); - } - - if (recipe.hasLabels()) { - final JsonArray labels = new JsonArray(); - for (SlimefunLabel label : recipe.labels()) { - labels.add(label.id()); - } - page.add("labels", labels); - } - - if (recipe.hasInputs()) { - final JsonArray inputs = new JsonArray(); - for (SlimefunRecipeComponent input : recipe.inputs()) { - inputs.add(input.serialize()); - } - page.add("inputs", inputs); - } - - if (recipe.hasOutputs()) { - final JsonArray outputs = new JsonArray(); - for (SlimefunRecipeComponent output : recipe.outputs()) { - outputs.add(output.serialize()); - } - page.add("outputs", outputs); - } - return page; } diff --git a/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/PatchouliWidget.java b/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/PatchouliWidget.java index 50d90b5..4282754 100644 --- a/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/PatchouliWidget.java +++ b/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/PatchouliWidget.java @@ -1,6 +1,5 @@ package me.justahuman.slimefun_essentials.compat.patchouli; -import me.justahuman.slimefun_essentials.api.OffsetBuilder; import net.minecraft.client.gui.DrawContext; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; @@ -12,20 +11,20 @@ @FunctionalInterface public interface PatchouliWidget { - PatchouliWidget EMPTY = (o1, o2, o3, o4, o5, o6) -> {}; + PatchouliWidget EMPTY = (o1, o2, o3, o4, o5, o6, o7) -> {}; - void render(GuiBookEntry gui, DrawContext graphics, OffsetBuilder offsets, int mouseX, int mouseY, float pTicks); + void render(GuiBookEntry gui, DrawContext graphics, int x, int y, int mouseX, int mouseY, float pTicks); static PatchouliWidget wrap(List widgets) { - return (gui, graphics, offsets, mouseX, mouseY, pTicks) -> { + return (gui, graphics, x, y, mouseX, mouseY, pTicks) -> { // Picks widgets on an interval of 10 ticks or half a second int index = (int) (pTicks / (widgets.size() * 10)) % widgets.size(); - widgets.get(index).render(gui, graphics, offsets, mouseX, mouseY, pTicks); + widgets.get(index).render(gui, graphics, x, y, mouseX, mouseY, pTicks); }; } static PatchouliWidget wrap(ItemStack itemStack) { - return (gui, graphics, offsets, mouseX, mouseY, pTicks) -> gui.renderItemStack(graphics, offsets.getX(), offsets.getY(), mouseX, mouseY, itemStack); + return (gui, graphics, x, y, mouseX, mouseY, pTicks) -> gui.renderItemStack(graphics, x, y, mouseX, mouseY, itemStack); } static PatchouliWidget wrap(Entity entity, int amount) { @@ -35,9 +34,9 @@ static PatchouliWidget wrap(Entity entity, int amount) { float renderScale = 100F / entitySize * 0.8F; float offset = Math.max(height, entitySize) * 0.5F; - return (gui, graphics, offsets, mouseX, mouseY, pTicks) -> { + return (gui, graphics, x, y, mouseX, mouseY, pTicks) -> { // TODO: render xAmount, render slot - PageEntity.renderEntity(graphics, entity, offsets.getX(), offsets.getY(), ClientTicker.total, renderScale, offset); + PageEntity.renderEntity(graphics, entity, x, y, ClientTicker.total, renderScale, offset); }; } } diff --git a/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/pages/ProcessPage.java b/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/pages/ProcessPage.java index 9b79272..6ddab3b 100644 --- a/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/pages/ProcessPage.java +++ b/src/main/java/me/justahuman/slimefun_essentials/compat/patchouli/pages/ProcessPage.java @@ -1,17 +1,12 @@ package me.justahuman.slimefun_essentials.compat.patchouli.pages; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; import me.justahuman.slimefun_essentials.api.ManualRecipeRenderer; import me.justahuman.slimefun_essentials.api.OffsetBuilder; import me.justahuman.slimefun_essentials.client.SlimefunLabel; import me.justahuman.slimefun_essentials.client.SlimefunRecipe; import me.justahuman.slimefun_essentials.client.SlimefunRecipeCategory; -import me.justahuman.slimefun_essentials.client.SlimefunRecipeComponent; import me.justahuman.slimefun_essentials.compat.patchouli.PatchouliIntegration; import me.justahuman.slimefun_essentials.compat.patchouli.PatchouliWidget; -import me.justahuman.slimefun_essentials.utils.TextureUtils; import net.minecraft.client.gui.DrawContext; import net.minecraft.world.World; import vazkii.patchouli.client.book.BookContentsBuilder; @@ -22,104 +17,37 @@ import java.util.List; public class ProcessPage extends BookPage implements ManualRecipeRenderer { + transient SlimefunRecipeCategory recipeCategory; transient SlimefunRecipe recipe; transient List inputWidgets = new ArrayList<>(); transient List outputWidgets = new ArrayList<>(); + transient int mouseX; + transient int mouseY; + transient float pTicks; @Override public void build(World level, BookEntry entry, BookContentsBuilder builder, int pageNum) { String id = this.sourceObject.get("id").getAsString(); - Integer sfTicks = null; - final JsonElement ticksElement = this.sourceObject.get("sfTicks"); - if (ticksElement != null) { - sfTicks = ticksElement.getAsInt(); - } - - Integer energy = null; - final JsonElement energyElement = this.sourceObject.get("energy"); - if (energyElement != null) { - energy = energyElement.getAsInt(); - } - - final List labels = new ArrayList<>(); - final JsonElement labelsElement = this.sourceObject.get("labels"); - if (labelsElement instanceof JsonArray labelsArray) { - for (JsonElement label : labelsArray) { - if (label instanceof JsonPrimitive labelPrimitive && labelPrimitive.isString()) { - final SlimefunLabel slimefunLabel = SlimefunLabel.getSlimefunLabels().get(labelPrimitive.getAsString()); - if (slimefunLabel != null) { - labels.add(slimefunLabel); - } - } - } - } - - final List inputs = new ArrayList<>(); - final JsonElement inputsElement = this.sourceObject.get("inputs"); - if (inputsElement instanceof JsonArray inputsArray) { - for (JsonElement component : inputsArray) { - final SlimefunRecipeComponent recipeComponent = SlimefunRecipeComponent.deserialize(component); - if (recipeComponent != null) { - inputs.add(recipeComponent); - this.inputWidgets.add(PatchouliIntegration.INTERPRETER.fromRecipeComponent(recipeComponent)); - } - } - } + int recipeIndex = this.sourceObject.get("recipe_index").getAsInt(); - final List outputs = new ArrayList<>(); - final JsonElement outputsElement = this.sourceObject.get("outputs"); - if (outputsElement instanceof JsonArray outputsArray) { - for (JsonElement component : outputsArray) { - final SlimefunRecipeComponent recipeComponent = SlimefunRecipeComponent.deserialize(component); - if (recipeComponent != null) { - outputs.add(recipeComponent); - this.outputWidgets.add(PatchouliIntegration.INTERPRETER.fromRecipeComponent(recipeComponent)); - } - } - } - - this.recipe = new SlimefunRecipe( - SlimefunRecipeCategory.getRecipeCategories().get(id), - sfTicks, - energy, - inputs, - outputs, - labels); + this.recipeCategory = SlimefunRecipeCategory.getAllCategories().get(id); + this.recipe = this.recipeCategory.recipesFor().get(recipeIndex); + this.inputWidgets.addAll(this.recipe.inputs().stream().map(PatchouliIntegration.INTERPRETER::fromRecipeComponent).toList()); + this.outputWidgets.addAll(this.recipe.outputs().stream().map(PatchouliIntegration.INTERPRETER::fromRecipeComponent).toList()); } @Override public void render(DrawContext graphics, int mouseX, int mouseY, float pTicks) { - final OffsetBuilder offsets = new OffsetBuilder(this, this.recipe, calculateXOffset(this.recipe.parent(), this.recipe)); - - // Display Labels - if (this.recipe.hasLabels()) { - for (SlimefunLabel slimefunLabel : this.recipe.labels()) { - slimefunLabel.draw(graphics, offsets.getX(), offsets.label()); - offsets.x().addLabel(); - } - } - - // Display Energy - addEnergyWithCheck(graphics, offsets, this.recipe); - - // Display Inputs, only the slot icon - if (this.recipe.hasInputs()) { - for (int i = 0; i < this.recipe.inputs().size(); i++) { - this.inputWidgets.get(i).render(this.parent, graphics, offsets, mouseX, mouseY, pTicks); - TextureUtils.SLOT.draw(graphics, offsets.getX(), offsets.slot()); - offsets.x().addSlot(); - } - } else { - PatchouliWidget.wrap(this.recipe.parent().getItemFromId()).render(this.parent, graphics, offsets, mouseX, mouseY, pTicks); - TextureUtils.SLOT.draw(graphics, offsets.getX(), offsets.slot()); - offsets.x().addSlot(); - } - - // Display Arrow - addArrow(graphics, offsets, this.recipe); - - // Display Outputs - addOutputsOrEnergy(graphics, offsets, this.recipe); + this.mouseX = mouseX; + this.mouseY = mouseY; + this.pTicks = pTicks; + + final OffsetBuilder offsets = new OffsetBuilder(this, recipe, 0, 0); + addLabels(graphics, offsets, recipe); + addEnergyWithCheck(graphics, offsets, recipe); + addInputsOrCatalyst(graphics, offsets, recipe); + addArrow(graphics, offsets, recipe); + addOutputsOrEnergy(graphics, offsets, recipe); } @Override @@ -128,20 +56,37 @@ public Type getType() { } @Override - public void drawEnergyFill(DrawContext graphics, int x, int y, boolean negative) { - + public SlimefunLabel.DrawMode getDrawMode() { + return SlimefunLabel.DrawMode.BOOK; } @Override - public void drawArrowFill(DrawContext graphics, int x, int y, int sfTicks, boolean backwards) { + public void drawEnergyFill(DrawContext graphics, int x, int y, boolean negative) {} + + @Override + public void drawArrowFill(DrawContext graphics, int x, int y, int sfTicks, boolean backwards) {} + @Override + public void addInputs(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { + for (int i = 0; i < recipe.inputs().size(); i++) { + addSlot(graphics, offsets.getX(), offsets.output(), true); + this.inputWidgets.get(i).render(this.parent, graphics, offsets.getX() + 1, offsets.slot() + 1, this.mouseX, this.mouseY, this.pTicks); + offsets.x().addSlot(); + } + } + + @Override + public void addCatalyst(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { + addSlot(graphics, offsets.getX(), offsets.slot(), false); + PatchouliWidget.wrap(this.recipeCategory.getItemFromId()).render(this.parent, graphics, offsets.getX() + 1, offsets.slot() + 1, this.mouseX, this.mouseY, this.pTicks); + offsets.x().addSlot(); } @Override public void addOutputs(DrawContext graphics, OffsetBuilder offsets, SlimefunRecipe recipe) { for (int i = 0; i < recipe.outputs().size(); i++) { - this.outputWidgets.get(i).render(this.parent, graphics, offsets, 0, 0, 0); - TextureUtils.OUTPUT.draw(graphics, offsets.getX(), offsets.output()); + addSlot(graphics, offsets.getX(), offsets.output(), true); + this.outputWidgets.get(i).render(this.parent, graphics, offsets.getX() + 5, offsets.slot() + 5, this.mouseX, this.mouseY, this.pTicks); offsets.x().addOutput(); } } diff --git a/src/main/java/me/justahuman/slimefun_essentials/compat/rei/ReiIntegration.java b/src/main/java/me/justahuman/slimefun_essentials/compat/rei/ReiIntegration.java index 81b595d..45ee09d 100644 --- a/src/main/java/me/justahuman/slimefun_essentials/compat/rei/ReiIntegration.java +++ b/src/main/java/me/justahuman/slimefun_essentials/compat/rei/ReiIntegration.java @@ -134,7 +134,7 @@ public static SlimefunDisplay getDisplay(SlimefunRecipeCategory slimefunRecipeCa } public static Widget widgetFromSlimefunLabel(SlimefunLabel slimefunLabel, int x, int y) { - return Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> slimefunLabel.draw(graphics, x, y, REIRuntime.getInstance().isDarkThemeEnabled())); + return Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> slimefunLabel.draw(graphics, x, y, REIRuntime.getInstance().isDarkThemeEnabled() ? SlimefunLabel.DrawMode.DARK : SlimefunLabel.DrawMode.LIGHT)); } public static Widget toolTipForSlimefunLabel(SlimefunLabel slimefunLabel, int x, int y) { @@ -188,7 +188,7 @@ public static Widget widgetFromSlimefunLabel(SlimefunLabel slimefunLabel, int x, } } - slimefunLabel.draw(graphics, mx, my, mw, mh, mu, mv, mrw, mrh, REIRuntime.getInstance().isDarkThemeEnabled()); + slimefunLabel.draw(graphics, mx, my, mw, mh, mu, mv, mrw, mrh, REIRuntime.getInstance().isDarkThemeEnabled() ? SlimefunLabel.DrawMode.DARK : SlimefunLabel.DrawMode.LIGHT); }); } } diff --git a/src/main/java/me/justahuman/slimefun_essentials/utils/TextureUtils.java b/src/main/java/me/justahuman/slimefun_essentials/utils/TextureUtils.java index 3ba4a5b..017fce9 100644 --- a/src/main/java/me/justahuman/slimefun_essentials/utils/TextureUtils.java +++ b/src/main/java/me/justahuman/slimefun_essentials/utils/TextureUtils.java @@ -21,17 +21,18 @@ public class TextureUtils { public static final int LABEL_SIZE = 13; public static final Identifier WIDGETS = new Identifier(Utils.ID, "textures/gui/widgets.png"); public static final Identifier WIDGETS_DARK = new Identifier(Utils.ID, "textures/gui/widgets_dark.png"); - public static final SlimefunLabel ENERGY = new SlimefunLabel("energy", WIDGETS, WIDGETS_DARK, 36, 0, ENERGY_WIDTH, ENERGY_HEIGHT); - public static final SlimefunLabel ENERGY_POSITIVE = new SlimefunLabel("energy_positive", WIDGETS, WIDGETS_DARK, 43, 0, ENERGY_WIDTH, ENERGY_HEIGHT); - public static final SlimefunLabel ENERGY_NEGATIVE = new SlimefunLabel("energy_negative", WIDGETS, WIDGETS_DARK, 50, 0, ENERGY_WIDTH, ENERGY_HEIGHT); - public static final SlimefunLabel SLOT = new SlimefunLabel("slot", WIDGETS, WIDGETS_DARK, 0, 238, SLOT_SIZE, SLOT_SIZE); - public static final SlimefunLabel OUTPUT = new SlimefunLabel("output", WIDGETS, WIDGETS_DARK, 18, 230, OUTPUT_SIZE, OUTPUT_SIZE); - public static final SlimefunLabel ARROW = new SlimefunLabel("arrow", WIDGETS, WIDGETS_DARK, 44, 222, ARROW_WIDTH, ARROW_HEIGHT); - public static final SlimefunLabel FILLED_ARROW = new SlimefunLabel("filled_arrow", WIDGETS, WIDGETS_DARK, 44, 239, ARROW_WIDTH, ARROW_HEIGHT); - public static final SlimefunLabel BACKWARDS_ARROW = new SlimefunLabel("backwards_arrow", WIDGETS, WIDGETS_DARK, 67, 222, ARROW_WIDTH, ARROW_HEIGHT); - public static final SlimefunLabel FILLED_BACKWARDS_ARROW = new SlimefunLabel("filled_backwards_arrow", WIDGETS, WIDGETS_DARK, 67, 239, ARROW_WIDTH, ARROW_HEIGHT); - public static final SlimefunLabel PEDESTAL = new SlimefunLabel("pedestal", WIDGETS, WIDGETS_DARK, 0, 0, SLOT_SIZE, SLOT_SIZE); - public static final SlimefunLabel ALTAR = new SlimefunLabel("altar", WIDGETS, WIDGETS_DARK, 18, 0, SLOT_SIZE, SLOT_SIZE); + public static final Identifier WIDGETS_BOOK = new Identifier(Utils.ID, "textures/gui/widgets_book.png"); + public static final SlimefunLabel ENERGY = new SlimefunLabel("energy", 36, 0, ENERGY_WIDTH, ENERGY_HEIGHT); + public static final SlimefunLabel ENERGY_POSITIVE = new SlimefunLabel("energy_positive", 43, 0, ENERGY_WIDTH, ENERGY_HEIGHT); + public static final SlimefunLabel ENERGY_NEGATIVE = new SlimefunLabel("energy_negative", 50, 0, ENERGY_WIDTH, ENERGY_HEIGHT); + public static final SlimefunLabel SLOT = new SlimefunLabel("slot", 0, 238, SLOT_SIZE, SLOT_SIZE); + public static final SlimefunLabel OUTPUT = new SlimefunLabel("output", 18, 230, OUTPUT_SIZE, OUTPUT_SIZE); + public static final SlimefunLabel ARROW = new SlimefunLabel("arrow", 44, 222, ARROW_WIDTH, ARROW_HEIGHT); + public static final SlimefunLabel FILLED_ARROW = new SlimefunLabel("filled_arrow", 44, 239, ARROW_WIDTH, ARROW_HEIGHT); + public static final SlimefunLabel BACKWARDS_ARROW = new SlimefunLabel("backwards_arrow", 67, 222, ARROW_WIDTH, ARROW_HEIGHT); + public static final SlimefunLabel FILLED_BACKWARDS_ARROW = new SlimefunLabel("filled_backwards_arrow", 67, 239, ARROW_WIDTH, ARROW_HEIGHT); + public static final SlimefunLabel PEDESTAL = new SlimefunLabel("pedestal", 0, 0, SLOT_SIZE, SLOT_SIZE); + public static final SlimefunLabel ALTAR = new SlimefunLabel("altar", 18, 0, SLOT_SIZE, SLOT_SIZE); public static final Map CACHED_WIDTH = new HashMap<>(); public static final Map CACHED_HEIGHT = new HashMap<>(); public static final NumberFormat numberFormat = NumberFormat.getInstance(); diff --git a/src/main/resources/assets/slimefun_essentials/textures/gui/widgets_book.png b/src/main/resources/assets/slimefun_essentials/textures/gui/widgets_book.png new file mode 100644 index 0000000..71a3fef Binary files /dev/null and b/src/main/resources/assets/slimefun_essentials/textures/gui/widgets_book.png differ