Skip to content

Commit b4d22c2

Browse files
committed
port to 26.2-snapshot-2
1 parent e54f9e8 commit b4d22c2

99 files changed

Lines changed: 636 additions & 459 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.

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ dependencies {
3333
implementation(plugin("dev.isxander.modstitch.base", "0.8.4"))
3434
implementation(plugin("dev.isxander.secrets", "0.1.0"))
3535
implementation(plugin("dev.kikugie.stonecutter", "0.8.2"))
36-
implementation(plugin("fabric-loom", "1.14.9"))
36+
implementation(plugin("fabric-loom", "1.16.1"))
3737
implementation(plugin("net.neoforged.moddev", "2.0.137"))
3838
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub.curseforgeSlug=controlify
1111
pub.modrinthId=DOUdJVEm
1212
githubProject=isXander/Controlify
1313

14-
deps.fabricLoader=0.18.4
14+
deps.fabricLoader=0.19.1
1515
deps.sdl3Target=3.2.18.release-3.2.18
1616
deps.sdl34jBuild=79
1717
deps.hid4java=0.8.0

src/main/java/dev/isxander/controlify/Controlify.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void preInitialiseControlify() {
173173
});
174174

175175
PlatformClientUtil.addHudLayer(CUtil.rl("button_guide"), (graphics, deltaTracker) ->
176-
inGameButtonGuide().ifPresent(guide -> guide.renderHud(graphics, deltaTracker.getGameTimeDeltaPartialTick(false))));
176+
inGameButtonGuide().ifPresent(guide -> guide.extractRenderState(graphics, deltaTracker.getGameTimeDeltaPartialTick(false))));
177177

