diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-09-22 12:20:12 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-09-28 23:21:14 +0800 |
| commit | 86a0e7cd198d393e0f8294249c52a8ce00f8d89c (patch) | |
| tree | 7d5adcd77713529d162859ce924d01cac9b1bdc7 /RoughlyEnoughItems-runtime | |
| parent | 23a720347250486e0552cb9d6890f47ed038de94 (diff) | |
| download | RoughlyEnoughItems-86a0e7cd198d393e0f8294249c52a8ce00f8d89c.tar.gz RoughlyEnoughItems-86a0e7cd198d393e0f8294249c52a8ce00f8d89c.tar.bz2 RoughlyEnoughItems-86a0e7cd198d393e0f8294249c52a8ce00f8d89c.zip | |
Fix #409 and more
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'RoughlyEnoughItems-runtime')
15 files changed, 202 insertions, 116 deletions
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 737600746..a98c49e69 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -76,6 +76,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.List; +import java.util.Random; import java.util.Set; @ApiStatus.Internal @@ -321,7 +322,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl } subsetsButtonBounds = getSubsetsButtonBounds(); if (ConfigObject.getInstance().isSubsetsEnabled()) { - widgets.add(InternalWidgets.wrapLateRenderable(InternalWidgets.wrapTranslate(Widgets.createButton(subsetsButtonBounds, ((ClientHelperImpl) ClientHelper.getInstance()).isAprilFools.get() ? new TranslationTextComponent("text.rei.tiny_potato") : new TranslationTextComponent("text.rei.subsets")) + widgets.add(InternalWidgets.wrapLateRenderable(InternalWidgets.wrapTranslate(Widgets.createButton(subsetsButtonBounds, ClientHelperImpl.getInstance().isAprilFools.get() ? new TranslationTextComponent("text.rei.tiny_potato") : new TranslationTextComponent("text.rei.subsets")) .onClick(button -> { if (subsetsMenu == null) { wrappedSubsetsMenu = InternalWidgets.wrapTranslate(InternalWidgets.wrapLateRenderable(this.subsetsMenu = Menu.createSubsetsMenuFromRegistry(new Point(this.subsetsButtonBounds.x, this.subsetsButtonBounds.getMaxY()))), 0, 0, 400); @@ -340,7 +341,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl }).tooltipLine(I18n.get("text.rei.go_back_first_page")).focusable(false).onRender((matrices, label) -> { label.setClickable(ENTRY_LIST_WIDGET.getTotalPages() > 1); label.setText(new StringTextComponent(String.format("%s/%s", ENTRY_LIST_WIDGET.getPage() + 1, Math.max(ENTRY_LIST_WIDGET.getTotalPages(), 1)))); - })); + }).rainbow(new Random().nextFloat() < 1.0E-4D || ClientHelperImpl.getInstance().isAprilFools.get())); } if (ConfigObject.getInstance().isCraftableFilterEnabled()) { Rectangle area = getCraftableToggleArea(); @@ -591,10 +592,10 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl public void renderTooltipInner(MatrixStack matrices, List<IReorderingProcessor> lines, int mouseX, int mouseY) { if (lines.isEmpty()) return; - tooltipWidth = lines.stream().map(font::width).max(Integer::compareTo).get(); - tooltipHeight = lines.size() <= 1 ? 8 : lines.size() * 10; - tooltipLines = lines; - ScreenHelper.drawHoveringWidget(matrices, mouseX, mouseY, renderTooltipCallback, tooltipWidth, tooltipHeight, 0); + matrices.pushPose(); + matrices.translate(0, 0, 500); + minecraft.screen.renderTooltip(matrices, lines, mouseX, mouseY); + matrices.popPose(); } public void addTooltip(@Nullable Tooltip tooltip) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java index 9c1a414f9..e2523bb29 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java @@ -327,17 +327,18 @@ public class FilteringScreen extends Screen { } public void updateEntriesPosition() { + int entrySize = entrySize(); this.innerBounds = updateInnerBounds(getBounds()); - int width = innerBounds.width / entrySize(); - int pageHeight = innerBounds.height / entrySize(); + int width = innerBounds.width / entrySize; + int pageHeight = innerBounds.height / entrySize; int slotsToPrepare = Math.max(entryStacks.size() * 3, width * pageHeight * 3); int currentX = 0; int currentY = 0; List<EntryListEntry> entries = Lists.newArrayList(); for (int i = 0; i < slotsToPrepare; i++) { - int xPos = currentX * entrySize() + innerBounds.x; - int yPos = currentY * entrySize() + innerBounds.y; - entries.add(new EntryListEntry(xPos, yPos)); + int xPos = currentX * entrySize + innerBounds.x; + int yPos = currentY * entrySize + innerBounds.y; + entries.add(new EntryListEntry(xPos, yPos, entrySize)); currentX++; if (currentX >= width) { currentX = 0; @@ -453,10 +454,10 @@ public class FilteringScreen extends Screen { private boolean filtered = false; private boolean dirty = true; - private EntryListEntry(int x, int y) { + private EntryListEntry(int x, int y, int entrySize) { super(new Point(x, y)); this.backupY = y; - getBounds().width = getBounds().height = entrySize(); + getBounds().width = getBounds().height = entrySize; interactableFavorites(false); interactable(false); noHighlight(); diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/credits/CreditsEntryListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/credits/CreditsEntryListWidget.java index 7678b225e..855f6033a 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/credits/CreditsEntryListWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/credits/CreditsEntryListWidget.java @@ -25,12 +25,20 @@ package me.shedaniel.rei.gui.credits; import com.mojang.blaze3d.matrix.MatrixStack; import me.shedaniel.clothconfig2.forge.gui.widget.DynamicNewSmoothScrollingEntryListWidget; +import me.shedaniel.rei.impl.TextTransformations; import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.SimpleSound; import net.minecraft.client.gui.AbstractGui; import net.minecraft.util.IReorderingProcessor; +import net.minecraft.util.SoundEvents; +import net.minecraft.util.Util; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TextFormatting; import org.jetbrains.annotations.ApiStatus; +import java.net.URI; +import java.net.URISyntaxException; import java.util.List; @ApiStatus.Internal @@ -139,4 +147,66 @@ public class CreditsEntryListWidget extends DynamicNewSmoothScrollingEntryListWi } } + public static class LinkItem extends CreditsItem { + private ITextComponent text; + private List<IReorderingProcessor> textSplit; + private String link; + private boolean contains; + private boolean rainbow; + + public LinkItem(ITextComponent text, String link, int width, boolean rainbow) { + this.text = text; + this.textSplit = Minecraft.getInstance().font.split(text, width); + this.link = link; + this.rainbow = rainbow; + } + + @Override + public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { + contains = mouseX >= x && mouseX <= x + entryWidth && mouseY >= y && mouseY <= y + entryHeight; + if (contains) { + Minecraft.getInstance().screen.renderTooltip(matrices, new StringTextComponent("Click to open link."), mouseX, mouseY); + int yy = y; + for (IReorderingProcessor textSp : textSplit) { + IReorderingProcessor underlined = characterVisitor -> { + return textSp.accept((charIndex, style, codePoint) -> characterVisitor.accept(charIndex, style.applyFormat(TextFormatting.UNDERLINE), codePoint)); + }; + if (rainbow) underlined = TextTransformations.applyRainbow(underlined, x + 5, yy); + Minecraft.getInstance().font.drawShadow(matrices, underlined, x + 5, yy, 0xff1fc3ff); + yy += 12; + } + } else { + int yy = y; + for (IReorderingProcessor textSp : textSplit) { + if (rainbow) textSp = TextTransformations.applyRainbow(textSp, x + 5, yy); + Minecraft.getInstance().font.drawShadow(matrices, textSp, x + 5, yy, 0xff1fc3ff); + yy += 12; + } + } + } + + @Override + public int getItemHeight() { + return 12 * textSplit.size(); + } + + @Override + public boolean changeFocus(boolean boolean_1) { + return false; + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (contains && button == 0) { + Minecraft.getInstance().getSoundManager().play(SimpleSound.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + try { + Util.getPlatform().openUri(new URI(link)); + return true; + } catch (URISyntaxException e) { + e.printStackTrace(); + } + } + return false; + } + } } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java index 4c1a71e70..60f6a217a 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java @@ -110,6 +110,10 @@ public class CreditsScreen extends Screen { } } else entryListWidget.creditsAddEntry(new TextCreditsItem(new ImmutableLiteralText(line))); entryListWidget.creditsAddEntry(new TextCreditsItem(NarratorChatListener.NO_TITLE)); + entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(new ImmutableLiteralText("Visit the project at GitHub."), "https://www.github.com/shedaniel/RoughlyEnoughItems", entryListWidget.getItemWidth(), false)); + entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(new ImmutableLiteralText("Visit the project page at CurseForge."), "https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items", entryListWidget.getItemWidth(), false)); + entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(new ImmutableLiteralText("Support the project via Patreon!"), "https://patreon.com/shedaniel", entryListWidget.getItemWidth(), true)); + entryListWidget.creditsAddEntry(new TextCreditsItem(NarratorChatListener.NO_TITLE)); children.add(buttonDone = new AbstractButton(width / 2 - 100, height - 26, 200, 20, new TranslationTextComponent("gui.done")) { @Override public void onPress() { @@ -131,7 +135,7 @@ public class CreditsScreen extends Screen { public void render(MatrixStack matrices, int int_1, int int_2, float float_1) { this.renderDirtBackground(0); this.entryListWidget.render(matrices, int_1, int_2, float_1); - this.drawCenteredString(matrices, this.font, I18n.get("text.rei.credits"), this.width / 2, 16, 16777215); + drawCenteredString(matrices, this.font, I18n.get("text.rei.credits"), this.width / 2, 16, 16777215); super.render(matrices, int_1, int_2, float_1); buttonDone.render(matrices, int_1, int_2, float_1); } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java index 02acc94dc..14e92c0af 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java @@ -70,12 +70,12 @@ public class DefaultRuntimePlugin implements REIPluginV0 { @Override public boolean isEmpty() { - return !((ClientHelperImpl) ClientHelper.getInstance()).isAprilFools.get(); + return !ClientHelperImpl.getInstance().isAprilFools.get(); } @Override public @Nullable Tooltip getTooltip(Point point) { - return Tooltip.create(new StringTextComponent("Kibby")); + return Tooltip.create(new StringTextComponent("Kirby"), ClientHelper.getInstance().getFormattedModFromModId("Dream Land")); } }); } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListEntryWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListEntryWidget.java index b57cad0b3..1c0d32744 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListEntryWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListEntryWidget.java @@ -31,15 +31,13 @@ import me.shedaniel.rei.api.EntryStack; import net.minecraft.client.gui.screen.Screen; import net.minecraft.item.Item; -import static me.shedaniel.rei.gui.widget.EntryListWidget.entrySize; - public class EntryListEntryWidget extends EntryWidget { public int backupY; - protected EntryListEntryWidget(Point point) { + protected EntryListEntryWidget(Point point, int entrySize) { super(point); this.backupY = point.y; - getBounds().width = getBounds().height = entrySize(); + getBounds().width = getBounds().height = entrySize; } @Override diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java index 8e3c4f75d..bebf829f4 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java @@ -112,31 +112,42 @@ public class EntryListWidget extends WidgetWithBounds { return MathHelper.ceil(SIZE * ConfigObject.getInstance().getEntrySize()); } - static boolean notSteppingOnExclusionZones(int left, int top, Rectangle listArea) { + static boolean notSteppingOnExclusionZones(int left, int top, int width, int height, Rectangle listArea) { Minecraft instance = Minecraft.getInstance(); for (OverlayDecider decider : DisplayHelper.getInstance().getSortedOverlayDeciders(instance.screen.getClass())) { - ActionResultType fit = decider.isInZone(left, top); - if (fit == ActionResultType.FAIL) - return false; - ActionResultType fit2 = decider.isInZone(left + 18, top + 18); - if (fit2 == ActionResultType.FAIL) - return false; - if (fit == ActionResultType.SUCCESS && fit2 == ActionResultType.SUCCESS) - return true; + ActionResultType fit = canItemSlotWidgetFit(left, top, width, height, decider); + if (fit != ActionResultType.PASS) + return fit == ActionResultType.SUCCESS; } return true; } + private static ActionResultType canItemSlotWidgetFit(int left, int top, int width, int height, OverlayDecider decider) { + ActionResultType fit; + fit = decider.isInZone(left, top); + if (fit != ActionResultType.PASS) + return fit; + fit = decider.isInZone(left + width, top); + if (fit != ActionResultType.PASS) + return fit; + fit = decider.isInZone(left, top + height); + if (fit != ActionResultType.PASS) + return fit; + fit = decider.isInZone(left + width, top + height); + return fit; + } + private static Rectangle updateInnerBounds(Rectangle bounds) { + int entrySize = entrySize(); if (ConfigObject.getInstance().isEntryListWidgetScrolled()) { - int width = Math.max(MathHelper.floor((bounds.width - 2 - 6) / (float) entrySize()), 1); + int width = Math.max(MathHelper.floor((bounds.width - 2 - 6) / (float) entrySize), 1); if (ConfigObject.getInstance().isLeftHandSidePanel()) - 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); + 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) / (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()); + 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); } @Override @@ -234,9 +245,11 @@ public class EntryListWidget extends WidgetWithBounds { blockedCount = 0; Stream<EntryListEntry> entryStream = this.entries.stream().skip(nextIndex).filter(entry -> { - entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount); - if (entry.getBounds().y > bounds.getMaxY()) return false; - if (notSteppingOnExclusionZones(entry.getBounds().x, entry.getBounds().y, innerBounds)) { + Rectangle entryBounds = entry.getBounds(); + + entryBounds.y = (int) (entry.backupY - scrolling.scrollAmount); + if (entryBounds.y > this.bounds.getMaxY()) return false; + if (notSteppingOnExclusionZones(entryBounds.x, entryBounds.y, entryBounds.width, entryBounds.height, innerBounds)) { EntryStack stack = allStacks.get(i[0]++); if (!stack.isEmpty()) { entry.entry(stack); @@ -368,17 +381,20 @@ public class EntryListWidget extends WidgetWithBounds { } public void updateEntriesPosition() { + int entrySize = entrySize(); this.innerBounds = updateInnerBounds(bounds); if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { this.renders = Lists.newArrayList(); page = Math.max(page, 0); List<EntryListEntry> entries = Lists.newArrayList(); - int width = innerBounds.width / entrySize(); - int height = innerBounds.height / entrySize(); + 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 * entrySize() + innerBounds.x, currentY * entrySize() + innerBounds.y, innerBounds)) { - entries.add((EntryListEntry) new EntryListEntry(currentX * entrySize() + innerBounds.x, currentY * entrySize() + innerBounds.y).noBackground()); + int slotX = currentX * entrySize + innerBounds.x; + int slotY = currentY * entrySize + innerBounds.y; + if (notSteppingOnExclusionZones(slotX - 1, slotY - 1, entrySize, entrySize, innerBounds)) { + entries.add((EntryListEntry) new EntryListEntry(slotX, slotY, entrySize).noBackground()); } } } @@ -393,16 +409,16 @@ public class EntryListWidget extends WidgetWithBounds { this.widgets.addAll(entries); } else { page = 0; - int width = innerBounds.width / entrySize(); - int pageHeight = innerBounds.height / entrySize(); + int width = innerBounds.width / entrySize; + int pageHeight = innerBounds.height / entrySize; int slotsToPrepare = Math.max(allStacks.size() * 3, width * pageHeight * 3); int currentX = 0; int currentY = 0; List<EntryListEntry> entries = Lists.newArrayList(); for (int i = 0; i < slotsToPrepare; i++) { - int xPos = currentX * entrySize() + innerBounds.x; - int yPos = currentY * entrySize() + innerBounds.y; - entries.add((EntryListEntry) new EntryListEntry(xPos, yPos).noBackground()); + int xPos = currentX * entrySize + innerBounds.x; + int yPos = currentY * entrySize + innerBounds.y; + entries.add((EntryListEntry) new EntryListEntry(xPos, yPos, entrySize).noBackground()); currentX++; if (currentX >= width) { currentX = 0; @@ -531,8 +547,8 @@ public class EntryListWidget extends WidgetWithBounds { } private class EntryListEntry extends EntryListEntryWidget { - private EntryListEntry(int x, int y) { - super(new Point(x, y)); + private EntryListEntry(int x, int y, int entrySize) { + super(new Point(x, y), entrySize); } @Override diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java index c75c84700..5e7860e0d 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java @@ -84,10 +84,11 @@ public class FavoritesListWidget extends WidgetWithBounds { private boolean draggingScrollBar = false; private static Rectangle updateInnerBounds(Rectangle bounds) { - int width = Math.max(MathHelper.floor((bounds.width - 2 - 6) / (float) entrySize()), 1); + int entrySize = entrySize(); + int width = Math.max(MathHelper.floor((bounds.width - 2 - 6) / (float) entrySize), 1); if (!ConfigObject.getInstance().isLeftHandSidePanel()) - 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); + 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); } @Override @@ -119,9 +120,11 @@ public class FavoritesListWidget extends WidgetWithBounds { blockedCount = 0; Stream<EntryListEntry> entryStream = this.entries.stream().skip(nextIndex).filter(entry -> { - entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount); - if (entry.getBounds().y > bounds.getMaxY()) return false; - if (notSteppingOnExclusionZones(entry.getBounds().x, entry.getBounds().y, innerBounds)) { + Rectangle entryBounds = entry.getBounds(); + + entryBounds.y = (int) (entry.backupY - scrolling.scrollAmount); + if (entryBounds.y > this.bounds.getMaxY()) return false; + if (notSteppingOnExclusionZones(entryBounds.x, entryBounds.y, entryBounds.width, entryBounds.height, innerBounds)) { EntryStack stack = favorites.get(i[0]++); if (!stack.isEmpty()) { entry.entry(stack); @@ -242,17 +245,18 @@ public class FavoritesListWidget extends WidgetWithBounds { } public void updateEntriesPosition() { + int entrySize = entrySize(); this.innerBounds = updateInnerBounds(bounds); - int width = innerBounds.width / entrySize(); - int pageHeight = innerBounds.height / entrySize(); + int width = innerBounds.width / entrySize; + int pageHeight = innerBounds.height / entrySize; int slotsToPrepare = Math.max(favorites.size() * 3, width * pageHeight * 3); int currentX = 0; int currentY = 0; List<EntryListEntry> entries = Lists.newArrayList(); for (int i = 0; i < slotsToPrepare; i++) { - int xPos = currentX * entrySize() + innerBounds.x; - int yPos = currentY * entrySize() + innerBounds.y; - entries.add((EntryListEntry) new EntryListEntry(xPos, yPos).noBackground()); + int xPos = currentX * entrySize + innerBounds.x; + int yPos = currentY * entrySize + innerBounds.y; + entries.add((EntryListEntry) new EntryListEntry(xPos, yPos, entrySize).noBackground()); currentX++; if (currentX >= width) { currentX = 0; @@ -295,8 +299,8 @@ public class FavoritesListWidget extends WidgetWithBounds { } private class EntryListEntry extends EntryListEntryWidget { - private EntryListEntry(int x, int y) { - super(new Point(x, y)); + private EntryListEntry(int x, int y, int entrySize) { + super(new Point(x, y), entrySize); } @Override diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java index 9dcde9654..8e42df4ef 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -100,29 +100,6 @@ public class ClientHelperImpl implements ClientHelper { } @Override - public ITextComponent getFormattedModFromItem(Item item) { - String mod = getModFromItem(item); - if (mod.isEmpty()) - return NarratorChatListener.NO_TITLE; - return new StringTextComponent(mod).withStyle(TextFormatting.BLUE, TextFormatting.ITALIC); - } - - @Override - public ITextComponent getFormattedModFromIdentifier(ResourceLocation identifier) { - String mod = getModFromIdentifier(identifier); - if (mod.isEmpty()) - return NarratorChatListener.NO_TITLE; - return new StringTextComponent(mod).withStyle(TextFormatting.BLUE, TextFormatting.ITALIC); - } - - @Override - public String getModFromItem(Item item) { - if (item.equals(Items.AIR)) - return ""; - return getModFromIdentifier(Registry.ITEM.getKey(item)); - } - - @Override public String getModFromModId(String modid) { if (modid == null) return ""; @@ -292,7 +269,8 @@ public class ClientHelperImpl implements ClientHelper { @Nullable private ResourceLocation preferredOpenedCategory = null; @Nullable private EntryStack inputNotice; @Nullable private EntryStack outputNotice; - @NotNull private final LazyValue<Map<RecipeCategory<?>, List<RecipeDisplay>>> map = new LazyValue<>(() -> RecipeHelper.getInstance().buildMapFor(this)); + @NotNull + private final LazyValue<Map<RecipeCategory<?>, List<RecipeDisplay>>> map = new LazyValue<>(() -> RecipeHelper.getInstance().buildMapFor(this)); @Override public ClientHelper.ViewSearchBuilder addCategory(ResourceLocation category) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java index 111fe0398..5a3bd6168 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java @@ -377,7 +377,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } public static class Appearance { - @UseSpecialRecipeTypeScreen private RecipeScreenType recipeScreenType = RecipeScreenType.UNSET; + @UseSpecialRecipeTypeScreen private RecipeScreenType recipeScreenType = RecipeScreenType.ORIGINAL; @Comment("Declares the appearance of REI windows.") @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private AppearanceTheme theme = AppearanceTheme.LIGHT; @ConfigEntry.Gui.CollapsibleObject(startExpanded = true) diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java index 2f20dd3c8..1017717b1 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java @@ -33,7 +33,6 @@ import me.shedaniel.rei.api.ClientHelper; import me.shedaniel.rei.api.ConfigObject; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.widgets.Tooltip; -import me.shedaniel.rei.utils.FormattingUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderState; @@ -48,6 +47,7 @@ import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.registry.Registry; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; @@ -193,18 +193,12 @@ public class FluidEntryStack extends AbstractEntryStack { if (amountTooltip != null) toolTip.addAll(Stream.of(amountTooltip.split("\n")).map(StringTextComponent::new).collect(Collectors.toList())); } + if (Minecraft.getInstance().options.advancedItemTooltips) { + toolTip.add((new StringTextComponent(Registry.FLUID.getKey(this.getFluid()).toString())).withStyle(TextFormatting.DARK_GRAY)); + } toolTip.addAll(get(Settings.TOOLTIP_APPEND_EXTRA).apply(this)); if (get(Settings.TOOLTIP_APPEND_MOD).get() && ConfigObject.getInstance().shouldAppendModNames()) { - ResourceLocation id = Registry.FLUID.getKey(stack.getFluid()); - final String modId = ClientHelper.getInstance().getModFromIdentifier(id); - boolean alreadyHasMod = false; - for (ITextComponent s : toolTip) |
