diff options
| author | shedaniel <daniel@shedaniel.me> | 2019-11-22 17:23:51 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2019-11-22 17:23:51 +0800 |
| commit | 0710ab56e7e8f76670dab785b907ccfe868ad1d5 (patch) | |
| tree | 6a8e7a6e3586bc0f679b82d5ec3ba791741cb842 /src/main/java | |
| parent | d15781a946d797a35fb00c248a3e57e2aa3414b5 (diff) | |
| download | RoughlyEnoughItems-0710ab56e7e8f76670dab785b907ccfe868ad1d5.tar.gz RoughlyEnoughItems-0710ab56e7e8f76670dab785b907ccfe868ad1d5.tar.bz2 RoughlyEnoughItems-0710ab56e7e8f76670dab785b907ccfe868ad1d5.zip | |
3.2.9
Diffstat (limited to 'src/main/java')
28 files changed, 297 insertions, 180 deletions
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index e4c79a060..c4163e1ae 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -10,6 +10,7 @@ import com.google.common.collect.Maps; import me.shedaniel.cloth.hooks.ClothClientHooks; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.*; +import me.shedaniel.rei.api.annotations.Internal; import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.widget.EntryListWidget; @@ -53,11 +54,16 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +@Internal public class RoughlyEnoughItemsCore implements ClientModInitializer { + @Internal public static final Logger LOGGER; + @SuppressWarnings("deprecation") private static final RecipeHelper RECIPE_HELPER = new RecipeHelperImpl(); + @SuppressWarnings("deprecation") private static final EntryRegistry ENTRY_REGISTRY = new EntryRegistryImpl(); + @SuppressWarnings("deprecation") private static final DisplayHelper DISPLAY_HELPER = new DisplayHelperImpl(); private static final Map<Identifier, REIPluginEntry> plugins = Maps.newHashMap(); private static final ExecutorService SYNC_RECIPES = Executors.newSingleThreadScheduledExecutor(r -> new Thread(r, "REI-SyncRecipes")); @@ -207,6 +213,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } } + @SuppressWarnings("deprecation") private void registerClothEvents() { final Identifier recipeButtonTex = new Identifier("textures/gui/recipe_button.png"); AtomicLong lastSync = new AtomicLong(-1); @@ -217,10 +224,8 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } lastSync.set(System.currentTimeMillis()); if (ConfigManager.getInstance().getConfig().doesRegisterRecipesInAnotherThread()) { - //noinspection deprecation CompletableFuture.runAsync(() -> ((RecipeHelperImpl) RecipeHelper.getInstance()).recipesLoaded(recipeManager), SYNC_RECIPES); } else { - //noinspection deprecation ((RecipeHelperImpl) RecipeHelper.getInstance()).recipesLoaded(recipeManager); } }); diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index b72e86ea0..331ab73d9 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -18,6 +18,7 @@ public interface ClientHelper { /** * @return the api instance of {@link ClientHelperImpl} */ + @SuppressWarnings("deprecation") static ClientHelper getInstance() { return ClientHelperImpl.instance; } diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index a1ccecbdb..3d14cc131 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -13,8 +13,8 @@ import java.io.IOException; public interface ConfigManager { + @SuppressWarnings("deprecation") static ConfigManager getInstance() { - //noinspection deprecation return RoughlyEnoughItemsCore.getConfigManager(); } diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java index fb5d0e66d..d6cb52a60 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -10,6 +10,7 @@ import me.shedaniel.rei.gui.config.ItemListOrdering; import me.shedaniel.rei.gui.config.RecipeScreenType; import me.shedaniel.rei.gui.config.SearchFieldLocation; import me.zeroeightsix.fiber.tree.ConfigNode; +import me.zeroeightsix.fiber.tree.ConfigValue; import me.zeroeightsix.fiber.tree.Node; public interface ConfigObject { @@ -18,6 +19,16 @@ public interface ConfigObject { ConfigNode getConfigNode(); + ConfigValue<Boolean> getOverlayVisibleNode(); + + boolean isLighterButtonHover(); + + void setLighterButtonHover(boolean lighterButtonHover); + + boolean isOverlayVisible(); + + void setOverlayVisible(boolean overlayVisible); + boolean isCheating(); void setCheating(boolean cheating); diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index de01337ea..165a61b93 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -16,8 +16,8 @@ import static net.minecraft.util.ActionResult.PASS; public interface DisplayHelper { + @SuppressWarnings("deprecation") static DisplayHelper getInstance() { - //noinspection deprecation return RoughlyEnoughItemsCore.getDisplayHelper(); } diff --git a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java index e2c66bf94..4fe71b5e3 100644 --- a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java @@ -14,6 +14,7 @@ import java.util.List; public interface EntryRegistry { + @SuppressWarnings("deprecation") static EntryRegistry getInstance() { return RoughlyEnoughItemsCore.getEntryRegistry(); } diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java index 3ddfdf7a4..cfe5b520b 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java @@ -20,8 +20,8 @@ import java.util.function.Predicate; public interface RecipeHelper { + @SuppressWarnings("deprecation") static RecipeHelper getInstance() { - //noinspection deprecation return RoughlyEnoughItemsCore.getRecipeHelper(); } @@ -115,15 +115,15 @@ public interface RecipeHelper { Map<RecipeCategory<?>, List<RecipeDisplay>> getUsagesFor(EntryStack stack); /** - * Gets the optional of the speed crafting button area from a category + * Gets the optional of the auto crafting button area from a category * * @param category the category of the display - * @return the optional of speed crafting button area + * @return the optional of auto crafting button area */ Optional<ButtonAreaSupplier> getAutoCraftButtonArea(RecipeCategory<?> category); /** - * Registers a speed crafting button area + * Registers a auto crafting button area * * @param category the category of the button area * @param rectangle the button area @@ -131,22 +131,15 @@ public interface RecipeHelper { void registerAutoCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle); /** - * Removes the speed crafting button + * Removes the auto crafting button * * @param category the category of the button */ - default void removeSpeedCraftButton(Identifier category) { + default void removeAutoCraftButton(Identifier category) { registerAutoCraftButtonArea(category, bounds -> null); } /** - * @param category the category of the button area - * @deprecated Not required anymore - */ - @Deprecated - void registerDefaultSpeedCraftButtonArea(Identifier category); - - /** * Gets the map of all recipes visible to the player * * @return the map of recipes @@ -222,3 +215,4 @@ public interface RecipeHelper { } } + diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index d33b38a67..e79890274 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -34,7 +34,6 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.container.Slot; import net.minecraft.item.ItemStack; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -73,7 +72,7 @@ public class ContainerScreenOverlay extends Widget { MatrixStack matrixStack_1 = new MatrixStack(); VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); matrixStack_1.translate(0.0D, 0.0D, getBlitOffset()); - Matrix4f matrix4f_1 = matrixStack_1.method_23760().method_23761(); + Matrix4f matrix4f_1 = matrixStack_1.peek().getModel(); for (int lineIndex = 0; lineIndex < tooltipLines.size(); lineIndex++) { font.draw(tooltipLines.get(lineIndex), x, currentY, -1, true, matrix4f_1, immediate, false, 0, 15728880); currentY += lineIndex == 0 ? 12 : 10; @@ -100,6 +99,7 @@ public class ContainerScreenOverlay extends Widget { init(false); } + @SuppressWarnings("deprecation") public void init(boolean setPage) { this.shouldReInit = false; //Update Variables @@ -112,7 +112,7 @@ public class ContainerScreenOverlay extends Widget { entryListWidget.updateList(boundsHandler, boundsHandler.getItemListArea(rectangle), page, searchTerm, false); if (!ConfigManager.getInstance().getConfig().isEntryListWidgetScrolled()) { - widgets.add(buttonLeft = new ButtonWidget(rectangle.x, rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16, new TranslatableText("text.rei.left_arrow")) { + widgets.add(buttonLeft = new ButtonWidget(new Rectangle(rectangle.x, rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), I18n.translate("text.rei.left_arrow")) { @Override public void onPressed() { page--; @@ -136,7 +136,7 @@ public class ContainerScreenOverlay extends Widget { return isNotInExclusionZones(mouseX, mouseY) && super.containsMouse(mouseX, mouseY); } }); - widgets.add(buttonRight = new ButtonWidget(rectangle.x + rectangle.width - 18, rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16, new TranslatableText("text.rei.right_arrow")) { + widgets.add(buttonRight = new ButtonWidget(new Rectangle(rectangle.x + rectangle.width - 18, rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 5, 16, 16), I18n.translate("text.rei.right_arrow")) { @Override public void onPressed() { page++; @@ -164,8 +164,8 @@ public class ContainerScreenOverlay extends Widget { if (setPage) page = MathHelper.clamp(page, 0, getTotalPage()); - - widgets.add(new ButtonWidget(ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10, 10, 20, 20, "") { + + widgets.add(new ButtonWidget(new Rectangle(ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10, 10, 20, 20), "") { @Override public void onPressed() { if (Screen.hasShiftDown()) { @@ -179,15 +179,16 @@ public class ContainerScreenOverlay extends Widget { public void render(int mouseX, int mouseY, float delta) { super.render(mouseX, mouseY, delta); GuiLighting.disable(); + Rectangle bounds = getBounds(); if (ClientHelper.getInstance().isCheating() && RoughlyEnoughItemsCore.hasOperatorPermission()) { if (RoughlyEnoughItemsCore.hasPermissionToUsePackets()) - fill(getBounds().x, getBounds().y, getBounds().x + 20, getBounds().y + 20, 721354752); + fill(bounds.x + 1, bounds.y+ 1, bounds.getMaxX() - 1, bounds.getMaxY() - 1, 721354752); else - fill(getBounds().x, getBounds().y, getBounds().x + 20, getBounds().y + 20, 1476440063); + fill(bounds.x+ 1, bounds.y+ 1, bounds.getMaxX() - 1, bounds.getMaxY() - 1, 1476440063); } MinecraftClient.getInstance().getTextureManager().bindTexture(CHEST_GUI_TEXTURE); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - blit(getBounds().x + 3, getBounds().y + 3, 0, 0, 14, 14); + blit(bounds.x + 3, bounds.y + 3, 0, 0, 14, 14); } @Override @@ -216,7 +217,7 @@ public class ContainerScreenOverlay extends Widget { } }); if (ConfigManager.getInstance().getConfig().doesShowUtilsButtons()) { - widgets.add(new ButtonWidget(ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 55 : 35, 10, 20, 20, "") { + widgets.add(new ButtonWidget(new Rectangle(ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 55 : 35, 10, 20, 20), "") { @Override public void onPressed() { MinecraftClient.getInstance().player.sendChatMessage(ConfigManager.getInstance().getConfig().getGamemodeCommand().replaceAll("\\{gamemode}", getNextGameMode(Screen.hasShiftDown()).getName())); @@ -224,7 +225,7 @@ public class ContainerScreenOverlay extends Widget { @Override public void render(int mouseX, int mouseY, float delta) { - text = getGameModeShortText(getCurrentGameMode()); + setText(getGameModeShortText(getCurrentGameMode())); super.render(mouseX, mouseY, delta); } @@ -245,7 +246,7 @@ public class ContainerScreenOverlay extends Widget { }); int xxx = ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10; for (Weather weather : Weather.values()) { - widgets.add(new ButtonWidget(xxx, 35, 20, 20, "") { + widgets.add(new ButtonWidget(new Rectangle(xxx, 35, 20, 20), "") { @Override public void onPressed() { MinecraftClient.getInstance().player.sendChatMessage(ConfigManager.getInstance().getConfig().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT))); @@ -279,11 +280,11 @@ public class ContainerScreenOverlay extends Widget { } } if (!ConfigManager.getInstance().getConfig().isEntryListWidgetScrolled()) { - widgets.add(new ClickableLabelWidget(rectangle.x + (rectangle.width / 2), rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10, "", getTotalPage() > 0) { + widgets.add(new ClickableLabelWidget(new Point(rectangle.x + (rectangle.width / 2), rectangle.y + (ConfigManager.getInstance().getConfig().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), "") { @Override public void render(int mouseX, int mouseY, float delta) { page = MathHelper.clamp(page, 0, getTotalPage()); - this.text = String.format("%s/%s", page + 1, getTotalPage() + 1); + setText(String.format("%s/%s", page + 1, getTotalPage() + 1)); super.render(mouseX, mouseY, delta); } @@ -303,11 +304,10 @@ public class ContainerScreenOverlay extends Widget { public boolean changeFocus(boolean boolean_1) { return false; } - }); + }.clickable(getTotalPage() > 0)); buttonLeft.enabled = buttonRight.enabled = getTotalPage() > 0; } if (ScreenHelper.getSearchField() == null) { - //noinspection deprecation ScreenHelper.setSearchField(new OverlaySearchField(0, 0, 0, 0)); } ScreenHelper.getSearchField().getBounds().setBounds(getTextFieldArea()); diff --git a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java index 869b401b2..0535ae957 100644 --- a/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java +++ b/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java @@ -30,7 +30,7 @@ public class OverlaySearchField extends TextFieldWidget { public void laterRender(int int_1, int int_2, float float_1) { GuiLighting.disable(); RenderSystem.disableDepthTest(); - setEditableColor(ContainerScreenOverlay.getEntryListWidget().children().isEmpty() && !getText().isEmpty() ? 16733525 : isSearching ? -1313241 : 14737632); + setEditableColor(ContainerScreenOverlay.getEntryListWidget().children().isEmpty() && !getText().isEmpty() ? 16733525 : isSearching ? -852212 : 14737632); setSuggestion(!isFocused() && getText().isEmpty() ? I18n.translate("text.rei.search.field.suggestion") : null); super.render(int_1, int_2, float_1); RenderSystem.enableDepthTest(); @@ -41,7 +41,7 @@ public class OverlaySearchField extends TextFieldWidget { if (!isSearching) super.renderBorder(); else if (this.hasBorder()) { - fill(this.getBounds().x - 1, this.getBounds().y - 1, this.getBounds().x + this.getBounds().width + 1, this.getBounds().y + this.getBounds().height + 1, -1313241); + fill(this.getBounds().x - 1, this.getBounds().y - 1, this.getBounds().x + this.getBounds().width + 1, this.getBounds().y + this.getBounds().height + 1, -852212); fill(this.getBounds().x, this.getBounds().y, this.getBounds().x + this.getBounds().width, this.getBounds().y + this.getBounds().height, -16777216); } } diff --git a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java index fda8ce246..e9226eea3 100644 --- a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java @@ -51,7 +51,7 @@ public class PreRecipeViewingScreen extends Screen { protected void init() { this.children.clear(); this.widgets.clear(); - this.widgets.add(new ButtonWidget(width / 2 - 100, height - 40, 200, 20, I18n.translate("text.rei.select")) { + this.widgets.add(new ButtonWidget(new Rectangle(width / 2 - 100, height - 40, 200, 20), I18n.translate("text.rei.select")) { @Override public void onPressed() { ConfigManager.getInstance().getConfig().setRecipeScreenType(original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER); diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index 4e1e98700..8ff213334 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -7,6 +7,7 @@ package me.shedaniel.rei.gui; import com.google.common.collect.Lists; import com.mojang.blaze3d.systems.RenderSystem; +import me.shedaniel.math.api.Point; import me.shedaniel.math.api.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.*; @@ -22,7 +23,6 @@ import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.Window; import net.minecraft.sound.SoundEvents; import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -129,7 +129,7 @@ public class RecipeViewingScreen extends Screen { this.page = MathHelper.clamp(page, 0, getTotalPages(selectedCategory) - 1); ButtonWidget w, w2; - this.widgets.add(w = new ButtonWidget(bounds.x + 2, bounds.y - 16, 10, 10, new TranslatableText("text.rei.left_arrow")) { + 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--; @@ -138,7 +138,7 @@ public class RecipeViewingScreen extends Screen { RecipeViewingScreen.this.init(); } }); - this.widgets.add(w2 = new ButtonWidget(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10, new TranslatableText("text.rei.right_arrow")) { + this.widgets.add(w2 = new ButtonWidget(new Rectangle(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10), I18n.translate("text.rei.right_arrow")) { @Override public void onPressed() { categoryPages++; @@ -148,7 +148,7 @@ public class RecipeViewingScreen extends Screen { } }); w.enabled = w2.enabled = categories.size() > TABS_PER_PAGE; - widgets.add(categoryBack = new ButtonWidget(bounds.getX() + 5, bounds.getY() + 5, 12, 12, new TranslatableText("text.rei.left_arrow")) { + 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() { int currentCategoryIndex = categories.indexOf(selectedCategory); @@ -166,10 +166,10 @@ public class RecipeViewingScreen extends Screen { return Optional.ofNullable(I18n.translate("text.rei.previous_category")); } }); - widgets.add(new ClickableLabelWidget(bounds.getCenterX(), bounds.getY() + 7, "") { + widgets.add(new ClickableLabelWidget(new Point(bounds.getCenterX(), bounds.getY() + 7), "") { @Override public void render(int mouseX, int mouseY, float delta) { - this.text = selectedCategory.getCategoryName(); + setText(selectedCategory.getCategoryName()); super.render(mouseX, mouseY, delta); } @@ -184,7 +184,7 @@ public class RecipeViewingScreen extends Screen { ClientHelper.getInstance().executeViewAllRecipesKeyBind(); } }); - widgets.add(categoryNext = new ButtonWidget(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12, new TranslatableText("text.rei.right_arrow")) { + widgets.add(categoryNext = new ButtonWidget(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 5, 12, 12), I18n.translate("text.rei.right_arrow")) { @Override public void onPressed() { int currentCategoryIndex = categories.indexOf(selectedCategory); @@ -205,7 +205,7 @@ public class RecipeViewingScreen extends Screen { categoryBack.enabled = categories.size() > 1; categoryNext.enabled = categories.size() > 1; - widgets.add(recipeBack = new ButtonWidget(bounds.getX() + 5, bounds.getY() + 21, 12, 12, new TranslatableText("text.rei.left_arrow")) { + widgets.add(recipeBack = new ButtonWidget(new Rectangle(bounds.getX() + 5, bounds.getY() + 21, 12, 12), I18n.translate("text.rei.left_arrow")) { @Override public void onPressed() { page--; @@ -219,10 +219,10 @@ public class RecipeViewingScreen extends Screen { return Optional.ofNullable(I18n.translate("text.rei.previous_page")); } }); - widgets.add(new ClickableLabelWidget(bounds.getCenterX(), bounds.getY() + 23, "", categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight()) { + widgets.add(new ClickableLabelWidget(new Point(bounds.getCenterX(), bounds.getY() + 23), "") { @Override public void render(int mouseX, int mouseY, float delta) { - this.text = String.format("%d/%d", page + 1, getTotalPages(selectedCategory)); + setText(String.format("%d/%d", page + 1, getTotalPages(selectedCategory))); super.render(mouseX, mouseY, delta); } @@ -237,8 +237,8 @@ public class RecipeViewingScreen extends Screen { RecipeViewingScreen.this.choosePageActivated = true; RecipeViewingScreen.this.init(); } - }); - widgets.add(recipeNext = new ButtonWidget(bounds.getMaxX() - 17, bounds.getY() + 21, 12, 12, new TranslatableText("text.rei.right_arrow")) { + }.clickable(categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight())); + widgets.add(recipeNext = new ButtonWidget(new Rectangle(bounds.getMaxX() - 17, bounds.getY() + 21, 12, 12), I18n.translate("text.rei.right_arrow")) { @Override public void onPressed() { page++; diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index 2abae2b1f..b6579bab8 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -12,6 +12,7 @@ import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget.Interpolation; import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget.Precision; +import me.shedaniel.math.api.Point; import me.shedaniel.math.api.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.*; @@ -138,7 +139,7 @@ public class VillagerRecipeViewingScreen extends Screen { int finalIndex = index; RecipeEntry recipeEntry; recipeRenderers.add(recipeEntry = category.getSimpleRenderer(recipeDisplay)); - buttonWidgets.add(new ButtonWidget(bounds.x + 5, 0, recipeEntry.getWidth(), recipeEntry.getHeight(), "") { + buttonWidgets.add(new ButtonWidget(new Rectangle(bounds.x + 5, 0, recipeEntry.getWidth(), recipeEntry.getHeight()), "") { @Override public void onPressed() { selectedRecipeIndex = finalIndex; @@ -192,7 +193,7 @@ public class VillagerRecipeViewingScreen extends Screen { } } ButtonWidget w, w2; - this.widgets.add(w = new ButtonWidget(bounds.x + 2, bounds.y - 16, 10, 10, new TranslatableText("text.rei.left_arrow")) { + this.widgets.add(w = new ButtonWidget(new Rectangle(bounds.x + 2, bounds.y - |
