aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/shedaniel/rei/api/ConfigObject.java2
-rw-r--r--src/main/java/me/shedaniel/rei/api/EntryStack.java19
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java31
-rw-r--r--src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java26
-rw-r--r--src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java6
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java19
-rw-r--r--src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java9
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java6
-rw-r--r--src/main/java/me/shedaniel/rei/impl/EmptyEntryStack.java5
-rw-r--r--src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java10
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java26
11 files changed, 97 insertions, 62 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java
index ab819e9bd..569e95de6 100644
--- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java
+++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java
@@ -127,6 +127,8 @@ public interface ConfigObject {
@Deprecated
abstract ConfigObjectImpl.General getGeneral();
+ boolean isUsingCompactTabs();
+
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@interface AddInFrontKeyCode {}
diff --git a/src/main/java/me/shedaniel/rei/api/EntryStack.java b/src/main/java/me/shedaniel/rei/api/EntryStack.java
index 1fd04a1d9..65c0ccd2b 100644
--- a/src/main/java/me/shedaniel/rei/api/EntryStack.java
+++ b/src/main/java/me/shedaniel/rei/api/EntryStack.java
@@ -166,7 +166,12 @@ public interface EntryStack {
return setting(settings, value);
}
- <T> ObjectHolder<T> getSetting(Settings<T> settings);
+ @Deprecated
+ default <T> ObjectHolder<T> getSetting(Settings<T> settings) {
+ return ObjectHolder.of(get(settings));
+ }
+
+ <T> T get(Settings<T> settings);
@Nullable
QueuedTooltip getTooltip(int mouseX, int mouseY);
@@ -183,11 +188,11 @@ public interface EntryStack {
class Settings<T> {
public static final Supplier<Boolean> TRUE = () -> true;
public static final Supplier<Boolean> FALSE = () -> false;
- public static final Settings<Supplier<Boolean>> RENDER = new Settings(TRUE);
- public static final Settings<Supplier<Boolean>> CHECK_TAGS = new Settings(FALSE);
- public static final Settings<Supplier<Boolean>> TOOLTIP_ENABLED = new Settings(TRUE);
- public static final Settings<Supplier<Boolean>> TOOLTIP_APPEND_MOD = new Settings(TRUE);
- public static final Settings<Supplier<Boolean>> RENDER_COUNTS = new Settings(TRUE);
+ public static final Settings<Supplier<Boolean>> RENDER = new Settings<>(TRUE);
+ public static final Settings<Supplier<Boolean>> CHECK_TAGS = new Settings<>(FALSE);
+ public static final Settings<Supplier<Boolean>> TOOLTIP_ENABLED = new Settings<>(TRUE);
+ public static final Settings<Supplier<Boolean>> TOOLTIP_APPEND_MOD = new Settings<>(TRUE);
+ public static final Settings<Supplier<Boolean>> RENDER_COUNTS = new Settings<>(TRUE);
public static final Settings<Function<EntryStack, List<String>>> TOOLTIP_APPEND_EXTRA = new Settings<Function<EntryStack, List<String>>>(stack -> Collections.emptyList());
public static final Settings<Function<EntryStack, String>> COUNTS = new Settings<Function<EntryStack, String>>(stack -> null);
@@ -202,7 +207,7 @@ public interface EntryStack {
}
public static class Item {
- public static final Settings<Supplier<Boolean>> RENDER_ENCHANTMENT_GLINT = new Settings(TRUE);
+ public static final Settings<Supplier<Boolean>> RENDER_ENCHANTMENT_GLINT = new Settings<>(TRUE);
@Deprecated public static final Settings<Supplier<Boolean>> RENDER_OVERLAY = RENDER_ENCHANTMENT_GLINT;
private Item() {
diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
index 73d744e56..7347c0694 100644
--- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java
@@ -33,7 +33,7 @@ import java.util.function.Supplier;
public class RecipeViewingScreen extends Screen {
public static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png");
- private static final int TABS_PER_PAGE = 5;
+ private int tabsPerPage = 5;
private final List<Widget> preWidgets;
private final List<Widget> widgets;
private final List<TabWidget> tabs;
@@ -128,6 +128,8 @@ public class RecipeViewingScreen extends Screen {
@Override
public void init() {
super.init();
+ boolean isCompactTabs = ConfigObject.getInstance().isUsingCompactTabs();
+ int tabSize = isCompactTabs ? 24 : 28;
this.children.clear();
this.tabs.clear();
this.preWidgets.clear();
@@ -137,16 +139,16 @@ public class RecipeViewingScreen extends Screen {
int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), display -> selectedCategory.getDisplayWidth(display), (Comparator<Integer>) Comparator.naturalOrder()).orElse(150);
this.guiWidth = maxWidthDisplay + 20;
this.guiHeight = MathHelper.floor(MathHelper.clamp((double) (selectedCategory.getDisplayHeight() + 4) * (getRecipesPerPage() + 1) + 36, 100, largestHeight));
+ this.tabsPerPage = Math.max(5, MathHelper.floor((guiWidth - 20d) / tabSize));
this.bounds = new Rectangle(width / 2 - guiWidth / 2, height / 2 - guiHeight / 2, guiWidth, guiHeight);
this.page = MathHelper.clamp(page, 0, getTotalPages(selectedCategory) - 1);
-
ButtonWidget w, w2;
this.widgets.add(w = new ButtonWidget(new Rectangle(bounds.x + 2, bounds.y - 16, 10, 10), I18n.translate("text.rei.left_arrow")) {
@Override
public void onPressed() {
categoryPages--;
if (categoryPages < 0)
- categoryPages = MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1;
+ categoryPages = MathHelper.ceil(categories.size() / (float) tabsPerPage) - 1;
RecipeViewingScreen.this.init();
}
});
@@ -154,12 +156,12 @@ public class RecipeViewingScreen extends Screen {
@Override
public void onPressed() {
categoryPages++;
- if (categoryPages > MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1)
+ if (categoryPages > MathHelper.ceil(categories.size() / (float) tabsPerPage) - 1)
categoryPages = 0;
RecipeViewingScreen.this.init();
}
});
- w.enabled = w2.enabled = categories.size() > TABS_PER_PAGE;
+ w.enabled = w2.enabled = categories.size() > tabsPerPage;
widgets.add(categoryBack = new ButtonWidget(new Rectangle(bounds.getX() + 5, bounds.getY() + 5, 12, 12), I18n.translate("text.rei.left_arrow")) {
@Override
public void onPressed() {
@@ -168,7 +170,7 @@ public class RecipeViewingScreen extends Screen {
if (currentCategoryIndex < 0)
currentCategoryIndex = categories.size() - 1;
selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(currentCategoryIndex);
- categoryPages = MathHelper.floor(currentCategoryIndex / (double) TABS_PER_PAGE);
+ categoryPages = MathHelper.floor(currentCategoryIndex / (double) tabsPerPage);
page = 0;
RecipeViewingScreen.this.init();
}
@@ -204,7 +206,7 @@ public class RecipeViewingScreen extends Screen {
if (currentCategoryIndex >= categories.size())
currentCategoryIndex = 0;
selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(currentCategoryIndex);
- categoryPages = MathHelper.floor(currentCategoryIndex / (double) TABS_PER_PAGE);
+ categoryPages = MathHelper.floor(currentCategoryIndex / (double) tabsPerPage);
page = 0;
RecipeViewingScreen.this.init();
}
@@ -265,18 +267,19 @@ public class RecipeViewingScreen extends Screen {
}
});
recipeBack.enabled = recipeNext.enabled = categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight();
- for (int i = 0; i < TABS_PER_PAGE; i++) {
- int j = i + categoryPages * TABS_PER_PAGE;
+ int tabV = isCompactTabs ? 166 : 192;
+ for (int i = 0; i < tabsPerPage; i++) {
+ int j = i + categoryPages * tabsPerPage;
if (categories.size() > j) {
TabWidget tab;
- tabs.add(tab = new TabWidget(i, new Rectangle(bounds.x + bounds.width / 2 - Math.min(categories.size() - categoryPages * TABS_PER_PAGE, TABS_PER_PAGE) * 14 + i * 28, bounds.y - 28, 28, 28)) {
+ tabs.add(tab = new TabWidget(i, tabSize, bounds.x + bounds.width / 2 - Math.min(categories.size() - categoryPages * tabsPerPage, tabsPerPage) * tabSize / 2, bounds.y, 0, tabV) {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
- if (getBounds().contains(mouseX, mouseY)) {
+ if (containsMouse(mouseX, mouseY)) {
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
- if (getId() + categoryPages * TABS_PER_PAGE == categories.indexOf(selectedCategory))
+ if (getId() + categoryPages * tabsPerPage == categories.indexOf(selectedCategory))
return false;
- selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(getId() + categoryPages * TABS_PER_PAGE);
+ selectedCategory = (RecipeCategory<RecipeDisplay>) categories.get(getId() + categoryPages * tabsPerPage);
page = 0;
RecipeViewingScreen.this.init();
return true;
@@ -284,7 +287,7 @@ public class RecipeViewingScreen extends Screen {
return false;
}
});
- tab.setRenderer(categories.get(j), categories.get(j).getLogo(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * TABS_PER_PAGE == categories.indexOf(selectedCategory));
+ tab.setRenderer(categories.get(j), categories.get(j).getLogo(), categories.get(j).getCategoryName(), tab.getId() + categoryPages * tabsPerPage == categories.indexOf(selectedCategory));
}
}
Optional<ButtonAreaSupplier> supplier = RecipeHelper.getInstance().getAutoCraftButtonArea(selectedCategory);
diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java
index c0b03a252..8dbbe8837 100644
--- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java
+++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java
@@ -41,7 +41,7 @@ import java.util.Optional;
public class VillagerRecipeViewingScreen extends Screen {
- private static final int TABS_PER_PAGE = 8;
+ private int tabsPerPage = 8;
private final Map<RecipeCategory<?>, List<RecipeDisplay>> categoryMap;
private final List<RecipeCategory<?>> categories;
private final List<Widget> widgets;
@@ -91,6 +91,8 @@ public class VillagerRecipeViewingScreen extends Screen {
@Override
protected void init() {
super.init();
+ boolean isCompactTabs = ConfigObject.getInstance().isUsingCompactTabs();
+ int tabSize = isCompactTabs ? 24 : 28;
this.draggingScrollBar = false;
this.children.clear();
this.widgets.clear();
@@ -103,6 +105,7 @@ public class VillagerRecipeViewingScreen extends Screen {
RecipeDisplay display = categoryMap.get(category).get(selectedRecipeIndex);
int guiWidth = MathHelper.clamp(category.getDisplayWidth(display) + 30, 0, largestWidth) + 100;
int guiHeight = MathHelper.clamp(category.getDisplayHeight() + 40, 166, largestHeight);
+ this.tabsPerPage = Math.max(5, MathHelper.floor((guiWidth - 20d) / tabSize));
this.bounds = new Rectangle(width / 2 - guiWidth / 2, height / 2 - guiHeight / 2, guiWidth, guiHeight);
List<List<EntryStack>> workingStations = RecipeHelper.getInstance().getWorkingStations(category.getIdentifier());
@@ -175,18 +178,19 @@ public class VillagerRecipeViewingScreen extends Screen {
});
index++;
}
- for (int i = 0; i < TABS_PER_PAGE; i++) {
- int j = i + tabsPage * TABS_PER_PAGE;
+ int tabV = isCompactTabs ? 166 : 192;
+ for (int i = 0; i < tabsPerPage; i++) {
+ int j = i + tabsPage * tabsPerPage;
if (categories.size() > j) {
TabWidget tab;
- tabs.add(tab = new TabWidget(i, new Rectangle(bounds.x + bounds.width / 2 - Math.min(categories.size() - tabsPage * TABS_PER_PAGE, TABS_PER_PAGE) * 14 + i * 28, bounds.y - 28, 28, 28)) {
+ tabs.add(tab = new TabWidget(i, tabSize, bounds.x + bounds.width / 2 - Math.min(categories.size() - tabsPage * tabsPerPage, tabsPerPage) * tabSize / 2, bounds.y, 0, tabV) {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
- if (getBounds().contains(mouseX, mouseY)) {
+ if (containsMouse(mouseX, mouseY)) {
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
- if (getId() + tabsPage * TABS_PER_PAGE == selectedCategoryIndex)
+ if (getId() + tabsPage * tabsPerPage == selectedCategoryIndex)
return false;
- selectedCategoryIndex = getId() + tabsPage * TABS_PER_PAGE;
+ selectedCategoryIndex = getId() + tabsPage * tabsPerPage;
scroll = 0;
selectedRecipeIndex = 0;
VillagerRecipeViewingScreen.this.init();
@@ -195,7 +199,7 @@ public class VillagerRecipeViewingScreen extends Screen {
return false;
}
});
- tab.setRenderer(categories.get(j), categories.get(j).getLogo(), categories.get(j).getCategoryName(), tab.getId() + tabsPage * TABS_PER_PAGE == selectedCategoryIndex);
+ tab.setRenderer(categories.get(j), categories.get(j).getLogo(), categories.get(j).getCategoryName(), tab.getId() + tabsPage * tabsPerPage == selectedCategoryIndex);
}
}
ButtonWidget w, w2;
@@ -204,7 +208,7 @@ public class VillagerRecipeViewingScreen extends Screen {
public void onPressed() {
tabsPage--;
if (tabsPage < 0)
- tabsPage = MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1;
+ tabsPage = MathHelper.ceil(categories.size() / (float) tabsPerPage) - 1;
VillagerRecipeViewingScreen.this.init();
}
});
@@ -212,12 +216,12 @@ public class VillagerRecipeViewingScreen extends Screen {
@Override
public void onPressed() {
tabsPage++;
- if (tabsPage > MathHelper.ceil(categories.size() / (float) TABS_PER_PAGE) - 1)
+ if (tabsPage > MathHelper.ceil(categories.size() / (float) tabsPerPage) - 1)
tabsPage = 0;
VillagerRecipeViewingScreen.this.init();
}
});
- w.enabled = w2.enabled = categories.size() > TABS_PER_PAGE;
+ w.enabled = w2.enabled = categories.size() > tabsPerPage;
this.widgets.add(new ClickableLabelWidget(new Point(bounds.x + 4 + scrollListBounds.width / 2, bounds.y + 6), categories.get(selectedCategoryIndex).getCategoryName()) {
@Override
diff --git a/src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java b/src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java
index 97f5b7401..0361c2ba5 100644
--- a/src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java
+++ b/src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java
@@ -6,7 +6,6 @@
package me.shedaniel.rei.gui.entries;
import me.shedaniel.rei.api.EntryStack;
-import me.shedaniel.rei.api.ObjectHolder;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.util.Identifier;
@@ -103,10 +102,9 @@ public abstract class RecipeEntry extends DrawableHelper implements EntryStack {
return this;
}
- @SuppressWarnings("deprecation")
@Override
- public <T> ObjectHolder<T> getSetting(Settings<T> settings) {
- return ObjectHolder.of(settings.getDefaultValue());
+ public <T> T get(Settings<T> settings) {
+ return settings.getDefaultValue();
}
public abstract int getHeight();
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java
index 7623a20a6..ca3bb420d 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java
@@ -27,10 +27,25 @@ public class TabWidget extends WidgetWithBounds {
public String categoryName;
public Rectangle bounds;
public RecipeCategory category;
+ public int u, v;
public TabWidget(int id, Rectangle bounds) {
+ this(id, bounds, 0, 192);
+ }
+
+ public TabWidget(int id, Rectangle bounds, int u, int v) {
this.id = id;
this.bounds = bounds;
+ this.u = u;
+ this.v = v;
+ }
+
+ public TabWidget(int id, int tabSize, int leftX, int bottomY) {
+ this(id, new Rectangle(leftX + id * tabSize, bottomY - tabSize, tabSize, tabSize));
+ }
+
+ public TabWidget(int id, int tabSize, int leftX, int bottomY, int u, int v) {
+ this(id, new Rectangle(leftX + id * tabSize, bottomY - tabSize, tabSize, tabSize), u, v);
}
public void setRenderer(RecipeCategory category, EntryStack logo, String categoryName, boolean selected) {
@@ -67,9 +82,9 @@ public class TabWidget extends WidgetWithBounds {
public void render(int mouseX, int mouseY, float delta) {
if (shown) {
minecraft.getTextureManager().bindTexture(ScreenHelper.isDarkModeEnabled() ? CHEST_GUI_TEXTURE_DARK : CHEST_GUI_TEXTURE);
- this.blit(bounds.x, bounds.y + 2, selected ? 28 : 0, 192, 28, (selected ? 30 : 27));
+ this.blit(bounds.x, bounds.y + 2, u + (selected ? bounds.width : 0), v, bounds.width, (selected ? bounds.height + 2 : bounds.height - 1));
logo.setZ(100);
- logo.render(new Rectangle(bounds.getCenterX() - 8, bounds.getCenterY() - 6, 16, 16), mouseX, mouseY, delta);
+ logo.render(new Rectangle(bounds.getCenterX() - 8, bounds.getCenterY() - 5, 16, 16), mouseX, mouseY, delta);
if (containsMouse(mouseX, mouseY)) {
drawTooltip();
}
diff --git a/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java b/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java
index cdbbfdccd..1a1626042 100644
--- a/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java
+++ b/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java
@@ -6,7 +6,6 @@
package me.shedaniel.rei.impl;
import me.shedaniel.rei.api.EntryStack;
-import me.shedaniel.rei.api.ObjectHolder;
import net.minecraft.client.gui.DrawableHelper;
import java.util.HashMap;
@@ -39,11 +38,11 @@ public abstract class AbstractEntryStack extends DrawableHelper implements Entry
}
@Override
- public <T> ObjectHolder<T> getSetting(Settings<T> settings) {
+ public <T> T get(Settings<T> settings) {
Object o = this.settings.get(settings);
if (o == null)
- return ObjectHolder.of(settings.getDefaultValue());
- return ObjectHolder.of((T) o);
+ return settings.getDefaultValue();
+ return (T) o;
}
@Override
@@ -62,7 +61,7 @@ public abstract class AbstractEntryStack extends DrawableHelper implements Entry
if (!(obj instanceof EntryStack))
return false;
EntryStack stack = (EntryStack) obj;
- boolean checkTags = getSetting(Settings.CHECK_TAGS).value().get() || stack.getSetting(Settings.CHECK_TAGS).value().get();
+ boolean checkTags = get(Settings.CHECK_TAGS).get() || stack.get(Settings.CHECK_TAGS).get();
return equals(stack, !checkTags, true);
}
diff --git a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
index a284f37b5..280af5701 100644
--- a/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
+++ b/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
@@ -264,6 +264,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
return general;
}
+ @Override
+ public boolean isUsingCompactTabs() {
+ return appearance.useCompactTabs;
+ }
+
public static class General {
@ConfigEntry.Gui.Excluded public List<String> favorites = new ArrayList<>();
@Comment("Declares whether cheating mode is on.") private boolean cheating = false;
@@ -299,6 +304,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
private boolean displayFavoritesTooltip = false;
@Comment("Declares whether favorites will be searched.") private boolean searchFavorites = true;
@UsePercentage(min = 0.5, max = 4.0) private double entrySize = 1.0;
+ private boolean useCompactTabs = true;
}
public static class Technical {
diff --git a/src/main/java/me/shedaniel/rei/impl/EmptyEntryStack.java b/src/main/java/me/shedaniel/rei/impl/EmptyEntryStack.java
index 0d40b8e97..bf3f76772 100644
--- a/src/main/java/me/shedaniel/rei/impl/EmptyEntryStack.java
+++ b/src/main/java/me/shedaniel/rei/impl/EmptyEntryStack.java
@@ -7,7 +7,6 @@ package me.shedaniel.rei.impl;
import me.shedaniel.math.api.Rectangle;
import me.shedaniel.rei.api.EntryStack;
-import me.shedaniel.rei.api.ObjectHolder;
import me.shedaniel.rei.gui.widget.QueuedTooltip;
import net.minecraft.util.Identifier;
@@ -108,8 +107,8 @@ public class EmptyEntryStack implements EntryStack {
}
@Override
- public <T> ObjectHolder<T> getSetting(Settings<T> settings) {
- return ObjectHolder.of(settings.getDefaultValue());
+ public <T> T get(Settings<T> settings) {
+ return settings.getDefaultValue();
}
@Override
diff --git a/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java b/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java
index 7b92a314b..b38f27f34 100644
--- a/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java
+++ b/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java
@@ -145,16 +145,16 @@ public class FluidEntryStack extends AbstractEntryStack {
@Nullable
@Override
public QueuedTooltip getTooltip(int mouseX, int mouseY) {
- if (!getSetting(Settings.TOOLTIP_ENABLED).value().get() || isEmpty())
+ if (!get(Settings.TOOLTIP_ENABLED).get() || isEmpty())
return null;
List<String> toolTip = Lists.newArrayList(SearchArgument.tryGetEntryStackName(this));
if (amount >= 0) {
- String amountTooltip = getSetting(Settings.Fluid.AMOUNT_TOOLTIP).value().apply(this);
+ String amountTooltip = get(Settings.Fluid.AMOUNT_TOOLTIP).apply(this);
if (amountTooltip != null)
toolTip.addAll(Arrays.asList(amountTooltip.split("\n")));
}
- toolTip.addAll(getSetting(Settings.TOOLTIP_APPEND_EXTRA).value().apply(this));
- if (getSetting(Settings.TOOLTIP_APPEND_MOD).value().get() && ConfigObject.getInstance().shouldAppendModNames()) {
+ toolTip.addAll(get(Settings.TOOLTIP_APPEND_EXTRA).apply(this));
+ if (get(Settings.TOOLTIP_APPEND_MOD).get() && ConfigObject.getInstance().shouldAppendModNames()) {
final String modString = ClientHelper.getInstance().getFormattedModFromIdentifier(Registry.FLUID.getId(fluid));
boolean alreadyHasMod = false;
for (String s : toolTip)
@@ -170,7 +170,7 @@ public class FluidEntryStack extends AbstractEntryStack {
@Override
public void render(Rectangle bounds, int mouseX, int mouseY, float delta) {
- if (getSetting(Settings.RENDER).value().get()) {
+ if (get(Settings.RENDER).get()) {
Pair<Sprite, Integer> pair = getOrLoadSprite(getFluid());
if (pair != null) {
Sprite sprite = pair.getLeft();
diff --git a/src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java b/src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java
index e48b7074a..fa000359e 100644
--- a/src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java
+++ b/src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java
@@ -8,11 +8,14 @@ package me.shedaniel.rei.impl;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.platform.GlStateManager;
import me.shedaniel.math.api.Rectangle;
-import me.shedaniel.rei.api.*;
+import me.shedaniel.rei.api.ClientHelper;
+import me.shedaniel.rei.api.ConfigObject;
+import me.shedaniel.rei.api.EntryStack;
+import me.shedaniel.rei.api.ItemStackHook;
import me.shedaniel.rei.gui.widget.QueuedTooltip;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.*;
-import net.minecraft.client.render.item.BuiltinModelItemRenderer;
+import net.minecraft.client.render.OverlayTexture;
+import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformation;
@@ -25,7 +28,6 @@ import net.minecraft.util.registry.Registry;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Optional;
@Deprecated
@@ -64,6 +66,7 @@ public class ItemEntryStack extends AbstractEntryStack {
return itemStack.isEmpty();
}
+ @SuppressWarnings("rawtypes")
@Override
public EntryStack copy() {
EntryStack stack = EntryStack.create(getItemStack().copy());
@@ -131,11 +134,11 @@ public class ItemEntryStack extends AbstractEntryStack {
@Nullable
@Override
public QueuedTooltip getTooltip(int mouseX, int mouseY) {
- if (isEmpty() || !getSetting(Settings.TOOLTIP_ENABLED).value().get())
+ if (isEmpty() || !get(Settings.TOOLTIP_ENABLED).get())
return null;
List<String> toolTip = Lists.newArrayList(SearchArgument.tryGetItemStackToolTip(getItemStack(), true));
- toolTip.addAll(getSetting(Settings.TOOLTIP_APPEND_EXTRA).value().apply(this));
- if (getSetting(Settings.TOOLTIP_APPEND_MOD).value().get() && ConfigObject.getInstance().shouldAppendModNames()) {
+ toolTip.addAll(get(Settings.TOOLTIP_APPEND_EXTRA).apply(this));
+ if (get(Settings.TOOLTIP_APPEND_MOD).get() && ConfigObject.getInstance().shouldAppendModNames()) {
final String modString = ClientHelper.getInstance().getFormattedModFromItem(getItem());
boolean alreadyHasMod = false;
for (String s : toolTip)
@@ -149,9 +152,10 @@ public class ItemEntryStack extends AbstractEntryStack {
return QueuedTooltip.create(toolTip);
}
+ @SuppressWarnings("PointlessBooleanExpression")
@Override
public void render(Rectangle bounds, int mouseX, int mouseY, float delta) {
- if (!isEmpty() && getSetting(Settings.RENDER).value().get()) {
+ if (!isEmpty() && get(Settings.RENDER).get()) {
ItemStack stack = getItemStack();
if (ConfigObject.getInstance().doesFastEntryRendering() || true) {
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
@@ -175,16 +179,16 @@ public class ItemEntryStack extends AbstractEntryStack {
if (bl)
GlStateManager.method_24222();
GlStateManager.disableRescaleNormal();
- itemRenderer.renderGuiItemOverlay(MinecraftClient.getInstance().textRenderer, stack, bounds.x, bounds.y, getSetting(Settings.RENDER_COUNTS).value().get() ? getSetting(Settings.COUNTS).value().apply(this) : "");
+ itemRenderer.renderGuiItemOverlay(MinecraftClient.getInstance().textRenderer, stack, bounds.x, bounds.y, get(Settings.RENDER_COUNTS).get() ? get(Settings.COUNTS).apply(this) : "");
itemRenderer.zOffset = 0.0F;
} else {
- ((ItemStackHook) (Object) stack).rei_setRenderEnchantmentGlint(getSetting(Settings.Item.RENDER_ENCHANTMENT_GLINT).value().get());
+ ((ItemStackHook) (Object) stack).rei_setRenderEnchantmentGlint(get(Settings.Item.RENDER_ENCHANTMENT_GLINT).get());
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
itemRenderer.zOffset = getZ();
int i1 = bounds.x;
int i2 = bounds.y;
itemRenderer.renderGuiItemIcon(stack, i1, i2);
- itemRenderer.renderGuiItemOverlay(MinecraftClient.getInstance().textRenderer, stack, i1, i2, getSetting(Settings.RENDER_COUNTS).value().get() ? getSetting(Settings.COUNTS).value().apply(this) : "");
+ itemRenderer.renderGuiItemOverlay(MinecraftClient.getInstance().textRenderer, stack, i1, i2, get(Settings.RENDER_COUNTS).get() ? get(Settings.COUNTS).apply(this) : "");
itemRenderer.zOffset = 0.0F;
((ItemStackHook) (Object) stack).rei_setRenderEnchantmentGlint(true);
}