Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -744,4 +744,10 @@ public static class Filtering {
public List<FilteringRule<?>> filteringRules = new ArrayList<>();
}
}

/**
* Suppresses the "partial recipe" warning permanently.
*/
public boolean hideNotFullRecipeWarning = false;

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

package me.shedaniel.rei.impl.client.gui.hints;

import me.shedaniel.rei.impl.client.config.ConfigManagerImpl;
import me.shedaniel.rei.impl.client.config.ConfigObjectImpl;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.gui.config.DisplayPanelLocation;
Expand All @@ -48,82 +50,147 @@ public class ImportantWarningsWidget extends WidgetWithBounds {
};
private static String prevId = "";
private static boolean dirty = false;

private boolean visible;
private final Rectangle bounds;
private final Rectangle buttonBounds = new Rectangle();
private List<Component> texts;

public ImportantWarningsWidget() {
if (((EntryRegistryImpl) EntryRegistry.getInstance()).listeners.add(LISTENER)) {
String newId = Minecraft.getInstance().hasSingleplayerServer() ?
"integrated:" + Minecraft.getInstance().getSingleplayerServer().getWorldData().getLevelName()
: InstanceHelper.connectionFromClient() != null ? "server:" + InstanceHelper.connectionFromClient().getId()
String newId = Minecraft.getInstance().hasSingleplayerServer()
? "integrated:" + Minecraft.getInstance().getSingleplayerServer().getWorldData().getLevelName()
: InstanceHelper.connectionFromClient() != null
? "server:" + InstanceHelper.connectionFromClient().getId()
: "null";

if (!newId.equals(prevId)) {
prevId = newId;
dirty = true;
}
dirty = dirty && !ClientHelper.getInstance().canUseMovePackets();
}

this.visible = dirty;

ConfigObjectImpl config = ConfigManagerImpl.getInstance().getConfig();

this.visible = dirty && !config.hideNotFullRecipeWarning;


this.texts = List.of(
Component.translatable("text.rei.recipes.not.full.title").withStyle(ChatFormatting.RED),
Component.translatable("text.rei.recipes.not.full.desc", Component.translatable("text.rei.recipes.not.full.desc.command").withStyle(ChatFormatting.AQUA, ChatFormatting.UNDERLINE)).withStyle(ChatFormatting.GRAY)
Component.translatable("text.rei.recipes.not.full.title")
.withStyle(ChatFormatting.RED),
Component.translatable(
"text.rei.recipes.not.full.desc",
Component.translatable("text.rei.recipes.not.full.desc.command")
.withStyle(ChatFormatting.AQUA, ChatFormatting.UNDERLINE)
).withStyle(ChatFormatting.GRAY)
);

this.bounds = ScreenRegistry.getInstance()
.getOverlayBounds(DisplayPanelLocation.LEFT, Minecraft.getInstance().screen);

this.bounds.setBounds(
this.bounds.x + 10,
this.bounds.y + 10,
this.bounds.width - 20,
this.bounds.height - 20
);
this.bounds = ScreenRegistry.getInstance().getOverlayBounds(DisplayPanelLocation.LEFT, Minecraft.getInstance().screen);
this.bounds.setBounds(this.bounds.x + 10, this.bounds.y + 10, this.bounds.width - 20, this.bounds.height - 20);

int heightRequired = -5;
for (Component text : texts) {
heightRequired += Minecraft.getInstance().font.wordWrapHeight(text, this.bounds.width * 2) / 2;
heightRequired += Minecraft.getInstance().font
.wordWrapHeight(text, this.bounds.width * 2) / 2;
heightRequired += 5;
}
this.bounds.height = Math.min(heightRequired + 20, this.bounds.height);
}

@Override
public Rectangle getBounds() {
return bounds;
}

@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
if (!visible)
return;
if (!visible) return;

graphics.pose().pushMatrix();
graphics.fill(bounds.x - 5, bounds.y - 5, bounds.getMaxX() + 5, bounds.getMaxY() + 5, 0x90111111);
graphics.fill(
bounds.x - 5,
bounds.y - 5,
bounds.getMaxX() + 5,
bounds.getMaxY() + 5,
0x90111111
);

