aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/utils/ClothRegistry.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/shedaniel/rei/utils/ClothRegistry.java')
-rw-r--r--src/main/java/me/shedaniel/rei/utils/ClothRegistry.java58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/main/java/me/shedaniel/rei/utils/ClothRegistry.java b/src/main/java/me/shedaniel/rei/utils/ClothRegistry.java
index 7e85cfab1..ba87250f2 100644
--- a/src/main/java/me/shedaniel/rei/utils/ClothRegistry.java
+++ b/src/main/java/me/shedaniel/rei/utils/ClothRegistry.java
@@ -1,8 +1,7 @@
package me.shedaniel.rei.utils;
-import me.shedaniel.cloth.ClothInitializer;
-import me.shedaniel.cloth.api.EventPriority;
-import me.shedaniel.cloth.hooks.ClothHooks;
+import me.shedaniel.cloth.api.ClientUtils;
+import me.shedaniel.cloth.hooks.ClothClientHooks;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.TabGetter;
import me.shedaniel.rei.client.RecipeHelperImpl;
@@ -12,46 +11,49 @@ 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;
+import net.minecraft.util.ActionResult;
public class ClothRegistry {
public static void register() {
- ClothHooks.CLIENT_SYNC_RECIPES.registerListener(event -> {
- ((RecipeHelperImpl) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(event.getManager());
+ ClothClientHooks.SYNC_RECIPES.register((minecraftClient, recipeManager, synchronizeRecipesS2CPacket) -> {
+ ((RecipeHelperImpl) RoughlyEnoughItemsCore.getRecipeHelper()).recipesLoaded(recipeManager);
});
- 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();
+ ClothClientHooks.SCREEN_ADD_BUTTON.register((minecraftClient, screen, abstractButtonWidget) -> {
+ if (RoughlyEnoughItemsCore.getConfigManager().getConfig().disableRecipeBook && screen instanceof ContainerScreen && abstractButtonWidget instanceof RecipeBookButtonWidget)
+ return ActionResult.FAIL;
+ return ActionResult.PASS;
+ });
+ ClothClientHooks.SCREEN_INIT_POST.register((minecraftClient, screen, screenHooks) -> {
+ if (screen instanceof ContainerScreen) {
+ if (screen instanceof CreativePlayerInventoryScreen) {
+ TabGetter tabGetter = (TabGetter) screen;
if (tabGetter.rei_getSelectedTab() != ItemGroup.INVENTORY.getIndex())
return;
}
- ScreenHelper.setLastContainerScreen((ContainerScreen) post.getScreen());
- post.getInputListeners().add(ScreenHelper.getLastOverlay(true, false));
+ ScreenHelper.setLastContainerScreen((ContainerScreen) screen);
+ screenHooks.cloth_getInputListeners().add(ScreenHelper.getLastOverlay(true, false));
}
- }, EventPriority.LOWEST);
- ClothHooks.CLIENT_POST_DRAW_SCREEN.registerListener(post -> {
- if (post.getScreen() instanceof ContainerScreen) {
- if (post.getScreen() instanceof CreativePlayerInventoryScreen) {
- TabGetter tabGetter = (TabGetter) post.getScreen();
+ });
+ ClothClientHooks.SCREEN_RENDER_POST.register((minecraftClient, screen, i, i1, v) -> {
+ if (screen instanceof ContainerScreen) {
+ if (screen instanceof CreativePlayerInventoryScreen) {
+ TabGetter tabGetter = (TabGetter) screen;
if (tabGetter.rei_getSelectedTab() != ItemGroup.INVENTORY.getIndex())
return;
}
- ScreenHelper.getLastOverlay().drawOverlay(post.getMouseX(), post.getMouseY(), post.getDelta());
+ ScreenHelper.getLastOverlay().drawOverlay(i, i1, v);
}
- }, EventPriority.LOWEST);
- ClothHooks.CLIENT_SCREEN_MOUSE_SCROLLED.registerListener(event -> {
- if (event.getScreen() instanceof ContainerScreen && !(event.getScreen() instanceof CreativePlayerInventoryScreen)) {
+ });
+ ClothClientHooks.SCREEN_MOUSE_SCROLLED.register((minecraftClient, screen, v, v1, v2) -> {
+ if (screen instanceof ContainerScreen && !(screen instanceof CreativePlayerInventoryScreen)) {
ContainerScreenOverlay overlay = ScreenHelper.getLastOverlay();
- if (ScreenHelper.isOverlayVisible() && ContainerScreenOverlay.getItemListOverlay().getListArea().contains(ClothInitializer.clientUtils.getMouseLocation()))
- if (overlay.mouseScrolled(event.getMouseX(), event.getMouseY(), event.getAmount()))
- event.setCancelled(true);
+ if (ScreenHelper.isOverlayVisible() && ContainerScreenOverlay.getItemListOverlay().getListArea().contains(ClientUtils.getMouseLocation()))
+ if (overlay.mouseScrolled(v, v1, v2))
+ return ActionResult.SUCCESS;
}
- }, EventPriority.LOWEST);
+ return ActionResult.PASS;
+ });
}
}