diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-03-14 19:22:18 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-03-14 19:22:18 +0800 |
| commit | d0f4d495957d2454bdf43a64d31a21f06849e677 (patch) | |
| tree | b1ae87962790074f91e1ade3be8e7eb331a45b30 /src/main/java/me/shedaniel/rei/utils/ClothRegistry.java | |
| parent | 72144a3911b69f25a2ab0e45acdd5d9edabeda80 (diff) | |
| download | RoughlyEnoughItems-d0f4d495957d2454bdf43a64d31a21f06849e677.tar.gz RoughlyEnoughItems-d0f4d495957d2454bdf43a64d31a21f06849e677.tar.bz2 RoughlyEnoughItems-d0f4d495957d2454bdf43a64d31a21f06849e677.zip | |
Using Cloth as a hard dependency now
Diffstat (limited to 'src/main/java/me/shedaniel/rei/utils/ClothRegistry.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/utils/ClothRegistry.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/rei/utils/ClothRegistry.java b/src/main/java/me/shedaniel/rei/utils/ClothRegistry.java new file mode 100644 index 000000000..3879feded --- /dev/null +++ b/src/main/java/me/shedaniel/rei/utils/ClothRegistry.java @@ -0,0 +1,58 @@ +package me.shedaniel.rei.utils; + +import me.shedaniel.cloth.api.EventPriority; +import me.shedaniel.cloth.hooks.ClothHooks; +import me.shedaniel.cloth.hooks.ClothModMenuHooks; +import me.shedaniel.rei.RoughlyEnoughItemsCore; +import me.shedaniel.rei.api.TabGetter; +import me.shedaniel.rei.client.ClientHelper; +import me.shedaniel.rei.client.RecipeHelperImpl; +import me.shedaniel.rei.client.ScreenHelper; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.ContainerScreen; +import net.minecraft.client.gui.ingame.CreativePlayerInventoryScreen; +import net.minecraft.client.gui.widget.RecipeBookButtonWidget; +import net.minecraft.item.ItemGroup; + +public class ClothRegistry { + + public static void register() { + Runnable configRunnable = () -> ClientHelper.openConfigWindow(MinecraftClient.getInstance().currentScreen, false); + ClothModMenuHooks.CONFIG_BUTTON_EVENT.registerListener(event -> { + if (event.getModContainer() != null && event.getModContainer().getMetadata().getId().equalsIgnoreCase("roughlyenoughitems")) { + event.setEnabled(true); + event.setClickedRunnable(configRunnable); + event.setCancelled(true); + } + }, EventPriority.LOWEST); + ClothHooks.CLIENT_SYNC_RECIPES.registerListener(event -> { + ((RecipeHelperImpl) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(event.getManager()); + }); + ClothHooks.CLIENT_SCREEN_ADD_BUTTON.registerListener(event -> { + if (RoughlyEnoughItemsCore.getConfigManager().getConfig().disableRecipeBook && event.getScreen() instanceof ContainerScreen && event.getButtonWidget() instanceof RecipeBookButtonWidget) + event.setCancelled(true); + }, EventPriority.LOWEST); + ClothHooks.CLIENT_POST_INIT_SCREEN.registerListener(post -> { + if (post.getScreen() instanceof ContainerScreen) { + if (post.getScreen() instanceof CreativePlayerInventoryScreen) { + TabGetter tabGetter = (TabGetter) post.getScreen(); + if (tabGetter.rei_getSelectedTab() != ItemGroup.INVENTORY.getIndex()) + return; + } + ScreenHelper.setLastContainerScreen((ContainerScreen) post.getScreen()); + post.getInputListeners().add(ScreenHelper.getLastOverlay(true)); + } + }, EventPriority.LOWEST); + ClothHooks.CLIENT_POST_DRAW_SCREEN.registerListener(post -> { + if (post.getScreen() instanceof ContainerScreen) { + if (post.getScreen() instanceof CreativePlayerInventoryScreen) { + TabGetter tabGetter = (TabGetter) post.getScreen(); + if (tabGetter.rei_getSelectedTab() != ItemGroup.INVENTORY.getIndex()) + return; + } + ScreenHelper.getLastOverlay().drawOverlay(post.getMouseX(), post.getMouseY(), post.getDelta()); + } + }, EventPriority.LOWEST); + } + +} |
