diff options
| author | Daniel She <shekwancheung0528@gmail.com> | 2019-05-12 18:10:21 +0800 |
|---|---|---|
| committer | Daniel She <shekwancheung0528@gmail.com> | 2019-05-12 18:10:21 +0800 |
| commit | d979cb8b465c73eabca4e32be2ffa26648471fee (patch) | |
| tree | 8aac9df58b40052b6b19c0c3ac7da66076dc5b1c | |
| parent | 54f120195a63dbc145b74485e410abcd4c5acdf4 (diff) | |
| parent | a98d9191f1a97925a8a3e2e23c0a07867540a93a (diff) | |
| download | RoughlyEnoughItems-d979cb8b465c73eabca4e32be2ffa26648471fee.tar.gz RoughlyEnoughItems-d979cb8b465c73eabca4e32be2ffa26648471fee.tar.bz2 RoughlyEnoughItems-d979cb8b465c73eabca4e32be2ffa26648471fee.zip | |
Merge branch '1.14-dev' into 1.14
40 files changed, 437 insertions, 159 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 66a4b2643..76669a938 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,20 @@ View full changelog [here](https://github.com/shedaniel/RoughlyEnoughItems/blob/1.14/CHANGELOG.md). -## v2.9-beta+build.109 (BETA) +## v2.9+build.110 +- Fixed: Build 109 Crash +- Fixed: Next Page / Previous Page crash in villager recipe mode +- Added: Scrolling in villager recipe mode +- Added: New bad javadoc: https://shedaniel.me/RoughlyEnoughItems/ +#### v2.9-beta+build.109 (BETA) - Fixed [#92](https://github.com/shedaniel/RoughlyEnoughItems/issues/92): Make REI Buttons use an extra sheet - Adds: Support for `{item_name}` in cheating items for getting the path of the item identifier -## v2.9-beta+build.108 (BETA) +#### v2.9-beta+build.108 (BETA) - Fixed [#88](https://github.com/shedaniel/RoughlyEnoughItems/issues/88): Stupid Item Search -## v2.9-beta+build.107 (BETA) +#### v2.9-beta+build.107 (BETA) - Fixed: Crashing when clicking tabs - Added: Buttons to switch category page - Fixed: NullPointerException by geniii - Fixed [#58](https://github.com/shedaniel/RoughlyEnoughItems/issues/58): Keybinds (e.g. O, R, U) working even a search field is focused -## v2.9-beta+build.106 (BETA) +#### v2.9-beta+build.106 (BETA) - Using: [HammerLib](https://minecraft.curseforge.com/projects/hammer-lib) as a simple opengl scissors api - New: Mod Name of category new shows in category tooltips - New: Renderer API diff --git a/build.gradle b/build.gradle index 66ca0e783..8f283b91d 100755 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ import net.fabricmc.loom.task.RemapJar plugins { - id 'fabric-loom' version '0.2.1-SNAPSHOT' + id 'fabric-loom' version '0.2.2-SNAPSHOT' id "com.github.johnrengelman.shadow" version "4.0.3" } @@ -51,20 +51,20 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_version}" modCompile "net.fabricmc:fabric-loader:${project.fabricloader_version}" // modCompile "net.fabricmc:fabric:${project.fabric_version}" - modCompile "net.fabricmc.fabric-api:fabric-keybindings:${project.fabric_keybindings}" - modCompile "net.fabricmc.fabric-api:fabric-lib:${project.fabric_lib}" - modCompile "net.fabricmc.fabric-api:fabric-networking:${project.fabric_networking}" - modCompile "net.fabricmc.fabric-api:fabric-events-lifecycle:${project.fabric_events_lifecycle}" - modCompile "net.fabricmc.fabric-api:fabric-resource-loader:${project.fabric_resource_loader}" + modCompile "net.fabricmc.fabric-api:fabric-keybindings-v0:${project.fabric_keybindings}" + modCompile "net.fabricmc.fabric-api:fabric-api-base:${project.fabric_api_base}" + modCompile "net.fabricmc.fabric-api:fabric-networking-v0:${project.fabric_networking}" + modCompile "net.fabricmc.fabric-api:fabric-events-lifecycle-v0:${project.fabric_events_lifecycle}" + modCompile "net.fabricmc.fabric-api:fabric-resource-loader-v0:${project.fabric_resource_loader}" modCompile "cloth:ClothEvents:${cloth_events_version}" modCompile "cloth-config:ClothConfig:${cloth_config_version}" if (includeDep) { -// include "net.fabricmc:fabric:${project.fabric_version}" - include "net.fabricmc.fabric-api:fabric-keybindings:${project.fabric_keybindings}" - include "net.fabricmc.fabric-api:fabric-lib:${project.fabric_lib}" - include "net.fabricmc.fabric-api:fabric-networking:${project.fabric_networking}" - include "net.fabricmc.fabric-api:fabric-events-lifecycle:${project.fabric_events_lifecycle}" - include "net.fabricmc.fabric-api:fabric-resource-loader:${project.fabric_resource_loader}" + include "net.fabricmc:fabric:${project.fabric_version}" +// include "net.fabricmc.fabric-api:fabric-keybindings-v0:${project.fabric_keybindings}" +// include "net.fabricmc.fabric-api:fabric-api-base:${project.fabric_api_base}" +// include "net.fabricmc.fabric-api:fabric-networking-v0:${project.fabric_networking}" +// include "net.fabricmc.fabric-api:fabric-events-lifecycle-v0:${project.fabric_events_lifecycle}" +// include "net.fabricmc.fabric-api:fabric-resource-loader-v0:${project.fabric_resource_loader}" include "cloth:ClothEvents:${cloth_events_version}" include "cloth-config:ClothConfig:${cloth_config_version}" } diff --git a/gradle.properties b/gradle.properties index ab4d7e811..beeb1a445 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ -mod_version=2.9-beta+build.109 +mod_version=2.9+build.110 minecraft_version=1.14 -yarn_version=1.14+build.5 +yarn_version=1.14+build.21 fabricloader_version=0.4.6+build.141 jankson_version=1.1.0 cloth_events_version=0.3.1.23 @@ -8,8 +8,8 @@ cloth_config_version=0.2.1.14 modmenu_version=1.4.0-71 fabric_version=0.2.7+build.127 -fabric_keybindings=0.1.0+93af775a -fabric_lib=0.1.0+93af775a -fabric_networking=0.1.0+93af775a -fabric_events_lifecycle=0.1.0+93af775a -fabric_resource_loader=0.1.0+93af775a +fabric_keybindings=0.1.0+f1618918 +fabric_networking=0.1.0+f1618918 +fabric_events_lifecycle=0.1.0+9232ac87 +fabric_resource_loader=0.1.0+f1618918 +fabric_api_base=0.1.0+f1618918 diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index f96ccd42a..eb3bec81f 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -41,7 +41,7 @@ import java.util.Optional; import java.util.stream.Collectors; public class RoughlyEnoughItemsCore implements ClientModInitializer { - + public static final Logger LOGGER; private static final RecipeHelper RECIPE_HELPER = new RecipeHelperImpl(); private static final PluginDisabler PLUGIN_DISABLER = new PluginDisablerImpl(); @@ -49,70 +49,80 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { private static final DisplayHelper DISPLAY_HELPER = new DisplayHelperImpl(); private static final Map<Identifier, REIPluginEntry> plugins = Maps.newHashMap(); private static ConfigManagerImpl configManager; - + static { LOGGER = LogManager.getFormatterLogger("REI"); } - + public static RecipeHelper getRecipeHelper() { return RECIPE_HELPER; } - + public static me.shedaniel.rei.api.ConfigManager getConfigManager() { return configManager; } - + public static ItemRegistry getItemRegisterer() { return ITEM_REGISTRY; } - + public static PluginDisabler getPluginDisabler() { return PLUGIN_DISABLER; } - + public static DisplayHelper getDisplayHelper() { return DISPLAY_HELPER; } - + public static REIPluginEntry registerPlugin(Identifier identifier, REIPluginEntry plugin) { plugins.put(identifier, plugin); RoughlyEnoughItemsCore.LOGGER.info("[REI] Registered plugin %s from %s", identifier.toString(), plugin.getClass().getSimpleName()); plugin.onFirstLoad(getPluginDisabler()); return plugin; } - + public static List<REIPluginEntry> getPlugins() { return new LinkedList<>(plugins.values()); } - + public static Optional<Identifier> getPluginIdentifier(REIPluginEntry plugin) { for(Identifier identifier : plugins.keySet()) if (identifier != null && plugins.get(identifier).equals(plugin)) return Optional.of(identifier); return Optional.empty(); } - + public static boolean hasPermissionToUsePackets() { - return hasOperatorPermission() && canUsePackets(); + try { + MinecraftClient.getInstance().getNetworkHandler().getCommandSource().hasPermissionLevel(0); + return hasOperatorPermission() && canUsePackets(); + } catch (NullPointerException e) { + return true; + } } - + public static boolean hasOperatorPermission() { - return MinecraftClient.getInstance().getNetworkHandler().getCommandSource().hasPermissionLevel(1); + try { + return MinecraftClient.getInstance().getNetworkHandler().getCommandSource().hasPermissionLevel(1); + } catch (NullPointerException e) { + return true; + } } - + public static boolean canUsePackets() { return ClientSidePacketRegistry.INSTANCE.canServerReceive(RoughlyEnoughItemsNetwork.CREATE_ITEMS_PACKET) && ClientSidePacketRegistry.INSTANCE.canServerReceive(RoughlyEnoughItemsNetwork.DELETE_ITEMS_PACKET); } - + @Override public void onInitializeClient() { configManager = new ConfigManagerImpl(); - + registerClothEvents(); discoverOldPlugins(); discoverPluginEntries(); } - + + @SuppressWarnings("deprecation") private void discoverPluginEntries() { for(REIPluginEntry reiPlugin : FabricLoader.getInstance().getEntrypoints("rei_plugins", REIPluginEntry.class)) { try { @@ -125,7 +135,8 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } } } - + + @SuppressWarnings("deprecation") private void discoverOldPlugins() { List<Pair<Identifier, String>> list = Lists.newArrayList(); for(ModMetadata metadata : FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).filter(metadata -> metadata.containsCustomElement("roughlyenoughitems:plugins")).collect(Collectors.toList())) { @@ -164,7 +175,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } } } - + private void loadPluginFromJsonObject(List<Pair<Identifier, String>> list, ModMetadata modMetadata, JsonObject object) { String namespace = modMetadata.getId(); if (object.has("namespace")) @@ -173,7 +184,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { String className = object.get("class").getAsString(); list.add(new Pair<>(new Identifier(namespace, id), className)); } - + private void registerClothEvents() { ClothClientHooks.SYNC_RECIPES.register((minecraftClient, recipeManager, synchronizeRecipesS2CPacket) -> { ((RecipeHelperImpl) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(recipeManager); @@ -232,7 +243,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { ScreenHelper.getLastOverlay().lateRender(i, i1, v); }); ClothClientHooks.SCREEN_KEY_PRESSED.register((minecraftClient, screen, i, i1, i2) -> { - if (screen.getFocused() != null && screen.getFocused() instanceof TextFieldWidget || (screen.getFocused() instanceof RecipeBookGui && ((RecipeBookGuiHooks)screen.getFocused()).rei_getSearchField() != null && ((RecipeBookGuiHooks)screen.getFocused()).rei_getSearchField().isFocused())) + if (screen.getFocused() != null && screen.getFocused() instanceof TextFieldWidget || (screen.getFocused() instanceof RecipeBookGui && ((RecipeBookGuiHooks) screen.getFocused()).rei_getSearchField() != null && ((RecipeBookGuiHooks) screen.getFocused()).rei_getSearchField().isFocused())) return ActionResult.PASS; if (screen instanceof ContainerScreen) if (ScreenHelper.getLastOverlay().keyPressed(i, i1, i2)) @@ -240,5 +251,5 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { return ActionResult.PASS; }); } - + } diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java index 63b7765e2..b2c444ec1 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java @@ -8,12 +8,12 @@ package me.shedaniel.rei; import me.shedaniel.rei.gui.widget.ItemListOverlay; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.network.ServerSidePacketRegistry; +import net.minecraft.ChatFormat; import net.minecraft.client.resource.language.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.StringTextComponent; -import net.minecraft.text.TextFormat; -import net.minecraft.text.TranslatableTextComponent; import net.minecraft.util.Identifier; public class RoughlyEnoughItemsNetwork implements ModInitializer { @@ -26,7 +26,7 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer { ServerSidePacketRegistry.INSTANCE.register(DELETE_ITEMS_PACKET, (packetContext, packetByteBuf) -> { ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer(); if (player.getServer().getPermissionLevel(player.getGameProfile()) < player.getServer().getOpPermissionLevel()) { - player.addChatMessage(new TranslatableTextComponent("text.rei.no_permission_cheat").applyFormat(TextFormat.RED), false); + player.addChatMessage(new TranslatableComponent("text.rei.no_permission_cheat").applyFormat(ChatFormat.RED), false); return; } if (!player.inventory.getCursorStack().isEmpty()) @@ -35,14 +35,14 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer { ServerSidePacketRegistry.INSTANCE.register(CREATE_ITEMS_PACKET, (packetContext, packetByteBuf) -> { ServerPlayerEntity player = (ServerPlayerEntity) packetContext.getPlayer(); if (player.getServer().getPermissionLevel(player.getGameProfile()) < player.getServer().getOpPermissionLevel()) { - player.addChatMessage(new TranslatableTextComponent("text.rei.no_permission_cheat").applyFormat(TextFormat.RED), false); + player.addChatMessage(new TranslatableComponent("text.rei.no_permission_cheat").applyFormat(ChatFormat.RED), false); return; } ItemStack stack = packetByteBuf.readItemStack(); if (player.inventory.insertStack(stack.copy())) - player.addChatMessage(new StringTextComponent(I18n.translate("text.rei.cheat_items").replaceAll("\\{item_name}", ItemListOverlay.tryGetItemStackName(stack.copy())).replaceAll("\\{item_count}", stack.copy().getAmount() + "").replaceAll("\\{player_name}", player.getEntityName())), false); + player.addChatMessage(new TextComponent(I18n.translate("text.rei.cheat_items").replaceAll("\\{item_name}", ItemListOverlay.tryGetItemStackName(stack.copy())).replaceAll("\\{item_count}", stack.copy().getAmount() + "").replaceAll("\\{player_name}", player.getEntityName())), false); else - player.addChatMessage(new TranslatableTextComponent("text.rei.failed_cheat_items"), false); + player.addChatMessage(new TranslatableComponent("text.rei.failed_cheat_items"), false); }); } diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java index f363dccac..3aaf1f482 100644 --- a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java +++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java @@ -11,11 +11,30 @@ import java.awt.*; import java.util.List; public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Screen> { + /** + * Gets the exclusion zones by the screen class + * + * @param currentScreenClass the current screen class + * @param isOnRightSide whether the user has set the overlay to the right + * @return the list of exclusion zones + */ List<Rectangle> getCurrentExclusionZones(Class<? extends Screen> currentScreenClass, boolean isOnRightSide); + /** + * Register an exclusion zone + * + * @param screenClass the screen + * @param supplier the exclusion zone supplier + */ void registerExclusionZones(Class<? extends Screen> screenClass, ExclusionZoneSupplier supplier); public static interface ExclusionZoneSupplier { + /** + * Gets the current exclusion zones + * + * @param isOnRightSide whether the user has set the overlay to the right + * @return the list of exclusion zones + */ List<Rectangle> apply(boolean isOnRightSide); } } diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index fe33ddc64..d9f6c7ae8 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -41,9 +41,9 @@ public interface ClientHelper { /** * Opens a recipe viewing screen: - * {@link me.shedaniel.rei.gui.PreRecipeViewingScreen} if not set - * {@link me.shedaniel.rei.gui.RecipeViewingScreen} if set to default - * {@link me.shedaniel.rei.gui.VillagerRecipeViewingScreen} if set to villager + * Opens {@link me.shedaniel.rei.gui.PreRecipeViewingScreen} if not set + * Opens {@link me.shedaniel.rei.gui.RecipeViewingScreen} if set to default + * Opens {@link me.shedaniel.rei.gui.VillagerRecipeViewingScreen} if set to villager * * @param map the map of recipes */ @@ -115,14 +115,29 @@ public interface ClientHelper { */ String getModFromIdentifier(Identifier identifier); + /** + * @return the recipe keybind, defaulted R + */ FabricKeyBinding getRecipeKeyBinding(); + /** + * @return the usage keybind, defaulted U + */ FabricKeyBinding getUsageKeyBinding(); + /** + * @return the hide keybind, defaulted O + */ FabricKeyBinding getHideKeyBinding(); + /** + * @return the previous page keybind, defaulted not set + */ FabricKeyBinding getPreviousPageKeyBinding(); + /** + * @return the next page keybind, defaulted not set + */ FabricKeyBinding getNextPageKeyBinding(); /** diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 9fea85839..5cabf4ad1 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -56,11 +56,6 @@ public interface DisplayHelper { public static interface DisplayBoundsHandler<T> { /** - * An empty rectangle - */ - public static final Rectangle EMPTY = new Rectangle(); - - /** * Gets the base supported class for the bounds handler * * @return the base class diff --git a/src/main/java/me/shedaniel/rei/api/ItemRegistry.java b/src/main/java/me/shedaniel/rei/api/ItemRegistry.java index 0a9da2c46..a29682985 100644 --- a/src/main/java/me/shedaniel/rei/api/ItemRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/ItemRegistry.java @@ -27,6 +27,12 @@ public interface ItemRegistry { @Deprecated List<ItemStack> getModifiableItemList(); + /** + * Gets all possible stacks from an item + * + * @param item the item to find + * @return the array of possible stacks + */ ItemStack[] getAllStacksFromItem(Item item); /** @@ -37,12 +43,23 @@ public interface ItemRegistry { */ void registerItemStack(Item afterItem, ItemStack stack); + /** + * Registers multiple stacks to the item list + * + * @param afterItem the stack to put after + * @param stacks the stacks to register + */ default void registerItemStack(Item afterItem, ItemStack... stacks) { for(ItemStack stack : stacks) if (stack != null && !stack.isEmpty()) registerItemStack(afterItem, stack); } + /** + * Registers multiple stacks to the item list + * + * @param stacks the stacks to register + */ default void registerItemStack(ItemStack... stacks) { for(ItemStack stack : stacks) if (stack != null && !stack.isEmpty()) diff --git a/src/main/java/me/shedaniel/rei/api/PluginDisabler.java b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java index cd3b61578..ed4f8638c 100644 --- a/src/main/java/me/shedaniel/rei/api/PluginDisabler.java +++ b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java @@ -9,20 +9,51 @@ import net.minecraft.util.Identifier; public interface PluginDisabler { + /** + * Disables multiple functions from a plugin + * + * @param plugin the identifier of the plugin + * @param functions the array of functions to be disabled + */ default void disablePluginFunctions(Identifier plugin, PluginFunction... functions) { for(PluginFunction function : functions) disablePluginFunction(plugin, function); } + /** + * Enables multiple functions from a plugin + * + * @param plugin the identifier of the plugin + * @param functions the array of functions to be enabled + */ default void enablePluginFunctions(Identifier plugin, PluginFunction... functions) { for(PluginFunction function : functions) enablePluginFunction(plugin, function); } + /** + * Disables a function from a plugin + * + * @param plugin the identifier of the plugin + * @param function the function to be disabled + */ void disablePluginFunction(Identifier plugin, PluginFunction function); + /** + * Enables a function from a plugin + * + * @param plugin the identifier of the plugin + * @param function the function to be enabled + */ void enablePluginFunction(Identifier plugin, PluginFunction function); + /** + * Checks if a plugin function has been disabled + * + * @param plugin the identifier of the plugin + * @param function the function to check + * @return whether if it has been disabled + */ boolean isFunctionEnabled(Identifier plugin, PluginFunction function); } diff --git a/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java b/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java index 4fb564133..9e17159bc 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java @@ -15,16 +15,35 @@ import java.util.Optional; public interface RecipeDisplay<T extends Recipe> { + /** + * @return the optional recipe + */ Optional<T> getRecipe(); + /** + * @return a list of items + */ List<List<ItemStack>> getInput(); + /** + * @return a list of outputs + */ List<ItemStack> getOutput(); + /** + * Gets the required items used in craftable filters + * + * @return the list of required items + */ default List<List<ItemStack& |
