aboutsummaryrefslogtreecommitdiff
path: root/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-08-27 19:36:00 +0800
committershedaniel <daniel@shedaniel.me>2020-08-27 19:36:50 +0800
commit6104964f60bac00a4ac1359bd244d361e50786bd (patch)
tree04bf0350e7305633436bb133e8647f0cecce0bf5 /RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java
parent935417891d62500610fb05ce75dc8d63219c39d2 (diff)
downloadRoughlyEnoughItems-6104964f60bac00a4ac1359bd244d361e50786bd.tar.gz
RoughlyEnoughItems-6104964f60bac00a4ac1359bd244d361e50786bd.tar.bz2
RoughlyEnoughItems-6104964f60bac00a4ac1359bd244d361e50786bd.zip
Migrate from yarn to mojmap
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java')
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java54
1 files changed, 27 insertions, 27 deletions
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java
index 07cf9fcfc..bb0cb8a2b 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java
@@ -26,6 +26,8 @@ package me.shedaniel.rei.impl;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import com.mojang.blaze3d.platform.Window;
+import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.cloth.api.client.events.v0.ClothClientHooks;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
@@ -47,34 +49,32 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
import net.fabricmc.loader.api.FabricLoader;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.screen.ingame.ContainerScreen;
-import net.minecraft.client.util.Window;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.ActionResult;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.InteractionResult;
+import net.minecraft.world.item.ItemStack;
import org.apache.logging.log4j.util.TriConsumer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
-import static me.shedaniel.rei.impl.Internals.attachInstance;
-
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
+import static me.shedaniel.rei.impl.Internals.attachInstance;
+
@ApiStatus.Internal
@Environment(EnvType.CLIENT)
public class ScreenHelper implements ClientModInitializer, REIHelper {
- private static final Identifier DISPLAY_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/display.png");
- private static final Identifier DISPLAY_TEXTURE_DARK = new Identifier("roughlyenoughitems", "textures/gui/display_dark.png");
+ private static final ResourceLocation DISPLAY_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/display.png");
+ private static final ResourceLocation DISPLAY_TEXTURE_DARK = new ResourceLocation("roughlyenoughitems", "textures/gui/display_dark.png");
private OverlaySearchField searchField;
@ApiStatus.Internal
public static List<ItemStack> inventoryStacks = Lists.newArrayList();
private static ContainerScreenOverlay overlay;
- private static ContainerScreen<?> previousContainerScreen = null;
+ private static AbstractContainerScreen<?> previousContainerScreen = null;
private static LinkedHashSet<RecipeScreen> lastRecipeScreen = Sets.newLinkedHashSetWithExpectedSize(5);
private static ScreenHelper instance;
@@ -171,25 +171,25 @@ public class ScreenHelper implements ClientModInitializer, REIHelper {
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
- public static ContainerScreen<?> getLastHandledScreen() {
+ public static AbstractContainerScreen<?> getLastHandledScreen() {
return previousContainerScreen;
}
@Override
- public ContainerScreen<?> getPreviousContainerScreen() {
+ public AbstractContainerScreen<?> getPreviousContainerScreen() {
return previousContainerScreen;
}
- public static void setPreviousContainerScreen(ContainerScreen<?> previousContainerScreen) {
+ public static void setPreviousContainerScreen(AbstractContainerScreen<?> previousContainerScreen) {
ScreenHelper.previousContainerScreen = previousContainerScreen;
}
- public static void drawHoveringWidget(MatrixStack matrices, int x, int y, TriConsumer<MatrixStack, Point, Float> consumer, int width, int height, float delta) {
- Window window = MinecraftClient.getInstance().getWindow();
- drawHoveringWidget(matrices, window.getScaledWidth(), window.getScaledHeight(), x, y, consumer, width, height, delta);
+ public static void drawHoveringWidget(PoseStack matrices, int x, int y, TriConsumer<PoseStack, Point, Float> consumer, int width, int height, float delta) {
+ Window window = Minecraft.getInstance().getWindow();
+ drawHoveringWidget(matrices, window.getGuiScaledWidth(), window.getGuiScaledHeight(), x, y, consumer, width, height, delta);
}
- public static void drawHoveringWidget(MatrixStack matrices, int screenWidth, int screenHeight, int x, int y, TriConsumer<MatrixStack, Point, Float> consumer, int width, int height, float delta) {
+ public static void drawHoveringWidget(PoseStack matrices, int screenWidth, int screenHeight, int x, int y, TriConsumer<PoseStack, Point, Float> consumer, int width, int height, float delta) {
int actualX = Math.max(x + 12, 6);
int actualY = Math.min(y - height / 2, screenHeight - height - 6);
if (actualX + width > screenWidth)
@@ -215,7 +215,7 @@ public class ScreenHelper implements ClientModInitializer, REIHelper {
}
@Override
- public Identifier getDefaultDisplayTexture() {
+ public ResourceLocation getDefaultDisplayTexture() {
return isDarkThemeEnabled() ? DISPLAY_TEXTURE_DARK : DISPLAY_TEXTURE;
}
@@ -240,14 +240,14 @@ public class ScreenHelper implements ClientModInitializer, REIHelper {
WarningAndErrorScreen warningAndErrorScreen = WarningAndErrorScreen.INSTANCE.get();
warningAndErrorScreen.setParent(screen);
try {
- if (client.currentScreen != null) client.currentScreen.removed();
+ if (client.screen != null) client.screen.removed();
} catch (Throwable ignored) {
}
- client.currentScreen = null;
- client.openScreen(warningAndErrorScreen);
- } else if (previousContainerScreen != screen && screen instanceof ContainerScreen)
- previousContainerScreen = (ContainerScreen<?>) screen;
- return ActionResult.PASS;
+ client.screen = null;
+ client.setScreen(warningAndErrorScreen);
+ } else if (previousContainerScreen != screen && screen instanceof AbstractContainerScreen)
+ previousContainerScreen = (AbstractContainerScreen<?>) screen;
+ return InteractionResult.PASS;
});
boolean loaded = FabricLoader.getInstance().isModLoaded("fabric-events-lifecycle-v0");
if (!loaded) {