int y = bounds.y;
for (Component text : texts) {
graphics.pose().pushMatrix();
graphics.pose().translate(bounds.x, y);
graphics.pose().scale(0.5f, 0.5f);
graphics.drawWordWrap(Minecraft.getInstance().font, text, 0, 0, bounds.width * 2, -1);
y += Minecraft.getInstance().font.wordWrapHeight(text, bounds.width * 2) / 2 + 5;
graphics.drawWordWrap(
Minecraft.getInstance().font,
text,
0,
0,
bounds.width * 2,
-1
);
y += Minecraft.getInstance().font
.wordWrapHeight(text, bounds.width * 2) / 2 + 5;
graphics.pose().popMatrix();
}

MutableComponent okayText = Component.translatable("text.rei.recipes.not.full.button.okay");

MutableComponent okayText =
Component.translatable("text.rei.recipes.not.full.button.okay");

graphics.pose().pushMatrix();
graphics.pose().translate(bounds.x + bounds.width / 2 - Minecraft.getInstance().font.width(okayText) * 0.75f / 2, bounds.getMaxY() - 9);
graphics.pose().translate(
bounds.x + bounds.width / 2f
- Minecraft.getInstance().font.width(okayText) * 0.75f / 2f,
bounds.getMaxY() - 9
);
graphics.pose().scale(0.75f, 0.75f);
this.buttonBounds.setBounds(bounds.x, bounds.getMaxY() - 20, bounds.width, 20);
graphics.drawString(Minecraft.getInstance().font, okayText, 0, 0,
buttonBounds.contains(mouseX, mouseY) ? 0xfffff8de : 0xAAFFFFFF);

this.buttonBounds.setBounds(
bounds.x,
bounds.getMaxY() - 20,
bounds.width,
20
);

graphics.drawString(
Minecraft.getInstance().font,
okayText,
0,
0,
buttonBounds.contains(mouseX, mouseY)
? 0xfffff8de
: 0xAAFFFFFF
);

graphics.pose().popMatrix();
graphics.pose().popMatrix();
}

@Override
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
if (this.visible && event.button() == 0 && buttonBounds.contains(event.x(), event.y())) {
dirty = false;
if (this.visible && event.button() == 0
&& buttonBounds.contains(event.x(), event.y())) {

this.visible = false;
dirty = false;

ConfigObjectImpl config = ConfigManagerImpl.getInstance().getConfig();
config.hideNotFullRecipeWarning = true;
ConfigManagerImpl.getInstance().saveConfig();

Widgets.produceClickSound();
return true;
}
return false;
}

@Override
public List<? extends GuiEventListener> children() {
return List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"text.rei.release_export": "Lasse %s los, um zu exportieren",
"text.rei.ask_to_export": "Möchtest du \"%s\" exportieren?",
"text.rei.ask_to_export.subtitle": "Dies wird %d Anzeigen als Bilder exportieren.",
"text.rei.recipes.not.full.button.okay": "Okay, nicht erneut anzeigen",
"text.rei.recipe_id": "\n%sRezept-Id: %s",
"text.rei.recipe_screen_type.selection": "Darstellung Rezept-Bildschirm",
"text.rei.recipe_screen_type.selection.sub": "Du kannst diese Einstellung jederzeit über den Konfigurationsbildschirm wieder bearbeiten.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"text.rei.recipes.not.full.title": "Partial Recipes Data Warning",
"text.rei.recipes.not.full.desc": "REI does not have access to all recipes data!\nHere's what you can do:\n• If you are on a vanilla server and have operator permissions, running %s will unlock some recipes.\n• If you are on a modded server, ask the server owner to install REI on the server.",
"text.rei.recipes.not.full.desc.command": "/recipe give @p *",
"text.rei.recipes.not.full.button.okay": "Okay, I understand!",
"text.rei.recipes.not.full.button.okay": "Okay, don't show it again!",
"text.rei.config.menu.dark_theme": "Dark Theme",
"text.rei.config.menu.reduced_motion": "Reduced Motion",
"text.rei.config.menu.craftable_filter": "Craftable Filter",
Expand Down