Skip to content

Commit 0c9f171

Browse files
committed
Switch project to official Mojang mappings
1 parent 6d051c3 commit 0c9f171

File tree

561 files changed

+62630
-11075
lines changed

Some content is hidden

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

561 files changed

+62630
-11075
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ repositories {
6060
dependencies {
6161
// To change the versions see the gradle.properties file
6262
minecraft "com.mojang:minecraft:${project.minecraft_version}"
63-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
63+
mappings loom.officialMojangMappings()
6464
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
6565
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
6666

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ org.gradle.configuration-cache=true
77
# check these at https://fabricmc.net/develop/ and
88
# https://modrinth.com/mod/fabric-api/versions
99
minecraft_version=1.21.10
10-
yarn_mappings=1.21.10+build.2
10+
official_mappings=1.21.10
1111
loader_version=0.17.3
1212
loom_version=1.13-SNAPSHOT
1313

mojmap-migration.patch

Lines changed: 51788 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.joml.Vector2i;
2424
import org.lwjgl.glfw.GLFW;
2525
import org.lwjgl.system.MemoryUtil;
26-
26+
import com.mojang.blaze3d.platform.NativeImage;
2727
import com.mojang.brigadier.ParseResults;
2828
import com.mojang.brigadier.exceptions.CommandSyntaxException;
2929

@@ -34,12 +34,11 @@
3434
import net.fabricmc.fabric.api.client.gametest.v1.screenshot.TestScreenshotComparisonAlgorithm.RawImage;
3535
import net.fabricmc.fabric.impl.client.gametest.screenshot.TestScreenshotComparisonAlgorithms.RawImageImpl;
3636
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;
37+
import net.minecraft.client.gui.screens.TitleScreen;
38+
import net.minecraft.commands.CommandSourceStack;
39+
import net.minecraft.world.item.Item;
40+
import net.minecraft.world.item.ItemStack;
41+
import net.minecraft.world.level.block.Block;
4342

4443
public enum WurstClientTestHelper
4544
{
@@ -99,7 +98,7 @@ public static void assertScreenshotEquals(ClientGameTestContext context,
9998

10099
private static boolean[][] alphaChannelToMask(NativeImage template)
101100
{
102-
if(!template.getFormat().hasAlpha())
101+
if(!template.format().hasAlpha())
103102
{
104103
int width = template.getWidth();
105104
int height = template.getHeight();
@@ -115,15 +114,15 @@ private static boolean[][] alphaChannelToMask(NativeImage template)
115114
boolean[][] mask = new boolean[width][height];
116115

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

121120
for(int i = 0; i < size; i++)
122121
{
123122
int x = i % width;
124123
int y = i / width;
125124
int alpha = MemoryUtil.memGetByte(
126-
template.imageId() + i * channelCount + alphaOffset) & 0xff;
125+
template.getPointer() + i * channelCount + alphaOffset) & 0xff;
127126
mask[x][y] = alpha > 127;
128127
}
129128

@@ -172,7 +171,7 @@ public static NativeImage downloadImage(String url)
172171
public static void hideSplashTexts(ClientGameTestContext context)
173172
{
174173
context.runOnClient(mc -> {
175-
mc.options.getHideSplashTexts().setValue(true);
174+
mc.options.hideSplashTexts().set(true);
176175
});
177176
}
178177

@@ -183,20 +182,20 @@ public static void hideSplashTexts(ClientGameTestContext context)
183182
public static void waitForTitleScreenFade(ClientGameTestContext context)
184183
{
185184
context.waitFor(mc -> {
186-
if(!(mc.currentScreen instanceof TitleScreen titleScreen))
185+
if(!(mc.screen instanceof TitleScreen titleScreen))
187186
return false;
188187

189-
return !titleScreen.doBackgroundFade;
188+
return !titleScreen.fading;
190189
});
191190
}
192191

193192
public static void runCommand(TestServerContext server, String command)
194193
{
195194
String commandWithPlayer = "execute as @p at @s run " + command;
196195
server.runOnServer(mc -> {
197-
ParseResults<ServerCommandSource> results =
198-
mc.getCommandManager().getDispatcher().parse(commandWithPlayer,
199-
mc.getCommandSource());
196+
ParseResults<CommandSourceStack> results =
197+
mc.getCommands().getDispatcher().parse(commandWithPlayer,
198+
mc.createCommandSourceStack());
200199

201200
if(!results.getExceptions().isEmpty())
202201
{
@@ -208,7 +207,7 @@ public static void runCommand(TestServerContext server, String command)
208207
throw new RuntimeException(errors.toString());
209208
}
210209

211-
mc.getCommandManager().execute(results, commandWithPlayer);
210+
mc.getCommands().performCommand(results, commandWithPlayer);
212211
});
213212
}
214213

@@ -288,14 +287,14 @@ public static String tryUploadToImgur(Path imagePath)
288287
public static void waitForBlock(ClientGameTestContext context, int relX,
289288
int relY, int relZ, Block block)
290289
{
291-
context.waitFor(mc -> mc.world
292-
.getBlockState(mc.player.getBlockPos().add(relX, relY, relZ))
290+
context.waitFor(mc -> mc.level
291+
.getBlockState(mc.player.blockPosition().offset(relX, relY, relZ))
293292
.getBlock() == block);
294293
}
295294

296295
public static void clearChat(ClientGameTestContext context)
297296
{
298-
context.runOnClient(mc -> mc.inGameHud.getChatHud().clear(true));
297+
context.runOnClient(mc -> mc.gui.getChat().clearMessages(true));
299298
}
300299

301300
public static void clearInventory(ClientGameTestContext context)
@@ -308,7 +307,7 @@ public static void clearInventory(ClientGameTestContext context)
308307

309308
public static void clearParticles(ClientGameTestContext context)
310309
{
311-
context.runOnClient(mc -> mc.particleManager.clearParticles());
310+
context.runOnClient(mc -> mc.particleEngine.clearParticles());
312311
}
313312

314313
public static void clearToasts(ClientGameTestContext context)
@@ -320,8 +319,8 @@ public static void assertOneItemInSlot(ClientGameTestContext context,
320319
int slot, Item item)
321320
{
322321
ItemStack stack = context
323-
.computeOnClient(mc -> mc.player.getInventory().getStack(slot));
324-
if(!stack.isOf(item) || stack.getCount() != 1)
322+
.computeOnClient(mc -> mc.player.getInventory().getItem(slot));
323+
if(!stack.is(item) || stack.getCount() != 1)
325324
throw new RuntimeException(
326325
"Expected 1 " + item.getName().getString() + " at slot " + slot
327326
+ ", found " + stack.getCount() + " "
@@ -332,7 +331,7 @@ public static void assertNoItemInSlot(ClientGameTestContext context,
332331
int slot)
333332
{
334333
ItemStack stack = context
335-
.computeOnClient(mc -> mc.player.getInventory().getStack(slot));
334+
.computeOnClient(mc -> mc.player.getInventory().getItem(slot));
336335
if(!stack.isEmpty())
337336
throw new RuntimeException("Expected no item in slot " + slot
338337
+ ", 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().name();
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().name();
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 & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@
77
*/
88
package net.wurstclient.gametest.mixin;
99

10+
import net.minecraft.client.gui.GuiGraphics;
11+
import net.minecraft.client.gui.components.Renderable;
12+
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
13+
import net.minecraft.client.gui.screens.Screen;
14+
import net.minecraft.util.CommonColors;
1015
import org.spongepowered.asm.mixin.Mixin;
1116
import org.spongepowered.asm.mixin.Shadow;
1217
import org.spongepowered.asm.mixin.injection.At;
1318
import org.spongepowered.asm.mixin.injection.Inject;
1419
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1520

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;
21-
2221
@Mixin(Screen.class)
23-
public abstract class ScreenMixin extends AbstractParentElement
24-
implements Drawable
22+
public abstract class ScreenMixin extends AbstractContainerEventHandler
23+
implements Renderable
2524
{
2625
@Shadow
2726
public int width;
@@ -32,13 +31,11 @@ public abstract class ScreenMixin extends AbstractParentElement
3231
* Replaces the panorama background with a gray background to make test
3332
* screenshots consistent.
3433
*/
35-
@Inject(at = @At("HEAD"),
36-
method = "renderPanoramaBackground",
37-
cancellable = true)
38-
public void renderPanoramaBackground(DrawContext context, float deltaTicks,
34+
@Inject(at = @At("HEAD"), method = "renderPanorama", cancellable = true)
35+
public void renderPanoramaBackground(GuiGraphics context, float deltaTicks,
3936
CallbackInfo ci)
4037
{
41-
context.fill(0, 0, width, height, Colors.GRAY);
38+
context.fill(0, 0, width, height, CommonColors.GRAY);
4239
ci.cancel();
4340
}
4441
}

src/gametest/java/net/wurstclient/gametest/tests/AltManagerTest.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
package net.wurstclient.gametest.tests;
99

1010
import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext;
11-
import net.minecraft.client.MinecraftClient;
12-
import net.minecraft.client.gui.Drawable;
13-
import net.minecraft.client.gui.screen.TitleScreen;
14-
import net.minecraft.client.gui.widget.ButtonWidget;
15-
import net.minecraft.client.resource.language.I18n;
11+
import net.minecraft.client.Minecraft;
12+
import net.minecraft.client.gui.components.Button;
13+
import net.minecraft.client.gui.components.Renderable;
14+
import net.minecraft.client.gui.screens.TitleScreen;
15+
import net.minecraft.client.resources.language.I18n;
1616
import net.wurstclient.gametest.WurstTest;
1717

1818
public enum AltManagerTest
@@ -26,12 +26,12 @@ public static void testAltManagerButton(ClientGameTestContext context)
2626
WurstTest.LOGGER.info("Checking AltManager button position");
2727

2828
context.runOnClient(mc -> {
29-
if(!(mc.currentScreen instanceof TitleScreen))
29+
if(!(mc.screen instanceof TitleScreen))
3030
throw new RuntimeException("Not on the title screen");
3131

32-
ButtonWidget multiplayerButton = findButton(mc, "menu.multiplayer");
33-
ButtonWidget realmsButton = findButton(mc, "menu.online");
34-
ButtonWidget altManagerButton = findButton(mc, "Alt Manager");
32+
Button multiplayerButton = findButton(mc, "menu.multiplayer");
33+
Button realmsButton = findButton(mc, "menu.online");
34+
Button altManagerButton = findButton(mc, "Alt Manager");
3535

3636
checkButtonPosition(altManagerButton, realmsButton.getRight() + 4,
3737
multiplayerButton.getBottom() + 4);
@@ -46,13 +46,12 @@ public static void testAltManagerButton(ClientGameTestContext context)
4646
* For non-translated buttons, the translationKey parameter should be the
4747
* raw button text instead.
4848
*/
49-
public static ButtonWidget findButton(MinecraftClient mc,
50-
String translationKey)
49+
public static Button findButton(Minecraft mc, String translationKey)
5150
{
52-
String message = I18n.translate(translationKey);
51+
String message = I18n.get(translationKey);
5352

54-
for(Drawable drawable : mc.currentScreen.drawables)
55-
if(drawable instanceof ButtonWidget button
53+
for(Renderable drawable : mc.screen.renderables)
54+
if(drawable instanceof Button button
5655
&& button.getMessage().getString().equals(message))
5756
return button;
5857

@@ -63,7 +62,7 @@ public static ButtonWidget findButton(MinecraftClient mc,
6362
* Looks for the given button at the given coordinates and fails if it is
6463
* not there.
6564
*/
66-
public static void checkButtonPosition(ButtonWidget button, int expectedX,
65+
public static void checkButtonPosition(Button button, int expectedX,
6766
int expectedY)
6867
{
6968
String buttonName = button.getMessage().getString();

src/gametest/java/net/wurstclient/gametest/tests/AutoMineHackTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import net.fabricmc.fabric.api.client.gametest.v1.context.TestClientWorldContext;
1414
import net.fabricmc.fabric.api.client.gametest.v1.context.TestServerContext;
1515
import net.fabricmc.fabric.api.client.gametest.v1.context.TestSingleplayerContext;
16-
import net.minecraft.block.Blocks;
16+
import net.minecraft.world.level.block.Blocks;
1717
import net.wurstclient.gametest.WurstTest;
1818

1919
public enum AutoMineHackTest

src/gametest/java/net/wurstclient/gametest/tests/CopyItemCmdTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import net.fabricmc.fabric.api.client.gametest.v1.context.TestClientWorldContext;
1717
import net.fabricmc.fabric.api.client.gametest.v1.context.TestServerContext;
1818
import net.fabricmc.fabric.api.client.gametest.v1.context.TestSingleplayerContext;
19-
import net.minecraft.item.Items;
19+
import net.minecraft.world.item.Items;
2020
import net.wurstclient.gametest.WurstTest;
2121

2222
public enum CopyItemCmdTest

src/gametest/java/net/wurstclient/gametest/tests/GiveCmdTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext;
1313
import net.fabricmc.fabric.api.client.gametest.v1.context.TestSingleplayerContext;
14-
import net.minecraft.item.Items;
14+
import net.minecraft.world.item.Items;
1515
import net.wurstclient.gametest.WurstTest;
1616

1717
public enum GiveCmdTest

0 commit comments

Comments
 (0)