Created
June 7, 2023 15:29
-
-
Save isXander/620141860bbcea24af4190c18443bda2 to your computer and use it in GitHub Desktop.
mixin error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dev.isxander.yacl3.mixin; | |
import net.minecraft.client.gui.components.events.ContainerEventHandler; | |
import net.minecraft.client.gui.components.events.GuiEventListener; | |
import net.minecraft.client.gui.components.tabs.TabNavigationBar; | |
import net.minecraft.client.gui.navigation.FocusNavigationEvent; | |
import net.minecraft.client.gui.navigation.ScreenAxis; | |
import net.minecraft.client.gui.navigation.ScreenDirection; | |
import net.minecraft.client.gui.navigation.ScreenRectangle; | |
import org.jetbrains.annotations.Nullable; | |
import org.spongepowered.asm.mixin.Mixin; | |
import org.spongepowered.asm.mixin.injection.At; | |
import org.spongepowered.asm.mixin.injection.Redirect; | |
import java.util.List; | |
@Mixin(ContainerEventHandler.class) | |
public interface ContainerEventHandlerMixin { | |
/** | |
* This mixin is used to prevent the tab bar from being focused when navigating left or right | |
* through the YACL options screen. This can also apply to vanilla as navigating left or right | |
* should never result in focusing the always-at-the-top tab bar. | |
* Without this, navigating right from the option list focuses the tab bar, not the action buttons/description. | |
*/ | |
@Redirect(method = {"nextFocusPathVaguelyInDirection", "nextFocusPathInDirection"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/events/ContainerEventHandler;children()Ljava/util/List;")) | |
private List<?> modifyFocusCandidates(ContainerEventHandler instance, ScreenRectangle screenArea, ScreenDirection direction, @Nullable GuiEventListener focused, FocusNavigationEvent event) { | |
if (direction.getAxis() == ScreenAxis.HORIZONTAL) | |
return instance.children().stream().filter(child -> !(child instanceof TabNavigationBar)).toList(); | |
return instance.children(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment