Skip to content

Commit eefca91

Browse files
Migrate to official mappings
1 parent 6ba8448 commit eefca91

File tree

497 files changed

+7855
-7709
lines changed

Some content is hidden

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

497 files changed

+7855
-7709
lines changed

.github/workflows/auto_snapshot_update.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,14 @@ jobs:
6161

6262
- name: Migrate mappings
6363
run: |
64-
./gradlew migrateMappings --mappings ${{ inputs.yarn_mappings }} --overrideInputsIHaveABackup
65-
./gradlew migrateTestMappings --mappings ${{ inputs.yarn_mappings }} --overrideInputsIHaveABackup
66-
./gradlew migrateClassTweakerMappings --mappings ${{ inputs.yarn_mappings }} --overrideInputsIHaveABackup
64+
./gradlew migrateMappings --mappings "net.minecraft:mappings:${{ inputs.mc_version }}" --overrideInputsIHaveABackup
65+
./gradlew migrateGametestMappings --mappings "net.minecraft:mappings:${{ inputs.mc_version }}" --overrideInputsIHaveABackup
66+
./gradlew migrateClassTweakerMappings --mappings "net.minecraft:mappings:${{ inputs.mc_version }}" --overrideInputsIHaveABackup
6767
6868
- name: Update version constants
6969
run: |
7070
python scripts/update_version_constants.py \
7171
"${{ inputs.mc_version }}" \
72-
"${{ inputs.yarn_mappings }}" \
7372
"${{ inputs.fabric_loader }}" \
7473
"${{ inputs.fapi_version }}"
7574

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ repositories {
4040
dependencies {
4141
// To change the versions see the gradle.properties file
4242
minecraft "com.mojang:minecraft:${project.minecraft_version}"
43-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
43+
mappings loom.officialMojangMappings()
4444
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
4545
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
4646

scripts/update_version_constants.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re
33

44

5-
def update_gradle_properties(mc_version, yarn_mappings, fabric_loader, fapi_version):
5+
def update_gradle_properties(mc_version, fabric_loader, fapi_version):
66
print("Updating gradle.properties...")
77

88
# Read gradle.properties
@@ -12,7 +12,6 @@ def update_gradle_properties(mc_version, yarn_mappings, fabric_loader, fapi_vers
1212
# Define replacements
1313
replacements = {
1414
"minecraft_version": lambda v: mc_version,
15-
"yarn_mappings": lambda v: yarn_mappings,
1615
"loader_version": lambda v: fabric_loader,
1716
"fabric_version": lambda v: fapi_version,
1817
"mod_version": lambda v: v[: v.index("MC") + 2] + mc_version,
@@ -70,14 +69,12 @@ def update_mc_version_constant(mc_version):
7069
if __name__ == "__main__":
7170
parser = argparse.ArgumentParser()
7271
parser.add_argument("mc_version", help="Minecraft version")
73-
parser.add_argument("yarn_mappings", help="Yarn mappings version")
7472
parser.add_argument("fabric_loader", help="Fabric Loader version")
7573
parser.add_argument("fapi_version", help="Fabric API version")
7674
args = parser.parse_args()
7775

7876
update_gradle_properties(
7977
args.mc_version,
80-
args.yarn_mappings,
8178
args.fabric_loader,
8279
args.fapi_version,
8380
)

src/gametest/java/net/wurstclient/gametest/WurstClientTestHelper.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.lwjgl.glfw.GLFW;
2525
import org.lwjgl.system.MemoryUtil;
2626

27+
import com.mojang.blaze3d.platform.NativeImage;
2728
import com.mojang.brigadier.ParseResults;
2829
import com.mojang.brigadier.exceptions.CommandSyntaxException;
2930

@@ -34,12 +35,11 @@
3435
import net.fabricmc.fabric.api.client.gametest.v1.screenshot.TestScreenshotComparisonAlgorithm.RawImage;
3536
import net.fabricmc.fabric.impl.client.gametest.screenshot.TestScreenshotComparisonAlgorithms.RawImageImpl;
3637
import net.fabricmc.fabric.impl.client.gametest.threading.ThreadingImpl;
37-
import net.minecraft.block.Block;
38-
import net.minecraft.client.gui.screen.TitleScreen;
39-
import net.minecraft.client.texture.NativeImage;
40-
import net.minecraft.item.Item;
41-
import net.minecraft.item.ItemStack;
42-
import net.minecraft.server.command.ServerCommandSource;
38+
import net.minecraft.client.gui.screens.TitleScreen;
39+
import net.minecraft.commands.CommandSourceStack;
40+
import net.minecraft.world.item.Item;
41+
import net.minecraft.world.item.ItemStack;
42+
import net.minecraft.world.level.block.Block;
4343

4444
public enum WurstClientTestHelper
4545
{
@@ -99,7 +99,7 @@ public static void assertScreenshotEquals(ClientGameTestContext context,
9999

100100
private static boolean[][] alphaChannelToMask(NativeImage template)
101101
{
102-
if(!template.getFormat().hasAlpha())
102+
if(!template.format().hasAlpha())
103103
{
104104
int width = template.getWidth();
105105
int height = template.getHeight();
@@ -115,15 +115,15 @@ private static boolean[][] alphaChannelToMask(NativeImage template)
115115
boolean[][] mask = new boolean[width][height];
116116

117117
int size = width * height;
118-
int alphaOffset = template.getFormat().getAlphaOffset() / 8;
119-
int channelCount = template.getFormat().getChannelCount();
118+
int alphaOffset = template.format().alphaOffset() / 8;
119+
int channelCount = template.format().components();
120120

121121
for(int i = 0; i < size; i++)
122122
{
123123
int x = i % width;
124124
int y = i / width;
125125
int alpha = MemoryUtil.memGetByte(
126-
template.pointer + i * channelCount + alphaOffset) & 0xff;
126+
template.pixels + i * channelCount + alphaOffset) & 0xff;
127127
mask[x][y] = alpha > 127;
128128
}
129129

@@ -172,7 +172,7 @@ public static NativeImage downloadImage(String url)
172172
public static void hideSplashTexts(ClientGameTestContext context)
173173
{
174174
context.runOnClient(mc -> {
175-
mc.options.getHideSplashTexts().setValue(true);
175+
mc.options.hideSplashTexts().set(true);
176176
});
177177
}
178178

@@ -183,20 +183,20 @@ public static void hideSplashTexts(ClientGameTestContext context)
183183
public static void waitForTitleScreenFade(ClientGameTestContext context)
184184
{
185185
context.waitFor(mc -> {
186-
if(!(mc.currentScreen instanceof TitleScreen titleScreen))
186+
if(!(mc.screen instanceof TitleScreen titleScreen))
187187
return false;
188188

189-
return !titleScreen.doBackgroundFade;
189+
return !titleScreen.fading;
190190
});
191191
}
192192

193193
public static void runCommand(TestServerContext server, String command)
194194
{
195195
String commandWithPlayer = "execute as @p at @s run " + command;
196196
server.runOnServer(mc -> {
197-
ParseResults<ServerCommandSource> results =
198-
mc.getCommandManager().getDispatcher().parse(commandWithPlayer,
199-
mc.getCommandSource());
197+
ParseResults<CommandSourceStack> results =
198+
mc.getCommands().getDispatcher().parse(commandWithPlayer,
199+
mc.createCommandSourceStack());
200200

201201
if(!results.getExceptions().isEmpty())
202202
{
@@ -208,7 +208,7 @@ public static void runCommand(TestServerContext server, String command)
208208
throw new RuntimeException(errors.toString());
209209
}
210210

211-
mc.getCommandManager().execute(results, commandWithPlayer);
211+
mc.getCommands().performCommand(results, commandWithPlayer);
212212
});
213213
}
214214

@@ -288,14 +288,14 @@ public static String tryUploadToImgur(Path imagePath)
288288
public static void waitForBlock(ClientGameTestContext context, int relX,
289289
int relY, int relZ, Block block)
290290
{
291-
context.waitFor(mc -> mc.world
292-
.getBlockState(mc.player.getBlockPos().add(relX, relY, relZ))
291+
context.waitFor(mc -> mc.level
292+
.getBlockState(mc.player.blockPosition().offset(relX, relY, relZ))
293293
.getBlock() == block);
294294
}
295295

296296
public static void clearChat(ClientGameTestContext context)
297297
{
298-
context.runOnClient(mc -> mc.inGameHud.getChatHud().clear(true));
298+
context.runOnClient(mc -> mc.gui.getChat().clearMessages(true));
299299
}
300300

301301
public static void clearInventory(ClientGameTestContext context)
@@ -308,7 +308,7 @@ public static void clearInventory(ClientGameTestContext context)
308308

309309
public static void clearParticles(ClientGameTestContext context)
310310
{
311-
context.runOnClient(mc -> mc.particleManager.clearParticles());
311+
context.runOnClient(mc -> mc.particleEngine.clearParticles());
312312
}
313313

314314
public static void clearToasts(ClientGameTestContext context)
@@ -320,8 +320,8 @@ public static void assertOneItemInSlot(ClientGameTestContext context,
320320
int slot, Item item)
321321
{
322322
ItemStack stack = context
323-
.computeOnClient(mc -> mc.player.getInventory().getStack(slot));
324-
if(!stack.isOf(item) || stack.getCount() != 1)
323+
.computeOnClient(mc -> mc.player.getInventory().getItem(slot));
324+
if(!stack.is(item) || stack.getCount() != 1)
325325
throw new RuntimeException(
326326
"Expected 1 " + item.getName().getString() + " at slot " + slot
327327
+ ", found " + stack.getCount() + " "
@@ -332,7 +332,7 @@ public static void assertNoItemInSlot(ClientGameTestContext context,
332332
int slot)
333333
{
334334
ItemStack stack = context
335-
.computeOnClient(mc -> mc.player.getInventory().getStack(slot));
335+
.computeOnClient(mc -> mc.player.getInventory().getItem(slot));
336336
if(!stack.isEmpty())
337337
throw new RuntimeException("Expected no item in slot " + slot
338338
+ ", found " + stack.getCount() + " "

src/gametest/java/net/wurstclient/gametest/WurstTest.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
import net.fabricmc.fabric.api.client.gametest.v1.context.TestSingleplayerContext;
2525
import net.fabricmc.fabric.api.client.gametest.v1.world.TestWorldBuilder;
2626
import net.minecraft.SharedConstants;
27-
import net.minecraft.block.Blocks;
28-
import net.minecraft.client.gui.screen.world.WorldCreator;
29-
import net.minecraft.world.GameRules;
30-
import net.minecraft.world.gen.chunk.FlatChunkGenerator;
31-
import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig;
32-
import net.minecraft.world.gen.chunk.FlatChunkGeneratorLayer;
27+
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
28+
import net.minecraft.world.level.GameRules;
29+
import net.minecraft.world.level.block.Blocks;
30+
import net.minecraft.world.level.levelgen.FlatLevelSource;
31+
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
32+
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
3333
import net.wurstclient.gametest.tests.*;
3434

3535
public class WurstTest implements FabricClientGameTest
@@ -55,10 +55,10 @@ public void runTest(ClientGameTestContext context)
5555
LOGGER.info("Creating test world");
5656
TestWorldBuilder worldBuilder = context.worldBuilder();
5757
worldBuilder.adjustSettings(creator -> {
58-
String mcVersion = SharedConstants.getGameVersion().getName();
59-
creator.setWorldName("E2E Test " + mcVersion);
60-
creator.setGameMode(WorldCreator.Mode.CREATIVE);
61-
creator.getGameRules().get(GameRules.SEND_COMMAND_FEEDBACK)
58+
String mcVersion = SharedConstants.getCurrentVersion().getName();
59+
creator.setName("E2E Test " + mcVersion);
60+
creator.setGameMode(WorldCreationUiState.SelectedGameMode.CREATIVE);
61+
creator.getGameRules().getRule(GameRules.RULE_SENDCOMMANDFEEDBACK)
6262
.set(false, null);
6363
applyFlatPresetWithSmoothStone(creator);
6464
});
@@ -138,19 +138,19 @@ private void testInWorld(ClientGameTestContext context,
138138
}
139139

140140
// because the grass texture is randomized and smooth stone isn't
141-
private void applyFlatPresetWithSmoothStone(WorldCreator creator)
141+
private void applyFlatPresetWithSmoothStone(WorldCreationUiState creator)
142142
{
143-
FlatChunkGeneratorConfig config =
144-
((FlatChunkGenerator)creator.getGeneratorOptionsHolder()
145-
.selectedDimensions().getChunkGenerator()).getConfig();
146-
147-
List<FlatChunkGeneratorLayer> layers =
148-
List.of(new FlatChunkGeneratorLayer(1, Blocks.BEDROCK),
149-
new FlatChunkGeneratorLayer(2, Blocks.DIRT),
150-
new FlatChunkGeneratorLayer(1, Blocks.SMOOTH_STONE));
151-
152-
creator.applyModifier((drm, dorHolder) -> dorHolder.with(drm,
153-
new FlatChunkGenerator(config.with(layers,
154-
config.getStructureOverrides(), config.getBiome()))));
143+
FlatLevelGeneratorSettings config = ((FlatLevelSource)creator
144+
.getSettings().selectedDimensions().overworld()).settings();
145+
146+
List<FlatLayerInfo> layers =
147+
List.of(new FlatLayerInfo(1, Blocks.BEDROCK),
148+
new FlatLayerInfo(2, Blocks.DIRT),
149+
new FlatLayerInfo(1, Blocks.SMOOTH_STONE));
150+
151+
creator.updateDimensions(
152+
(drm, dorHolder) -> dorHolder.replaceOverworldGenerator(drm,
153+
new FlatLevelSource(config.withBiomeAndLayers(layers,
154+
config.structureOverrides(), config.getBiome()))));
155155
}
156156
}

src/gametest/java/net/wurstclient/gametest/mixin/ScreenMixin.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
import org.spongepowered.asm.mixin.injection.Inject;
1414
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1515

16-
import net.minecraft.client.gui.AbstractParentElement;
17-
import net.minecraft.client.gui.DrawContext;
18-
import net.minecraft.client.gui.Drawable;
19-
import net.minecraft.client.gui.screen.Screen;
20-
import net.minecraft.util.Colors;
16+
import net.minecraft.client.gui.GuiGraphics;
17+
import net.minecraft.client.gui.components.Renderable;
18+
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
19+
import net.minecraft.client.gui.screens.Screen;
20+
import net.minecraft.util.CommonColors;
2121

2222
@Mixin(Screen.class)
23-
public abstract class ScreenMixin extends AbstractParentElement
24-
implements Drawable
23+
public abstract class ScreenMixin extends AbstractContainerEventHandler
24+
implements Renderable
2525
{
2626
@Shadow
2727
public int width;
@@ -32,13 +32,11 @@ public abstract class ScreenMixin extends AbstractParentElement
3232
* Replaces the panorama background with a gray background to make test
3333
* screenshots consistent.
3434
*/
35-
@Inject(at = @At("HEAD"),
36-
method = "renderPanoramaBackground",
37-
cancellable = true)
38-
public void renderPanoramaBackground(DrawContext context, float deltaTicks,
35+
@Inject(at = @At("HEAD"), method = "renderPanorama", cancellable = true)
36+
public void renderPanoramaBackground(GuiGraphics context, float deltaTicks,
3937
CallbackInfo ci)
4038
{
41-
context.fill(0, 0, width, height, Colors.GRAY);
39+
context.fill(0, 0, width, height, CommonColors.GRAY);
4240
ci.cancel();
4341
}
4442
}

src/gametest/java/net/wurstclient/gametest/mixin/TitleScreenMixin.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
import org.spongepowered.asm.mixin.injection.Inject;
1313
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1414

15-
import net.minecraft.client.gui.DrawContext;
16-
import net.minecraft.client.gui.screen.Screen;
17-
import net.minecraft.client.gui.screen.TitleScreen;
18-
import net.minecraft.text.Text;
19-
import net.minecraft.util.Colors;
15+
import net.minecraft.client.gui.GuiGraphics;
16+
import net.minecraft.client.gui.screens.Screen;
17+
import net.minecraft.client.gui.screens.TitleScreen;
18+
import net.minecraft.network.chat.Component;
19+
import net.minecraft.util.CommonColors;
2020
import net.wurstclient.WurstClient;
2121

2222
@Mixin(TitleScreen.class)
2323
public abstract class TitleScreenMixin extends Screen
2424
{
25-
private TitleScreenMixin(WurstClient wurst, Text title)
25+
private TitleScreenMixin(WurstClient wurst, Component title)
2626
{
2727
super(title);
2828
}
@@ -31,13 +31,11 @@ private TitleScreenMixin(WurstClient wurst, Text title)
3131
* Replaces the panorama background with a gray background to make test
3232
* screenshots consistent.
3333
*/
34-
@Inject(at = @At("HEAD"),
35-
method = "renderPanoramaBackground",
36-
cancellable = true)
37-
public void renderPanoramaBackground(DrawContext context, float deltaTicks,
34+
@Inject(at = @At("HEAD"), method = "renderPanorama", cancellable = true)
35+
public void renderPanoramaBackground(GuiGraphics context, float deltaTicks,
3836
CallbackInfo ci)
3937
{
40-
context.fill(0, 0, width, height, Colors.GRAY);
38+
context.fill(0, 0, width, height, CommonColors.GRAY);
4139
ci.cancel();
4240
}
4341
}

0 commit comments

Comments
 (0)