|
@@ -8,6 +8,7 @@ package me.shedaniel.rei.gui.widget;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.mojang.blaze3d.systems.RenderSystem;
|
|
|
import me.shedaniel.clothconfig2.ClothConfigInitializer;
|
|
|
+import me.shedaniel.clothconfig2.api.ModifierKeyCode;
|
|
|
import me.shedaniel.clothconfig2.api.ScissorsHandler;
|
|
|
import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget;
|
|
|
import me.shedaniel.math.api.Point;
|
|
@@ -46,7 +47,7 @@ import java.util.function.Supplier;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
public class EntryListWidget extends WidgetWithBounds {
|
|
|
-
|
|
|
+
|
|
|
static final Supplier<Boolean> RENDER_ENCHANTMENT_GLINT = ConfigObject.getInstance()::doesRenderEntryEnchantmentGlint;
|
|
|
@SuppressWarnings("deprecation")
|
|
|
static final Comparator<? super EntryStack> ENTRY_NAME_COMPARER = Comparator.comparing(SearchArgument::tryGetEntryStackName);
|
|
@@ -58,6 +59,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
return Integer.MAX_VALUE;
|
|
|
});
|
|
|
+ private static final int SIZE = 18;
|
|
|
private static final boolean LAZY = true;
|
|
|
private static final String SPACE = " ", EMPTY = "";
|
|
|
private static int page;
|
|
@@ -72,10 +74,13 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
private List<EntryStack> favorites = null;
|
|
|
private List<EntryListEntry> entries = Collections.emptyList();
|
|
|
private List<Widget> widgets = Collections.emptyList();
|
|
|
- @SuppressWarnings("deprecation")
|
|
|
- private List<SearchArgument.SearchArguments> lastSearchArguments = Collections.emptyList();
|
|
|
+ @SuppressWarnings("deprecation") private List<SearchArgument.SearchArguments> lastSearchArguments = Collections.emptyList();
|
|
|
private boolean draggingScrollBar = false;
|
|
|
-
|
|
|
+
|
|
|
+ public static int entrySize() {
|
|
|
+ return MathHelper.ceil(SIZE * ConfigObject.getInstance().getEntrySize());
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
static boolean notSteppingOnExclusionZones(int left, int top, Rectangle listArea) {
|
|
|
MinecraftClient instance = MinecraftClient.getInstance();
|
|
@@ -86,73 +91,73 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private static Rectangle updateInnerBounds(Rectangle bounds) {
|
|
|
if (ConfigObject.getInstance().isEntryListWidgetScrolled()) {
|
|
|
- int width = Math.max(MathHelper.floor((bounds.width - 2 - 6) / 18f), 1);
|
|
|
+ int width = Math.max(MathHelper.floor((bounds.width - 2 - 6) / (float) entrySize()), 1);
|
|
|
if (ConfigObject.getInstance().isLeftHandSidePanel())
|
|
|
- return new Rectangle(bounds.getCenterX() - width * 9 + 3, bounds.y, width * 18, bounds.height);
|
|
|
- return new Rectangle(bounds.getCenterX() - width * 9 - 3, bounds.y, width * 18, bounds.height);
|
|
|
+ return new Rectangle((int) (bounds.getCenterX() - width * (entrySize() / 2f) + 3), bounds.y, width * entrySize(), bounds.height);
|
|
|
+ return new Rectangle((int) (bounds.getCenterX() - width * (entrySize() / 2f) - 3), bounds.y, width * entrySize(), bounds.height);
|
|
|
}
|
|
|
- int width = Math.max(MathHelper.floor((bounds.width - 2) / 18f), 1);
|
|
|
- int height = Math.max(MathHelper.floor((bounds.height - 2) / 18f), 1);
|
|
|
- return new Rectangle(bounds.getCenterX() - width * 9, bounds.getCenterY() - height * 9, width * 18, height * 18);
|
|
|
+ int width = Math.max(MathHelper.floor((bounds.width - 2) / (float) entrySize()), 1);
|
|
|
+ int height = Math.max(MathHelper.floor((bounds.height - 2) / (float) entrySize()), 1);
|
|
|
+ return new Rectangle((int) (bounds.getCenterX() - width * (entrySize() / 2f)), (int) (bounds.getCenterY() - height * (entrySize() / 2f)), width * entrySize(), height * entrySize());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final int getSlotsHeightNumberForFavorites() {
|
|
|
if (favorites.isEmpty())
|
|
|
return 0;
|
|
|
if (ConfigObject.getInstance().isEntryListWidgetScrolled())
|
|
|
- return MathHelper.ceil(2 + favorites.size() / (innerBounds.width / 18f));
|
|
|
- int height = MathHelper.ceil(favorites.size() / (innerBounds.width / 18f));
|
|
|
- int pagesToFit = MathHelper.ceil(height / (innerBounds.height / 18f - 1));
|
|
|
- if (height > (innerBounds.height / 18 - 1) && (height) % (innerBounds.height / 18) == (innerBounds.height / 18) - 2)
|
|
|
+ return MathHelper.ceil(2 + favorites.size() / (innerBounds.width / (float) entrySize()));
|
|
|
+ int height = MathHelper.ceil(favorites.size() / (innerBounds.width / (float) entrySize()));
|
|
|
+ int pagesToFit = MathHelper.ceil(height / (innerBounds.height / (float) entrySize() - 1));
|
|
|
+ if (height > (innerBounds.height / entrySize() - 1) && (height) % (innerBounds.height / entrySize()) == (innerBounds.height / entrySize()) - 2)
|
|
|
height--;
|
|
|
return height + pagesToFit + 1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final int getScrollNumberForFavorites() {
|
|
|
if (favorites.isEmpty())
|
|
|
return 0;
|
|
|
- return (innerBounds.width / 18) * getSlotsHeightNumberForFavorites();
|
|
|
+ return (innerBounds.width / entrySize()) * getSlotsHeightNumberForFavorites();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final int getMaxScrollPosition() {
|
|
|
if (favorites.isEmpty())
|
|
|
- return MathHelper.ceil((allStacks.size() + blockedCount) / (innerBounds.width / 18f)) * 18;
|
|
|
- return MathHelper.ceil((allStacks.size() + blockedCount + getScrollNumberForFavorites()) / (innerBounds.width / 18f)) * 18 - 12;
|
|
|
+ return MathHelper.ceil((allStacks.size() + blockedCount) / (innerBounds.width / (float) entrySize())) * entrySize();
|
|
|
+ return MathHelper.ceil((allStacks.size() + blockedCount + getScrollNumberForFavorites()) / (innerBounds.width / (float) entrySize())) * entrySize() - 12;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final int getMaxScroll() {
|
|
|
return Math.max(0, this.getMaxScrollPosition() - innerBounds.height);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final double clamp(double v) {
|
|
|
return this.clamp(v, 200.0D);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final double clamp(double v, double clampExtension) {
|
|
|
return MathHelper.clamp(v, -clampExtension, (double) this.getMaxScroll() + clampExtension);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final void offset(double value, boolean animated) {
|
|
|
scrollTo(target + value, animated);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final void scrollTo(double value, boolean animated) {
|
|
|
scrollTo(value, animated, ClothConfigInitializer.getScrollDuration());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected final void scrollTo(double value, boolean animated, long duration) {
|
|
|
target = clamp(value);
|
|
|
-
|
|
|
+
|
|
|
if (animated) {
|
|
|
start = System.currentTimeMillis();
|
|
|
this.duration = duration;
|
|
|
} else
|
|
|
scroll = target;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public boolean mouseScrolled(double double_1, double double_2, double double_3) {
|
|
|
if (ConfigObject.getInstance().isEntryListWidgetScrolled() && bounds.contains(double_1, double_2)) {
|
|
@@ -161,34 +166,34 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
return super.mouseScrolled(double_1, double_2, double_3);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public Rectangle getBounds() {
|
|
|
return bounds;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public int getPage() {
|
|
|
return page;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void setPage(int page) {
|
|
|
- this.page = page;
|
|
|
+ EntryListWidget.page = page;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void previousPage() {
|
|
|
- this.page--;
|
|
|
+ page--;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void nextPage() {
|
|
|
- this.page++;
|
|
|
+ page++;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public int getTotalPages() {
|
|
|
if (ConfigObject.getInstance().isEntryListWidgetScrolled())
|
|
|
return 1;
|
|
|
return MathHelper.ceil((allStacks.size() + getScrollNumberForFavorites()) / (float) entries.size());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void render(int mouseX, int mouseY, float delta) {
|
|
|
if (ConfigObject.getInstance().isEntryListWidgetScrolled()) {
|
|
@@ -196,8 +201,8 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
entry.clearStacks();
|
|
|
ScissorsHandler.INSTANCE.scissor(bounds);
|
|
|
int sizeForFavorites = getSlotsHeightNumberForFavorites();
|
|
|
- int skip = Math.max(0, MathHelper.floor(scroll / 18f) - sizeForFavorites);
|
|
|
- int nextIndex = skip * innerBounds.width / 18;
|
|
|
+ int skip = Math.max(0, MathHelper.floor(scroll / (float) entrySize()) - sizeForFavorites);
|
|
|
+ int nextIndex = skip * innerBounds.width / entrySize();
|
|
|
int i = nextIndex;
|
|
|
blockedCount = 0;
|
|
|
if (debugTime) {
|
|
@@ -205,10 +210,9 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
long time = 0;
|
|
|
if (sizeForFavorites > 0) {
|
|
|
drawString(font, I18n.translate("text.rei.favorites"), innerBounds.x + 2, (int) (innerBounds.y + 8 - scroll), -1);
|
|
|
- nextIndex += innerBounds.width / 18;
|
|
|
- for (int i1 = 0; i1 < favorites.size(); i1++) {
|
|
|
- EntryStack stack = favorites.get(i1);
|
|
|
- back1:
|
|
|
+ nextIndex += innerBounds.width / entrySize();
|
|
|
+ back1:
|
|
|
+ for (EntryStack stack : favorites) {
|
|
|
while (true) {
|
|
|
EntryListEntry entry = entries.get(nextIndex);
|
|
|
entry.getBounds().y = (int) (entry.backupY - scroll);
|
|
@@ -229,7 +233,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- nextIndex += innerBounds.width / -18 + getScrollNumberForFavorites() - favorites.size();
|
|
|
+ nextIndex += innerBounds.width / -entrySize() + getScrollNumberForFavorites() - favorites.size();
|
|
|
}
|
|
|
int offset = sizeForFavorites > 0 ? -12 : 0;
|
|
|
back:
|
|
@@ -244,9 +248,9 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
entry.entry(stack);
|
|
|
entry.isFavorites = false;
|
|
|
size++;
|
|
|
- long l = System.currentTimeMillis();
|
|
|
+ long l = System.nanoTime();
|
|
|
entry.render(mouseX, mouseY, delta);
|
|
|
- time += (System.currentTimeMillis() - l);
|
|
|
+ time += (System.nanoTime() - l);
|
|
|
nextIndex++;
|
|
|
break;
|
|
|
} else {
|
|
@@ -257,7 +261,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
int z = getZ();
|
|
|
setZ(500);
|
|
|
- String str = String.format("%d entries, avg. %.2fms, %s fps", size, time / (double) size, minecraft.fpsDebugString.split(" ")[0]);
|
|
|
+ String str = String.format("%d entries, avg. %.0fns, %s fps", size, time / (double) size, minecraft.fpsDebugString.split(" ")[0]);
|
|
|
fillGradient(bounds.x, bounds.y, bounds.x + font.getStringWidth(str) + 2, bounds.y + font.fontHeight + 2, -16777216, -16777216);
|
|
|
MatrixStack matrixStack_1 = new MatrixStack();
|
|
|
VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
|
|
@@ -269,10 +273,9 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
} else {
|
|
|
if (sizeForFavorites > 0) {
|
|
|
drawString(font, I18n.translate("text.rei.favorites"), innerBounds.x + 2, (int) (innerBounds.y + 8 - scroll), -1);
|
|
|
- nextIndex += innerBounds.width / 18;
|
|
|
- for (int i1 = 0; i1 < favorites.size(); i1++) {
|
|
|
- EntryStack stack = favorites.get(i1);
|
|
|
- back1:
|
|
|
+ nextIndex += innerBounds.width / entrySize();
|
|
|
+ back1:
|
|
|
+ for (EntryStack stack : favorites) {
|
|
|
while (true) {
|
|
|
EntryListEntry entry = entries.get(nextIndex);
|
|
|
entry.getBounds().y = (int) (entry.backupY - scroll);
|
|
@@ -290,7 +293,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- nextIndex += innerBounds.width / -18 + getScrollNumberForFavorites() - favorites.size();
|
|
|
+ nextIndex += innerBounds.width / -entrySize() + getScrollNumberForFavorites() - favorites.size();
|
|
|
}
|
|
|
int offset = sizeForFavorites > 0 ? -12 : 0;
|
|
|
back:
|
|
@@ -324,15 +327,15 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
for (Widget widget : widgets) {
|
|
|
if (widget instanceof EntryListEntry) {
|
|
|
size++;
|
|
|
- long l = System.currentTimeMillis();
|
|
|
+ long l = System.nanoTime();
|
|
|
widget.render(mouseX, mouseY, delta);
|
|
|
- time += (System.currentTimeMillis() - l);
|
|
|
+ time += (System.nanoTime() - l);
|
|
|
} else
|
|
|
widget.render(mouseX, mouseY, delta);
|
|
|
}
|
|
|
int z = getZ();
|
|
|
setZ(500);
|
|
|
- String str = String.format("%d entries, avg. %.2fms, %s fps", size, time / (double) size, minecraft.fpsDebugString.split(" ")[0]);
|
|
|
+ String str = String.format("%d entries, avg. %.0fns, %s fps", size, time / (double) size, minecraft.fpsDebugString.split(" ")[0]);
|
|
|
fillGradient(bounds.x, bounds.y, bounds.x + font.getStringWidth(str) + 2, bounds.y + font.fontHeight + 2, -16777216, -16777216);
|
|
|
MatrixStack matrixStack_1 = new MatrixStack();
|
|
|
VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
|
|
@@ -348,26 +351,26 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private int getScrollbarMinX() {
|
|
|
if (ConfigObject.getInstance().isLeftHandSidePanel())
|
|
|
return bounds.x + 1;
|
|
|
return bounds.getMaxX() - 7;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public boolean mouseDragged(double mouseX, double mouseY, int int_1, double double_3, double double_4) {
|
|
|
if (int_1 == 0 && draggingScrollBar) {
|
|
|
float height = getMaxScrollPosition();
|
|
|
int actualHeight = innerBounds.height;
|
|
|
if (height > actualHeight && mouseY >= innerBounds.y && mouseY <= innerBounds.getMaxY()) {
|
|
|
- double double_5 = (double) Math.max(1, this.getMaxScroll());
|
|
|
+ double double_5 = Math.max(1, this.getMaxScroll());
|
|
|
int int_2 = innerBounds.height;
|
|
|
int int_3 = MathHelper.clamp((int) ((float) (int_2 * int_2) / (float) getMaxScrollPosition()), 32, int_2 - 8);
|
|
|
double double_6 = Math.max(1.0D, double_5 / (double) (int_2 - int_3));
|
|
|
float to = MathHelper.clamp((float) (scroll + double_4 * double_6), 0, height - innerBounds.height);
|
|
|
if (ConfigObject.getInstance().doesSnapToRows()) {
|
|
|
- double nearestRow = Math.round(to / 18.0) * 18.0;
|
|
|
+ double nearestRow = Math.round(to / (double) entrySize()) * (double) entrySize();
|
|
|
scrollTo(nearestRow, false);
|
|
|
} else
|
|
|
scrollTo(to, false);
|
|
@@ -375,7 +378,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
return super.mouseDragged(mouseX, mouseY, int_1, double_3, double_4);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void renderScrollbar() {
|
|
|
int maxScroll = getMaxScroll();
|
|
|
if (maxScroll > 0) {
|
|
@@ -384,13 +387,13 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
height -= Math.min((scroll < 0 ? (int) -scroll : scroll > maxScroll ? (int) scroll - maxScroll : 0), height * .95);
|
|
|
height = Math.max(10, height);
|
|
|
int minY = Math.min(Math.max((int) scroll * (innerBounds.height - height) / maxScroll + innerBounds.y, innerBounds.y), innerBounds.getMaxY() - height);
|
|
|
-
|
|
|
+
|
|
|
int scrollbarPositionMinX = getScrollbarMinX();
|
|
|
int scrollbarPositionMaxX = scrollbarPositionMinX + 6;
|
|
|
boolean hovered = (new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height)).contains(PointHelper.fromMouse());
|
|
|
float bottomC = (hovered ? .67f : .5f) * (ScreenHelper.isDarkModeEnabled() ? 0.8f : 1f);
|
|
|
float topC = (hovered ? .87f : .67f) * (ScreenHelper.isDarkModeEnabled() ? 0.8f : 1f);
|
|
|
-
|
|
|
+
|
|
|
RenderSystem.disableTexture();
|
|
|
RenderSystem.enableBlend();
|
|
|
RenderSystem.disableAlphaTest();
|
|
@@ -416,7 +419,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
RenderSystem.enableTexture();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void updatePosition(float delta) {
|
|
|
target = clamp(target);
|
|
|
if (target < 0) {
|
|
@@ -424,7 +427,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
} else if (target > getMaxScroll()) {
|
|
|
target = (target - getMaxScroll()) * (1 - (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3) + getMaxScroll();
|
|
|
} else if (ConfigObject.getInstance().doesSnapToRows()) {
|
|
|
- double nearestRow = Math.round(target / 18.0) * 18.0;
|
|
|
+ double nearestRow = Math.round(target / (double) entrySize()) * (double) entrySize();
|
|
|
if (!DynamicNewSmoothScrollingEntryListWidget.Precision.almostEquals(target, nearestRow, DynamicNewSmoothScrollingEntryListWidget.Precision.FLOAT_EPSILON))
|
|
|
target += (nearestRow - target) * Math.min(delta / 2.0, 1.0);
|
|
|
else
|
|
@@ -435,7 +438,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
else
|
|
|
scroll = target;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public boolean keyPressed(int int_1, int int_2, int int_3) {
|
|
|
if (containsMouse(PointHelper.fromMouse()))
|
|
@@ -444,7 +447,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
return true;
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void updateArea(DisplayHelper.DisplayBoundsHandler<?> boundsHandler, @Nullable String searchTerm) {
|
|
|
this.bounds = boundsHandler.getItemListArea(ScreenHelper.getLastOverlay().getBounds());
|
|
|
FavoritesListWidget favoritesListWidget = ContainerScreenOverlay.getFavoritesListWidget();
|
|
@@ -457,18 +460,18 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
else
|
|
|
updateEntriesPosition();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void updateEntriesPosition() {
|
|
|
this.innerBounds = updateInnerBounds(bounds);
|
|
|
if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) {
|
|
|
page = Math.max(page, 0);
|
|
|
List<EntryListEntry> entries = Lists.newLinkedList();
|
|
|
- int width = innerBounds.width / 18;
|
|
|
- int height = innerBounds.height / 18;
|
|
|
+ int width = innerBounds.width / entrySize();
|
|
|
+ int height = innerBounds.height / entrySize();
|
|
|
for (int currentY = 0; currentY < height; currentY++) {
|
|
|
for (int currentX = 0; currentX < width; currentX++) {
|
|
|
- if (notSteppingOnExclusionZones(currentX * 18 + innerBounds.x, currentY * 18 + innerBounds.y, innerBounds)) {
|
|
|
- entries.add((EntryListEntry) new EntryListEntry(currentX * 18 + innerBounds.x, currentY * 18 + innerBounds.y).noBackground());
|
|
|
+ if (notSteppingOnExclusionZones(currentX * entrySize() + innerBounds.x, currentY * entrySize() + innerBounds.y, innerBounds)) {
|
|
|
+ entries.add((EntryListEntry) new EntryListEntry(currentX * entrySize() + innerBounds.x, currentY * entrySize() + innerBounds.y).noBackground());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -490,8 +493,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
j += width;
|
|
|
}
|
|
|
List<EntryStack> subFavoritesList = favorites.stream().skip(skippedFavorites).limit(Math.max(0, entries.size() - width)).collect(Collectors.toList());
|
|
|
- for (int i = 0; i < subFavoritesList.size(); i++) {
|
|
|
- EntryStack stack = subFavoritesList.get(i);
|
|
|
+ for (EntryStack stack : subFavoritesList) {
|
|
|
entries.get(j).clearStacks().entry(stack);
|
|
|
entries.get(j).isFavorites = true;
|
|
|
j++;
|
|
@@ -499,16 +501,16 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
} else {
|
|
|
page = 0;
|
|
|
- int width = innerBounds.width / 18;
|
|
|
- int pageHeight = innerBounds.height / 18;
|
|
|
+ int width = innerBounds.width / entrySize();
|
|
|
+ int pageHeight = innerBounds.height / entrySize();
|
|
|
int sizeForFavorites = getScrollNumberForFavorites();
|
|
|
- int slotsToPrepare = allStacks.size() * 3 + sizeForFavorites * 3;
|
|
|
+ int slotsToPrepare = Math.max(allStacks.size() * 3 + sizeForFavorites * 3, width * pageHeight * 3);
|
|
|
int currentX = 0;
|
|
|
int currentY = 0;
|
|
|
List<EntryListEntry> entries = Lists.newLinkedList();
|
|
|
for (int i = 0; i < slotsToPrepare; i++) {
|
|
|
- int xPos = currentX * 18 + innerBounds.x;
|
|
|
- int yPos = currentY * 18 + innerBounds.y;
|
|
|
+ int xPos = currentX * entrySize() + innerBounds.x;
|
|
|
+ int yPos = currentY * entrySize() + innerBounds.y;
|
|
|
entries.add((EntryListEntry) new EntryListEntry(xPos, yPos).noBackground());
|
|
|
currentX++;
|
|
|
if (currentX >= width) {
|
|
@@ -523,13 +525,12 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
if (favoritesListWidget != null)
|
|
|
favoritesListWidget.updateEntriesPosition();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Deprecated
|
|
|
public List<EntryStack> getAllStacks() {
|
|
|
return allStacks;
|
|
|
}
|
|
|
-
|
|
|
- @SuppressWarnings("deprecation")
|
|
|
+
|
|
|
public void updateSearch(String searchTerm) {
|
|
|
lastSearchArguments = processSearchTerm(searchTerm);
|
|
|
{
|
|
@@ -582,17 +583,19 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
favoritesListWidget.updateSearch(this, searchTerm);
|
|
|
updateEntriesPosition();
|
|
|
}
|
|
|
-
|
|
|
- @SuppressWarnings("deprecation")
|
|
|
+
|
|
|
public boolean canLastSearchTermsBeAppliedTo(EntryStack stack) {
|
|
|
return lastSearchArguments.isEmpty() || canSearchTermsBeAppliedTo(stack, lastSearchArguments);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@SuppressWarnings("deprecation")
|
|
|
private boolean canSearchTermsBeAppliedTo(EntryStack stack, List<SearchArgument.SearchArguments> searchArguments) {
|
|
|
if (searchArguments.isEmpty())
|
|
|
return true;
|
|
|
- String mod = null, name = null, tooltip = null, tags[] = null;
|
|
|
+ String mod = null;
|
|
|
+ String name = null;
|
|
|
+ String tooltip = null;
|
|
|
+ String[] tags = null;
|
|
|
for (SearchArgument.SearchArguments arguments : searchArguments) {
|
|
|
boolean applicable = true;
|
|
|
for (SearchArgument argument : arguments.getArguments()) {
|
|
@@ -654,7 +657,7 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@SuppressWarnings("deprecation")
|
|
|
private List<SearchArgument.SearchArguments> processSearchTerm(String searchTerm) {
|
|
|
List<SearchArgument.SearchArguments> searchArguments = Lists.newArrayList();
|
|
@@ -689,30 +692,32 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
return searchArguments;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public List<? extends Widget> children() {
|
|
|
return widgets;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public boolean mouseClicked(double double_1, double double_2, int int_1) {
|
|
|
- double height = getMaxScroll();
|
|
|
- int actualHeight = bounds.height;
|
|
|
- if (height > actualHeight && double_2 >= bounds.y && double_2 <= bounds.getMaxY()) {
|
|
|
- double scrollbarPositionMinX = getScrollbarMinX();
|
|
|
- if (double_1 >= scrollbarPositionMinX - 1 & double_1 <= scrollbarPositionMinX + 8) {
|
|
|
- this.draggingScrollBar = true;
|
|
|
- return true;
|
|
|
+ if (ConfigObject.getInstance().isEntryListWidgetScrolled()) {
|
|
|
+ double height = getMaxScroll();
|
|
|
+ int actualHeight = bounds.height;
|
|
|
+ if (height > actualHeight && double_2 >= bounds.y && double_2 <= bounds.getMaxY()) {
|
|
|
+ double scrollbarPositionMinX = getScrollbarMinX();
|
|
|
+ if (double_1 >= scrollbarPositionMinX - 1 & double_1 <= scrollbarPositionMinX + 8) {
|
|
|
+ this.draggingScrollBar = true;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
+ this.draggingScrollBar = false;
|
|
|
}
|
|
|
- this.draggingScrollBar = false;
|
|
|
-
|
|
|
+
|
|
|
if (containsMouse(double_1, double_2)) {
|
|
|
ClientPlayerEntity player = minecraft.player;
|
|
|
if (ClientHelper.getInstance().isCheating() && !player.inventory.getCursorStack().isEmpty() && RoughlyEnoughItemsCore.hasPermissionToUsePackets()) {
|
|
|
ClientHelper.getInstance().sendDeletePacket();
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
}
|
|
|
if (!player.inventory.getCursorStack().isEmpty() && RoughlyEnoughItemsCore.hasPermissionToUsePackets())
|
|
|
return false;
|
|
@@ -722,27 +727,28 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private class EntryListEntry extends EntryWidget {
|
|
|
private int backupY;
|
|
|
private boolean isFavorites;
|
|
|
-
|
|
|
+
|
|
|
private EntryListEntry(int x, int y) {
|
|
|
super(x, y);
|
|
|
this.backupY = y;
|
|
|
+ getBounds().width = getBounds().height = entrySize();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public boolean containsMouse(double mouseX, double mouseY) {
|
|
|
return super.containsMouse(mouseX, mouseY) && bounds.contains(mouseX, mouseY);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
protected void drawHighlighted(int mouseX, int mouseY, float delta) {
|
|
|
if (getCurrentEntry().getType() != EntryStack.Type.EMPTY)
|
|
|
super.drawHighlighted(mouseX, mouseY, delta);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private String getLocalizedName(InputUtil.KeyCode value) {
|
|
|
String string_1 = value.getName();
|
|
|
int int_1 = value.getKeyCode();
|
|
@@ -755,21 +761,20 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
string_2 = InputUtil.getScancodeName(int_1);
|
|
|
break;
|
|
|
case MOUSE:
|
|
|
- String string_3 = I18n.translate(string_1, new Object[0]);
|
|
|
- string_2 = Objects.equals(string_3, string_1) ? I18n.translate(InputUtil.Type.MOUSE.getName(), new Object[]{int_1 + 1}) : string_3;
|
|
|
+ String string_3 = I18n.translate(string_1);
|
|
|
+ string_2 = Objects.equals(string_3, string_1) ? I18n.translate(InputUtil.Type.MOUSE.getName(), int_1 + 1) : string_3;
|
|
|
}
|
|
|
-
|
|
|
- return string_2 == null ? I18n.translate(string_1, new Object[0]) : string_2;
|
|
|
+
|
|
|
+ return string_2 == null ? I18n.translate(string_1) : string_2;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
protected void queueTooltip(int mouseX, int mouseY, float delta) {
|
|
|
if (!ClientHelper.getInstance().isCheating() || minecraft.player.inventory.getCursorStack().isEmpty()) {
|
|
|
QueuedTooltip tooltip = getCurrentTooltip(mouseX, mouseY);
|
|
|
if (tooltip != null) {
|
|
|
- // if (ConfigObject.getInstance().doDisplayFavoritesTooltip()) {
|
|
|
- if (ConfigObject.getInstance().doDisplayFavoritesTooltip() && !ConfigObject.getInstance().doDisplayFavoritesOnTheLeft()) {
|
|
|
- String name = getLocalizedName(ConfigObject.getInstance().getFavoriteKeybind());
|
|
|
+ if (ConfigObject.getInstance().doDisplayFavoritesTooltip() && !ConfigObject.getInstance().getFavoriteKeyCode().isUnknown()) {
|
|
|
+ String name = ConfigObject.getInstance().getFavoriteKeyCode().getLocalizedName();
|
|
|
if (!isFavorites)
|
|
|
tooltip.getText().addAll(Arrays.asList(I18n.translate("text.rei.favorites_tooltip", name).split("\n")));
|
|
|
else
|
|
@@ -779,32 +784,19 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public boolean keyPressed(int int_1, int int_2, int int_3) {
|
|
|
if (interactable && ConfigObject.getInstance().isFavoritesEnabled() && containsMouse(PointHelper.fromMouse()) && !getCurrentEntry().isEmpty()) {
|
|
|
- InputUtil.KeyCode keyCode = ConfigObject.getInstance().getFavoriteKeybind();
|
|
|
- if (int_1 == InputUtil.UNKNOWN_KEYCODE.getKeyCode()) {
|
|
|
- if (keyCode.getCategory() == InputUtil.Type.SCANCODE && keyCode.getKeyCode() == int_2) {
|
|
|
- if (!isFavorites) {
|
|
|
- ConfigManager.getInstance().getFavorites().add(getCurrentEntry().copy());
|
|
|
- ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText());
|
|
|
- } else {
|
|
|
- ConfigManager.getInstance().getFavorites().remove(getCurrentEntry());
|
|
|
- ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText());
|
|
|
- }
|
|
|
- ConfigManager.getInstance().saveConfig();
|
|
|
- minecraft.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
|
|
- return true;
|
|
|
- }
|
|
|
- } else if (keyCode.getCategory() == InputUtil.Type.KEYSYM && keyCode.getKeyCode() == int_1) {
|
|
|
+ ModifierKeyCode keyCode = ConfigObject.getInstance().getFavoriteKeyCode();
|
|
|
+ if (keyCode.matchesKey(int_1, int_2)) {
|
|
|
if (!isFavorites) {
|
|
|
- ConfigManager.getInstance().getFavorites().add(getCurrentEntry().copy());
|
|
|
- ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText());
|
|
|
+ if (!CollectionUtils.anyMatchEqualsAll(ConfigManager.getInstance().getFavorites(), getCurrentEntry()))
|
|
|
+ ConfigManager.getInstance().getFavorites().add(getCurrentEntry().copy());
|
|
|
} else {
|
|
|
ConfigManager.getInstance().getFavorites().remove(getCurrentEntry());
|
|
|
- ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText());
|
|
|
}
|
|
|
+ ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText());
|
|
|
ConfigManager.getInstance().saveConfig();
|
|
|
minecraft.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
|
|
return true;
|
|
@@ -812,23 +804,25 @@ public class EntryListWidget extends WidgetWithBounds {
|
|
|
}
|
|
|
return super.keyPressed(int_1, int_2, int_3);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
|
|
if (!interactable)
|
|
|
return super.mouseClicked(mouseX, mouseY, button);
|
|
|
if (containsMouse(mouseX, mouseY) && ClientHelper.getInstance().isCheating()) {
|
|
|
EntryStack entry = getCurrentEntry().copy();
|
|
|
- if (entry.getType() == EntryStack.Type.ITEM) {
|
|
|
- if (ConfigObject.getInstance().getItemCheatingMode() == ItemCheatingMode.REI_LIKE)
|
|
|
- entry.setAmount(button != 1 ? 1 : entry.getItemStack().getMaxCount());
|
|
|
- else if (ConfigObject.getInstance().getItemCheatingMode() == ItemCheatingMode.JEI_LIKE)
|
|
|
- entry.setAmount(button != 0 ? 1 : entry.getItemStack().getMaxCount());
|
|
|
- else
|
|
|
- entry.setAmount(1);
|
|
|
+ if (!entry.isEmpty()) {
|
|
|
+ if (entry.getType() == EntryStack.Type.ITEM) {
|
|
|
+ if (ConfigObject.getInstance().getItemCheatingMode() == ItemCheatingMode.REI_LIKE)
|
|
|
+ entry.setAmount(button != 1 ? 1 : entry.getItemStack().getMaxCount());
|
|
|
+ else if (ConfigObject.getInstance().getItemCheatingMode() == ItemCheatingMode.JEI_LIKE)
|
|
|
+ entry.setAmount(button != 0 ? 1 : entry.getItemStack().getMaxCount());
|
|
|
+ else
|
|
|
+ entry.setAmount(1);
|
|
|
+ }
|
|
|
+ ClientHelper.getInstance().tryCheatingEntry(entry);
|
|
|
+ return true;
|
|
|
}
|
|
|
- ClientHelper.getInstance().tryCheatingEntry(entry);
|
|
|
- return true;
|
|
|
}
|
|
|
return super.mouseClicked(mouseX, mouseY, button);
|
|
|
}
|