diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-08-04 22:11:07 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-08-04 22:11:07 +0800 |
| commit | 721ea24a226c2dca5cfef4b3f638d251547df0b8 (patch) | |
| tree | 76c9d8c2790db8730c95af2d250a4b062df1215a /src/main/java/me | |
| parent | 82225991887f55047d161a18e6fa19f798c0ba67 (diff) | |
| download | RoughlyEnoughItems-721ea24a226c2dca5cfef4b3f638d251547df0b8.tar.gz RoughlyEnoughItems-721ea24a226c2dca5cfef4b3f638d251547df0b8.tar.bz2 RoughlyEnoughItems-721ea24a226c2dca5cfef4b3f638d251547df0b8.zip | |
yes thank you
Diffstat (limited to 'src/main/java/me')
38 files changed, 225 insertions, 227 deletions
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<Identifier> 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<Rectangle> 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<Rectangle> 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<Identifier> categories) { Map<RecipeCategory<?>, List<RecipeDisplay>> map = Maps.newLinkedHashMap(); - for(Identifier category : categories) { + for (Identifier category : categories) { Optional<RecipeCategory> 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<String> 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<ItemStack> findCraftableByItems(List<ItemStack> inventoryItems) { List<ItemStack> craftables = new ArrayList<>(); - for(List<RecipeDisplay> value : recipeCategoryListMap.values()) - for(RecipeDisplay recipeDisplay : value) { + for (List<RecipeDisplay> value : recipeCategoryListMap.values()) + for (RecipeDisplay recipeDisplay : value) { int slotsCraftable = 0; List<List<ItemStack>> requiredInput = (List<List<ItemStack>>) recipeDisplay.getRequiredItems(); - for(List<ItemStack> slot : requiredInput) { + for (List<ItemStack> 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<RecipeCategory<?>, List<RecipeDisplay>> getRecipesFor(ItemStack stack) { Map<Identifier, List<RecipeDisplay>> categoriesMap = new HashMap<>(); categories.forEach(f -> categoriesMap.put(f.getIdentifier(), Lists.newArrayList())); - for(Map.Entry<Identifier, List<RecipeDisplay>> entry : recipeCategoryListMap.entrySet()) { + for (Map.Entry<Identifier, List<RecipeDisplay>> entry : recipeCategoryListMap.entrySet()) { RecipeCategory category = getCategory(entry.getKey()); - for(RecipeDisplay recipeDisplay : entry.getValue()) - for(ItemStack outputStack : (List<ItemStack>) recipeDisplay.getOutput()) + for (RecipeDisplay recipeDisplay : entry.getValue()) + for (ItemStack outputStack : (List<ItemStack>) 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<List>) liveRecipeGenerator.getRecipeFor(stack)).ifPresent(o -> categoriesMap.get(liveRecipeGenerator.getCategoryIdentifier()).addAll(o)); Map<RecipeCategory<?>, List<RecipeDisplay>> 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<RecipeCategory<?>, List<RecipeDisplay>> getUsagesFor(ItemStack stack) { Map<Identifier, List<RecipeDisplay>> categoriesMap = new HashMap<>(); categories.forEach(f -> categoriesMap.put(f.getIdentifier(), Lists.newArrayList())); - for(Map.Entry<Identifier, List<RecipeDisplay>> entry : recipeCategoryListMap.entrySet()) { + for (Map.Entry<Identifier, List<RecipeDisplay>> entry : recipeCategoryListMap.entrySet()) { RecipeCategory category = getCategory(entry.getKey()); - for(RecipeDisplay recipeDisplay : entry.getValue()) { + for (RecipeDisplay recipeDisplay : entry.getValue()) { boolean found = false; - for(List<ItemStack> input : (List<List<ItemStack>>) recipeDisplay.getInput()) { - for(ItemStack itemStack : input) { + for (List<ItemStack> input : (List<List<ItemStack>>) 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<List>) liveRecipeGenerator.getUsageFor(stack)).ifPresent(o -> categoriesMap.get(liveRecipeGenerator.getCategoryIdentifier()).addAll(o)); Map<RecipeCategory<?>, List<RecipeDisplay>> 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<DisplayVisibilityHandler> 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<String, Boolean> INCLUDE = s -> search(text, s); - public final Function<String, Boolean> NOT_INCLUDE = s -> !search(text, s); + public final Function<String, Boolean> INCLUDE = s -> s.contains(text); + public final Function<String, Boolean> 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<String, Boolean> 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<Queue |
