|
| 1 | +package net.F53.HorseBuff.mixin.Client; |
| 2 | + |
| 3 | +import net.minecraft.client.MinecraftClient; |
| 4 | +import net.minecraft.client.gui.screen.Screen; |
| 5 | +import net.minecraft.client.gui.screen.ingame.InventoryScreen; |
| 6 | +import net.minecraft.client.network.ClientPlayerEntity; |
| 7 | +import net.minecraft.client.tutorial.TutorialManager; |
| 8 | +import org.jetbrains.annotations.Nullable; |
| 9 | +import org.spongepowered.asm.mixin.Final; |
| 10 | +import org.spongepowered.asm.mixin.Mixin; |
| 11 | +import org.spongepowered.asm.mixin.Shadow; |
| 12 | +import org.spongepowered.asm.mixin.injection.At; |
| 13 | +import org.spongepowered.asm.mixin.injection.Redirect; |
| 14 | + |
| 15 | +@Mixin(MinecraftClient.class) |
| 16 | +public abstract class InventoryAccessor { |
| 17 | + @Shadow @Final private TutorialManager tutorialManager; |
| 18 | + |
| 19 | + @Shadow public abstract void setScreen(@Nullable Screen screen); |
| 20 | + |
| 21 | + @Shadow @Nullable public ClientPlayerEntity player; |
| 22 | + |
| 23 | + @Redirect(method="net/minecraft/client/MinecraftClient.handleInputEvents()V", at = @At(value = "INVOKE", target = "net/minecraft/client/network/ClientPlayerEntity.openRidingInventory ()V")) |
| 24 | + void teergtoind(ClientPlayerEntity instance){ |
| 25 | + assert this.player != null; |
| 26 | + if (MinecraftClient.getInstance().options.sprintKey.isPressed()) { |
| 27 | + tutorialManager.onInventoryOpened(); |
| 28 | + setScreen(new InventoryScreen(this.player)); |
| 29 | + } |
| 30 | + else { |
| 31 | + instance.openRidingInventory(); |
| 32 | + } |
| 33 | + } |
| 34 | +} |
0 commit comments