From 721ea24a226c2dca5cfef4b3f638d251547df0b8 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 4 Aug 2019 22:11:07 +0800 Subject: yes thank you --- .../me/shedaniel/rei/RoughlyEnoughItemsCore.java | 6 +- .../java/me/shedaniel/rei/api/ItemRegistry.java | 2 +- .../java/me/shedaniel/rei/api/PluginDisabler.java | 4 +- .../me/shedaniel/rei/api/plugins/REIPluginV0.java | 23 +++-- .../rei/client/BaseBoundsHandlerImpl.java | 6 +- .../me/shedaniel/rei/client/ClientHelperImpl.java | 2 +- .../me/shedaniel/rei/client/ConfigManagerImpl.java | 2 +- .../java/me/shedaniel/rei/client/ConfigObject.java | 21 +++-- .../me/shedaniel/rei/client/ItemRegistryImpl.java | 2 +- .../me/shedaniel/rei/client/RecipeHelperImpl.java | 34 +++---- .../me/shedaniel/rei/client/SearchArgument.java | 32 +------ src/main/java/me/shedaniel/rei/client/Weather.java | 2 +- .../shedaniel/rei/gui/ContainerScreenOverlay.java | 102 ++++++++++----------- .../shedaniel/rei/gui/PreRecipeViewingScreen.java | 4 +- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 16 ++-- .../rei/gui/VillagerRecipeViewingScreen.java | 16 ++-- .../shedaniel/rei/gui/credits/CreditsScreen.java | 6 +- .../shedaniel/rei/gui/renderers/EmptyRenderer.java | 2 +- .../rei/gui/renderers/ItemStackRenderer.java | 2 +- .../rei/gui/renderers/SimpleRecipeRenderer.java | 8 +- .../rei/gui/widget/AutoCraftingButtonWidget.java | 4 +- .../me/shedaniel/rei/gui/widget/ButtonWidget.java | 2 +- .../shedaniel/rei/gui/widget/DraggableWidget.java | 7 +- .../shedaniel/rei/gui/widget/ItemListOverlay.java | 20 ++-- .../shedaniel/rei/gui/widget/RecipeBaseWidget.java | 4 +- .../rei/gui/widget/RecipeChoosePageWidget.java | 6 +- .../shedaniel/rei/gui/widget/TextFieldWidget.java | 2 +- .../rei/mixin/MixinBrewingRecipeRegistry.java | 9 +- .../me/shedaniel/rei/plugin/DefaultPlugin.java | 52 +++++------ .../plugin/DefaultPotionEffectExclusionZones.java | 2 +- .../rei/plugin/brewing/DefaultBrewingDisplay.java | 4 +- .../composting/DefaultCompostingCategory.java | 4 +- .../plugin/crafting/DefaultCraftingCategory.java | 6 +- .../rei/plugin/crafting/DefaultCustomDisplay.java | 2 +- .../plugin/stripping/DefaultStrippingCategory.java | 1 - .../plugin/stripping/DefaultStrippingDisplay.java | 18 ++-- .../rei/plugin/stripping/DummyAxeItem.java | 7 +- .../shedaniel/rei/utils/ClothScreenRegistry.java | 10 +- 38 files changed, 225 insertions(+), 227 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 36652cf4d..ad910dcfd 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -99,7 +99,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } public static Optional getPluginIdentifier(REIPluginEntry plugin) { - for(Identifier identifier : plugins.keySet()) + for (Identifier identifier : plugins.keySet()) if (identifier != null && plugins.get(identifier).equals(plugin)) return Optional.of(identifier); return Optional.empty(); @@ -145,7 +145,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { @SuppressWarnings("deprecation") private void discoverPluginEntries() { - for(REIPluginEntry reiPlugin : FabricLoader.getInstance().getEntrypoints("rei_plugins", REIPluginEntry.class)) { + for (REIPluginEntry reiPlugin : FabricLoader.getInstance().getEntrypoints("rei_plugins", REIPluginEntry.class)) { try { if (!REIPluginV0.class.isAssignableFrom(reiPlugin.getClass())) throw new IllegalArgumentException("REI plugin is too old!"); @@ -179,7 +179,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { return; ScreenHelper.setLastContainerScreen((AbstractContainerScreen) screen); boolean alreadyAdded = false; - for(Element element : Lists.newArrayList(screenHooks.cloth_getInputListeners())) + for (Element element : Lists.newArrayList(screenHooks.cloth_getInputListeners())) if (ContainerScreenOverlay.class.isAssignableFrom(element.getClass())) if (alreadyAdded) screenHooks.cloth_getInputListeners().remove(element); diff --git a/src/main/java/me/shedaniel/rei/api/ItemRegistry.java b/src/main/java/me/shedaniel/rei/api/ItemRegistry.java index 93b4510eb..5c55ae3ac 100644 --- a/src/main/java/me/shedaniel/rei/api/ItemRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/ItemRegistry.java @@ -50,7 +50,7 @@ public interface ItemRegistry { * @param stacks the stacks to register */ default void registerItemStack(Item afterItem, ItemStack... stacks) { - for(int i = stacks.length - 1; i >= 0; i--) { + for (int i = stacks.length - 1; i >= 0; i--) { ItemStack stack = stacks[i]; if (stack != null && !stack.isEmpty()) registerItemStack(afterItem, stack); diff --git a/src/main/java/me/shedaniel/rei/api/PluginDisabler.java b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java index 231db17ad..e58a0cfd7 100644 --- a/src/main/java/me/shedaniel/rei/api/PluginDisabler.java +++ b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java @@ -16,7 +16,7 @@ public interface PluginDisabler { * @param functions the array of functions to be disabled */ default void disablePluginFunctions(Identifier plugin, PluginFunction... functions) { - for(PluginFunction function : functions) + for (PluginFunction function : functions) disablePluginFunction(plugin, function); } @@ -27,7 +27,7 @@ public interface PluginDisabler { * @param functions the array of functions to be enabled */ default void enablePluginFunctions(Identifier plugin, PluginFunction... functions) { - for(PluginFunction function : functions) + for (PluginFunction function : functions) enablePluginFunction(plugin, function); } diff --git a/src/main/java/me/shedaniel/rei/api/plugins/REIPluginV0.java b/src/main/java/me/shedaniel/rei/api/plugins/REIPluginV0.java index 414f6ea3e..6211e0672 100644 --- a/src/main/java/me/shedaniel/rei/api/plugins/REIPluginV0.java +++ b/src/main/java/me/shedaniel/rei/api/plugins/REIPluginV0.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api.plugins; import me.shedaniel.rei.api.*; @@ -13,41 +18,47 @@ public interface REIPluginV0 extends REIPluginEntry { * * @param pluginDisabler the helper class to disable other plugins */ - default void onFirstLoad(PluginDisabler pluginDisabler) {} + default void onFirstLoad(PluginDisabler pluginDisabler) { + } /** * Registers items on the item panel * * @param itemRegistry the helper class */ - default void registerItems(ItemRegistry itemRegistry) {} + default void registerItems(ItemRegistry itemRegistry) { + } /** * Registers categories * * @param recipeHelper the helper class */ - default void registerPluginCategories(RecipeHelper recipeHelper) {} + default void registerPluginCategories(RecipeHelper recipeHelper) { + } /** * Registers displays for categories * * @param recipeHelper the helper class */ - default void registerRecipeDisplays(RecipeHelper recipeHelper) {} + default void registerRecipeDisplays(RecipeHelper recipeHelper) { + } /** * Registers bounds handlers * * @param displayHelper the helper class */ - default void registerBounds(DisplayHelper displayHelper) {} + default void registerBounds(DisplayHelper displayHelper) { + } /** * Register other stuff * * @param recipeHelper the helper class */ - default void registerOthers(RecipeHelper recipeHelper) {} + default void registerOthers(RecipeHelper recipeHelper) { + } } diff --git a/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java b/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java index e66bc3279..dfef934e7 100644 --- a/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java +++ b/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java @@ -55,7 +55,7 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler { @Override public ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) { - for(Rectangle zone : getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide)) + for (Rectangle zone : getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide)) if (zone.contains(mouseX, mouseY)) return ActionResult.FAIL; return ActionResult.PASS; @@ -81,7 +81,7 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler { @Override public ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, Screen screen, Rectangle fullBounds) { List currentExclusionZones = getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide); - for(Rectangle currentExclusionZone : currentExclusionZones) + for (Rectangle currentExclusionZone : currentExclusionZones) if (left + 18 >= currentExclusionZone.x && top + 18 >= currentExclusionZone.y && left <= currentExclusionZone.x + currentExclusionZone.width && top <= currentExclusionZone.y + currentExclusionZone.height) return ActionResult.FAIL; return ActionResult.PASS; @@ -102,7 +102,7 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler { public long getLongFromAreas(Rectangle rectangle, List exclusionZones) { long a = RECTANGLE_LONG_FUNCTION.apply(rectangle); - for(Rectangle exclusionZone : exclusionZones) + for (Rectangle exclusionZone : exclusionZones) a -= RECTANGLE_LONG_FUNCTION.apply(exclusionZone); return a; } diff --git a/src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java b/src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java index 409d8815a..b05f5d15e 100644 --- a/src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java @@ -220,7 +220,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer { @Override public boolean executeViewAllRecipesFromCategories(List categories) { Map, List> map = Maps.newLinkedHashMap(); - for(Identifier category : categories) { + for (Identifier category : categories) { Optional any = RecipeHelper.getInstance().getAllCategories().stream().filter(c -> c.getIdentifier().equals(category)).findAny(); if (!any.isPresent()) continue; diff --git a/src/main/java/me/shedaniel/rei/client/ConfigManagerImpl.java b/src/main/java/me/shedaniel/rei/client/ConfigManagerImpl.java index 8552ad774..587eae8ce 100644 --- a/src/main/java/me/shedaniel/rei/client/ConfigManagerImpl.java +++ b/src/main/java/me/shedaniel/rei/client/ConfigManagerImpl.java @@ -149,7 +149,7 @@ public class ConfigManagerImpl implements ConfigManager { renderDirtBackground(0); List list = minecraft.textRenderer.wrapStringToWidthAsList(I18n.translate("text.rei.config_api_failed"), width - 100); int y = (int) (height / 2 - minecraft.textRenderer.fontHeight * 1.3f / 2 * list.size()); - for(int i = 0; i < list.size(); i++) { + for (int i = 0; i < list.size(); i++) { String s = list.get(i); drawCenteredString(minecraft.textRenderer, s, width / 2, y, -1); y += minecraft.textRenderer.fontHeight; diff --git a/src/main/java/me/shedaniel/rei/client/ConfigObject.java b/src/main/java/me/shedaniel/rei/client/ConfigObject.java index eadc9532a..11803a325 100644 --- a/src/main/java/me/shedaniel/rei/client/ConfigObject.java +++ b/src/main/java/me/shedaniel/rei/client/ConfigObject.java @@ -17,7 +17,8 @@ public class ConfigObject { @Comment("The ordering of the items on the item panel.") public ItemListOrdering itemListOrdering = ItemListOrdering.registry; - @Comment("The ordering of the items on the item panel.") public boolean isAscending = true; + @Comment("The ordering of the items on the item panel.") + public boolean isAscending = true; @Comment("To toggle the craftable button next to the search field.") public boolean enableCraftableOnlyButton = false; @@ -28,20 +29,26 @@ public class ConfigObject { @Comment("The command used in servers to cheat items") public String giveCommand = "/minecraft:give {player_name} {item_identifier}{nbt} {count}"; - @Comment("The command used to change gamemode") public String gamemodeCommand = "/gamemode {gamemode}"; + @Comment("The command used to change gamemode") + public String gamemodeCommand = "/gamemode {gamemode}"; - @Comment("The command used to change weather") public String weatherCommand = "/weather {weather}"; + @Comment("The command used to change weather") + public String weatherCommand = "/weather {weather}"; - @Comment("True: item panel on the left, false: on the right") public boolean mirrorItemPanel = false; + @Comment("True: item panel on the left, false: on the right") + public boolean mirrorItemPanel = false; @Comment("To disable REI's default plugin, don't change this unless you understand what you are doing") public boolean loadDefaultPlugin = true; - @Comment("Maximum recipes viewed at one time.") public int maxRecipePerPage = 3; + @Comment("Maximum recipes viewed at one time.") + public int maxRecipePerPage = 3; - @Comment("Toggle utils buttons") public boolean showUtilsButtons = false; + @Comment("Toggle utils buttons") + public boolean showUtilsButtons = false; - @Comment("Disable Recipe Book") public boolean disableRecipeBook = false; + @Comment("Disable Recipe Book") + public boolean disableRecipeBook = false; public ItemCheatingMode itemCheatingMode = ItemCheatingMode.REI_LIKE; diff --git a/src/main/java/me/shedaniel/rei/client/ItemRegistryImpl.java b/src/main/java/me/shedaniel/rei/client/ItemRegistryImpl.java index 91b16e873..81bdffad1 100644 --- a/src/main/java/me/shedaniel/rei/client/ItemRegistryImpl.java +++ b/src/main/java/me/shedaniel/rei/client/ItemRegistryImpl.java @@ -49,7 +49,7 @@ public class ItemRegistryImpl implements ItemRegistry { itemList.add(stack); else { int last = itemList.size(); - for(int i = 0; i < itemList.size(); i++) + for (int i = 0; i < itemList.size(); i++) if (itemList.get(i).getItem().equals(afterItem)) last = i + 1; itemList.add(last, stack); diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java index 492aa8b7c..979776040 100644 --- a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java @@ -58,18 +58,18 @@ public class RecipeHelperImpl implements RecipeHelper { @Override public List findCraftableByItems(List inventoryItems) { List craftables = new ArrayList<>(); - for(List value : recipeCategoryListMap.values()) - for(RecipeDisplay recipeDisplay : value) { + for (List value : recipeCategoryListMap.values()) + for (RecipeDisplay recipeDisplay : value) { int slotsCraftable = 0; List> requiredInput = (List>) recipeDisplay.getRequiredItems(); - for(List slot : requiredInput) { + for (List slot : requiredInput) { if (slot.isEmpty()) { slotsCraftable++; continue; } boolean slotDone = false; - for(ItemStack possibleType : inventoryItems) { - for(ItemStack slotPossible : slot) + for (ItemStack possibleType : inventoryItems) { + for (ItemStack slotPossible : slot) if (ItemStack.areItemsEqualIgnoreDamage(slotPossible, possibleType)) { slotsCraftable++; slotDone = true; @@ -126,21 +126,21 @@ public class RecipeHelperImpl implements RecipeHelper { public Map, List> getRecipesFor(ItemStack stack) { Map> categoriesMap = new HashMap<>(); categories.forEach(f -> categoriesMap.put(f.getIdentifier(), Lists.newArrayList())); - for(Map.Entry> entry : recipeCategoryListMap.entrySet()) { + for (Map.Entry> entry : recipeCategoryListMap.entrySet()) { RecipeCategory category = getCategory(entry.getKey()); - for(RecipeDisplay recipeDisplay : entry.getValue()) - for(ItemStack outputStack : (List) recipeDisplay.getOutput()) + for (RecipeDisplay recipeDisplay : entry.getValue()) + for (ItemStack outputStack : (List) recipeDisplay.getOutput()) if (category.checkTags() ? ItemStack.areEqualIgnoreDamage(stack, outputStack) : ItemStack.areItemsEqualIgnoreDamage(stack, outputStack)) categoriesMap.get(recipeDisplay.getRecipeCategory()).add(recipeDisplay); } - for(LiveRecipeGenerator liveRecipeGenerator : liveRecipeGenerators) + for (LiveRecipeGenerator liveRecipeGenerator : liveRecipeGenerators) ((Optional) liveRecipeGenerator.getRecipeFor(stack)).ifPresent(o -> categoriesMap.get(liveRecipeGenerator.getCategoryIdentifier()).addAll(o)); Map, List> recipeCategoryListMap = Maps.newLinkedHashMap(); categories.forEach(category -> { if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty()) recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier()).stream().filter(display -> isDisplayVisible(display)).collect(Collectors.toList())); }); - for(RecipeCategory category : Lists.newArrayList(recipeCategoryListMap.keySet())) + for (RecipeCategory category : Lists.newArrayList(recipeCategoryListMap.keySet())) if (recipeCategoryListMap.get(category).isEmpty()) recipeCategoryListMap.remove(category); return recipeCategoryListMap; @@ -160,12 +160,12 @@ public class RecipeHelperImpl implements RecipeHelper { public Map, List> getUsagesFor(ItemStack stack) { Map> categoriesMap = new HashMap<>(); categories.forEach(f -> categoriesMap.put(f.getIdentifier(), Lists.newArrayList())); - for(Map.Entry> entry : recipeCategoryListMap.entrySet()) { + for (Map.Entry> entry : recipeCategoryListMap.entrySet()) { RecipeCategory category = getCategory(entry.getKey()); - for(RecipeDisplay recipeDisplay : entry.getValue()) { + for (RecipeDisplay recipeDisplay : entry.getValue()) { boolean found = false; - for(List input : (List>) recipeDisplay.getInput()) { - for(ItemStack itemStack : input) { + for (List input : (List>) recipeDisplay.getInput()) { + for (ItemStack itemStack : input) { if (category.checkTags() ? ItemStack.areEqualIgnoreDamage(itemStack, stack) : ItemStack.areItemsEqualIgnoreDamage(itemStack, stack)) { categoriesMap.get(recipeDisplay.getRecipeCategory()).add(recipeDisplay); found = true; @@ -177,14 +177,14 @@ public class RecipeHelperImpl implements RecipeHelper { } } } - for(LiveRecipeGenerator liveRecipeGenerator : liveRecipeGenerators) + for (LiveRecipeGenerator liveRecipeGenerator : liveRecipeGenerators) ((Optional) liveRecipeGenerator.getUsageFor(stack)).ifPresent(o -> categoriesMap.get(liveRecipeGenerator.getCategoryIdentifier()).addAll(o)); Map, List> recipeCategoryListMap = Maps.newLinkedHashMap(); categories.forEach(category -> { if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty()) recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier()).stream().filter(display -> isDisplayVisible(display)).collect(Collectors.toList())); }); - for(RecipeCategory category : Lists.newArrayList(recipeCategoryListMap.keySet())) + for (RecipeCategory category : Lists.newArrayList(recipeCategoryListMap.keySet())) if (recipeCategoryListMap.get(category).isEmpty()) recipeCategoryListMap.remove(category); return recipeCategoryListMap; @@ -367,7 +367,7 @@ public class RecipeHelperImpl implements RecipeHelper { public boolean isDisplayVisible(RecipeDisplay display) { RecipeCategory category = getCategory(display.getRecipeCategory()); List list = getDisplayVisibilityHandlers().stream().sorted(VISIBILITY_HANDLER_COMPARATOR).collect(Collectors.toList()); - for(DisplayVisibilityHandler displayVisibilityHandler : list) { + for (DisplayVisibilityHandler displayVisibilityHandler : list) { try { ActionResult visibility = displayVisibilityHandler.handleDisplay(category, display); if (visibility != ActionResult.PASS) diff --git a/src/main/java/me/shedaniel/rei/client/SearchArgument.java b/src/main/java/me/shedaniel/rei/client/SearchArgument.java index c71ed8913..2cf8ef415 100644 --- a/src/main/java/me/shedaniel/rei/client/SearchArgument.java +++ b/src/main/java/me/shedaniel/rei/client/SearchArgument.java @@ -5,8 +5,6 @@ package me.shedaniel.rei.client; -import com.google.common.base.CharMatcher; - import java.util.Locale; import java.util.function.Function; @@ -15,8 +13,8 @@ public class SearchArgument { public static final SearchArgument ALWAYS = new SearchArgument(ArgumentType.ALWAYS, "", true); private ArgumentType argumentType; private String text; - public final Function INCLUDE = s -> search(text, s); - public final Function NOT_INCLUDE = s -> !search(text, s); + public final Function INCLUDE = s -> s.contains(text); + public final Function NOT_INCLUDE = s -> !s.contains(text); private boolean include; public SearchArgument(ArgumentType argumentType, String text, boolean include) { @@ -29,32 +27,6 @@ public class SearchArgument { this.include = include; } - public static boolean search(CharSequence pattern, String text) { - int patternLength = pattern.length(); - if (patternLength == 0) - return true; - if (patternLength > text.length()) - return false; - if (!CharMatcher.ascii().matchesAllOf(text) || !CharMatcher.ascii().matchesAllOf(pattern)) - return text.contains(pattern); - int shift[] = new int[256]; - for(int k = 0; k < 256; k++) - shift[k] = patternLength; - for(int k = 0; k < patternLength - 1; k++) - shift[pattern.charAt(k)] = patternLength - 1 - k; - int i = 0, j = 0; - while ((i + patternLength) <= text.length()) { - j = patternLength - 1; - while (text.charAt(i + j) == pattern.charAt(j)) { - j -= 1; - if (j < 0) - return i >= 0; - } - i = i + shift[text.charAt(i + patternLength - 1)]; - } - return false; - } - public Function getFunction(boolean include) { return include ? INCLUDE : NOT_INCLUDE; } diff --git a/src/main/java/me/shedaniel/rei/client/Weather.java b/src/main/java/me/shedaniel/rei/client/Weather.java index e3720a33f..466939992 100644 --- a/src/main/java/me/shedaniel/rei/client/Weather.java +++ b/src/main/java/me/shedaniel/rei/client/Weather.java @@ -26,7 +26,7 @@ public enum Weather { Weather[] var2 = values(); int var3 = var2.length; - for(int var4 = 0; var4 < var3; ++var4) { + for (int var4 = 0; var4 < var3; ++var4) { Weather gameMode_2 = var2[var4]; if (gameMode_2.id == int_1) return gameMode_2; diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index e43a5dc54..33daab37d 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -44,7 +44,7 @@ import java.util.*; import java.util.stream.Collectors; public class ContainerScreenOverlay extends AbstractParentElement implements Drawable { - + private static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png"); private static final List QUEUED_TOOLTIPS = Lists.newArrayList(); public static String searchTerm = ""; @@ -56,15 +56,15 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra private Window window; private CraftableToggleButtonWidget toggleButtonWidget; private ButtonWidget buttonLeft, buttonRight; - + public static ItemListOverlay getItemListOverlay() { return itemListOverlay; } - + public void init() { init(false); } - + public void init(boolean setPage) { this.shouldReInit = false; //Update Variables @@ -74,7 +74,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra this.rectangle = RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel ? boundsHandler.getLeftBounds(MinecraftClient.getInstance().currentScreen) : boundsHandler.getRightBounds(MinecraftClient.getInstance().currentScreen); widgets.add(itemListOverlay = new ItemListOverlay(page)); itemListOverlay.updateList(boundsHandler, boundsHandler.getItemListArea(rectangle), page, searchTerm, false); - + widgets.add(buttonLeft = new ButtonWidget(rectangle.x, rectangle.y + 5, 16, 16, new TranslatableText("text.rei.left_arrow")) { @Override public void onPressed() { @@ -83,12 +83,12 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra page = getTotalPage(); itemListOverlay.updateList(boundsHandler, boundsHandler.getItemListArea(rectangle), page, searchTerm, false); } - + @Override public Optional getTooltips() { return Optional.ofNullable(I18n.translate("text.rei.previous_page")); } - + @Override public boolean changeFocus(boolean boolean_1) { return false; @@ -102,21 +102,21 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra page = 0; itemListOverlay.updateList(boundsHandler, boundsHandler.getItemListArea(rectangle), page, searchTerm, false); } - + @Override public Optional getTooltips() { return Optional.ofNullable(I18n.translate("text.rei.next_page")); } - + @Override public boolean changeFocus(boolean boolean_1) { return false; } }); - + if (setPage) page = MathHelper.clamp(page, 0, getTotalPage()); - + widgets.add(new ButtonWidget(RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel ? window.getScaledWidth() - 30 : 10, 10, 20, 20, "") { @Override public void onPressed() { @@ -126,7 +126,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra } RoughlyEnoughItemsCore.getConfigManager().openConfigScreen(ScreenHelper.getLastContainerScreen()); } - + @Override public void render(int mouseX, int mouseY, float delta) { super.render(mouseX, mouseY, delta); @@ -141,7 +141,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); blit(getBounds().x + 3, getBounds().y + 3, 0, 0, 14, 14); } - + @Override public Optional getTooltips() { String tooltips = I18n.translate("text.rei.config_tooltip"); @@ -156,7 +156,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra tooltips += "\n" + I18n.translate("text.rei.cheating_limited_enabled"); return Optional.ofNullable(tooltips); } - + @Override public boolean changeFocus(boolean boolean_1) { return false; @@ -168,18 +168,18 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra public void onPressed() { MinecraftClient.getInstance().player.sendChatMessage(RoughlyEnoughItemsCore.getConfigManager().getConfig().gamemodeCommand.replaceAll("\\{gamemode}", getNextGameMode(Screen.hasShiftDown()).getName())); } - + @Override public void render(int mouseX, int mouseY, float delta) { text = getGameModeShortText(getCurrentGameMode()); super.render(mouseX, mouseY, delta); } - + @Override public Optional getTooltips() { return Optional.ofNullable(I18n.translate("text.rei.gamemode_button.tooltip", getGameModeText(getNextGameMode(Screen.hasShiftDown())))); } - + @Override public boolean changeFocus(boolean boolean_1) { return false; @@ -192,7 +192,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra public void onPressed() { MinecraftClient.getInstance().player.sendChatMessage(RoughlyEnoughItemsCore.getConfigManager().getConfig().weatherCommand.replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT))); } - + @Override public void render(int mouseX, int mouseY, float delta) { super.render(mouseX, mouseY, delta); @@ -201,12 +201,12 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); blit(getBounds().x + 3, getBounds().y + 3, weather.getId() * 14, 14, 14, 14); } - + @Override public Optional getTooltips() { return Optional.ofNullable(I18n.translate("text.rei.weather_button.tooltip", I18n.translate(weather.getTranslateKey()))); } - + @Override public boolean changeFocus(boolean boolean_1) { return false; @@ -222,19 +222,19 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra this.text = String.format("%s/%s", page + 1, getTotalPage() + 1); super.render(mouseX, mouseY, delta); } - + @Override public Optional getTooltips() { return Optional.ofNullable(I18n.translate("text.rei.go_back_first_page")); } - + @Override public void onLabelClicked() { MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); page = 0; itemListOverlay.updateList(boundsHandler, boundsHandler.getItemListArea(rectangle), page, searchTerm, false); } - + @Override public boolean changeFocus(boolean boolean_1) { return false; @@ -257,7 +257,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra RoughlyEnoughItemsCore.getConfigManager().toggleCraftableOnly(); itemListOverlay.updateList(boundsHandler, boundsHandler.getItemListArea(rectangle), page, searchTerm, true); } - + @Override public void lateRender(int mouseX, int mouseY, float delta) { blitOffset = 300; @@ -268,7 +268,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra toggleButtonWidget = null; this.itemListOverlay.updateList(boundsHandler, boundsHandler.getItemListArea(rectangle), page, searchTerm, false); } - + private Weather getNextWeather() { try { Weather current = getCurrentWeather(); @@ -280,7 +280,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra return Weather.CLEAR; } } - + private Weather getCurrentWeather() { ClientWorld world = MinecraftClient.getInstance().world; if (world.isThundering()) @@ -289,15 +289,15 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra return Weather.RAIN; return Weather.CLEAR; } - + private String getGameModeShortText(GameMode gameMode) { return I18n.translate("text.rei.short_gamemode." + gameMode.getName()); } - + private String getGameModeText(GameMode gameMode) { return I18n.translate("selectWorld.gameMode." + gameMode.getName()); } - + private GameMode getNextGameMode(boolean reverse) { try { GameMode current = getCurrentGameMode(); @@ -313,11 +313,11 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra return GameMode.NOT_SET; } } - + private GameMode getCurrentGameMode() { return MinecraftClient.getInstance().getNetworkHandler().getPlayerListEntry(MinecraftClient.getInstance().player.getGameProfile().getId()).getGameMode(); } - + private Rectangle getTextFieldArea() { int widthRemoved = RoughlyEnoughItemsCore.getConfigManager().getConfig().enableCraftableOnlyButton ? 22 : 2; if (RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField) @@ -332,22 +332,22 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra } return new Rectangle(ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft(), window.getScaledHeight() - 22, ScreenHelper.getLastContainerScreenHooks().rei_getContainerWidth() - widthRemoved, 18); } - + private Rectangle getCraftableToggleArea() { Rectangle searchBoxArea = getTextFieldArea(); searchBoxArea.setLocation(searchBoxArea.x + searchBoxArea.width + 4, searchBoxArea.y - 1); searchBoxArea.setSize(20, 20); return searchBoxArea; } - + private String getCheatModeText() { return I18n.translate(String.format("%s%s", "text.rei.", ClientHelper.getInstance().isCheating() ? "cheat" : "nocheat")); } - + public Rectangle getRectangle() { return rectangle; } - + @Override public void render(int mouseX, int mouseY, float delta) { List currentStacks = ClientHelper.getInstance().getInventoryItemsTypes(); @@ -384,7 +384,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra } } } - + public void lateRender(int mouseX, int mouseY, float delta) { if (ScreenHelper.isOverlayVisible()) { ScreenHelper.searchField.laterRender(mouseX, mouseY, delta); @@ -396,7 +396,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra } QUEUED_TOOLTIPS.clear(); } - + @SuppressWarnings("deprecation") public void renderTooltip(QueuedTooltip tooltip) { if (tooltip.getConsumer() == null) @@ -404,7 +404,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra else tooltip.getConsumer().accept(tooltip); } - + public void renderTooltip(List lines, int mouseX, int mouseY) { if (lines.isEmpty()) return; @@ -438,18 +438,18 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra GlStateManager.enableRescaleNormal(); }, width, height, 0); } - + private boolean hasSameListContent(List list1, List list2) { list1.sort((itemStack, t1) -> ItemListOverlay.tryGetItemStackName(itemStack).compareToIgnoreCase(ItemListOverlay.tryGetItemStackName(t1))); list2.sort((itemStack, t1) -> ItemListOverlay.tryGetItemStackName(itemStack).compareToIgnoreCase(ItemListOverlay.tryGetItemStackName(t1))); - + return list1.stream().map(ItemListOverlay::tryGetItemStackName).collect(Collectors.joining("")).equals(list2.stream().map(ItemListOverlay::tryGetItemStackName).collect(Collectors.joining(""))); } - + public void addTooltip(QueuedTooltip queuedTooltip) { QUEUED_TOOLTIPS.add(queuedTooltip); } - + public void renderWidgets(int int_1, int int_2, float float_1) { if (!ScreenHelper.isOverlayVisible()) return; @@ -460,11 +460,11 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra }); GuiLighting.disable(); } - + private int getTotalPage() { return itemListOverlay.getTotalPage(); } - + @Override public boolean mouseScrolled(double i, double j, double amount) { if (!ScreenHelper.isOverlayVisible()) @@ -483,7 +483,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra return true; return false; } - + @Override public boolean keyPressed(int int_1, int int_2, int int_3) { if (ScreenHelper.isOverlayVisible()) @@ -513,7 +513,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra } return false; } - + @Override public boolean charTyped(char char_1, int int_1) { if (!ScreenHelper.isOverlayVisible()) @@ -523,12 +523,12 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra return true; return false; } - + @Override public List children() { return widgets; } - + @Override public boolean mouseClicked(double double_1, double double_2, int int_1) { if (!ScreenHelper.isOverlayVisible()) @@ -552,7 +552,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra } return false; } - + public boolean isInside(double mouseX, double mouseY) { if (!rectangle.contains(mouseX, mouseY)) return false; @@ -563,9 +563,9 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra } return true; } - + public boolean isInside(Point point) { return isInside(point.getX(), point.getY()); } - + } diff --git a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java index 369993735..8a0b9c4e9 100644 --- a/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java @@ -13,8 +13,8 @@ import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.client.ScreenHelper; import me.shedaniel.rei.gui.config.RecipeScreenType; import me.shedaniel.rei.gui.widget.ButtonWidget; -import me.shedaniel.rei.gui.widget.WidgetWithBounds; import me.shedaniel.rei.gui.widget.Widget; +import me.shedaniel.rei.gui.widget.WidgetWithBounds; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.Element; import net.minecraft.client.gui.screen.Screen; @@ -72,7 +72,7 @@ public class PreRecipeViewingScreen extends Screen { this.renderBackground(); this.drawCenteredString(this.font, this.title.asFormattedString(), this.width / 2, 20, 16777215); int i = 30; - for(String s : this.font.wrapStringToWidthAsList(I18n.translate("text.rei.recipe_screen_type.selection.sub"), width - 30)) { + for (String s : this.font.wrapStringToWidthAsList(I18n.translate("text.rei.recipe_screen_type.selection.sub"), width - 30)) { this.drawCenteredString(this.font, Formatting.GRAY.toString() + s, width / 2, i, -1); i += 10; } diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index 390395f3e..5ed94de21 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -98,7 +98,7 @@ public class RecipeViewingScreen extends Screen { recipeBack.onPressed(); return recipeBack.enabled; } - for(Element element : children()) + for (Element element : children()) if (element.keyPressed(int_1, int_2, int_3)) return true; return super.keyPressed(int_1, int_2, int_3); @@ -248,7 +248,7 @@ public class RecipeViewingScreen extends Screen { } }); recipeBack.enabled = recipeNext.enabled = categoriesMap.get(selectedCategory).size() > getRecipesPerPageByHeight(); - for(int i = 0; i < TABS_PER_PAGE; i++) { + for (int i = 0; i < TABS_PER_PAGE; i++) { int j = i + categoryPages * TABS_PER_PAGE; if (categories.size() > j) { TabWidget tab; @@ -273,7 +273,7 @@ public class RecipeViewingScreen extends Screen { Optional supplier = RecipeHelper.getInstance().getSpeedCraftButtonArea(selectedCategory); int recipeHeight = selectedCategory.getDisplayHeight(); List currentDisplayed = getCurrentDisplayed(); - for(int i = 0; i < currentDisplayed.size(); i++) { + for (int i = 0; i < currentDisplayed.size(); i++) { int finalI = i; final Supplier displaySupplier = () -> currentDisplayed.get(finalI); int displayWidth = selectedCategory.getDisplayWidth(displaySupplier.get()); @@ -298,7 +298,7 @@ public class RecipeViewingScreen extends Screen { int index = 0; List list = Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("text.rei.working_station")); xx += (innerWidth - 1) * 18; - for(List workingStation : workingStations) { + for (List workingStation : workingStations) { preWidgets.add(new SlotWidget(xx, yy, workingStation, true, true, true) { @Override protected List getExtraToolTips(ItemStack stack) { @@ -328,7 +328,7 @@ public class RecipeViewingScreen extends Screen { public List getCurrentDisplayed() { List list = Lists.newArrayList(); int recipesPerPage = getRecipesPerPage(); - for(int i = 0; i <= recipesPerPage; i++) + for (int i = 0; i <= recipesPerPage; i++) if (page * (recipesPerPage + 1) + i < categoriesMap.get(selectedCategory).size()) list.add(categoriesMap.get(selectedCategory).get(page * (recipesPerPage + 1) + i)); return list; @@ -411,7 +411,7 @@ public class RecipeViewingScreen extends Screen { if (choosePageActivated) { return recipeChoosePageWidget.charTyped(char_1, int_1); } - for(Element listener : children()) + for (Element listener : children()) if (listener.charTyped(char_1, int_1)) return true; return super.charTyped(char_1, int_1); @@ -435,7 +435,7 @@ public class RecipeViewingScreen extends Screen { @Override public boolean mouseScrolled(double i, double j, double amount) { - for(Element listener : children()) + for (Element listener : children()) if (listener.mouseScrolled(i, j, amount)) return true; if (getBounds().contains(ClientUtils.getMouseLocation())) { @@ -463,7 +463,7 @@ public class RecipeViewingScreen extends Screen { init(); return false; } - for(Element entry : children()) + for (Element entry : children()) if (entry.mouseClicked(double_1, double_2, int_1)) { setFocused(entry); if (int_1 == 0) diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index d4de9bb00..07a9c96d4 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -106,7 +106,7 @@ public class VillagerRecipeViewingScreen extends Screen { widgets.add(new CategoryBaseWidget(new Rectangle(xx - 6, bounds.y + bounds.height - 5, 11 + w * 18, 15 + h * 18))); int index = 0; List list = Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("text.rei.working_station")); - for(List workingStation : workingStations) { + for (List workingStation : workingStations) { widgets.add(new SlotWidget(xx, yy, workingStation, true, true, true) { @Override protected List getExtraToolTips(ItemStack stack) { @@ -134,7 +134,7 @@ public class VillagerRecipeViewingScreen extends Screen { this.widgets.add(new AutoCraftingButtonWidget(supplier.get().get(recipeBounds), supplier.get().getButtonText(), () -> display)); int index = 0; - for(RecipeDisplay recipeDisplay : categoryMap.get(category)) { + for (RecipeDisplay recipeDisplay : categoryMap.get(category)) { int finalIndex = index; RecipeRenderer recipeRenderer; recipeRenderers.add(recipeRenderer = category.getSimpleRenderer(recipeDisplay)); @@ -153,7 +153,7 @@ public class VillagerRecipeViewingScreen extends Screen { }); index++; } - for(int i = 0; i < TABS_PER_PAGE; i++) { + for (int i = 0; i < TABS_PER_PAGE; i++) { int j = i + tabsPage * TABS_PER_PAGE; if (categories.size() > j) { TabWidget tab; @@ -251,7 +251,7 @@ public class VillagerRecipeViewingScreen extends Screen { @Override public boolean charTyped(char char_1, int int_1) { - for(Element listener : children()) + for (Element listener : children()) if (listener.charTyped(char_1, int_1)) return true; return super.charTyped(char_1, int_1); @@ -271,7 +271,7 @@ public class VillagerRecipeViewingScreen extends Screen { scrollBarAlphaFutureTime = System.currentTimeMillis(); return true; } - for(Element listener : children()) + for (Element listener : children()) if (listener.mouseScrolled(double_1, double_2, double_3)) return true; if (bounds.contains(ClientUtils.getMouseLocation())) { @@ -326,7 +326,7 @@ public class VillagerRecipeViewingScreen extends Screen { GlStateManager.pushMatrix(); Scissors.begin(); Scissors.scissor(0, scrollListBounds.y + 1, width, scrollListBounds.height - 2); - for(int i = 0; i < buttonWidgets.size(); i++) { + for (int i = 0; i < buttonWidgets.size(); i++) { ButtonWidget buttonWidget = buttonWidgets.get(i); buttonWidget.getBounds().y = scrollListBounds.y + 1 + yOffset - (int) scroll; if (buttonWidget.getBounds().getMaxY() > scrollListBounds.getMinY() && buttonWidget.getBounds().getMinY() < scrollListBounds.getMaxY()) { @@ -335,7 +335,7 @@ public class VillagerRecipeViewingScreen extends Screen { } yOffset += buttonWidget.getBounds().height; } - for(int i = 0; i < buttonWidgets.size(); i++) { + for (int i = 0; i < buttonWidgets.size(); i++) { if (buttonWidgets.get(i).getBounds().getMaxY() > scrollListBounds.getMinY() && buttonWidgets.get(i).getBounds().getMinY() < scrollListBounds.getMaxY()) { GuiLighting.disable(); recipeRenderers.get(i).setBlitOffset(1); @@ -429,7 +429,7 @@ public class VillagerRecipeViewingScreen extends Screen { } return false; } - for(Element element : children()) + for (Element element : children()) if (element.keyPressed(int_1, int_2, int_3)) return true; return super.keyPressed(int_1, int_2, int_3); diff --git a/src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java b/src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java index 278001b14..b6d66ef41 100644 --- a/src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java @@ -52,7 +52,7 @@ public class CreditsScreen extends Screen { try { if (rei.getMetadata().containsCustomElement("rei:translators")) { JsonObject jsonObject = rei.getMetadata().getCustomElement("rei:translators").getAsJsonObject(); - for(Map.Entry entry : jsonObject.entrySet()) { + for (Map.Entry entry : jsonObject.entrySet()) { JsonElement value = entry.getValue(); String behind = value.isJsonArray() ? Lists.newArrayList(value.getAsJsonArray().iterator()).stream().map(json -> json.getAsString()).sorted(String::compareToIgnoreCase).collect(Collectors.joining(", ")) : value.getAsString(); translators.add(String.format(" %s - %s", entry.getKey(), behind)); @@ -62,7 +62,7 @@ public class CreditsScreen extends Screen { } catch (Exception e) { translators.clear(); translators.add("Failed to get translators: " + e.toString()); - for(StackTraceElement traceElement : e.getStackTrace()) + for (StackTraceElement traceElement : e.getStackTrace()) translators.add(" at " + traceElement); e.printStackTrace(); } @@ -70,7 +70,7 @@ public class CreditsScreen extends Screen { List actualTranslators = Lists.newArrayList(); int i = width - 80 - 6; translators.forEach(s -> font.wrapStringToWidthAsList(s, i).forEach(actualTranslators::add)); - for(String line : I18n.translate("text.rei.credit.text", FabricLoader.getInstance().getModContainer("roughlyenoughitems").map(mod -> mod.getMetadata().getVersion().getFriendlyString()).orElse("Unknown"), String.join("\n", actualTranslators)).split("\n")) + for (String line : I18n.translate("text.rei.credit.text", FabricLoader.getInstance().getModContainer("roughlyenoughitems").map(mod -> mod.getMetadata().getVersion().getFriendlyString()).orElse("Unknown"), String.join("\n", actualTranslators)).split("\n")) entryListWidget.creditsAddEntry(new CreditsItem(new LiteralText(line))); entryListWidget.creditsAddEntry(new CreditsItem(new LiteralText(""))); children.add(buttonDone = new AbstractPressableButtonWidget(width / 2 - 100, height - 26, 200, 20, I18n.translate("gui.done")) { diff --git a/src/main/java/me/shedaniel/rei/gui/renderers/EmptyRenderer.java b/src/main/java/me/shedaniel/rei/gui/renderers/EmptyRenderer.java index cc63910a8..99c1da024 100644 --- a/src/main/java/me/shedaniel/rei/gui/renderers/EmptyRenderer.java +++ b/src/main/java/me/shedaniel/rei/gui/renderers/EmptyRenderer.java @@ -13,7 +13,7 @@ public class EmptyRenderer extends Renderer { @Override public void render(int x, int y, double mouseX, double mouseY, float delta) { - + } } diff --git a/src/main/java/me/shedaniel/rei/gui/renderers/ItemStackRenderer.java b/src/main/java/me/shedaniel/rei/gui/renderers/ItemStackRenderer.java index 8f7fe1a50..8fb3f65a8 100644 --- a/src/main/java/me/shedaniel/rei/gui/renderers/ItemStackRenderer.java +++ b/src/main/java/me/shedaniel/rei/gui/renderers/ItemStackRenderer.java @@ -55,7 +55,7 @@ public abstract class ItemStackRenderer extends Renderer { List toolTip = Lists.newArrayList(ItemListOverlay.tryGetItemStackToolTip(itemStack, true)); toolTip.addAll(getExtraToolTips(itemStack)); boolean alreadyHasMod = false; - for(String s : toolTip) + for (String s : toolTip) if (s.equalsIgnoreCase(modString)) { alreadyHasMod = true; break; diff --git a/src/main/java/me/shedaniel/rei/gui/renderers/SimpleRecipeRenderer.java b/src/main/java/me/shedaniel/rei/gui/renderers/SimpleRecipeRenderer.java index 42265832d..9c5ad4ebc 100644 --- a/src/main/java/me/shedaniel/rei/gui/renderers/SimpleRecipeRenderer.java +++ b/src/main/java/me/shedaniel/rei/gui/renderers/SimpleRecipeRenderer.java @@ -44,7 +44,7 @@ public class SimpleRecipeRenderer extends RecipeRenderer { public SimpleRecipeRenderer(Supplier>> input, Supplier> output) { List, AtomicInteger>> newList = Lists.newArrayList(); List, Integer>> a = input.get().stream().map(stacks -> new Pair<>(stacks, stacks.stream().map(ItemStack::getCount).max(Integer::compareTo).orElse(1))).collect(Collectors.toList()); - for(Pair, Integer> pair : a) { + for (Pair, Integer> pair : a) { Optional, AtomicInteger>> any = newList.stream().filter(pairr -> equalsList(pair.getLeft(), pairr.getLeft())).findAny(); if (any.isPresent()) { any.get().getRight().addAndGet(pair.getRight()); @@ -52,7 +52,7 @@ public class SimpleRecipeRenderer extends RecipeRenderer { newList.add(new Pair<>(pair.getLeft(), new AtomicInteger(pair.getRight()))); } List> b = Lists.newArrayList(); - for(Pair, AtomicInteger> pair : newList) + for (Pair, AtomicInteger> pair : newList) b.add(pair.getLeft().stream().map(stack -> { ItemStack s = stack.copy(); s.setCount(pair.getRight().get()); @@ -69,7 +69,7 @@ public class SimpleRecipeRenderer extends RecipeRenderer { return true; if (stacks_1.size() != stacks_2.size()) return false; - for(int i = 0; i < stacks_1.size(); i++) + for (int i = 0; i < stacks_1.size(); i++) if (!stacks_1.get(i).isItemEqualIgnoreDamage(stacks_2.get(i))) return false; return true; @@ -80,7 +80,7 @@ public class SimpleRecipeRenderer extends RecipeRenderer { int xx = x + 4, yy = y + 2; int j = 0; int itemsPerLine = getItemsPerLine(); - for(ItemStackRenderer itemStackRenderer : inputRenderer) { + for (ItemStackRenderer itemStackRenderer : inputRenderer) { itemStackRenderer.setBlitOffset(getBlitOffset() + 50); itemStackRenderer.drawTooltip = MinecraftClient.getInstance().currentScreen instanceof VillagerRecipeViewingScreen; itemStackRenderer.render(xx + 8, yy + 6, mouseX, mouseY, delta); diff --git a/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java index 4f43ab66c..1640a03b3 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/AutoCraftingButtonWidget.java @@ -34,7 +34,7 @@ public class AutoCraftingButtonWidget extends ButtonWidget { @Override public void onPressed() { - for(AutoCraftingHandler autoCraftingHandler : RecipeHelper.getInstance().getSortedAutoCraftingHandler()) + for (AutoCraftingHandler autoCraftingHandler : RecipeHelper.getInstance().getSortedAutoCraftingHandler()) if (autoCraftingHandler.canHandle(displaySupplier, minecraft, minecraft.currentScreen, containerScreen, ScreenHelper.getLastOverlay())) if (autoCraftingHandler.handle(displaySupplier, minecraft, minecraft.currentScreen, containerScreen, ScreenHelper.getLastOverlay())) return; @@ -45,7 +45,7 @@ public class AutoCraftingButtonWidget extends ButtonWidget { @Override public void render(int mouseX, int mouseY, float delta) { this.enabled = false; - for(AutoCraftingHandler autoCraftingHandler : RecipeHelper.getInstance().getSortedAutoCraftingHandler()) + for (AutoCraftingHandler autoCraftingHandler : RecipeHelper.getInstance().getSortedAutoCraftingHandler()) if (autoCraftingHandler.canHandle(displaySupplier, minecraft, minecraft.currentScreen, containerScreen, ScreenHelper.getLastOverlay())) { enabled = true; break; diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java index 3e6ab9d7f..72f265a97 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java @@ -81,7 +81,7 @@ public abstract class ButtonWidget extends WidgetWithBounds { blit(x + 4, y + height - 4, 4, textureOffset * 80 + 76, MathHelper.ceil((width - 8) / 2f), 4); blit(x + 4 + MathHelper.ceil((width - 8) / 2f), y + height - 4, 252 - MathHelper.floor((width - 8) / 2f), textureOffset * 80 + 76, MathHelper.floor((width - 8) / 2f), 4); blit(x + 4 + MathHelper.ceil((width - 8) / 2f), y, 252 - MathHelper.floor((width - 8) / 2f), textureOffset * 80, MathHelper.floor((width - 8) / 2f), 4); - for(int i = y + 4; i < y + height - 4; i += 76) { + for (int i = y + 4; i < y + height - 4; i += 76) { blit(x, i, 0, 4 + textureOffset * 80, MathHelper.ceil(width / 2f), MathHelper.clamp(y + height - 4 - i, 0, 76)); blit(x + MathHelper.ceil(width / 2f), i, 256 - MathHelper.floor(width / 2f), 4 + textureOffset * 80, MathHelper.floor(width / 2f), MathHelper.clamp(y + height - 4 - i, 0, 76)); } diff --git a/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java index fde17acb0..5c8e7657f 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/DraggableWidget.java @@ -56,7 +56,7 @@ public abstract class DraggableWidget extends WidgetWithBounds { } return true; } - for(Element listener : children()) + for (Element listener : children()) if (listener.mouseDragged(double_1, double_2, int_1, double_3, double_4)) return true; return false; @@ -72,12 +72,13 @@ public abstract class DraggableWidget extends WidgetWithBounds { onMouseReleaseMidPoint(getMidPoint()); return true; } - for(Element listener : children()) + for (Element listener : children()) if (listener.mouseReleased(double_1, double_2, int_1)) return true; return false; } - public void onMouseReleaseMidPoint(Point midPoint) {} + public void onMouseReleaseMidPoint(Point midPoint) { + } } diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java index e87d4d97d..81a5b3a09 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java @@ -98,9 +98,9 @@ public class ItemListOverlay extends Widget { if (arguments.isEmpty()) return true; AtomicReference mod = null, tooltips = null, name = null; - for(SearchArgument[] arguments1 : arguments) { + for (SearchArgument[] arguments1 : arguments) { boolean b = true; - for(SearchArgument argument : arguments1) { + for (SearchArgument argument : arguments1) { if (argument.getArgumentType().equals(SearchArgument.ArgumentType.ALWAYS)) return true; if (argument.getArgumentType().equals(SearchArgument.ArgumentType.MOD)) @@ -168,8 +168,8 @@ public class ItemListOverlay extends Widget { this.listArea = new Rectangle((int) startX, (int) startY, width * 18, height * 18); int fitSlotsPerPage = getTotalFitSlotsPerPage(startX, startY, listArea); int j = page * fitSlotsPerPage; - for(int yy = 0; yy < height; yy++) { - for(int xx = 0; xx < width; xx++) { + for (int yy = 0; yy < height; yy++) { + for (int xx = 0; xx < width; xx++) { int x = startX + xx * 18, y = startY + yy * 18; if (!canBeFit(x, y, listArea)) continue; @@ -221,15 +221,15 @@ public class ItemListOverlay extends Widget { public int getTotalFitSlotsPerPage(int startX, int startY, Rectangle listArea) { int slots = 0; - for(int x = 0; x < width; x++) - for(int y = 0; y < height; y++) + for (int x = 0; x < width; x++) + for (int y = 0; y < height; y++) if (canBeFit(startX + x * 18, startY + y * 18, listArea)) slots++; return slots; } public boolean canBeFit(int left, int top, Rectangle listArea) { - for(DisplayHelper.DisplayBoundsHandler sortedBoundsHandler : RoughlyEnoughItemsCore.getDisplayHelper().getSortedBoundsHandlers(minecraft.currentScreen.getClass())) { + for (DisplayHelper.DisplayBoundsHandler sortedBoundsHandler : RoughlyEnoughItemsCore.getDisplayHelper().getSortedBoundsHandlers(minecraft.currentScreen.getClass())) { ActionResult fit = sortedBoundsHandler.canItemSlotWidgetFit(!R