| 1 | package net.minecraft.client.gui.screens.options.controls;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import java.util.List;
|
| 5 | import net.fabricmc.api.EnvType;
|
| 6 | import net.fabricmc.api.Environment;
|
| 7 | import net.minecraft.client.OptionInstance;
|
| 8 | import net.minecraft.client.Options;
|
| 9 | import net.minecraft.client.gui.components.Button;
|
| 10 | import net.minecraft.client.gui.screens.Screen;
|
| 11 | import net.minecraft.client.gui.screens.options.MouseSettingsScreen;
|
| 12 | import net.minecraft.client.gui.screens.options.OptionsSubScreen;
|
| 13 | import net.minecraft.client.input.InputQuirks;
|
| 14 | import net.minecraft.network.chat.Component;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class ControlsScreen extends OptionsSubScreen {
|
| 18 | private static final Component TITLE = Component.translatable("controls.title");
|
| 19 |
|
| 20 | private static OptionInstance<?>[] options(final Options options) {
|
| 21 | List<OptionInstance<?>> result = Lists.newArrayList(
|
| 22 | options.toggleCrouch(),
|
| 23 | options.toggleSprint(),
|
| 24 | options.toggleAttack(),
|
| 25 | options.toggleUse(),
|
| 26 | options.autoJump(),
|
| 27 | options.sprintWindow(),
|
| 28 | options.quitShortcuts()
|
| 29 | );
|
| 30 | if (InputQuirks.EMULATE_RIGHT_CLICK_WITH_CTRL_KEY) {
|
| 31 | result.add(options.ctrlClickEmulatesRightClick());
|
| 32 | }
|
| 33 |
|
| 34 | result.add(options.operatorItemsTab());
|
| 35 | return result.toArray(OptionInstance[]::new);
|
| 36 | }
|
| 37 |
|
| 38 | public ControlsScreen(final Screen lastScreen, final Options options) {
|
| 39 | super(lastScreen, options, TITLE);
|
| 40 | }
|
| 41 |
|
| 42 | @Override
|
| 43 | protected void addOptions() {
|
| 44 | this.list
|
| 45 | .addSmall(
|
| 46 | Button.builder(Component.translatable("options.mouse_settings"), var1 -> this.minecraft.gui.setScreen(new MouseSettingsScreen(this, this.options))).build(),
|
| 47 | Button.builder(Component.translatable("controls.keybinds"), var1 -> this.minecraft.gui.setScreen(new KeyBindsScreen(this, this.options))).build()
|
| 48 | );
|
| 49 | this.list.addSmall(options(this.options));
|
| 50 | }
|
| 51 | }
|
| 52 |
|