178178
PlatformMainUtil.applyToControlifyEntrypoint(entrypoint -> {
179179
try {
@@ -386,7 +386,7 @@ private void onControllerAdded(ControllerEntity controller, boolean hotplugged)
386386
);
387387

388388
if (hotplugged) {
389-
ToastUtils.sendToast(
389+
MinecraftUtil.sendToast(
390390
Component.translatable("controlify.toast.controller_connected.title"),
391391
Component.translatable("controlify.toast.controller_connected.description", controller.name()),
392392
false
@@ -410,7 +410,7 @@ private void onControllerRemoved(ControllerEntity controller) {
410410
this.selectFirstConnectedController();
411411
}
412412

413-
ToastUtils.sendToast(
413+
MinecraftUtil.sendToast(
414414
Component.translatable("controlify.toast.controller_disconnected.title"),
415415
Component.translatable("controlify.toast.controller_disconnected.description", controller.name()),
416416
false
@@ -429,14 +429,14 @@ private void selectFirstConnectedController() {
429429
* Only the current controller ticks.
430430
*/
431431
public void tick(Minecraft client) {
432-
if (minecraft.getOverlay() == null) {
432+
if (MinecraftUtil.getOverlay() == null) {
433433
if (currentSetupWizard != null && currentSetupWizard.isDone()) {
434434
currentSetupWizard = null;
435435
}
436436

437-
if (!setupWizards.isEmpty() && !(minecraft.screen instanceof DontInteruptScreen)) {
437+
if (!setupWizards.isEmpty() && !(MinecraftUtil.getScreen() instanceof DontInteruptScreen)) {
438438
currentSetupWizard = setupWizards.poll();
439-
minecraft.setScreen(currentSetupWizard.start(minecraft.screen));
439+
MinecraftUtil.setScreen(currentSetupWizard.start(MinecraftUtil.getScreen()));
440440
}
441441
}
442442

@@ -493,8 +493,8 @@ private void tickActiveController(ControllerEntity controller, boolean outOfFocu
493493
ControllerStateView state = input.stateNow();
494494
Optional<RumbleManager> rumbleManager = controller.rumble().map(RumbleComponent::rumbleManager);
495495

496-
boolean isPaused = minecraft.isPaused() || minecraft.screen instanceof PauseScreen;
497-
boolean isConfigScreen = minecraft.screen instanceof YACLScreen;
496+
boolean isPaused = minecraft.isPaused() || MinecraftUtil.getScreen() instanceof PauseScreen;
497+
boolean isConfigScreen = MinecraftUtil.getScreen() instanceof YACLScreen;
498498

499499
rumbleManager.ifPresent(rumble -> rumble.setSilent(outOfFocus || (isPaused && !isConfigScreen) || currentInputMode() == InputMode.KEYBOARD_MOUSE));
500500
if (outOfFocus) {
@@ -515,7 +515,7 @@ private void tickActiveController(ControllerEntity controller, boolean outOfFocu
515515

516516
if (consecutiveInputSwitches > 100) {
517517
CUtil.LOGGER.warn("Controlify detected current controller to be constantly giving input and has been disabled.");
518-
ToastUtils.sendToast(
518+
MinecraftUtil.sendToast(
519519
Component.translatable("controlify.toast.faulty_input.title"),
520520
Component.translatable("controlify.toast.faulty_input.description"),
521521
true
@@ -530,8 +530,8 @@ private void tickActiveController(ControllerEntity controller, boolean outOfFocu
530530
}
531531

532532
if (this.currentInputMode().isController()) {
533-
if (minecraft.screen != null) {
534-
ScreenProcessorProvider.provide(minecraft.screen).onControllerUpdate(controller);
533+
if (MinecraftUtil.getScreen() != null) {
534+
ScreenProcessorProvider.provide(MinecraftUtil.getScreen()).onControllerUpdate(controller);
535535
}
536536

537537
ControlifyEvents.ACTIVE_CONTROLLER_TICKED.invoke(new ControlifyEvents.ControllerStateUpdate(controller));
@@ -611,8 +611,8 @@ public boolean setInputMode(@NotNull InputMode newInputMode) {
611611
}
612612

613613
// notify current screen of input mode change
614-
if (minecraft.screen != null) {
615-
ScreenProcessorProvider.provide(minecraft.screen).onInputModeChanged(newInputMode);
614+
if (MinecraftUtil.getScreen() != null) {
615+
ScreenProcessorProvider.provide(MinecraftUtil.getScreen()).onInputModeChanged(newInputMode);
616616
}
617617

618618
// notify event listeners of input mode change
@@ -673,12 +673,12 @@ public void hideMouse(boolean hide, boolean moveMouse) {
673673
? GLFW.GLFW_CURSOR_HIDDEN
674674
: GLFW.GLFW_CURSOR_NORMAL
675675
);
676-
if (minecraft.screen != null) {
676+
if (MinecraftUtil.getScreen() != null) {
677677
var mouseHandlerAccessor = (MouseHandlerAccessor) minecraft.mouseHandler;
678678
if (hide && !virtualMouseHandler().isVirtualMouseEnabled() && moveMouse) {
679679
// stop mouse hovering over last element before hiding cursor but don't actually move it
680680
// so when the user switches back to mouse it will be in the same place
681-
mouseHandlerAccessor.invokeOnMove(handle, -50, -50);
681+
mouseHandlerAccessor.controlify$invokeOnMove(handle, -50, -50);
682682
}
683683
}
684684
}
@@ -722,7 +722,7 @@ public void notifyNewServer(ServerData data) {
722722
return;
723723

724724
if (config().getSettings().globalSettings().seenServers.add(data.ip)) {
725-
ToastUtils.sendToast(
725+
MinecraftUtil.sendToast(
726726
Component.translatable("controlify.toast.new_server.title"),
727727
Component.translatable("controlify.toast.new_server.description", data.name),
728728
true

src/main/java/dev/isxander/controlify/api/guide/InGameFacts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private InGameFacts() {}
4848
/** When the player is in a state where pressing jump will cause the elytra to deploy */
4949
public static final Fact<InGameCtx> CAN_ELYTRA_FLY = register(
5050
CUtil.rl("can_elytra_fly"),
51-
ctx -> ((PlayerAccessor) ctx.player()).callCanGlide()
51+
ctx -> ((PlayerAccessor) ctx.player()).controlify$callCanGlide()
5252
&& !ctx.player().onClimbable()
5353
&& !ctx.player().onGround()
5454
&& !ctx.player().isInLiquid()

src/main/java/dev/isxander/controlify/bindings/BindContext.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dev.isxander.controlify.gui.screen.RadialMenuScreen;
55
import dev.isxander.controlify.screenop.ScreenProcessorProvider;
66
import dev.isxander.controlify.utils.CUtil;
7+
import dev.isxander.controlify.utils.MinecraftUtil;
78
import dev.isxander.controlify.virtualmouse.VirtualMouseBehaviour;
89
import net.minecraft.client.Minecraft;
910
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
@@ -23,42 +24,42 @@ public record BindContext(Identifier id, Function<Minecraft, Boolean> isApplicab
2324

2425
public static final BindContext IN_GAME = register(
2526
"in_game",
26-
mc -> mc.screen == null && mc.level != null && mc.player != null
27+
mc -> MinecraftUtil.getScreen() == null && mc.level != null && mc.player != null
2728
);
2829

2930
public static final BindContext ANY_SCREEN = register(
3031
"screen",
31-
mc -> mc.screen != null
32+
mc -> MinecraftUtil.getScreen() != null
3233
);
3334

3435
public static final BindContext REGULAR_SCREEN = register(
3536
"regular_screen",
36-
mc -> mc.screen != null
37+
mc -> MinecraftUtil.getScreen() != null
3738
&& !Controlify.instance().virtualMouseHandler().isVirtualMouseEnabled()
3839
);
3940

4041
public static final BindContext CONTAINER = register(
4142
"container",
42-
mc -> mc.screen instanceof AbstractContainerScreen<?>
43+
mc -> MinecraftUtil.getScreen() instanceof AbstractContainerScreen<?>
4344
);
4445

4546
public static final BindContext V_MOUSE_CURSOR = register(
4647
"vmouse_cursor",
47-
mc -> mc.screen != null
48-
&& ScreenProcessorProvider.provide(mc.screen).virtualMouseBehaviour().hasCursor()
48+
mc -> MinecraftUtil.getScreen() != null
49+
&& ScreenProcessorProvider.provide(MinecraftUtil.getScreen()).virtualMouseBehaviour().hasCursor()
4950
&& Controlify.instance().virtualMouseHandler().isVirtualMouseEnabled()
5051
);
5152

5253
public static final BindContext V_MOUSE_COMPAT = register(
5354
"vmouse_compat",
54-
mc -> mc.screen != null
55-
&& ScreenProcessorProvider.provide(mc.screen).virtualMouseBehaviour() == VirtualMouseBehaviour.ENABLED
55+
mc -> MinecraftUtil.getScreen() != null
56+
&& ScreenProcessorProvider.provide(MinecraftUtil.getScreen()).virtualMouseBehaviour() == VirtualMouseBehaviour.ENABLED
5657
&& Controlify.instance().virtualMouseHandler().isVirtualMouseEnabled()
5758
);
5859

5960
public static final BindContext RADIAL_MENU = register(
6061
"radial_menu",
61-
mc -> mc.screen instanceof RadialMenuScreen
62+
mc -> MinecraftUtil.getScreen() instanceof RadialMenuScreen
6263
);
6364

6465
private static BindContext register(String path, Function<Minecraft, Boolean> predicate) {

src/main/java/dev/isxander/controlify/bindings/RadialIcons.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import dev.isxander.controlify.utils.CUtil;
55
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
66
import net.minecraft.client.Minecraft;
7-
import net.minecraft.client.gui.Gui;
87
import net.minecraft.client.renderer.RenderPipelines;
98
import net.minecraft.core.Holder;
109
import net.minecraft.core.registries.BuiltInRegistries;
@@ -70,7 +69,11 @@ private static void addPotionEffects(Map<Identifier, RadialIcon> map) {
7069

7170
Holder<MobEffect> effect = BuiltInRegistries.MOB_EFFECT.wrapAsHolder(entry.getValue());
7271

73-
Identifier sprite = Gui.getMobEffectSprite(effect);
72+
//? if >=26.2 {
73+
Identifier sprite = net.minecraft.client.gui.Hud.getMobEffectSprite(effect);
74+
//?} else {
75+
/*Identifier sprite = net.minecraft.client.gui.Gui.getMobEffectSprite(effect);
76+
*///?}
7477

7578
map.put(key.identifier().withPrefix("effect/"), (graphics, x, y, a) -> {
7679
var pose = graphics.pose().pushMatrix();

src/main/java/dev/isxander/controlify/bindings/output/KeyMappingEmulationOutput.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import dev.isxander.controlify.bindings.KeyMappingHandle;
66
import dev.isxander.controlify.bindings.StateAccess;
77
import dev.isxander.controlify.controller.ControllerEntity;
8+
import dev.isxander.controlify.utils.MinecraftUtil;
89
import net.minecraft.client.KeyMapping;
910
import net.minecraft.client.Minecraft;
1011

@@ -37,7 +38,7 @@ private void push() {
3738
if (ControlifyApi.get().getCurrentController().orElse(null) != controller)
3839
return; // only emulate current controller
3940

40-
if (Minecraft.getInstance().screen != null)
41+
if (MinecraftUtil.getScreen() != null)
4142
return; // minecraft keybinds don't work in gui screens it conflicts
4243

4344
KeyMappingHandle handle = (KeyMappingHandle) keyMapping;

src/main/java/dev/isxander/controlify/compatibility/fancymenu/OpenControlifySettingsAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import de.keksuccino.fancymenu.customization.action.Action;
55
import dev.isxander.controlify.gui.screen.ControlifySettingsScreen;
6+
import dev.isxander.controlify.utils.MinecraftUtil;
67
import net.minecraft.client.Minecraft;
78
import net.minecraft.network.chat.Component;
89
import org.jetbrains.annotations.NotNull;
@@ -20,7 +21,7 @@ public boolean hasValue() {
2021

2122
@Override
2223
public void execute(@Nullable String s) {
23-
ControlifySettingsScreen.openScreen(Minecraft.getInstance().screen);
24+
ControlifySettingsScreen.openScreen(MinecraftUtil.getScreen());
2425
}
2526

2627
@Override

src/main/java/dev/isxander/controlify/compatibility/simplevoicechat/SimpleVoiceChatCompat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import dev.isxander.controlify.api.bind.InputBindingSupplier;
99
import dev.isxander.controlify.compatibility.simplevoicechat.mixins.KeyEventsAccessor;
1010
import dev.isxander.controlify.controller.ControllerEntity;
11+
import dev.isxander.controlify.utils.MinecraftUtil;
1112
import net.minecraft.client.Minecraft;
1213
import net.minecraft.client.renderer.RenderPipelines;
1314
import net.minecraft.network.chat.CommonComponents;
@@ -98,7 +99,7 @@ public static boolean isWhisperDown() {
9899
}
99100

100101
private static void checkConnected() {
101-
if (Minecraft.getInstance().getOverlay() == null && Minecraft.getInstance().screen == null) {
102+
if (MinecraftUtil.getOverlay() == null && MinecraftUtil.getScreen() == null) {
102103
((KeyEventsAccessor) ClientManager.instance().getKeyEvents()).invokeCheckConnected();
103104
}
104105
}

src/main/java/dev/isxander/controlify/controller/haptic/HDHapticComponent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public void playHaptic(SoundEvent sound) {
5454
.getSound(randomSource).getLocation();
5555

5656
SoundManager soundManager = Minecraft.getInstance().getSoundManager();
57-
SoundEngine soundEngine = ((SoundManagerAccessor) soundManager).getSoundEngine();
58-
SoundBufferLibrary bufferLibrary = ((SoundEngineAccessor) soundEngine).getSoundBuffers();
57+
SoundEngine soundEngine = ((SoundManagerAccessor) soundManager).controlify$getSoundEngine();
58+
SoundBufferLibrary bufferLibrary = ((SoundEngineAccessor) soundEngine).controlify$getSoundBuffers();
5959

6060
Identifier soundId = location.withPrefix("sounds/").withSuffix(".ogg");
6161

@@ -75,8 +75,8 @@ private CompletableFuture<CompleteSoundData> getSoundData(Identifier id, Complet
7575
return sound
7676
.thenApply(soundBuffer -> hapticData.computeIfAbsent(id, key -> {
7777
var accessor = (SoundBufferAccessor) soundBuffer;
78-
ByteBuffer bytes = accessor.getData();
79-
AudioFormat format = accessor.getFormat();
78+
ByteBuffer bytes = accessor.controlify$getData();
79+
AudioFormat format = accessor.controlify$getFormat();
8080

8181
if (bytes == null) {
8282
return null;

0 commit comments

Comments
 (0)