Skip to content

Commit c51c1c9

Browse files
committed
port: migrate to Minecraft 26.2
Version bumps (gradle.properties, fabric.mod.json, neoforge.mods.toml, build.gradle, CI workflow) and adaptation to 26.2 API breakages: - Minecraft#setScreen(Screen) -> setScreenAndShow(Screen) (global rename) - Minecraft#screen field removed -> Minecraft#gui.screen() (Gui refactor), including the one write site -> Minecraft#gui.setScreen(...) - Minecraft#getToastManager() -> Minecraft#gui.toastManager() - I18n.exists(String) removed -> Language.getInstance().has(String) - net.minecraft.util.Tuple removed -> new api.common.util.Pair record (exposes getA/getB and getFirst/getSecond); swapped across all modules - com.mojang.blaze3d.vertex.Tesselator removed; the single usage was dead code (consumers already commented out), so just removed the variable - MultiBufferSource removal already handled in SpriteRenderer (dead code) - GuiGraphicsExtractor$ScissorStack ctor -> ScreenRectangle arg - Architectury 21 networking: migrate the Identifier + FriendlyByteBuf C2S/S2C packets to CustomPacketPayload + StreamCodec (new REIPackets), gating S2C payload type registration to Env.SERVER to avoid double registration on the client/integrated server - neoforge: FluidStackHooksForge removed -> FluidStack.create(...) - accessWidener: drop AbstractContainerScreen#draggingItem (removed in 26.2, unused)
1 parent 3de4576 commit c51c1c9

72 files changed

Lines changed: 429 additions & 281 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/curseforge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ on:
2727
- 1.21.9
2828
- 1.21.11
2929
- 26.1
30+
- 26.2
3031

3132
jobs:
3233
build:

