| 1 | package net.minecraft.server.dialog;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import java.util.Optional;
|
| 5 | import net.minecraft.core.HolderGetter;
|
| 6 | import net.minecraft.core.registries.Registries;
|
| 7 | import net.minecraft.data.worldgen.BootstrapContext;
|
| 8 | import net.minecraft.network.chat.CommonComponents;
|
| 9 | import net.minecraft.network.chat.Component;
|
| 10 | import net.minecraft.resources.Identifier;
|
| 11 | import net.minecraft.resources.ResourceKey;
|
| 12 | import net.minecraft.tags.DialogTags;
|
| 13 |
|
| 14 | public class Dialogs {
|
| 15 | public static final ResourceKey<Dialog> SERVER_LINKS = create("server_links");
|
| 16 | public static final ResourceKey<Dialog> CUSTOM_OPTIONS = create("custom_options");
|
| 17 | public static final ResourceKey<Dialog> QUICK_ACTIONS = create("quick_actions");
|
| 18 | public static final int BIG_BUTTON_WIDTH = 310;
|
| 19 | private static final ActionButton DEFAULT_BACK_BUTTON = new ActionButton(new CommonButtonData(CommonComponents.GUI_BACK, 200), Optional.empty());
|
| 20 |
|
| 21 | private static ResourceKey<Dialog> create(final String id) {
|
| 22 | return ResourceKey.create(Registries.DIALOG, Identifier.withDefaultNamespace(id));
|
| 23 | }
|
| 24 |
|
| 25 | public static void bootstrap(final BootstrapContext<Dialog> context) {
|
| 26 | HolderGetter<Dialog> dialogs = context.lookup(Registries.DIALOG);
|
| 27 | context.register(
|
| 28 | SERVER_LINKS,
|
| 29 | new ServerLinksDialog(
|
| 30 | new CommonDialogData(
|
| 31 | Component.translatable("menu.server_links.title"),
|
| 32 | Optional.of(Component.translatable("menu.server_links")),
|
| 33 | true,
|
| 34 | true,
|
| 35 | DialogAction.CLOSE,
|
| 36 | List.of(),
|
| 37 | List.of()
|
| 38 | ),
|
| 39 | Optional.of(DEFAULT_BACK_BUTTON),
|
| 40 | 1,
|
| 41 | 310
|
| 42 | )
|
| 43 | );
|
| 44 | context.register(
|
| 45 | CUSTOM_OPTIONS,
|
| 46 | new DialogListDialog(
|
| 47 | new CommonDialogData(
|
| 48 | Component.translatable("menu.custom_options.title"),
|
| 49 | Optional.of(Component.translatable("menu.custom_options")),
|
| 50 | true,
|
| 51 | true,
|
| 52 | DialogAction.CLOSE,
|
| 53 | List.of(),
|
| 54 | List.of()
|
| 55 | ),
|
| 56 | dialogs.getOrThrow(DialogTags.PAUSE_SCREEN_ADDITIONS),
|
| 57 | Optional.of(DEFAULT_BACK_BUTTON),
|
| 58 | 1,
|
| 59 | 310
|
| 60 | )
|
| 61 | );
|
| 62 | context.register(
|
| 63 | QUICK_ACTIONS,
|
| 64 | new DialogListDialog(
|
| 65 | new CommonDialogData(
|
| 66 | Component.translatable("menu.quick_actions.title"),
|
| 67 | Optional.of(Component.translatable("menu.quick_actions")),
|
| 68 | true,
|
| 69 | true,
|
| 70 | DialogAction.CLOSE,
|
| 71 | List.of(),
|
| 72 | List.of()
|
| 73 | ),
|
| 74 | dialogs.getOrThrow(DialogTags.QUICK_ACTIONS),
|
| 75 | Optional.of(DEFAULT_BACK_BUTTON),
|
| 76 | 1,
|
| 77 | 310
|
| 78 | )
|
| 79 | );
|
| 80 | }
|
| 81 | }
|
| 82 |
|