Skip to content

Commit 00ebaf1

Browse files
committed
(half) working port to 1.21.11 splitscreen
1 parent 9440eb0 commit 00ebaf1

36 files changed

Lines changed: 179 additions & 152 deletions

splitscreen/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77

88
modstitch {
99
metadata {
10-
modVersion = "0.1.0-alpha.2+${stonecutter.current.version}"
10+
modVersion = "0.1.0-alpha.3+${stonecutter.current.version}"
1111
modId = "controlify_splitscreen"
1212
modName = "Controlify (Splitscreen)"
1313
}
@@ -31,7 +31,7 @@ repositories {
3131
}
3232

3333
val lwjglVersion = when (project.mcVersion) {
34-
"1.21.8" -> "3.3.3"
34+
"1.21.11" -> "3.3.3"
3535
else -> throw IllegalStateException("Can't get LWJGL version for: $mcVersion")
3636
}
3737

splitscreen/src/main/java/dev/isxander/splitscreen/client/ControllerBridge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ public interface ControllerBridge extends Bridge {
3131
/**
3232
* The client's music manager has attempted to play a track.
3333
*/
34-
void requestPlayMusic(@Nullable Music music, float volume);
34+
void requestPlayMusic(@Nullable Music music);
3535
}

splitscreen/src/main/java/dev/isxander/splitscreen/client/LocalSplitscreenPawn.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import net.minecraft.client.multiplayer.ClientLevel;
1010
import net.minecraft.client.multiplayer.ServerData;
1111
import net.minecraft.client.multiplayer.resolver.ServerAddress;
12-
import net.minecraft.resources.ResourceLocation;
12+
import net.minecraft.resources.Identifier;
1313
import org.jetbrains.annotations.Nullable;
1414

1515
/**
@@ -47,7 +47,7 @@ public void joinServer(String host, int port, byte @Nullable [] nonce) {
4747

4848
@Override
4949
public void disconnectFromServer() {
50-
PauseScreen.disconnectFromWorld(this.minecraft, ClientLevel.DEFAULT_QUIT_MESSAGE);
50+
this.minecraft.disconnectFromWorld(ClientLevel.DEFAULT_QUIT_MESSAGE);
5151
}
5252

5353
@Override
@@ -76,7 +76,7 @@ public void useInputMethod(InputMethod inputMethod) {
7676
}
7777

7878
@Override
79-
public void onConfigSave(ResourceLocation config) {
79+
public void onConfigSave(Identifier config) {
8080
ConfigSyncRegistry.onSave(config);
8181
}
8282

splitscreen/src/main/java/dev/isxander/splitscreen/client/SplitscreenPawn.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dev.isxander.splitscreen.client;
22

3-
import net.minecraft.resources.ResourceLocation;
3+
import net.minecraft.resources.Identifier;
44
import org.jetbrains.annotations.Nullable;
55

66
/**
@@ -50,7 +50,7 @@ public interface SplitscreenPawn extends Bridge {
5050
* Tells the pawns to load a specific config as it has been saved on the controller.
5151
* @param config the id of the config that was saved
5252
*/
53-
void onConfigSave(ResourceLocation config);
53+
void onConfigSave(Identifier config);
5454

5555
/**
5656
* @return the associated controller UID for this pawn, or null if no controller is associated

splitscreen/src/main/java/dev/isxander/splitscreen/client/config/SplitscreenConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import dev.isxander.yacl3.config.v3.JsonFileCodecConfig;
1212
import dev.isxander.yacl3.config.v3.ReadonlyConfigEntry;
1313
import net.fabricmc.loader.api.FabricLoader;
14-
import net.minecraft.resources.ResourceLocation;
14+
import net.minecraft.resources.Identifier;
1515

1616
@SuppressWarnings("UnstableApiUsage")
1717
public class SplitscreenConfig extends JsonFileCodecConfig<SplitscreenConfig> {
1818
public static final SplitscreenConfig INSTANCE = new SplitscreenConfig();
19-
public static final ResourceLocation CONFIG_ID = CSUtil.rl("config");
19+
public static final Identifier CONFIG_ID = CSUtil.rl("config");
2020

2121
public SplitscreenConfig() {
2222
super(FabricLoader.getInstance().getConfigDir().resolve("splitscreen.json"));

splitscreen/src/main/java/dev/isxander/splitscreen/client/engine/impl/reparenting/ReparentingHostSplitscreenEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void initWindow(
9393
LOGGER.info("Setting up parent window");
9494

9595
this.parentWindow = new ParentWindow(this.minecraft, screenSize, screenManager, this, initialTitle);
96-
this.localPawn = new LocalReparentingPawn(this.minecraft, this.windowManager.getNativeWindowHandle(this.minecraft.getWindow().getWindow()));
96+
this.localPawn = new LocalReparentingPawn(this.minecraft, this.windowManager.getNativeWindowHandle(this.minecraft.getWindow().handle()));
9797
this.registerPawn(this.localInputMethod, this.localPawn);
9898

9999
this.parentWindow.setIcon(minecraft.getVanillaPackResources(), SharedConstants.getCurrentVersion().stable() ? IconSet.RELEASE : IconSet.SNAPSHOT);
@@ -207,7 +207,7 @@ public void onResizeParentWindow(int width, int height) {
207207
public void onFocusParentWindow(boolean focused) {
208208
if (focused) {
209209
this.windowManager.setWindowForeground(this.parentWindow.getNativeWindowHandle());
210-
this.windowManager.setWindowFocused(this.windowManager.getNativeWindowHandle(this.minecraft.getWindow().getWindow()));
210+
this.windowManager.setWindowFocused(this.windowManager.getNativeWindowHandle(this.minecraft.getWindow().handle()));
211211
}
212212
}
213213

splitscreen/src/main/java/dev/isxander/splitscreen/client/engine/impl/reparenting/ReparentingRemoteSplitscreenEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static Optional<ReparentingRemoteSplitscreenEngine> tryGet(RemotePawnMain
5656

5757
public void onWindowInit() {
5858
Window window = this.minecraft.getWindow();
59-
NativeWindowHandle nativeHandle = this.windowManager.getNativeWindowHandle(window.getWindow());
59+
NativeWindowHandle nativeHandle = this.windowManager.getNativeWindowHandle(window.handle());
6060

6161
this.localPawn = new LocalReparentingPawn(this.minecraft, nativeHandle);
6262
this.payloadSender.sendPayload(new ControllerboundThisIsMyWindowPayload(nativeHandle));

splitscreen/src/main/java/dev/isxander/splitscreen/client/features/configsync/ConfigSyncRegistry.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
import dev.isxander.splitscreen.client.SplitscreenBootstrapper;
44
import dev.isxander.splitscreen.client.config.SplitscreenConfig;
5-
import net.minecraft.resources.ResourceLocation;
5+
import net.minecraft.resources.Identifier;
66

77
import java.util.HashMap;
88
import java.util.Map;
99

1010
public final class ConfigSyncRegistry {
11-
private static final Map<ResourceLocation, Runnable> savers = new HashMap<>();
11+
private static final Map<Identifier, Runnable> savers = new HashMap<>();
1212

1313
static {
1414
registerSaver(SplitscreenConfig.CONFIG_ID, SplitscreenConfig.INSTANCE::loadFromFile);
1515
}
1616

17-
public static void registerSaver(ResourceLocation location, Runnable saver) {
17+
public static void registerSaver(Identifier location, Runnable saver) {
1818
if (savers.containsKey(location)) {
1919
throw new IllegalArgumentException("Duplicate saver location: " + location);
2020
}
2121

2222
savers.put(location, saver);
2323
}
2424

25-
public static void onSave(ResourceLocation location) {
25+
public static void onSave(Identifier location) {
2626
SplitscreenBootstrapper.getController().ifPresent(controller -> {
2727
controller.forEachPawn(pawn -> pawn.onConfigSave(location));
2828
});

splitscreen/src/main/java/dev/isxander/splitscreen/client/host/HostLocalSplitscreenPawn.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import dev.isxander.splitscreen.client.InputMethod;
44
import dev.isxander.splitscreen.client.LocalSplitscreenPawn;
55
import net.minecraft.client.Minecraft;
6-
import net.minecraft.resources.ResourceLocation;
6+
import net.minecraft.resources.Identifier;
77
import org.jetbrains.annotations.Nullable;
88

99
public class HostLocalSplitscreenPawn extends LocalSplitscreenPawn {
@@ -30,7 +30,7 @@ public void joinServer(String host, int port, byte @Nullable [] nonce) {
3030
* @param config the id of the config that was saved
3131
*/
3232
@Override
33-
public void onConfigSave(ResourceLocation config) {
33+
public void onConfigSave(Identifier config) {
3434
// no-op
3535
}
3636
}

splitscreen/src/main/java/dev/isxander/splitscreen/client/host/LocalControllerBridge.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ public void signalRemoteClientReady(boolean finished, float progress, RemoteSpli
6262
}
6363

6464
@Override
65-
public void requestPlayMusic(@Nullable Music music, float volume) {
66-
this.requestPlayMusicRemote(music, volume, this.controller.getLocalPawn());
65+
public void requestPlayMusic(@Nullable Music music) {
66+
this.requestPlayMusicRemote(music, this.controller.getLocalPawn());
6767
}
6868

69-
public void requestPlayMusicRemote(@Nullable Music music, float volume, SplitscreenPawn pawn) {
70-
this.controller.getPawnMusicManager().onRequest(music, volume, pawn);
69+
public void requestPlayMusicRemote(@Nullable Music music, SplitscreenPawn pawn) {
70+
this.controller.getPawnMusicManager().onRequest(music, pawn);
7171
}
7272

7373
@Override

0 commit comments

Comments
 (0)