api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static ConfigManager getInstance() {
6363
* @param parent the screen shown before
6464
*/
6565
default void openConfigScreen(Screen parent) {
66-
Minecraft.getInstance().setScreen(getConfigScreen(parent));
66+
Minecraft.getInstance().setScreenAndShow(getConfigScreen(parent));
6767
}
6868

6969
/**

api/src/main/java/me/shedaniel/rei/api/client/config/addon/ConfigAddon.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public interface ConfigAddon {
5050

5151
/**
5252
* Opens the config screen for this addon, given the parent screen.
53-
* Do not call {@link net.minecraft.client.Minecraft#setScreen(Screen)} directly,
53+
* Do not call {@link net.minecraft.client.Minecraft#setScreenAndShow(Screen)} directly,
5454
* and make sure to set the screen as the parent screen to exit the config screen.
5555
*
5656
* @param parent the parent screen

api/src/main/java/me/shedaniel/rei/api/client/gui/compat/GuiGraphics.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.minecraft.client.Minecraft;
44
import net.minecraft.client.gui.Font;
55
import net.minecraft.client.gui.GuiGraphicsExtractor;
6+
import net.minecraft.client.gui.navigation.ScreenRectangle;
67
import net.minecraft.client.renderer.state.gui.GuiRenderState;
78
import net.minecraft.network.chat.Component;
89
import net.minecraft.util.FormattedCharSequence;
@@ -99,7 +100,7 @@ public void renderItemDecorations(Font font, ItemStack stack, int x, int y, Stri
99100
public void withFreshScissorStack(Runnable runnable) {
100101
GuiGraphicsExtractor.ScissorStack previous = this.scissorStack;
101102
try {
102-
this.scissorStack = new GuiGraphicsExtractor.ScissorStack();
103+
this.scissorStack = new GuiGraphicsExtractor.ScissorStack(ScreenRectangle.empty());
103104
runnable.run();
104105
} finally {
105106
this.scissorStack = previous;

api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import net.fabricmc.api.Environment;
3131
import net.minecraft.client.Minecraft;
3232
import me.shedaniel.rei.api.client.gui.compat.GuiGraphics;
33-
import net.minecraft.client.renderer.MultiBufferSource;
3433
import net.minecraft.client.renderer.rendertype.*;
3534
import net.minecraft.client.renderer.texture.AbstractTexture;
3635
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -70,7 +69,6 @@ public static class RenderPass {
7069
private float nZ = 0;
7170
private TextureAtlasSprite sprite;
7271
private VertexConsumer consumer;
73-
private MultiBufferSource consumers;
7472
private Matrix3x2fStack matrices;
7573
private Matrix4f model;
7674
private Matrix3f normal;
@@ -79,13 +77,6 @@ public static class RenderPass {
7977
private RenderPass() {
8078
}
8179

82-
public RenderPass setup(MultiBufferSource consumers, RenderType type) {
83-
this.consumers = consumers;
84-
this.setup(consumers.getBuffer(type), type);
85-
86-
return this;
87-
}
88-
8980
public RenderPass setup(VertexConsumer consumer, RenderType type) {
9081
this.consumer = consumer;
9182
this.matrices = new Matrix3x2fStack();
@@ -94,15 +85,6 @@ public RenderPass setup(VertexConsumer consumer, RenderType type) {
9485
return this;
9586
}
9687

97-
public RenderPass setup(MultiBufferSource consumers, GuiGraphics graphics, RenderType type) {
98-
this.consumers = consumers;
99-
this.consumer = consumers.getBuffer(type);
100-
this.matrices = graphics.pose();
101-
this.layer = type;
102-
103-
return this;
104-
}
105-
10688
public RenderPass position(Matrix4f model, float x1, float y1, float x2, float y2, float z1) {
10789
this.position(x1, y1, x2, y2, z1);
10890
this.model = model;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* This file is licensed under the MIT License, part of Roughly Enough Items.
3+
* Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
package me.shedaniel.rei.api.common.util;
25+
26+
/**
27+
* An immutable pair of values.
28+
*
29+
* <p>Introduced as a replacement for the removed
30+
* {@code net.minecraft.util.Tuple} in Minecraft 26.2. It exposes both the
31+
* old {@code Tuple} accessors ({@link #getA()} / {@link #getB()}) and the
32+
* {@code com.mojang.datafixers.util.Pair} accessors
33+
* ({@link #getFirst()} / {@link #getSecond()}) so call sites swapping away
34+
* from either removed type need no accessor renames.
35+
*/
36+
public record Pair<A, B>(A first, B second) {
37+
public A getA() {
38+
return first;
39+
}
40+
41+
public B getB() {
42+
return second;
43+
}
44+
45+
public A getFirst() {
46+
return first;
47+
}
48+
49+
public B getSecond() {
50+
return second;
51+
}
52+
}

default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/recipebook/DefaultRecipeBookHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Result handle(Context context) {
7373
return Result.createFailed(Component.translatable("error.rei.transfer.too_small", h, w));
7474
if (!context.isActuallyCrafting())
7575
return Result.createSuccessful();
76-
context.getMinecraft().setScreen(context.getContainerScreen());
76+
context.getMinecraft().setScreenAndShow(context.getContainerScreen());
7777
if (context.getContainerScreen() instanceof AbstractRecipeBookScreen<?> screen)
7878
screen.recipeBookComponent.ghostSlots.clear();
7979
context.getMinecraft().gameMode.handlePlaceRecipe(container.containerId, id, context.isStackedCrafting());
@@ -84,7 +84,7 @@ public Result handle(Context context) {
8484
RecipeDisplayId id = defaultDisplay.recipeDisplayId().get();
8585
if (!context.isActuallyCrafting())
8686
return Result.createSuccessful();
87-
context.getMinecraft().setScreen(context.getContainerScreen());
87+
context.getMinecraft().setScreenAndShow(context.getContainerScreen());
8888
if (context.getContainerScreen() instanceof AbstractRecipeBookScreen<?> screen)
8989
screen.recipeBookComponent.ghostSlots.clear();
9090
context.getMinecraft().gameMode.handlePlaceRecipe(container.containerId, id, context.isStackedCrafting());

fabric/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ unifiedPublishing {
123123
project {
124124
displayName = "[Fabric $rootProject.supported_version] v$project.version"
125125
releaseType = rootProject.unstable == "false" ? "release" : "alpha"
126-
gameVersions = ["26.1", "26.1.1", "26.1.2"]
126+
gameVersions = ["26.2"]
127127
gameLoaders = ["fabric"]
128128
changelog = rootProject.releaseChangelog
129129

fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ public class ErrorDisplayerImpl implements ErrorDisplayer.ErrorGuiInitializer {
3838
@Override
3939
public void registerGuiInit(UnaryOperator<Screen> consumer) {
4040
consumerList.add(screen -> {
41-
if (screen != Minecraft.getInstance().screen) return;
41+
if (screen != Minecraft.getInstance().gui.screen()) return;
4242
Screen screen1 = consumer.apply(screen);
4343
if (screen1 != null) {
4444
Minecraft minecraft = Minecraft.getInstance();
4545
try {
46-
if (minecraft.screen != null) minecraft.screen.removed();
46+
if (minecraft.gui.screen() != null) minecraft.gui.screen().removed();
4747
} catch (Throwable ignored) {
4848
}
49-
minecraft.screen = null;
50-
minecraft.setScreen(screen1);
49+
minecraft.gui.setScreen(null);
50+
minecraft.setScreenAndShow(screen1);
5151
}
5252
});
5353
}

fabric/src/main/java/me/shedaniel/rei/impl/client/gui/credits/fabric/CreditsScreenImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
package me.shedaniel.rei.impl.client.gui.credits.fabric;
2525

2626
import com.google.common.collect.Lists;
27+
import me.shedaniel.rei.api.common.util.Pair;
2728
import me.shedaniel.rei.impl.client.gui.credits.CreditsScreen;
2829
import net.fabricmc.loader.api.FabricLoader;
2930
import net.fabricmc.loader.api.metadata.CustomValue;
30-
import net.minecraft.util.Tuple;
3131

3232
import java.util.Comparator;
3333
import java.util.List;
3434
import java.util.stream.Collectors;
3535

3636
public class CreditsScreenImpl {
37-
public static void fillTranslators(Exception[] exception, List<Tuple<String, List<CreditsScreen.TranslatorEntry>>> translators) {
37+
public static void fillTranslators(Exception[] exception, List<Pair<String, List<CreditsScreen.TranslatorEntry>>> translators) {
3838
FabricLoader.getInstance().getModContainer("roughlyenoughitems").ifPresent(rei -> {
3939
try {
4040
if (rei.getMetadata().containsCustomValue("rei:translators")) {
@@ -56,10 +56,10 @@ public static void fillTranslators(Exception[] exception, List<Tuple<String, Lis
5656
.sorted(Comparator.comparing(CreditsScreen.TranslatorEntry::getName, String::compareToIgnoreCase))
5757
.collect(Collectors.toList())
5858
: Lists.newArrayList(new CreditsScreen.TranslatorEntry(value.getAsString()));
59-
translators.add(new Tuple<>(entry.getKey(), behind));
59+
translators.add(new Pair<>(entry.getKey(), behind));
6060
});
6161
}
62-
translators.sort(Comparator.comparing(Tuple::getA, String::compareToIgnoreCase));
62+
translators.sort(Comparator.comparing(Pair::getA, String::compareToIgnoreCase));
6363
} catch (Exception e) {
6464
exception[0] = e;
6565
e.printStackTrace();

0 commit comments

Comments
 (0)