瀏覽代碼

Port to Architectury

Add workflows from architectury-api

Add maven and CurseForge publish

We need a dummy fabric.mod.json after all

Remove unused travis workflow

Relicense to LGPLv3

Finished the base port! \o/
(Please test this in production before publishing)

Basic module setup \o/

Base arch setup (haven't populated buildscripts yet)

Add .editorconfig from architectury

Update ALL THE THINGS!!!
(gradle, loom, mappings, mc, mod versions, aw, maybe something else i missed)
Max 4 年之前
父節點
當前提交
90bf3b6d70
共有 100 個文件被更改,包括 2393 次插入1797 次删除
  1. 261 0
      .editorconfig
  2. 0 29
      .github/workflows/gradle.yml
  3. 28 0
      .github/workflows/publish.yml
  4. 29 0
      .github/workflows/snapshot.yml
  5. 15 23
      .gitignore
  6. 0 2
      .travis.yml
  7. 0 24
      LICENSE
  8. 163 0
      LICENSE.md
  9. 41 145
      build.gradle
  10. 46 0
      common/build.gradle
  11. 2 0
      common/src/main/java/me/shedaniel/clothconfig2/ClothConfigInitializer.java
  12. 15 16
      common/src/main/java/me/shedaniel/clothconfig2/api/AbstractConfigEntry.java
  13. 6 6
      common/src/main/java/me/shedaniel/clothconfig2/api/AbstractConfigListEntry.java
  14. 11 12
      common/src/main/java/me/shedaniel/clothconfig2/api/ConfigBuilder.java
  15. 10 10
      common/src/main/java/me/shedaniel/clothconfig2/api/ConfigCategory.java
  16. 140 0
      common/src/main/java/me/shedaniel/clothconfig2/api/ConfigEntryBuilder.java
  17. 3 3
      common/src/main/java/me/shedaniel/clothconfig2/api/ConfigScreen.java
  18. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/api/Expandable.java
  19. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/api/LazyResettable.java
  20. 3 4
      common/src/main/java/me/shedaniel/clothconfig2/api/Modifier.java
  21. 83 0
      common/src/main/java/me/shedaniel/clothconfig2/api/ModifierKeyCode.java
  22. 15 15
      common/src/main/java/me/shedaniel/clothconfig2/api/QueuedTooltip.java
  23. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/api/ReferenceBuildingConfigScreen.java
  24. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/api/ReferenceProvider.java
  25. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/api/ScissorsHandler.java
  26. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/api/ScissorsScreen.java
  27. 29 29
      common/src/main/java/me/shedaniel/clothconfig2/api/ScrollingContainer.java
  28. 10 0
      common/src/main/java/me/shedaniel/clothconfig2/api/TabbedConfigScreen.java
  29. 7 8
      common/src/main/java/me/shedaniel/clothconfig2/api/Tooltip.java
  30. 65 65
      common/src/main/java/me/shedaniel/clothconfig2/gui/AbstractConfigScreen.java
  31. 8 9
      common/src/main/java/me/shedaniel/clothconfig2/gui/AbstractTabbedConfigScreen.java
  32. 97 97
      common/src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigScreen.java
  33. 13 14
      common/src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigTabButton.java
  34. 20 0
      common/src/main/java/me/shedaniel/clothconfig2/gui/ClothRequiresRestartScreen.java
  35. 106 106
      common/src/main/java/me/shedaniel/clothconfig2/gui/GlobalizedClothConfigScreen.java
  36. 5 5
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/AbstractListListEntry.java
  37. 19 20
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/AbstractTextFieldListListEntry.java
  38. 9 10
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListCell.java
  39. 44 45
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java
  40. 25 25
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BooleanListEntry.java
  41. 26 27
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/ColorEntry.java
  42. 19 19
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DoubleListEntry.java
  43. 11 11
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DoubleListListEntry.java
  44. 99 99
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DropdownBoxEntry.java
  45. 7 7
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/EnumListEntry.java
  46. 19 19
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/FloatListEntry.java
  47. 11 11
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/FloatListListEntry.java
  48. 19 19
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerListEntry.java
  49. 11 11
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerListListEntry.java
  50. 31 31
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerSliderEntry.java
  51. 27 26
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/KeyCodeEntry.java
  52. 19 19
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/LongListEntry.java
  53. 11 11
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/LongListListEntry.java
  54. 31 31
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/LongSliderEntry.java
  55. 28 28
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/MultiElementListEntry.java
  56. 7 7
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/NestedListListEntry.java
  57. 30 29
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/SelectionListEntry.java
  58. 6 6
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/StringListEntry.java
  59. 6 6
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/StringListListEntry.java
  60. 29 30
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/SubCategoryListEntry.java
  61. 33 33
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/TextFieldListEntry.java
  62. 17 18
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/TextListEntry.java
  63. 11 12
      common/src/main/java/me/shedaniel/clothconfig2/gui/entries/TooltipListEntry.java
  64. 9 9
      common/src/main/java/me/shedaniel/clothconfig2/gui/widget/ColorDisplayWidget.java
  65. 9 9
      common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicElementListWidget.java
  66. 101 100
      common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicEntryListWidget.java
  67. 36 35
      common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicNewSmoothScrollingEntryListWidget.java
  68. 18 21
      common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigBuilderImpl.java
  69. 13 13
      common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigCategoryImpl.java
  70. 30 30
      common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigEntryBuilderImpl.java
  71. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/impl/EasingMethod.java
  72. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/impl/EasingMethods.java
  73. 2 2
      common/src/main/java/me/shedaniel/clothconfig2/impl/GameOptionsHooks.java
  74. 0 0
      common/src/main/java/me/shedaniel/clothconfig2/impl/KeyBindingHooks.java
  75. 13 13
      common/src/main/java/me/shedaniel/clothconfig2/impl/ModifierKeyCodeImpl.java
  76. 12 14
      common/src/main/java/me/shedaniel/clothconfig2/impl/ScissorsHandlerImpl.java
  77. 12 12
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/BooleanToggleBuilder.java
  78. 12 12
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/ColorFieldBuilder.java
  79. 8 8
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DoubleFieldBuilder.java
  80. 15 16
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DoubleListBuilder.java
  81. 87 88
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DropdownMenuBuilder.java
  82. 10 10
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/EnumSelectorBuilder.java
  83. 7 7
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/FieldBuilder.java
  84. 8 8
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/FloatFieldBuilder.java
  85. 15 16
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/FloatListBuilder.java
  86. 8 8
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/IntFieldBuilder.java
  87. 15 15
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/IntListBuilder.java
  88. 10 10
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/IntSliderBuilder.java
  89. 14 15
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/KeyCodeBuilder.java
  90. 8 8
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/LongFieldBuilder.java
  91. 15 15
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/LongListBuilder.java
  92. 10 10
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/LongSliderBuilder.java
  93. 10 10
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/SelectorBuilder.java
  94. 8 8
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/StringFieldBuilder.java
  95. 15 16
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/StringListBuilder.java
  96. 7 7
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/SubCategoryBuilder.java
  97. 8 8
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/TextDescriptionBuilder.java
  98. 8 8
      common/src/main/java/me/shedaniel/clothconfig2/impl/builders/TextFieldBuilder.java
  99. 0 0
      common/src/main/java/me/shedaniel/math/api/Executor.java
  100. 4 4
      common/src/main/java/me/shedaniel/math/impl/PointHelper.java

+ 261 - 0
.editorconfig

@@ -0,0 +1,261 @@
+# This is beautiful.
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+tab_width = 4
+trim_trailing_whitespace = false
+ij_continuation_indent_size = 8
+
+[*.java]
+ij_java_align_consecutive_assignments = false
+ij_java_align_consecutive_variable_declarations = false
+ij_java_align_group_field_declarations = false
+ij_java_align_multiline_annotation_parameters = true
+ij_java_align_multiline_array_initializer_expression = false
+ij_java_align_multiline_assignment = false
+ij_java_align_multiline_binary_operation = true
+ij_java_align_multiline_chained_methods = false
+ij_java_align_multiline_extends_list = false
+ij_java_align_multiline_for = true
+ij_java_align_multiline_method_parentheses = false
+ij_java_align_multiline_parameters = false
+ij_java_align_multiline_parameters_in_calls = false
+ij_java_align_multiline_parenthesized_expression = false
+ij_java_align_multiline_records = true
+ij_java_align_multiline_resources = true
+ij_java_align_multiline_ternary_operation = false
+ij_java_align_multiline_text_blocks = false
+ij_java_align_multiline_throws_list = false
+ij_java_align_subsequent_simple_methods = false
+ij_java_align_throws_keyword = false
+ij_java_annotation_parameter_wrap = normal
+ij_java_array_initializer_new_line_after_left_brace = false
+ij_java_array_initializer_right_brace_on_new_line = false
+ij_java_array_initializer_wrap = off
+ij_java_assert_statement_colon_on_next_line = false
+ij_java_assert_statement_wrap = off
+ij_java_assignment_wrap = off
+ij_java_binary_operation_sign_on_next_line = false
+ij_java_binary_operation_wrap = off
+ij_java_blank_lines_after_anonymous_class_header = 0
+ij_java_blank_lines_after_class_header = 0
+ij_java_blank_lines_after_imports = 1
+ij_java_blank_lines_after_package = 1
+ij_java_blank_lines_around_class = 1
+ij_java_blank_lines_around_field = 0
+ij_java_blank_lines_around_field_in_interface = 0
+ij_java_blank_lines_around_initializer = 1
+ij_java_blank_lines_around_method = 1
+ij_java_blank_lines_around_method_in_interface = 1
+ij_java_blank_lines_before_class_end = 0
+ij_java_blank_lines_before_imports = 1
+ij_java_blank_lines_before_method_body = 0
+ij_java_blank_lines_before_package = 0
+ij_java_block_brace_style = end_of_line
+ij_java_block_comment_at_first_column = true
+ij_java_call_parameters_new_line_after_left_paren = false
+ij_java_call_parameters_right_paren_on_new_line = false
+ij_java_call_parameters_wrap = off
+ij_java_case_statement_on_separate_line = true
+ij_java_catch_on_new_line = false
+ij_java_class_annotation_wrap = split_into_lines
+ij_java_class_brace_style = end_of_line
+ij_java_class_count_to_use_import_on_demand = 5
+ij_java_class_names_in_javadoc = 1
+ij_java_do_not_indent_top_level_class_members = false
+ij_java_do_not_wrap_after_single_annotation = false
+ij_java_do_while_brace_force = never
+ij_java_doc_add_blank_line_after_description = true
+ij_java_doc_add_blank_line_after_param_comments = false
+ij_java_doc_add_blank_line_after_return = false
+ij_java_doc_add_p_tag_on_empty_lines = true
+ij_java_doc_align_exception_comments = true
+ij_java_doc_align_param_comments = true
+ij_java_doc_do_not_wrap_if_one_line = false
+ij_java_doc_enable_formatting = true
+ij_java_doc_enable_leading_asterisks = true
+ij_java_doc_indent_on_continuation = false
+ij_java_doc_keep_empty_lines = true
+ij_java_doc_keep_empty_parameter_tag = true
+ij_java_doc_keep_empty_return_tag = true
+ij_java_doc_keep_empty_throws_tag = true
+ij_java_doc_keep_invalid_tags = true
+ij_java_doc_param_description_on_new_line = false
+ij_java_doc_preserve_line_breaks = false
+ij_java_doc_use_throws_not_exception_tag = true
+ij_java_else_on_new_line = false
+ij_java_entity_dd_suffix = EJB
+ij_java_entity_eb_suffix = Bean
+ij_java_entity_hi_suffix = Home
+ij_java_entity_lhi_prefix = Local
+ij_java_entity_lhi_suffix = Home
+ij_java_entity_li_prefix = Local
+ij_java_entity_pk_class = java.lang.String
+ij_java_entity_vo_suffix = VO
+ij_java_enum_constants_wrap = split_into_lines
+ij_java_extends_keyword_wrap = off
+ij_java_extends_list_wrap = off
+ij_java_field_annotation_wrap = on_every_item
+ij_java_finally_on_new_line = false
+ij_java_for_brace_force = never
+ij_java_for_statement_new_line_after_left_paren = false
+ij_java_for_statement_right_paren_on_new_line = false
+ij_java_for_statement_wrap = off
+ij_java_generate_final_locals = false
+ij_java_generate_final_parameters = false
+ij_java_if_brace_force = never
+ij_java_imports_layout = *,|,javax.**,java.**,|,$*
+ij_java_indent_case_from_switch = true
+ij_java_insert_inner_class_imports = false
+ij_java_insert_override_annotation = true
+ij_java_keep_blank_lines_before_right_brace = 2
+ij_java_keep_blank_lines_between_package_declaration_and_header = 2
+ij_java_keep_blank_lines_in_code = 2
+ij_java_keep_blank_lines_in_declarations = 2
+ij_java_keep_control_statement_in_one_line = true
+ij_java_keep_first_column_comment = true
+ij_java_keep_indents_on_empty_lines = true
+ij_java_keep_line_breaks = true
+ij_java_keep_multiple_expressions_in_one_line = false
+ij_java_keep_simple_blocks_in_one_line = false
+ij_java_keep_simple_classes_in_one_line = true
+ij_java_keep_simple_lambdas_in_one_line = true
+ij_java_keep_simple_methods_in_one_line = true
+ij_java_label_indent_absolute = false
+ij_java_label_indent_size = 0
+ij_java_lambda_brace_style = end_of_line
+ij_java_layout_static_imports_separately = true
+ij_java_line_comment_add_space = false
+ij_java_line_comment_at_first_column = true
+ij_java_message_dd_suffix = EJB
+ij_java_message_eb_suffix = Bean
+ij_java_method_annotation_wrap = split_into_lines
+ij_java_method_brace_style = end_of_line
+ij_java_method_call_chain_wrap = off
+ij_java_method_parameters_new_line_after_left_paren = false
+ij_java_method_parameters_right_paren_on_new_line = false
+ij_java_method_parameters_wrap = off
+ij_java_modifier_list_wrap = false
+ij_java_names_count_to_use_import_on_demand = 3
+ij_java_new_line_after_lparen_in_record_header = false
+ij_java_parameter_annotation_wrap = normal
+ij_java_parentheses_expression_new_line_after_left_paren = false
+ij_java_parentheses_expression_right_paren_on_new_line = false
+ij_java_place_assignment_sign_on_next_line = false
+ij_java_prefer_longer_names = true
+ij_java_prefer_parameters_wrap = false
+ij_java_record_components_wrap = normal
+ij_java_repeat_synchronized = true
+ij_java_replace_instanceof_and_cast = false
+ij_java_replace_null_check = true
+ij_java_replace_sum_lambda_with_method_ref = true
+ij_java_resource_list_new_line_after_left_paren = false
+ij_java_resource_list_right_paren_on_new_line = false
+ij_java_resource_list_wrap = off
+ij_java_rparen_on_new_line_in_record_header = false
+ij_java_session_dd_suffix = EJB
+ij_java_session_eb_suffix = Bean
+ij_java_session_hi_suffix = Home
+ij_java_session_lhi_prefix = Local
+ij_java_session_lhi_suffix = Home
+ij_java_session_li_prefix = Local
+ij_java_session_si_suffix = Service
+ij_java_space_after_closing_angle_bracket_in_type_argument = false
+ij_java_space_after_colon = true
+ij_java_space_after_comma = true
+ij_java_space_after_comma_in_type_arguments = true
+ij_java_space_after_for_semicolon = true
+ij_java_space_after_quest = true
+ij_java_space_after_type_cast = true
+ij_java_space_before_annotation_array_initializer_left_brace = false
+ij_java_space_before_annotation_parameter_list = false
+ij_java_space_before_array_initializer_left_brace = false
+ij_java_space_before_catch_keyword = true
+ij_java_space_before_catch_left_brace = true
+ij_java_space_before_catch_parentheses = true
+ij_java_space_before_class_left_brace = true
+ij_java_space_before_colon = true
+ij_java_space_before_colon_in_foreach = true
+ij_java_space_before_comma = false
+ij_java_space_before_do_left_brace = true
+ij_java_space_before_else_keyword = true
+ij_java_space_before_else_left_brace = true
+ij_java_space_before_finally_keyword = true
+ij_java_space_before_finally_left_brace = true
+ij_java_space_before_for_left_brace = true
+ij_java_space_before_for_parentheses = true
+ij_java_space_before_for_semicolon = false
+ij_java_space_before_if_left_brace = true
+ij_java_space_before_if_parentheses = true
+ij_java_space_before_method_call_parentheses = false
+ij_java_space_before_method_left_brace = true
+ij_java_space_before_method_parentheses = false
+ij_java_space_before_opening_angle_bracket_in_type_parameter = false
+ij_java_space_before_quest = true
+ij_java_space_before_switch_left_brace = true
+ij_java_space_before_switch_parentheses = true
+ij_java_space_before_synchronized_left_brace = true
+ij_java_space_before_synchronized_parentheses = true
+ij_java_space_before_try_left_brace = true
+ij_java_space_before_try_parentheses = true
+ij_java_space_before_type_parameter_list = false
+ij_java_space_before_while_keyword = true
+ij_java_space_before_while_left_brace = true
+ij_java_space_before_while_parentheses = true
+ij_java_space_inside_one_line_enum_braces = false
+ij_java_space_within_empty_array_initializer_braces = false
+ij_java_space_within_empty_method_call_parentheses = false
+ij_java_space_within_empty_method_parentheses = false
+ij_java_spaces_around_additive_operators = true
+ij_java_spaces_around_assignment_operators = true
+ij_java_spaces_around_bitwise_operators = true
+ij_java_spaces_around_equality_operators = true
+ij_java_spaces_around_lambda_arrow = true
+ij_java_spaces_around_logical_operators = true
+ij_java_spaces_around_method_ref_dbl_colon = false
+ij_java_spaces_around_multiplicative_operators = true
+ij_java_spaces_around_relational_operators = true
+ij_java_spaces_around_shift_operators = true
+ij_java_spaces_around_type_bounds_in_type_parameters = true
+ij_java_spaces_around_unary_operator = false
+ij_java_spaces_within_angle_brackets = false
+ij_java_spaces_within_annotation_parentheses = false
+ij_java_spaces_within_array_initializer_braces = false
+ij_java_spaces_within_braces = false
+ij_java_spaces_within_brackets = false
+ij_java_spaces_within_cast_parentheses = false
+ij_java_spaces_within_catch_parentheses = false
+ij_java_spaces_within_for_parentheses = false
+ij_java_spaces_within_if_parentheses = false
+ij_java_spaces_within_method_call_parentheses = false
+ij_java_spaces_within_method_parentheses = false
+ij_java_spaces_within_parentheses = false
+ij_java_spaces_within_record_header = false
+ij_java_spaces_within_switch_parentheses = false
+ij_java_spaces_within_synchronized_parentheses = false
+ij_java_spaces_within_try_parentheses = false
+ij_java_spaces_within_while_parentheses = false
+ij_java_special_else_if_treatment = true
+ij_java_subclass_name_suffix = Impl
+ij_java_ternary_operation_signs_on_next_line = false
+ij_java_ternary_operation_wrap = off
+ij_java_test_name_suffix = Test
+ij_java_throws_keyword_wrap = normal
+ij_java_throws_list_wrap = off
+ij_java_use_external_annotations = false
+ij_java_use_fq_class_names = false
+ij_java_use_relative_indents = false
+ij_java_use_single_class_imports = true
+ij_java_variable_annotation_wrap = normal
+ij_java_visibility = public
+ij_java_while_brace_force = never
+ij_java_while_on_new_line = false
+ij_java_wrap_comments = false
+ij_java_wrap_first_method_in_call_chain = false
+ij_java_wrap_long_lines = false

+ 0 - 29
.github/workflows/gradle.yml

@@ -1,29 +0,0 @@
-name: Java CI
-
-on:
-  push:
-    branches:    
-      - v2
-      - v2-unstable
-      - v4
-      - v4-unstable
-
-jobs:
-  build:
-
-    runs-on: ubuntu-latest
-
-    steps:
-    - uses: actions/checkout@v1
-    - name: Set up JDK 1.8
-      uses: actions/setup-java@v1
-      with:
-        java-version: 1.8
-    - name: Upload to Bintray & CurseForge
-      run: ./gradlew clean bintrayUpload curseforge
-      env:
-        BINTRAY_USER: shedaniel
-        OSS_TOKEN: shedaniel
-        BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
-        OSS_PASS: ${{ secrets.OSS_PASS }}
-        CF_API_KEY: ${{ secrets.CF_API_KEY }}

+ 28 - 0
.github/workflows/publish.yml

@@ -0,0 +1,28 @@
+name: Compile & Release
+
+on:
+    push:
+        paths:
+            - '**.gradle'
+            - '**.properties'
+            - '**/src/**'
+        branches:
+            - "4.9"
+
+jobs:
+    build:
+        runs-on: ubuntu-latest
+        steps:
+            - uses: actions/checkout@v1
+            - name: Set up JDK 1.8
+              uses: actions/setup-java@v1
+              with:
+                  java-version: 1.8
+            - name: Upload to Bintray
+              run: ./gradlew bintrayUpload curseforgePublish --stacktrace
+              if: |
+                  !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.pull_request.title, '[ci skip]')
+              env:
+                  BINTRAY_USER: shedaniel
+                  BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
+                  curse_api_key: ${{ secrets.CURSE_API_KEY }}

+ 29 - 0
.github/workflows/snapshot.yml

@@ -0,0 +1,29 @@
+name: Snapshot Compile & Release
+
+on:
+    pull_request:
+        paths:
+            - '**.gradle'
+            - '**.properties'
+            - '**/src/**'
+        types: [ opened, synchronize, reopened ]
+
+jobs:
+    build:
+
+        runs-on: ubuntu-latest
+
+        steps:
+            - uses: actions/checkout@v1
+            - name: Set up JDK 1.8
+              uses: actions/setup-java@v1
+              with:
+                  java-version: 1.8
+            - name: Upload to Bintray
+              run: ./gradlew bintrayUpload --stacktrace
+              if: |
+                  !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.pull_request.title, '[ci skip]')
+              env:
+                  BINTRAY_USER: shedaniel
+                  BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
+                  PR_NUM: ${{github.event.number}}

+ 15 - 23
.gitignore

@@ -1,27 +1,19 @@
-# Compiled nonsense that does not belong in *source* control
-/build
-/bin
-/.gradle
-/minecraft
-/out
-/run
-/classes
-/old
-
-# IDE nonsense that could go in source control but really shouldn't
-.classpath
-.project
-.metadata
-.settings
-*.launch
-*.iml
-.idea
+build/
 *.ipr
+run/
 *.iws
+out/
+*.iml
+.gradle/
+output/
+bin/
+libs/
 
-# Sekrit files
-private.properties
+.classpath
+.project
+.settings/org.eclipse.core.resources.prefs
+.idea/
+classes/
 
-# Files from bad operating systems :^)
-Thumbs.db
-.DS_Store
+.vscode/
+logs/

+ 0 - 2
.travis.yml

@@ -1,2 +0,0 @@
-language: java
-script: ./gradlew clean build

+ 0 - 24
LICENSE

@@ -1,24 +0,0 @@
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means unless stated otherwise.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org>

+ 163 - 0
LICENSE.md

@@ -0,0 +1,163 @@
+GNU Lesser General Public License
+=================================
+
+_Version 3, 29 June 2007_  
+_Copyright © 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;_
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+
+This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+### 0. Additional Definitions
+
+As used herein, “this License” refers to version 3 of the GNU Lesser
+General Public License, and the “GNU GPL” refers to version 3 of the GNU
+General Public License.
+
+“The Library” refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+An “Application” is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+A “Combined Work” is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the “Linked
+Version”.
+
+The “Minimal Corresponding Source” for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+The “Corresponding Application Code” for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+### 1. Exception to Section 3 of the GNU GPL
+
+You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+### 2. Conveying Modified Versions
+
+If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+* **a)** under this License, provided that you make a good faith effort to
+  ensure that, in the event an Application does not supply the
+  function or data, the facility still operates, and performs
+  whatever part of its purpose remains meaningful, or
+
+* **b)** under the GNU GPL, with none of the additional permissions of
+  this License applicable to that copy.
+
+### 3. Object Code Incorporating Material from Library Header Files
+
+The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+* **a)** Give prominent notice with each copy of the object code that the
+  Library is used in it and that the Library and its use are
+  covered by this License.
+* **b)** Accompany the object code with a copy of the GNU GPL and this license
+  document.
+
+### 4. Combined Works
+
+You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+* **a)** Give prominent notice with each copy of the Combined Work that
+  the Library is used in it and that the Library and its use are
+  covered by this License.
+
+* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license
+  document.
+
+* **c)** For a Combined Work that displays copyright notices during
+  execution, include the copyright notice for the Library among
+  these notices, as well as a reference directing the user to the
+  copies of the GNU GPL and this license document.
+
+* **d)** Do one of the following:
+    - **0)** Convey the Minimal Corresponding Source under the terms of this
+      License, and the Corresponding Application Code in a form
+      suitable for, and under terms that permit, the user to
+      recombine or relink the Application with a modified version of
+      the Linked Version to produce a modified Combined Work, in the
+      manner specified by section 6 of the GNU GPL for conveying
+      Corresponding Source.
+    - **1)** Use a suitable shared library mechanism for linking with the
+      Library.  A suitable mechanism is one that **(a)** uses at run time
+      a copy of the Library already present on the user's computer
+      system, and **(b)** will operate properly with a modified version
+      of the Library that is interface-compatible with the Linked
+      Version.
+
+* **e)** Provide Installation Information, but only if you would otherwise
+  be required to provide such information under section 6 of the
+  GNU GPL, and only to the extent that such information is
+  necessary to install and execute a modified version of the
+  Combined Work produced by recombining or relinking the
+  Application with a modified version of the Linked Version. (If
+  you use option **4d0**, the Installation Information must accompany
+  the Minimal Corresponding Source and Corresponding Application
+  Code. If you use option **4d1**, you must provide the Installation
+  Information in the manner specified by section 6 of the GNU GPL
+  for conveying Corresponding Source.)
+
+### 5. Combined Libraries
+
+You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+* **a)** Accompany the combined library with a copy of the same work based
+  on the Library, uncombined with any other library facilities,
+  conveyed under the terms of this License.
+* **b)** Give prominent notice with the combined library that part of it
+  is a work based on the Library, and explaining where to find the
+  accompanying uncombined form of the same work.
+
+### 6. Revised Versions of the GNU Lesser General Public License
+
+The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License “or any later version”
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.

+ 41 - 145
build.gradle

@@ -1,181 +1,77 @@
 plugins {
-    id 'fabric-loom' version "0.4-SNAPSHOT"
-    id 'maven-publish'
-    id 'maven'
-    id 'signing'
+    id "architectury-plugin" version "2.0.65"
+    id "forgified-fabric-loom" version "0.6.54" apply false
     id 'com.jfrog.bintray' version '1.8.4'
-    id 'com.matthewprenger.cursegradle' version '1.4.0'
-    id 'java-library'
-    id 'net.corda.plugins.jar-filter' version "5.0.8" apply false
+    id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
+    id 'maven-publish'
 }
 
-repositories {
-    maven {
-        name = 'Fabric'
-        url = 'https://maven.fabricmc.net/'
-    }
-    jcenter()
-    maven { url "https://jitpack.io" }
-    maven { url "https://dl.bintray.com/shedaniel/legacy-yarn-updated" }
+architectury {
+    minecraft = rootProject.minecraft_version
 }
 
-sourceCompatibility = targetCompatibility = 1.8
-
-group = "me.shedaniel.cloth"
-archivesBaseName = "config-2"
-version = project.mod_version
+subprojects {
+    apply plugin: "forgified-fabric-loom"
 
-repositories {
-    maven { url "https://dl.bintray.com/shedaniel/shedaniel-mods" }
+    loom {
+        silentMojangMappingsLicense()
+        useFabricMixin = true
+    }
 }
 
-minecraft {
-    accessWidener = file("src/main/resources/cloth-config.accessWidener")
-}
+allprojects {
+    apply plugin: 'java'
+    apply plugin: 'architectury-plugin'
 
-processResources {
-    filesMatching('fabric.mod.json') {
-        expand 'version': project.version
+    ext {
+        isSnapshot = System.getenv("PR_NUM") != null
     }
-    inputs.property "version", project.version
-}
-
-dependencies {
-    compile("org.jetbrains:annotations:18.0.0")
 
-    minecraft("com.mojang:minecraft:${project.minecraft_version}")
-    mappings("me.shedaniel:legacy-yarn:${project.yarn_mappings}:v2")
+    def runNumber = (System.getenv("GITHUB_RUN_NUMBER") == null ? "9999" : System.getenv("GITHUB_RUN_NUMBER"))
 
-    modApi("net.fabricmc:fabric-loader:${project.loader_version}")
-    modApi("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
+    if (!ext.isSnapshot) {
+        version = rootProject.base_version + "." + runNumber
+        archivesBaseName = rootProject.archives_base_name
+    } else {
+        version = rootProject.base_version + "-PR." + System.getenv("PR_NUM") + "." + runNumber
+        archivesBaseName = rootProject.archives_base_name_snapshot
+    }
 
-    modApi("me.shedaniel.cloth:basic-math:0.5.1")
-    include("me.shedaniel.cloth:basic-math:0.5.1")
+    group = rootProject.maven_group
 
-    modCompileOnly("io.github.prospector:modmenu:${modmenu_version}") {
-        transitive(false)
-    }
-    modRuntime("io.github.prospector:modmenu:${modmenu_version}") {
-        transitive(false)
-    }
-//    modRuntime("me.shedaniel:SmoothScrollingEverywhere:3.0.3-unstable") {
-//        transitive(false)
-//    }
-}
+    tasks.withType(JavaCompile) {
+        options.encoding = "UTF-8"
 
-task jarFilter(type: net.corda.gradle.jarfilter.JarFilterTask) {
-    jars remapJar
-    annotations {
-        forRemove = [
-                "org.jetbrains.annotations.NotNull",
-                "org.jetbrains.annotations.Nullable",
-                "org.jetbrains.annotations.ApiStatus\$Experimental",
-                "org.jetbrains.annotations.ApiStatus\$Internal",
-                "org.jetbrains.annotations.ApiStatus\$ScheduledForRemoval",
-                "org.jetbrains.annotations.ApiStatus\$AvailableSince",
-                "org.jetbrains.annotations.ApiStatus\$NonExtendable",
-                "org.jetbrains.annotations.ApiStatus\$OverrideOnly"
-        ]
+        // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
+        // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
+        // We'll use that if it's available, but otherwise we'll use the older option.
+        def targetVersion = 8
+        if (JavaVersion.current().isJava9Compatible()) {
+            options.release = targetVersion
+        }
     }
-}
 
-task copyJarFilter(type: Copy) {
-    from jarFilter
-    into "${project.buildDir}/filtered-libs/"
-    rename { "${project.archivesBaseName}-${project.version}.jar" }
 }
 
 bintray {
     user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
     key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY')
-    publications = ["MyPublication"]
+    publications = ["mavenCommon", "mavenFabric", "mavenForge"]
     publish = true
     pkg {
         repo = "cloth-config-2"
         name = "config-2"
         userOrg = "shedaniel"
-        licenses = ["Unlicense"]
+        licenses = ["LPGL v3"]
         version {
             name = project.version
             vcsTag = project.version
             released = new Date()
             desc = "Cloth Config API for Minecraft"
-            githubRepo = 'shedaniel/ClothConfig'
-            websiteUrl = 'https://github.com/shedaniel/ClothConfig'
-            issueTrackerUrl = 'https://github.com/shedaniel/ClothConfig/issues'
-            vcsUrl = 'https://github.com/shedaniel/ClothConfig.git'
-            gpg {
-                sign = true
-            }
+            githubRepo = 'architectury/ClothConfig'
+            websiteUrl = 'https://github.com/architectury/ClothConfig'
+            issueTrackerUrl = 'https://github.com/architectury/ClothConfig/issues'
+            vcsUrl = 'https://github.com/architectury/ClothConfig.git'
         }
     }
 }
-
-// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
-// if it is present.
-// If you remove this task, sources will not be generated.
-task sourcesJar(type: Jar, dependsOn: classes) {
-    classifier = 'sources'
-    from sourceSets.main.allSource
-}
-
-task javadocs(type: Javadoc) {
-    source = sourceSets.main.allJava
-}
-
-task javadocsJar(type: Jar, dependsOn: javadocs) {
-    classifier = "javadocs"
-    javadocs.failOnError false
-    from javadocs.destinationDir
-}
-
-publishing {
-    publications {
-        MyPublication(MavenPublication) {
-            artifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}.jar")) {
-                builtBy remapJar
-            }
-            artifact(sourcesJar) {
-                builtBy remapSourcesJar
-            }
-            artifact javadocsJar
-            groupId 'me.shedaniel.cloth'
-            artifactId 'config-2'
-            version = project.version
-        }
-    }
-
-    // select the repositories you want to publish to
-    repositories {
-        // uncomment to publish to the local maven
-        // mavenLocal()
-    }
-}
-
-curseforge {
-    apiKey = project.hasProperty('apiKey') ? project.property('apiKey') : System.getenv('CF_API_KEY')
-    if (apiKey != null)
-        project {
-            id = '319057'
-            releaseType = 'release'
-            addGameVersion '1.16-Snapshot'
-            addGameVersion '1.16.2'
-            addGameVersion 'Fabric'
-            addGameVersion 'Java 8'
-            relations {
-                requiredDependency 'fabric-api'
-            }
-            mainArtifact(file("${project.buildDir}/filtered-libs/${project.archivesBaseName}-${project.version}.jar")) {
-                displayName = "[Fabric ${project.supported_version}] ClothConfig2-$project.version"
-            }
-            addArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar"))
-            afterEvaluate {
-                uploadTask.dependsOn("copyJarFilter")
-                uploadTask.dependsOn("remapSourcesJar")
-            }
-        }
-    options {
-        forgeGradleIntegration = false
-        javaVersionAutoDetect = false
-    }
-}

+ 46 - 0
common/build.gradle

@@ -0,0 +1,46 @@
+loom {
+    accessWidener = file("src/main/resources/cloth-config.accessWidener")
+}
+
+dependencies {
+    minecraft "com.mojang:minecraft:${rootProject.architectury.minecraft}"
+    mappings minecraft.officialMojangMappings()
+    // We depend on fabric loader here to use the fabric @Environment annotations
+    // Do NOT use other classes from fabric loader
+    modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
+
+    implementation("me.shedaniel.cloth:basic-math:0.5.1")
+}
+
+architectury {
+    common()
+}
+
+task sourcesJar(type: Jar, dependsOn: classes) {
+    classifier = "sources"
+    from sourceSets.main.allSource
+}
+
+task javadocs(type: Javadoc) {
+    source = sourceSets.main.allJava
+}
+
+task javadocsJar(type: Jar, dependsOn: javadocs) {
+    archiveClassifier.set("javadocs")
+    javadocs.failOnError false
+    from javadocs.destinationDir
+}
+
+publishing {
+    publications {
+        mavenCommon(MavenPublication) {
+            artifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}.jar")) {
+                builtBy build
+            }
+            artifact(sourcesJar) {
+                builtBy remapSourcesJar
+            }
+            artifact javadocsJar
+        }
+    }
+}

+ 2 - 0
src/main/java/me/shedaniel/clothconfig2/ClothConfigInitializer.java → common/src/main/java/me/shedaniel/clothconfig2/ClothConfigInitializer.java

@@ -13,6 +13,8 @@ import org.jetbrains.annotations.ApiStatus;
 public class ClothConfigInitializer {
     public static final Logger LOGGER = LogManager.getFormatterLogger("ClothConfig");
     
+    public static final String MOD_ID = "cloth-config2";
+    
     @Deprecated
     @ApiStatus.ScheduledForRemoval
     public static double handleScrollingPosition(double[] target, double scroll, double maxScroll, float delta, double start, double duration) {

+ 15 - 16
src/main/java/me/shedaniel/clothconfig2/api/AbstractConfigEntry.java → common/src/main/java/me/shedaniel/clothconfig2/api/AbstractConfigEntry.java

@@ -5,14 +5,13 @@ import me.shedaniel.clothconfig2.gui.ClothConfigScreen;
 import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
+import net.minecraft.ChatFormatting;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-
+import com.mojang.blaze3d.vertex.PoseStack;
 import java.util.List;
 import java.util.Optional;
 import java.util.function.Supplier;
@@ -21,7 +20,7 @@ import java.util.stream.Collectors;
 @Environment(EnvType.CLIENT)
 public abstract class AbstractConfigEntry<T> extends DynamicElementListWidget.ElementEntry<AbstractConfigEntry<T>> implements ReferenceProvider<T> {
     private AbstractConfigScreen screen;
-    private Supplier<Optional<Text>> errorSupplier;
+    private Supplier<Optional<Component>> errorSupplier;
     @Nullable
     private List<ReferenceProvider<?>> referencableEntries = null;
     
@@ -65,36 +64,36 @@ public abstract class AbstractConfigEntry<T> extends DynamicElementListWidget.El
     
     public abstract void setRequiresRestart(boolean requiresRestart);
     
-    public abstract Text getFieldName();
+    public abstract Component getFieldName();
     
-    public Text getDisplayedFieldName() {
-        MutableText text = getFieldName().shallowCopy();
+    public Component getDisplayedFieldName() {
+        MutableComponent text = getFieldName().copy();
         boolean hasError = getConfigError().isPresent();
         boolean isEdited = isEdited();
         if (hasError)
-            text = text.formatted(Formatting.RED);
+            text = text.withStyle(ChatFormatting.RED);
         if (isEdited)
-            text = text.formatted(Formatting.ITALIC);
+            text = text.withStyle(ChatFormatting.ITALIC);
         if (!hasError && !isEdited)
-            text = text.formatted(Formatting.GRAY);
+            text = text.withStyle(ChatFormatting.GRAY);
         return text;
     }
     
     public abstract T getValue();
     
-    public final Optional<Text> getConfigError() {
+    public final Optional<Component> getConfigError() {
         if (errorSupplier != null && errorSupplier.get().isPresent())
             return errorSupplier.get();
         return getError();
     }
     
-    public void lateRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {}
+    public void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta) {}
     
-    public void setErrorSupplier(Supplier<Optional<Text>> errorSupplier) {
+    public void setErrorSupplier(Supplier<Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
     }
     
-    public Optional<Text> getError() {
+    public Optional<Component> getError() {
         return Optional.empty();
     }
     

+ 6 - 6
src/main/java/me/shedaniel/clothconfig2/api/AbstractConfigListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/api/AbstractConfigListEntry.java

@@ -1,19 +1,19 @@
 package me.shedaniel.clothconfig2.api;
 
+import com.mojang.blaze3d.vertex.PoseStack;
 import me.shedaniel.clothconfig2.gui.ClothConfigScreen;
 import me.shedaniel.math.Rectangle;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 
 @Environment(EnvType.CLIENT)
 public abstract class AbstractConfigListEntry<T> extends AbstractConfigEntry<T> {
-    private Text fieldName;
+    private final Component fieldName;
     private boolean editable = true;
     private boolean requiresRestart;
     
-    public AbstractConfigListEntry(Text fieldName, boolean requiresRestart) {
+    public AbstractConfigListEntry(Component fieldName, boolean requiresRestart) {
         this.fieldName = fieldName;
         this.requiresRestart = requiresRestart;
     }
@@ -49,7 +49,7 @@ public abstract class AbstractConfigListEntry<T> extends AbstractConfigEntry<T>
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         if (isMouseInside(mouseX, mouseY, x, y, entryWidth, entryHeight)) {
             Rectangle area = getEntryArea(x, y, entryWidth, entryHeight);
             if (getParent() instanceof ClothConfigScreen.ListWidget)
@@ -58,7 +58,7 @@ public abstract class AbstractConfigListEntry<T> extends AbstractConfigEntry<T>
     }
     
     @Override
-    public Text getFieldName() {
+    public Component getFieldName() {
         return fieldName;
     }
 }

+ 11 - 12
src/main/java/me/shedaniel/clothconfig2/api/ConfigBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/api/ConfigBuilder.java

@@ -4,10 +4,9 @@ import me.shedaniel.clothconfig2.impl.ConfigBuilderImpl;
 import me.shedaniel.clothconfig2.impl.ConfigEntryBuilderImpl;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
-
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
 import java.util.function.Consumer;
 
 @Environment(EnvType.CLIENT)
@@ -23,21 +22,21 @@ public interface ConfigBuilder {
     
     ConfigBuilder setParentScreen(Screen parent);
     
-    Text getTitle();
+    Component getTitle();
     
-    ConfigBuilder setTitle(Text title);
+    ConfigBuilder setTitle(Component title);
     
     boolean isEditable();
     
     ConfigBuilder setEditable(boolean editable);
     
-    ConfigCategory getOrCreateCategory(Text categoryKey);
+    ConfigCategory getOrCreateCategory(Component categoryKey);
     
-    ConfigBuilder removeCategory(Text categoryKey);
+    ConfigBuilder removeCategory(Component categoryKey);
     
-    ConfigBuilder removeCategoryIfExists(Text categoryKey);
+    ConfigBuilder removeCategoryIfExists(Component categoryKey);
     
-    boolean hasCategory(Text category);
+    boolean hasCategory(Component category);
     
     ConfigBuilder setShouldTabsSmoothScroll(boolean shouldTabsSmoothScroll);
     
@@ -67,9 +66,9 @@ public interface ConfigBuilder {
         return false;
     }
     
-    Identifier getDefaultBackgroundTexture();
+    ResourceLocation getDefaultBackgroundTexture();
     
-    ConfigBuilder setDefaultBackgroundTexture(Identifier texture);
+    ConfigBuilder setDefaultBackgroundTexture(ResourceLocation texture);
     
     Runnable getSavingRunnable();
     

+ 10 - 10
src/main/java/me/shedaniel/clothconfig2/api/ConfigCategory.java → common/src/main/java/me/shedaniel/clothconfig2/api/ConfigCategory.java

@@ -2,9 +2,9 @@ package me.shedaniel.clothconfig2.api;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.StringRenderable;
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.FormattedText;
+import net.minecraft.resources.ResourceLocation;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.List;
@@ -14,25 +14,25 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public interface ConfigCategory {
     
-    Text getCategoryKey();
+    Component getCategoryKey();
     
     @Deprecated
     List<Object> getEntries();
     
     ConfigCategory addEntry(AbstractConfigListEntry entry);
     
-    ConfigCategory setCategoryBackground(Identifier identifier);
+    ConfigCategory setCategoryBackground(ResourceLocation identifier);
     
-    void setBackground(@Nullable Identifier background);
+    void setBackground(@Nullable ResourceLocation background);
     
-    @Nullable Identifier getBackground();
+    @Nullable ResourceLocation getBackground();
     
     @Nullable
-    Supplier<Optional<StringRenderable[]>> getDescription();
+    Supplier<Optional<FormattedText[]>> getDescription();
     
-    void setDescription(@Nullable Supplier<Optional<StringRenderable[]>> description);
+    void setDescription(@Nullable Supplier<Optional<FormattedText[]>> description);
     
-    default void setDescription(@Nullable StringRenderable[] description) {
+    default void setDescription(@Nullable FormattedText[] description) {
         setDescription(() -> Optional.ofNullable(description));
     }
     

+ 140 - 0
common/src/main/java/me/shedaniel/clothconfig2/api/ConfigEntryBuilder.java

@@ -0,0 +1,140 @@
+package me.shedaniel.clothconfig2.api;
+
+import com.mojang.blaze3d.platform.InputConstants;
+import me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry.DefaultSelectionCellCreator;
+import me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry.SelectionCellCreator;
+import me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry.SelectionTopCellElement;
+import me.shedaniel.clothconfig2.impl.ConfigEntryBuilderImpl;
+import me.shedaniel.clothconfig2.impl.builders.*;
+import me.shedaniel.clothconfig2.impl.builders.DropdownMenuBuilder.TopCellElementBuilder;
+import me.shedaniel.math.Color;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.KeyMapping;
+import net.minecraft.client.Minecraft;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextColor;
+import net.minecraft.network.chat.TextComponent;
+
+import java.util.List;
+import java.util.function.Function;
+
+@Environment(EnvType.CLIENT)
+public interface ConfigEntryBuilder {
+    
+    static ConfigEntryBuilder create() {
+        return ConfigEntryBuilderImpl.create();
+    }
+    
+    Component getResetButtonKey();
+    
+    ConfigEntryBuilder setResetButtonKey(Component resetButtonKey);
+    
+    IntListBuilder startIntList(Component fieldNameKey, List<Integer> value);
+    
+    LongListBuilder startLongList(Component fieldNameKey, List<Long> value);
+    
+    FloatListBuilder startFloatList(Component fieldNameKey, List<Float> value);
+    
+    DoubleListBuilder startDoubleList(Component fieldNameKey, List<Double> value);
+    
+    StringListBuilder startStrList(Component fieldNameKey, List<String> value);
+    
+    SubCategoryBuilder startSubCategory(Component fieldNameKey);
+    
+    SubCategoryBuilder startSubCategory(Component fieldNameKey, List<AbstractConfigListEntry> entries);
+    
+    BooleanToggleBuilder startBooleanToggle(Component fieldNameKey, boolean value);
+    
+    StringFieldBuilder startStrField(Component fieldNameKey, String value);
+    
+    ColorFieldBuilder startColorField(Component fieldNameKey, int value);
+    
+    default ColorFieldBuilder startColorField(Component fieldNameKey, TextColor color) {
+        return startColorField(fieldNameKey, color.getValue());
+    }
+    
+    default ColorFieldBuilder startColorField(Component fieldNameKey, Color color) {
+        return startColorField(fieldNameKey, color.getColor() & 0xFFFFFF);
+    }
+    
+    default ColorFieldBuilder startAlphaColorField(Component fieldNameKey, int value) {
+        return startColorField(fieldNameKey, value).setAlphaMode(true);
+    }
+    
+    default ColorFieldBuilder startAlphaColorField(Component fieldNameKey, Color color) {
+        return startColorField(fieldNameKey, color.getColor());
+    }
+    
+    TextFieldBuilder startTextField(Component fieldNameKey, String value);
+    
+    TextDescriptionBuilder startTextDescription(Component value);
+    
+    <T extends Enum<?>> EnumSelectorBuilder<T> startEnumSelector(Component fieldNameKey, Class<T> clazz, T value);
+    
+    <T> SelectorBuilder<T> startSelector(Component fieldNameKey, T[] valuesArray, T value);
+    
+    IntFieldBuilder startIntField(Component fieldNameKey, int value);
+    
+    LongFieldBuilder startLongField(Component fieldNameKey, long value);
+    
+    FloatFieldBuilder startFloatField(Component fieldNameKey, float value);
+    
+    DoubleFieldBuilder startDoubleField(Component fieldNameKey, double value);
+    
+    IntSliderBuilder startIntSlider(Component fieldNameKey, int value, int min, int max);
+    
+    LongSliderBuilder startLongSlider(Component fieldNameKey, long value, long min, long max);
+    
+    KeyCodeBuilder startModifierKeyCodeField(Component fieldNameKey, ModifierKeyCode value);
+    
+    default KeyCodeBuilder startKeyCodeField(Component fieldNameKey, InputConstants.Key value) {
+        return startModifierKeyCodeField(fieldNameKey, ModifierKeyCode.of(value, Modifier.none())).setAllowModifiers(false);
+    }
+    
+    default KeyCodeBuilder fillKeybindingField(Component fieldNameKey, KeyMapping value) {
+        return startKeyCodeField(fieldNameKey, value.key).setDefaultValue(value.getDefaultKey()).setSaveConsumer(code -> {
+            value.setKey(code);
+            KeyMapping.resetMapping();
+            Minecraft.getInstance().options.save();
+        });
+    }
+    
+    <T> DropdownMenuBuilder<T> startDropdownMenu(Component fieldNameKey, SelectionTopCellElement<T> topCellElement, SelectionCellCreator<T> cellCreator);
+    
+    default <T> DropdownMenuBuilder<T> startDropdownMenu(Component fieldNameKey, SelectionTopCellElement<T> topCellElement) {
+        return startDropdownMenu(fieldNameKey, topCellElement, new DefaultSelectionCellCreator<>());
+    }
+    
+    default <T> DropdownMenuBuilder<T> startDropdownMenu(Component fieldNameKey, T value, Function<String, T> toObjectFunction, SelectionCellCreator<T> cellCreator) {
+        return startDropdownMenu(fieldNameKey, TopCellElementBuilder.of(value, toObjectFunction), cellCreator);
+    }
+    
+    default <T> DropdownMenuBuilder<T> startDropdownMenu(Component fieldNameKey, T value, Function<String, T> toObjectFunction, Function<T, Component> toTextFunction, SelectionCellCreator<T> cellCreator) {
+        return startDropdownMenu(fieldNameKey, TopCellElementBuilder.of(value, toObjectFunction, toTextFunction), cellCreator);
+    }
+    
+    default <T> DropdownMenuBuilder<T> startDropdownMenu(Component fieldNameKey, T value, Function<String, T> toObjectFunction) {
+        return startDropdownMenu(fieldNameKey, TopCellElementBuilder.of(value, toObjectFunction), new DefaultSelectionCellCreator<>());
+    }
+    
+    default <T> DropdownMenuBuilder<T> startDropdownMenu(Component fieldNameKey, T value, Function<String, T> toObjectFunction, Function<T, Component> toTextFunction) {
+        return startDropdownMenu(fieldNameKey, TopCellElementBuilder.of(value, toObjectFunction, toTextFunction), new DefaultSelectionCellCreator<>());
+    }
+    
+    default DropdownMenuBuilder<String> startStringDropdownMenu(Component fieldNameKey, String value, SelectionCellCreator<String> cellCreator) {
+        return startDropdownMenu(fieldNameKey, TopCellElementBuilder.of(value, s -> s, TextComponent::new), cellCreator);
+    }
+    
+    default DropdownMenuBuilder<String> startStringDropdownMenu(Component fieldNameKey, String value, Function<String, Component> toTextFunction, SelectionCellCreator<String> cellCreator) {
+        return startDropdownMenu(fieldNameKey, TopCellElementBuilder.of(value, s -> s, toTextFunction), cellCreator);
+    }
+    
+    default DropdownMenuBuilder<String> startStringDropdownMenu(Component fieldNameKey, String value) {
+        return startDropdownMenu(fieldNameKey, TopCellElementBuilder.of(value, s -> s, TextComponent::new), new DefaultSelectionCellCreator<>());
+    }
+    
+    default DropdownMenuBuilder<String> startStringDropdownMenu(Component fieldNameKey, String value, Function<String, Component> toTextFunction) {
+        return startDropdownMenu(fieldNameKey, TopCellElementBuilder.of(value, s -> s, toTextFunction), new DefaultSelectionCellCreator<>());
+    }
+}

+ 3 - 3
src/main/java/me/shedaniel/clothconfig2/api/ConfigScreen.java → common/src/main/java/me/shedaniel/clothconfig2/api/ConfigScreen.java

@@ -1,17 +1,17 @@
 package me.shedaniel.clothconfig2.api;
 
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.util.Identifier;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.function.Consumer;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.resources.ResourceLocation;
 
 public interface ConfigScreen {
     void setSavingRunnable(@Nullable Runnable savingRunnable);
     
     void setAfterInitConsumer(@Nullable Consumer<Screen> afterInitConsumer);
     
-    Identifier getBackgroundLocation();
+    ResourceLocation getBackgroundLocation();
     
     boolean isRequiresRestart();
     

+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/api/Expandable.java → common/src/main/java/me/shedaniel/clothconfig2/api/Expandable.java


+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/api/LazyResettable.java → common/src/main/java/me/shedaniel/clothconfig2/api/LazyResettable.java


+ 3 - 4
src/main/java/me/shedaniel/clothconfig2/api/Modifier.java → common/src/main/java/me/shedaniel/clothconfig2/api/Modifier.java

@@ -2,8 +2,7 @@ package me.shedaniel.clothconfig2.api;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.screen.Screen;
-
+import net.minecraft.client.gui.screens.Screen;
 import java.util.Objects;
 
 /**
@@ -14,7 +13,7 @@ import java.util.Objects;
  */
 @Environment(EnvType.CLIENT)
 public class Modifier {
-    private short value;
+    private final short value;
     
     /**
      * Constructs a new modifier object by a raw value
@@ -140,4 +139,4 @@ public class Modifier {
     public int hashCode() {
         return Objects.hash(value);
     }
-}
+}

+ 83 - 0
common/src/main/java/me/shedaniel/clothconfig2/api/ModifierKeyCode.java

@@ -0,0 +1,83 @@
+package me.shedaniel.clothconfig2.api;
+
+import com.mojang.blaze3d.platform.InputConstants;
+import me.shedaniel.clothconfig2.impl.ModifierKeyCodeImpl;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.Minecraft;
+import net.minecraft.network.chat.Component;
+import org.lwjgl.glfw.GLFW;
+
+@Environment(EnvType.CLIENT)
+public interface ModifierKeyCode {
+    static ModifierKeyCode of(InputConstants.Key keyCode, Modifier modifier) {
+        return new ModifierKeyCodeImpl().setKeyCodeAndModifier(keyCode, modifier);
+    }
+    
+    static ModifierKeyCode copyOf(ModifierKeyCode code) {
+        return of(code.getKeyCode(), code.getModifier());
+    }
+    
+    static ModifierKeyCode unknown() {
+        return of(InputConstants.UNKNOWN, Modifier.none());
+    }
+    
+    InputConstants.Key getKeyCode();
+    
+    ModifierKeyCode setKeyCode(InputConstants.Key keyCode);
+    
+    default InputConstants.Type getType() {
+        return getKeyCode().getType();
+    }
+    
+    Modifier getModifier();
+    
+    ModifierKeyCode setModifier(Modifier modifier);
+    
+    default ModifierKeyCode copy() {
+        return copyOf(this);
+    }
+    
+    default boolean matchesMouse(int button) {
+        return !isUnknown() && getType() == InputConstants.Type.MOUSE && getKeyCode().getValue() == button && getModifier().matchesCurrent();
+    }
+    
+    default boolean matchesKey(int keyCode, int scanCode) {
+        if (isUnknown())
+            return false;
+        if (keyCode == InputConstants.UNKNOWN.getValue()) {
+            return getType() == InputConstants.Type.SCANCODE && getKeyCode().getValue() == scanCode && getModifier().matchesCurrent();
+        } else {
+            return getType() == InputConstants.Type.KEYSYM && getKeyCode().getValue() == keyCode && getModifier().matchesCurrent();
+        }
+    }
+    
+    default boolean matchesCurrentMouse() {
+        if (!isUnknown() && getType() == InputConstants.Type.MOUSE && getModifier().matchesCurrent()) {
+            return GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), getKeyCode().getValue()) == GLFW.GLFW_PRESS;
+        }
+        return false;
+    }
+    
+    default boolean matchesCurrentKey() {
+        return !isUnknown() && getType() == InputConstants.Type.KEYSYM && getModifier().matchesCurrent() && InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), getKeyCode().getValue());
+    }
+    
+    default ModifierKeyCode setKeyCodeAndModifier(InputConstants.Key keyCode, Modifier modifier) {
+        setKeyCode(keyCode);
+        setModifier(modifier);
+        return this;
+    }
+    
+    default ModifierKeyCode clearModifier() {
+        return setModifier(Modifier.none());
+    }
+    
+    String toString();
+    
+    Component getLocalizedName();
+    
+    default boolean isUnknown() {
+        return getKeyCode().equals(InputConstants.UNKNOWN);
+    }
+}

+ 15 - 15
src/main/java/me/shedaniel/clothconfig2/api/QueuedTooltip.java → common/src/main/java/me/shedaniel/clothconfig2/api/QueuedTooltip.java

@@ -1,10 +1,10 @@
 package me.shedaniel.clothconfig2.api;
 
 import me.shedaniel.math.Point;
-import net.minecraft.class_5481;
-import net.minecraft.text.StringRenderable;
-import net.minecraft.text.Text;
-import net.minecraft.util.Language;
+import net.minecraft.locale.Language;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.FormattedText;
+import net.minecraft.util.FormattedCharSequence;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.Arrays;
@@ -12,28 +12,28 @@ import java.util.Collections;
 import java.util.List;
 
 public class QueuedTooltip implements Tooltip {
-    private Point location;
-    private List<class_5481> text;
+    private final Point location;
+    private final List<FormattedCharSequence> text;
     
-    private QueuedTooltip(Point location, List<class_5481> text) {
+    private QueuedTooltip(Point location, List<FormattedCharSequence> text) {
         this.location = location;
         this.text = Collections.unmodifiableList(text);
     }
     
-    public static QueuedTooltip create(Point location, List<Text> text) {
-        return new QueuedTooltip(location, Language.getInstance().method_30933((List) text));
+    public static QueuedTooltip create(Point location, List<Component> text) {
+        return new QueuedTooltip(location, Language.getInstance().getVisualOrder((List) text));
     }
     
-    public static QueuedTooltip create(Point location, Text... text) {
+    public static QueuedTooltip create(Point location, Component... text) {
         return QueuedTooltip.create(location, Arrays.asList(text));
     }
     
-    public static QueuedTooltip create(Point location, class_5481... text) {
+    public static QueuedTooltip create(Point location, FormattedCharSequence... text) {
         return new QueuedTooltip(location, Arrays.asList(text));
     }
     
-    public static QueuedTooltip create(Point location, StringRenderable... text) {
-        return new QueuedTooltip(location, Language.getInstance().method_30933(Arrays.asList(text)));
+    public static QueuedTooltip create(Point location, FormattedText... text) {
+        return new QueuedTooltip(location, Language.getInstance().getVisualOrder(Arrays.asList(text)));
     }
     
     @Override
@@ -43,7 +43,7 @@ public class QueuedTooltip implements Tooltip {
     
     @ApiStatus.Internal
     @Override
-    public List<class_5481> getText() {
+    public List<FormattedCharSequence> getText() {
         return text;
     }
-}
+}

+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/api/ReferenceBuildingConfigScreen.java → common/src/main/java/me/shedaniel/clothconfig2/api/ReferenceBuildingConfigScreen.java


+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/api/ReferenceProvider.java → common/src/main/java/me/shedaniel/clothconfig2/api/ReferenceProvider.java


+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/api/ScissorsHandler.java → common/src/main/java/me/shedaniel/clothconfig2/api/ScissorsHandler.java


+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/api/ScissorsScreen.java → common/src/main/java/me/shedaniel/clothconfig2/api/ScissorsScreen.java


+ 29 - 29
src/main/java/me/shedaniel/clothconfig2/api/ScrollingContainer.java → common/src/main/java/me/shedaniel/clothconfig2/api/ScrollingContainer.java

@@ -25,15 +25,15 @@
 package me.shedaniel.clothconfig2.api;
 
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import com.mojang.blaze3d.vertex.Tesselator;
 import me.shedaniel.clothconfig2.ClothConfigInitializer;
 import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget;
 import me.shedaniel.clothconfig2.impl.EasingMethod;
 import me.shedaniel.math.Rectangle;
 import me.shedaniel.math.impl.PointHelper;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.util.math.MathHelper;
+import net.minecraft.util.Mth;
 
 public abstract class ScrollingContainer {
     public double scrollAmount;
@@ -71,7 +71,7 @@ public abstract class ScrollingContainer {
     }
     
     public final double clamp(double v, double clampExtension) {
-        return MathHelper.clamp(v, -clampExtension, (double) this.getMaxScroll() + clampExtension);
+        return Mth.clamp(v, -clampExtension, (double) this.getMaxScroll() + clampExtension);
     }
     
     public final void offset(double value, boolean animated) {
@@ -124,7 +124,7 @@ public abstract class ScrollingContainer {
     }
     
     public static double clampExtension(double v, double maxScroll, double clampExtension) {
-        return MathHelper.clamp(v, -clampExtension, maxScroll + clampExtension);
+        return Mth.clamp(v, -clampExtension, maxScroll + clampExtension);
     }
     
     public void renderScrollBar() {
@@ -137,7 +137,7 @@ public abstract class ScrollingContainer {
             Rectangle bounds = getBounds();
             int maxScroll = getMaxScroll();
             int height = bounds.height * bounds.height / getMaxScrollHeight();
-            height = MathHelper.clamp(height, 32, bounds.height);
+            height = Mth.clamp(height, 32, bounds.height);
             height -= Math.min((scrollAmount < 0 ? (int) -scrollAmount : scrollAmount > maxScroll ? (int) scrollAmount - maxScroll : 0), height * .95);
             height = Math.max(10, height);
             int minY = Math.min(Math.max((int) scrollAmount * (bounds.height - height) / maxScroll + bounds.y, bounds.y), bounds.getMaxY() - height);
@@ -153,32 +153,32 @@ public abstract class ScrollingContainer {
             RenderSystem.disableAlphaTest();
             RenderSystem.blendFuncSeparate(770, 771, 1, 0);
             RenderSystem.shadeModel(7425);
-            Tessellator tessellator = Tessellator.getInstance();
-            BufferBuilder buffer = tessellator.getBuffer();
+            Tesselator tessellator = Tesselator.getInstance();
+            BufferBuilder buffer = tessellator.getBuilder();
             {
                 float a = (background >> 24 & 255) / 255.0F;
                 float r = (background >> 16 & 255) / 255.0F;
                 float g = (background >> 8 & 255) / 255.0F;
                 float b = (background & 255) / 255.0F;
-                buffer.begin(7, VertexFormats.POSITION_COLOR);
-                buffer.vertex(scrollbarPositionMinX, bounds.getMaxY(), 0.0D).color(r, g, b, a).next();
-                buffer.vertex(scrollbarPositionMaxX, bounds.getMaxY(), 0.0D).color(r, g, b, a).next();
-                buffer.vertex(scrollbarPositionMaxX, bounds.y, 0.0D).color(r, g, b, a).next();
-                buffer.vertex(scrollbarPositionMinX, bounds.y, 0.0D).color(r, g, b, a).next();
+                buffer.begin(7, DefaultVertexFormat.POSITION_COLOR);
+                buffer.vertex(scrollbarPositionMinX, bounds.getMaxY(), 0.0D).color(r, g, b, a).endVertex();
+                buffer.vertex(scrollbarPositionMaxX, bounds.getMaxY(), 0.0D).color(r, g, b, a).endVertex();
+                buffer.vertex(scrollbarPositionMaxX, bounds.y, 0.0D).color(r, g, b, a).endVertex();
+                buffer.vertex(scrollbarPositionMinX, bounds.y, 0.0D).color(r, g, b, a).endVertex();
             }
-            tessellator.draw();
-            buffer.begin(7, VertexFormats.POSITION_COLOR);
-            buffer.vertex(scrollbarPositionMinX, minY + height, 0.0D).color(bottomC, bottomC, bottomC, alpha).next();
-            buffer.vertex(scrollbarPositionMaxX, minY + height, 0.0D).color(bottomC, bottomC, bottomC, alpha).next();
-            buffer.vertex(scrollbarPositionMaxX, minY, 0.0D).color(bottomC, bottomC, bottomC, alpha).next();
-            buffer.vertex(scrollbarPositionMinX, minY, 0.0D).color(bottomC, bottomC, bottomC, alpha).next();
-            tessellator.draw();
-            buffer.begin(7, VertexFormats.POSITION_COLOR);
-            buffer.vertex(scrollbarPositionMinX, (minY + height - 1), 0.0D).color(topC, topC, topC, alpha).next();
-            buffer.vertex((scrollbarPositionMaxX - 1), (minY + height - 1), 0.0D).color(topC, topC, topC, alpha).next();
-            buffer.vertex((scrollbarPositionMaxX - 1), minY, 0.0D).color(topC, topC, topC, alpha).next();
-            buffer.vertex(scrollbarPositionMinX, minY, 0.0D).color(topC, topC, topC, alpha).next();
-            tessellator.draw();
+            tessellator.end();
+            buffer.begin(7, DefaultVertexFormat.POSITION_COLOR);
+            buffer.vertex(scrollbarPositionMinX, minY + height, 0.0D).color(bottomC, bottomC, bottomC, alpha).endVertex();
+            buffer.vertex(scrollbarPositionMaxX, minY + height, 0.0D).color(bottomC, bottomC, bottomC, alpha).endVertex();
+            buffer.vertex(scrollbarPositionMaxX, minY, 0.0D).color(bottomC, bottomC, bottomC, alpha).endVertex();
+            buffer.vertex(scrollbarPositionMinX, minY, 0.0D).color(bottomC, bottomC, bottomC, alpha).endVertex();
+            tessellator.end();
+            buffer.begin(7, DefaultVertexFormat.POSITION_COLOR);
+            buffer.vertex(scrollbarPositionMinX, (minY + height - 1), 0.0D).color(topC, topC, topC, alpha).endVertex();
+            buffer.vertex((scrollbarPositionMaxX - 1), (minY + height - 1), 0.0D).color(topC, topC, topC, alpha).endVertex();
+            buffer.vertex((scrollbarPositionMaxX - 1), minY, 0.0D).color(topC, topC, topC, alpha).endVertex();
+            buffer.vertex(scrollbarPositionMinX, minY, 0.0D).color(topC, topC, topC, alpha).endVertex();
+            tessellator.end();
             RenderSystem.shadeModel(7424);
             RenderSystem.disableBlend();
             RenderSystem.enableAlphaTest();
@@ -197,9 +197,9 @@ public abstract class ScrollingContainer {
             int actualHeight = bounds.height;
             if (mouseY >= bounds.y && mouseY <= bounds.getMaxY()) {
                 double maxScroll = Math.max(1, getMaxScroll());
-                double int_3 = MathHelper.clamp(((double) (actualHeight * actualHeight) / (double) height), 32, actualHeight - 8);
+                double int_3 = Mth.clamp(((double) (actualHeight * actualHeight) / (double) height), 32, actualHeight - 8);
                 double double_6 = Math.max(1.0D, maxScroll / (actualHeight - int_3));
-                float to = MathHelper.clamp((float) (scrollAmount + dy * double_6), 0, getMaxScroll());
+                float to = Mth.clamp((float) (scrollAmount + dy * double_6), 0, getMaxScroll());
                 if (snapToRows) {
                     double nearestRow = Math.round(to / rowSize) * rowSize;
                     scrollTo(nearestRow, false);

+ 10 - 0
common/src/main/java/me/shedaniel/clothconfig2/api/TabbedConfigScreen.java

@@ -0,0 +1,10 @@
+package me.shedaniel.clothconfig2.api;
+
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
+
+public interface TabbedConfigScreen extends ConfigScreen {
+    void registerCategoryBackground(Component text, ResourceLocation identifier);
+    
+    Component getSelectedCategory();
+}

+ 7 - 8
src/main/java/me/shedaniel/clothconfig2/api/Tooltip.java → common/src/main/java/me/shedaniel/clothconfig2/api/Tooltip.java

@@ -1,22 +1,21 @@
 package me.shedaniel.clothconfig2.api;
 
 import me.shedaniel.math.Point;
-import net.minecraft.class_5481;
-import net.minecraft.text.StringRenderable;
-import net.minecraft.text.Text;
-
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.FormattedText;
+import net.minecraft.util.FormattedCharSequence;
 import java.util.List;
 
 public interface Tooltip {
-    static Tooltip of(Point location, Text... text) {
+    static Tooltip of(Point location, Component... text) {
         return QueuedTooltip.create(location, text);
     }
     
-    static Tooltip of(Point location, StringRenderable... text) {
+    static Tooltip of(Point location, FormattedText... text) {
         return QueuedTooltip.create(location, text);
     }
     
-    static Tooltip of(Point location, class_5481... text) {
+    static Tooltip of(Point location, FormattedCharSequence... text) {
         return QueuedTooltip.create(location, text);
     }
     
@@ -30,5 +29,5 @@ public interface Tooltip {
         return getPoint().getY();
     }
     
-    List<class_5481> getText();
+    List<FormattedCharSequence> getText();
 }

+ 65 - 65
src/main/java/me/shedaniel/clothconfig2/gui/AbstractConfigScreen.java → common/src/main/java/me/shedaniel/clothconfig2/gui/AbstractConfigScreen.java

@@ -1,26 +1,26 @@
 package me.shedaniel.clothconfig2.gui;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.InputConstants;
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.blaze3d.vertex.Tesselator;
+import com.mojang.math.Matrix4f;
 import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
 import me.shedaniel.clothconfig2.api.*;
 import me.shedaniel.clothconfig2.gui.entries.KeyCodeEntry;
 import me.shedaniel.math.Rectangle;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.screen.ConfirmScreen;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.widget.AbstractButtonWidget;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.util.InputUtil;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
-import net.minecraft.util.Identifier;
-import net.minecraft.util.Tickable;
-import net.minecraft.util.math.Matrix4f;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.gui.screens.ConfirmScreen;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.level.block.entity.TickableBlockEntity;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.Nullable;
 
@@ -30,16 +30,16 @@ import java.util.Optional;
 import java.util.function.Consumer;
 
 public abstract class AbstractConfigScreen extends Screen implements ConfigScreen {
-    protected static final Identifier CONFIG_TEX = new Identifier("cloth-config2", "textures/gui/cloth_config.png");
+    protected static final ResourceLocation CONFIG_TEX = new ResourceLocation("cloth-config2", "textures/gui/cloth_config.png");
     private boolean legacyEdited = false;
-    private final Identifier backgroundLocation;
+    private final ResourceLocation backgroundLocation;
     protected boolean legacyRequiresRestart = false;
     protected boolean confirmSave;
     protected final Screen parent;
     private boolean alwaysShowTabs = false;
     private boolean transparentBackground = false;
     @Nullable
-    private Text defaultFallbackCategory = null;
+    private Component defaultFallbackCategory = null;
     public int selectedCategoryIndex = 0;
     private boolean editable = true;
     private KeyCodeEntry focusedBinding;
@@ -50,7 +50,7 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
     @Nullable
     protected Consumer<Screen> afterInitConsumer = null;
     
-    protected AbstractConfigScreen(Screen parent, Text title, Identifier backgroundLocation) {
+    protected AbstractConfigScreen(Screen parent, Component title, ResourceLocation backgroundLocation) {
         super(title);
         this.parent = parent;
         this.backgroundLocation = backgroundLocation;
@@ -67,7 +67,7 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
     }
     
     @Override
-    public Identifier getBackgroundLocation() {
+    public ResourceLocation getBackgroundLocation() {
         return backgroundLocation;
     }
     
@@ -84,7 +84,7 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
         return false;
     }
     
-    public abstract Map<Text, List<AbstractConfigEntry<?>>> getCategorizedEntries();
+    public abstract Map<Component, List<AbstractConfigEntry<?>>> getCategorizedEntries();
     
     @Override
     public boolean isEdited() {
@@ -135,7 +135,7 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
     }
     
     public boolean isTransparentBackground() {
-        return transparentBackground && MinecraftClient.getInstance().world != null;
+        return transparentBackground && Minecraft.getInstance().level != null;
     }
     
     @ApiStatus.Internal
@@ -143,18 +143,18 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
         this.transparentBackground = transparentBackground;
     }
     
-    public Text getFallbackCategory() {
+    public Component getFallbackCategory() {
         if (defaultFallbackCategory != null)
             return defaultFallbackCategory;
         return getCategorizedEntries().keySet().iterator().next();
     }
     
     @ApiStatus.Internal
-    public void setFallbackCategory(@Nullable Text defaultFallbackCategory) {
+    public void setFallbackCategory(@Nullable Component defaultFallbackCategory) {
         this.defaultFallbackCategory = defaultFallbackCategory;
-        List<Text> categories = Lists.newArrayList(getCategorizedEntries().keySet());
+        List<Component> categories = Lists.newArrayList(getCategorizedEntries().keySet());
         for (int i = 0; i < categories.size(); i++) {
-            Text category = categories.get(i);
+            Component category = categories.get(i);
             if (category.equals(getFallbackCategory())) {
                 this.selectedCategoryIndex = i;
                 break;
@@ -171,9 +171,9 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
         setEdited(false);
         if (openOtherScreens) {
             if (isRequiresRestart())
-                AbstractConfigScreen.this.client.openScreen(new ClothRequiresRestartScreen(parent));
+                AbstractConfigScreen.this.minecraft.setScreen(new ClothRequiresRestartScreen(parent));
             else
-                AbstractConfigScreen.this.client.openScreen(parent);
+                AbstractConfigScreen.this.minecraft.setScreen(parent);
         }
         this.legacyRequiresRestart = false;
     }
@@ -205,7 +205,7 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
         this.focusedBinding = focusedBinding;
         if (focusedBinding != null) {
             startedKeyCode = this.focusedBinding.getValue();
-            startedKeyCode.setKeyCodeAndModifier(InputUtil.UNKNOWN_KEYCODE, Modifier.none());
+            startedKeyCode.setKeyCodeAndModifier(InputConstants.UNKNOWN, Modifier.none());
         } else
             startedKeyCode = null;
     }
@@ -234,24 +234,24 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
     public boolean mouseClicked(double double_1, double double_2, int int_1) {
         if (this.focusedBinding != null && this.startedKeyCode != null && focusedBinding.isAllowMouse()) {
             if (startedKeyCode.isUnknown())
-                startedKeyCode.setKeyCode(InputUtil.Type.MOUSE.createFromCode(int_1));
+                startedKeyCode.setKeyCode(InputConstants.Type.MOUSE.getOrCreate(int_1));
             else if (focusedBinding.isAllowModifiers()) {
-                if (startedKeyCode.getType() == InputUtil.Type.KEYSYM) {
-                    int code = startedKeyCode.getKeyCode().getKeyCode();
-                    if (MinecraftClient.IS_SYSTEM_MAC ? (code == 343 || code == 347) : (code == 341 || code == 345)) {
+                if (startedKeyCode.getType() == InputConstants.Type.KEYSYM) {
+                    int code = startedKeyCode.getKeyCode().getValue();
+                    if (Minecraft.ON_OSX ? (code == 343 || code == 347) : (code == 341 || code == 345)) {
                         Modifier modifier = startedKeyCode.getModifier();
                         startedKeyCode.setModifier(Modifier.of(modifier.hasAlt(), true, modifier.hasShift()));
-                        startedKeyCode.setKeyCode(InputUtil.Type.MOUSE.createFromCode(int_1));
+                        startedKeyCode.setKeyCode(InputConstants.Type.MOUSE.getOrCreate(int_1));
                         return true;
                     } else if (code == 344 || code == 340) {
                         Modifier modifier = startedKeyCode.getModifier();
                         startedKeyCode.setModifier(Modifier.of(modifier.hasAlt(), modifier.hasControl(), true));
-                        startedKeyCode.setKeyCode(InputUtil.Type.MOUSE.createFromCode(int_1));
+                        startedKeyCode.setKeyCode(InputConstants.Type.MOUSE.getOrCreate(int_1));
                         return true;
                     } else if (code == 342 || code == 346) {
                         Modifier modifier = startedKeyCode.getModifier();
                         startedKeyCode.setModifier(Modifier.of(true, modifier.hasControl(), modifier.hasShift()));
-                        startedKeyCode.setKeyCode(InputUtil.Type.MOUSE.createFromCode(int_1));
+                        startedKeyCode.setKeyCode(InputConstants.Type.MOUSE.getOrCreate(int_1));
                         return true;
                     }
                 }
@@ -269,28 +269,28 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
         if (this.focusedBinding != null && (focusedBinding.isAllowKey() || int_1 == 256)) {
             if (int_1 != 256) {
                 if (startedKeyCode.isUnknown())
-                    startedKeyCode.setKeyCode(InputUtil.getKeyCode(int_1, int_2));
+                    startedKeyCode.setKeyCode(InputConstants.getKey(int_1, int_2));
                 else if (focusedBinding.isAllowModifiers()) {
-                    if (startedKeyCode.getType() == InputUtil.Type.KEYSYM) {
-                        int code = startedKeyCode.getKeyCode().getKeyCode();
-                        if (MinecraftClient.IS_SYSTEM_MAC ? (code == 343 || code == 347) : (code == 341 || code == 345)) {
+                    if (startedKeyCode.getType() == InputConstants.Type.KEYSYM) {
+                        int code = startedKeyCode.getKeyCode().getValue();
+                        if (Minecraft.ON_OSX ? (code == 343 || code == 347) : (code == 341 || code == 345)) {
                             Modifier modifier = startedKeyCode.getModifier();
                             startedKeyCode.setModifier(Modifier.of(modifier.hasAlt(), true, modifier.hasShift()));
-                            startedKeyCode.setKeyCode(InputUtil.getKeyCode(int_1, int_2));
+                            startedKeyCode.setKeyCode(InputConstants.getKey(int_1, int_2));
                             return true;
                         } else if (code == 344 || code == 340) {
                             Modifier modifier = startedKeyCode.getModifier();
                             startedKeyCode.setModifier(Modifier.of(modifier.hasAlt(), modifier.hasControl(), true));
-                            startedKeyCode.setKeyCode(InputUtil.getKeyCode(int_1, int_2));
+                            startedKeyCode.setKeyCode(InputConstants.getKey(int_1, int_2));
                             return true;
                         } else if (code == 342 || code == 346) {
                             Modifier modifier = startedKeyCode.getModifier();
                             startedKeyCode.setModifier(Modifier.of(true, modifier.hasControl(), modifier.hasShift()));
-                            startedKeyCode.setKeyCode(InputUtil.getKeyCode(int_1, int_2));
+                            startedKeyCode.setKeyCode(InputConstants.getKey(int_1, int_2));
                             return true;
                         }
                     }
-                    if (MinecraftClient.IS_SYSTEM_MAC ? (int_1 == 343 || int_1 == 347) : (int_1 == 341 || int_1 == 345)) {
+                    if (Minecraft.ON_OSX ? (int_1 == 343 || int_1 == 347) : (int_1 == 341 || int_1 == 345)) {
                         Modifier modifier = startedKeyCode.getModifier();
                         startedKeyCode.setModifier(Modifier.of(modifier.hasAlt(), true, modifier.hasShift()));
                         return true;
@@ -320,9 +320,9 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
     
     protected final boolean quit() {
         if (confirmSave && isEdited())
-            client.openScreen(new ConfirmScreen(new QuitSaveConsumer(), new TranslatableText("text.cloth-config.quit_config"), new TranslatableText("text.cloth-config.quit_config_sure"), new TranslatableText("text.cloth-config.quit_discard"), new TranslatableText("gui.cancel")));
+            minecraft.setScreen(new ConfirmScreen(new QuitSaveConsumer(), new TranslatableComponent("text.cloth-config.quit_config"), new TranslatableComponent("text.cloth-config.quit_config_sure"), new TranslatableComponent("text.cloth-config.quit_discard"), new TranslatableComponent("gui.cancel")));
         else
-            client.openScreen(parent);
+            minecraft.setScreen(parent);
         return true;
     }
     
@@ -330,9 +330,9 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
         @Override
         public void accept(boolean t) {
             if (!t)
-                client.openScreen(AbstractConfigScreen.this);
+                minecraft.setScreen(AbstractConfigScreen.this);
             else
-                client.openScreen(parent);
+                minecraft.setScreen(parent);
         }
     }
     
@@ -340,19 +340,19 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
     public void tick() {
         super.tick();
         boolean edited = isEdited();
-        Optional.ofNullable(getQuitButton()).ifPresent(button -> button.setMessage(edited ? new TranslatableText("text.cloth-config.cancel_discard") : new TranslatableText("gui.cancel")));
-        for (Element child : children())
-            if (child instanceof Tickable)
-                ((Tickable) child).tick();
+        Optional.ofNullable(getQuitButton()).ifPresent(button -> button.setMessage(edited ? new TranslatableComponent("text.cloth-config.cancel_discard") : new TranslatableComponent("gui.cancel")));
+        for (GuiEventListener child : children())
+            if (child instanceof TickableBlockEntity)
+                ((TickableBlockEntity) child).tick();
     }
     
     @Nullable
-    protected AbstractButtonWidget getQuitButton() {
+    protected AbstractWidget getQuitButton() {
         return null;
     }
     
     @Override
-    public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
         super.render(matrices, mouseX, mouseY, delta);
         for (Tooltip tooltip : tooltips) {
             renderTooltip(matrices, tooltip.getText(), tooltip.getX(), tooltip.getY());
@@ -365,22 +365,22 @@ public abstract class AbstractConfigScreen extends Screen implements ConfigScree
         this.tooltips.add(tooltip);
     }
     
-    protected void overlayBackground(MatrixStack matrices, Rectangle rect, int red, int green, int blue, int startAlpha, int endAlpha) {
-        overlayBackground(matrices.peek().getModel(), rect, red, green, blue, startAlpha, endAlpha);
+    protected void overlayBackground(PoseStack matrices, Rectangle rect, int red, int green, int blue, int startAlpha, int endAlpha) {
+        overlayBackground(matrices.last().pose(), rect, red, green, blue, startAlpha, endAlpha);
     }
     
     protected void overlayBackground(Matrix4f matrix, Rectangle rect, int red, int green, int blue, int startAlpha, int endAlpha) {
         if (isTransparentBackground())
             return;
-        Tessellator tessellator = Tessellator.getInstance();
-        BufferBuilder buffer = tessellator.getBuffer();
-        client.getTextureManager().bindTexture(getBackgroundLocation());
+        Tesselator tessellator = Tesselator.getInstance();
+        BufferBuilder buffer = tessellator.getBuilder();
+        minecraft.getTextureManager().bind(getBackgroundLocation());
         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
-        buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-        buffer.vertex(matrix, rect.getMinX(), rect.getMaxY(), 0.0F).texture(rect.getMinX() / 32.0F, rect.getMaxY() / 32.0F).color(red, green, blue, endAlpha).next();
-        buffer.vertex(matrix, rect.getMaxX(), rect.getMaxY(), 0.0F).texture(rect.getMaxX() / 32.0F, rect.getMaxY() / 32.0F).color(red, green, blue, endAlpha).next();
-        buffer.vertex(matrix, rect.getMaxX(), rect.getMinY(), 0.0F).texture(rect.getMaxX() / 32.0F, rect.getMinY() / 32.0F).color(red, green, blue, startAlpha).next();
-        buffer.vertex(matrix, rect.getMinX(), rect.getMinY(), 0.0F).texture(rect.getMinX() / 32.0F, rect.getMinY() / 32.0F).color(red, green, blue, startAlpha).next();
-        tessellator.draw();
+        buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+        buffer.vertex(matrix, rect.getMinX(), rect.getMaxY(), 0.0F).uv(rect.getMinX() / 32.0F, rect.getMaxY() / 32.0F).color(red, green, blue, endAlpha).endVertex();
+        buffer.vertex(matrix, rect.getMaxX(), rect.getMaxY(), 0.0F).uv(rect.getMaxX() / 32.0F, rect.getMaxY() / 32.0F).color(red, green, blue, endAlpha).endVertex();
+        buffer.vertex(matrix, rect.getMaxX(), rect.getMinY(), 0.0F).uv(rect.getMaxX() / 32.0F, rect.getMinY() / 32.0F).color(red, green, blue, startAlpha).endVertex();
+        buffer.vertex(matrix, rect.getMinX(), rect.getMinY(), 0.0F).uv(rect.getMinX() / 32.0F, rect.getMinY() / 32.0F).color(red, green, blue, startAlpha).endVertex();
+        tessellator.end();
     }
 }

+ 8 - 9
src/main/java/me/shedaniel/clothconfig2/gui/AbstractTabbedConfigScreen.java → common/src/main/java/me/shedaniel/clothconfig2/gui/AbstractTabbedConfigScreen.java

@@ -2,27 +2,26 @@ package me.shedaniel.clothconfig2.gui;
 
 import com.google.common.collect.Maps;
 import me.shedaniel.clothconfig2.api.TabbedConfigScreen;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
-
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
 import java.util.Map;
 
 public abstract class AbstractTabbedConfigScreen extends AbstractConfigScreen implements TabbedConfigScreen {
-    private final Map<Text, Identifier> categoryBackgroundLocation = Maps.newHashMap();
+    private final Map<Component, ResourceLocation> categoryBackgroundLocation = Maps.newHashMap();
     
-    protected AbstractTabbedConfigScreen(Screen parent, Text title, Identifier backgroundLocation) {
+    protected AbstractTabbedConfigScreen(Screen parent, Component title, ResourceLocation backgroundLocation) {
         super(parent, title, backgroundLocation);
     }
     
     @Override
-    public final void registerCategoryBackground(Text text, Identifier identifier) {
+    public final void registerCategoryBackground(Component text, ResourceLocation identifier) {
         this.categoryBackgroundLocation.put(text, identifier);
     }
     
     @Override
-    public Identifier getBackgroundLocation() {
-        Text selectedCategory = getSelectedCategory();
+    public ResourceLocation getBackgroundLocation() {
+        Component selectedCategory = getSelectedCategory();
         if (categoryBackgroundLocation.containsKey(selectedCategory))
             return categoryBackgroundLocation.get(selectedCategory);
         return super.getBackgroundLocation();

+ 97 - 97
src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigScreen.java → common/src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigScreen.java

@@ -3,6 +3,11 @@ package me.shedaniel.clothconfig2.gui;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.blaze3d.vertex.Tesselator;
+import com.mojang.math.Matrix4f;
 import me.shedaniel.clothconfig2.api.*;
 import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget;
 import me.shedaniel.clothconfig2.impl.EasingMethod;
@@ -10,22 +15,17 @@ import me.shedaniel.math.Point;
 import me.shedaniel.math.Rectangle;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.widget.AbstractButtonWidget;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.resource.language.I18n;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
-import net.minecraft.util.Identifier;
-import net.minecraft.util.Pair;
-import net.minecraft.util.math.MathHelper;
-import net.minecraft.util.math.Matrix4f;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.resources.language.I18n;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.util.Mth;
+import net.minecraft.util.Tuple;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.LinkedHashMap;
@@ -37,7 +37,7 @@ import java.util.stream.Collectors;
 @SuppressWarnings({"deprecation", "rawtypes", "DuplicatedCode"})
 @Environment(EnvType.CLIENT)
 public class ClothConfigScreen extends AbstractTabbedConfigScreen {
-    private ScrollingContainer tabsScroller = new ScrollingContainer() {
+    private final ScrollingContainer tabsScroller = new ScrollingContainer() {
         @Override
         public Rectangle getBounds() {
             return new Rectangle(0, 0, 1, ClothConfigScreen.this.width - 40); // We don't need to handle dragging
@@ -55,23 +55,23 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         }
     };
     public ListWidget<AbstractConfigEntry<AbstractConfigEntry<?>>> listWidget;
-    private final LinkedHashMap<Text, List<AbstractConfigEntry<?>>> categorizedEntries = Maps.newLinkedHashMap();
-    private final List<Pair<Text, Integer>> tabs;
-    private AbstractButtonWidget quitButton, saveButton, buttonLeftTab, buttonRightTab;
+    private final LinkedHashMap<Component, List<AbstractConfigEntry<?>>> categorizedEntries = Maps.newLinkedHashMap();
+    private final List<Tuple<Component, Integer>> tabs;
+    private AbstractWidget quitButton, saveButton, buttonLeftTab, buttonRightTab;
     private Rectangle tabsBounds, tabsLeftBounds, tabsRightBounds;
     private double tabsMaximumScrolled = -1d;
     private final List<ClothConfigTabButton> tabButtons = Lists.newArrayList();
-    private final Map<Text, ConfigCategory> categoryMap;
+    private final Map<Component, ConfigCategory> categoryMap;
     
     @ApiStatus.Internal
-    public ClothConfigScreen(Screen parent, Text title, Map<Text, ConfigCategory> categoryMap, Identifier backgroundLocation) {
+    public ClothConfigScreen(Screen parent, Component title, Map<Component, ConfigCategory> categoryMap, ResourceLocation backgroundLocation) {
         super(parent, title, backgroundLocation);
         categoryMap.forEach((categoryName, category) -> {
             List<AbstractConfigEntry<?>> entries = Lists.newArrayList();
             for (Object object : category.getEntries()) {
                 AbstractConfigListEntry<?> entry;
-                if (object instanceof Pair<?, ?>) {
-                    entry = (AbstractConfigListEntry<?>) ((Pair<?, ?>) object).getRight();
+                if (object instanceof Tuple<?, ?>) {
+                    entry = (AbstractConfigListEntry<?>) ((Tuple<?, ?>) object).getB();
                 } else {
                     entry = (AbstractConfigListEntry<?>) object;
                 }
@@ -84,17 +84,17 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
             }
         });
         
-        this.tabs = categorizedEntries.keySet().stream().map(s -> new Pair<>(s, MinecraftClient.getInstance().textRenderer.getWidth(s) + 8)).collect(Collectors.toList());
+        this.tabs = categorizedEntries.keySet().stream().map(s -> new Tuple<>(s, Minecraft.getInstance().font.width(s) + 8)).collect(Collectors.toList());
         this.categoryMap = categoryMap;
     }
     
     @Override
-    public Text getSelectedCategory() {
-        return tabs.get(selectedCategoryIndex).getLeft();
+    public Component getSelectedCategory() {
+        return tabs.get(selectedCategoryIndex).getA();
     }
     
     @Override
-    public Map<Text, List<AbstractConfigEntry<?>>> getCategorizedEntries() {
+    public Map<Component, List<AbstractConfigEntry<?>>> getCategorizedEntries() {
         return categorizedEntries;
     }
     
@@ -130,15 +130,15 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         super.init();
         this.tabButtons.clear();
         
-        children.add(listWidget = new ListWidget(this, client, width, height, isShowingTabs() ? 70 : 30, height - 32, getBackgroundLocation()));
+        children.add(listWidget = new ListWidget(this, minecraft, width, height, isShowingTabs() ? 70 : 30, height - 32, getBackgroundLocation()));
         if (categorizedEntries.size() > selectedCategoryIndex) {
             listWidget.children().addAll((List) Lists.newArrayList(categorizedEntries.values()).get(selectedCategoryIndex));
         }
         int buttonWidths = Math.min(200, (width - 50 - 12) / 3);
-        addButton(quitButton = new ButtonWidget(width / 2 - buttonWidths - 3, height - 26, buttonWidths, 20, isEdited() ? new TranslatableText("text.cloth-config.cancel_discard") : new TranslatableText("gui.cancel"), widget -> quit()));
-        addButton(saveButton = new ButtonWidget(width / 2 + 3, height - 26, buttonWidths, 20, NarratorManager.EMPTY, button -> saveAll(true)) {
+        addButton(quitButton = new Button(width / 2 - buttonWidths - 3, height - 26, buttonWidths, 20, isEdited() ? new TranslatableComponent("text.cloth-config.cancel_discard") : new TranslatableComponent("gui.cancel"), widget -> quit()));
+        addButton(saveButton = new Button(width / 2 + 3, height - 26, buttonWidths, 20, NarratorChatListener.NO_TITLE, button -> saveAll(true)) {
             @Override
-            public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+            public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
                 boolean hasErrors = false;
                 for (List<AbstractConfigEntry<?>> entries : Lists.newArrayList(categorizedEntries.values())) {
                     for (AbstractConfigEntry<?> entry : entries)
@@ -150,7 +150,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
                         break;
                 }
                 active = isEdited() && !hasErrors;
-                setMessage(hasErrors ? new TranslatableText("text.cloth-config.error_cannot_save") : new TranslatableText("text.cloth-config.save_and_done"));
+                setMessage(hasErrors ? new TranslatableComponent("text.cloth-config.error_cannot_save") : new TranslatableComponent("text.cloth-config.save_and_done"));
                 super.render(matrices, mouseX, mouseY, delta);
             }
         });
@@ -159,34 +159,34 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
             tabsBounds = new Rectangle(0, 41, width, 24);
             tabsLeftBounds = new Rectangle(0, 41, 18, 24);
             tabsRightBounds = new Rectangle(width - 18, 41, 18, 24);
-            children.add(buttonLeftTab = new ButtonWidget(4, 44, 12, 18, NarratorManager.EMPTY, button -> tabsScroller.scrollTo(0, true)) {
+            children.add(buttonLeftTab = new Button(4, 44, 12, 18, NarratorChatListener.NO_TITLE, button -> tabsScroller.scrollTo(0, true)) {
                 @Override
-                public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
-                    client.getTextureManager().bindTexture(CONFIG_TEX);
+                public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
+                    minecraft.getTextureManager().bind(CONFIG_TEX);
                     RenderSystem.color4f(1.0F, 1.0F, 1.0F, this.alpha);
                     int int_3 = this.getYImage(this.isHovered());
                     RenderSystem.enableBlend();
                     RenderSystem.blendFuncSeparate(770, 771, 0, 1);
                     RenderSystem.blendFunc(770, 771);
-                    this.drawTexture(matrices, x, y, 12, 18 * int_3, width, height);
+                    this.blit(matrices, x, y, 12, 18 * int_3, width, height);
                 }
             });
             int j = 0;
-            for (Pair<Text, Integer> tab : tabs) {
-                tabButtons.add(new ClothConfigTabButton(this, j, -100, 43, tab.getRight(), 20, tab.getLeft(), this.categoryMap.get(tab.getLeft()).getDescription()));
+            for (Tuple<Component, Integer> tab : tabs) {
+                tabButtons.add(new ClothConfigTabButton(this, j, -100, 43, tab.getB(), 20, tab.getA(), this.categoryMap.get(tab.getA()).getDescription()));
                 j++;
             }
             children.addAll(tabButtons);
-            children.add(buttonRightTab = new ButtonWidget(width - 16, 44, 12, 18, NarratorManager.EMPTY, button -> tabsScroller.scrollTo(tabsScroller.getMaxScroll(), true)) {
+            children.add(buttonRightTab = new Button(width - 16, 44, 12, 18, NarratorChatListener.NO_TITLE, button -> tabsScroller.scrollTo(tabsScroller.getMaxScroll(), true)) {
                 @Override
-                public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
-                    client.getTextureManager().bindTexture(CONFIG_TEX);
+                public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
+                    minecraft.getTextureManager().bind(CONFIG_TEX);
                     RenderSystem.color4f(1.0F, 1.0F, 1.0F, this.alpha);
                     int int_3 = this.getYImage(this.isHovered());
                     RenderSystem.enableBlend();
                     RenderSystem.blendFuncSeparate(770, 771, 0, 1);
                     RenderSystem.blendFunc(770, 771);
-                    this.drawTexture(matrices, x, y, 0, 18 * int_3, width, height);
+                    this.blit(matrices, x, y, 0, 18 * int_3, width, height);
                 }
             });
         } else {
@@ -207,7 +207,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
     public double getTabsMaximumScrolled() {
         if (tabsMaximumScrolled == -1d) {
             int[] i = {0};
-            for (Pair<Text, Integer> pair : tabs) i[0] += pair.getRight() + 2;
+            for (Tuple<Component, Integer> pair : tabs) i[0] += pair.getB() + 2;
             tabsMaximumScrolled = i[0];
         }
         return tabsMaximumScrolled + 6;
@@ -218,7 +218,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
     }
     
     @Override
-    public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
         if (isShowingTabs()) {
             tabsScroller.updatePosition(delta * 3);
             int xx = 24 - (int) tabsScroller.scrollAmount;
@@ -232,7 +232,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         if (isTransparentBackground()) {
             fillGradient(matrices, 0, 0, this.width, this.height, -1072689136, -804253680);
         } else {
-            renderBackgroundTexture(0);
+            renderDirtBackground(0);
         }
         listWidget.render(matrices, mouseX, mouseY, delta);
         ScissorsHandler.INSTANCE.scissor(new Rectangle(listWidget.left, listWidget.top, listWidget.width, listWidget.bottom - listWidget.top));
@@ -240,7 +240,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
             child.lateRender(matrices, mouseX, mouseY, delta);
         ScissorsHandler.INSTANCE.removeLastScissor();
         if (isShowingTabs()) {
-            drawCenteredText(matrices, client.textRenderer, title, width / 2, 18, -1);
+            drawCenteredString(matrices, minecraft.font, title, width / 2, 18, -1);
             Rectangle onlyInnerTabBounds = new Rectangle(tabsBounds.x + 20, tabsBounds.y, tabsBounds.width - 40, tabsBounds.height);
             ScissorsHandler.INSTANCE.scissor(onlyInnerTabBounds);
             if (isTransparentBackground())
@@ -253,40 +253,40 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
             buttonLeftTab.render(matrices, mouseX, mouseY, delta);
             buttonRightTab.render(matrices, mouseX, mouseY, delta);
         } else
-            drawCenteredText(matrices, client.textRenderer, title, width / 2, 12, -1);
+            drawCenteredString(matrices, minecraft.font, title, width / 2, 12, -1);
         
         if (isEditable()) {
-            List<Text> errors = Lists.newArrayList();
+            List<Component> errors = Lists.newArrayList();
             for (List<AbstractConfigEntry<?>> entries : Lists.newArrayList(categorizedEntries.values()))
                 for (AbstractConfigEntry<?> entry : entries)
                     if (entry.getConfigError().isPresent())
                         errors.add(entry.getConfigError().get());
             if (errors.size() > 0) {
-                client.getTextureManager().bindTexture(CONFIG_TEX);
+                minecraft.getTextureManager().bind(CONFIG_TEX);
                 RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
-                String text = "§c" + (errors.size() == 1 ? errors.get(0).copy().getString() : I18n.translate("text.cloth-config.multi_error"));
+                String text = "§c" + (errors.size() == 1 ? errors.get(0).plainCopy().getString() : I18n.get("text.cloth-config.multi_error"));
                 if (isTransparentBackground()) {
-                    int stringWidth = client.textRenderer.getStringWidth(text);
-                    fillGradient(matrices, 8, 9, 20 + stringWidth, 14 + client.textRenderer.fontHeight, 0x68000000, 0x68000000);
+                    int stringWidth = minecraft.font.width(text);
+                    fillGradient(matrices, 8, 9, 20 + stringWidth, 14 + minecraft.font.lineHeight, 0x68000000, 0x68000000);
                 }
-                drawTexture(matrices, 10, 10, 0, 54, 3, 11);
-                drawStringWithShadow(matrices, client.textRenderer, text, 18, 12, -1);
+                blit(matrices, 10, 10, 0, 54, 3, 11);
+                drawString(matrices, minecraft.font, text, 18, 12, -1);
                 if (errors.size() > 1) {
-                    int stringWidth = client.textRenderer.getStringWidth(text);
-                    if (mouseX >= 10 && mouseY >= 10 && mouseX <= 18 + stringWidth && mouseY <= 14 + client.textRenderer.fontHeight)
-                        addTooltip(Tooltip.of(new Point(mouseX, mouseY), errors.toArray(new Text[0])));
+                    int stringWidth = minecraft.font.width(text);
+                    if (mouseX >= 10 && mouseY >= 10 && mouseX <= 18 + stringWidth && mouseY <= 14 + minecraft.font.lineHeight)
+                        addTooltip(Tooltip.of(new Point(mouseX, mouseY), errors.toArray(new Component[0])));
                 }
             }
         } else if (!isEditable()) {
-            client.getTextureManager().bindTexture(CONFIG_TEX);
+            minecraft.getTextureManager().bind(CONFIG_TEX);
             RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
-            String text = "§c" + I18n.translate("text.cloth-config.not_editable");
+            String text = "§c" + I18n.get("text.cloth-config.not_editable");
             if (isTransparentBackground()) {
-                int stringWidth = client.textRenderer.getStringWidth(text);
-                fillGradient(matrices, 8, 9, 20 + stringWidth, 14 + client.textRenderer.fontHeight, 0x68000000, 0x68000000);
+                int stringWidth = minecraft.font.width(text);
+                fillGradient(matrices, 8, 9, 20 + stringWidth, 14 + minecraft.font.lineHeight, 0x68000000, 0x68000000);
             }
-            drawTexture(matrices, 10, 10, 0, 54, 3, 11);
-            drawStringWithShadow(matrices, client.textRenderer, text, 18, 12, -1);
+            blit(matrices, 10, 10, 0, 54, 3, 11);
+            drawString(matrices, minecraft.font, text, 18, 12, -1);
         }
         super.render(matrices, mouseX, mouseY, delta);
     }
@@ -297,8 +297,8 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         super.addTooltip(queuedTooltip);
     }
     
-    private void drawTabsShades(MatrixStack matrices, int lightColor, int darkColor) {
-        drawTabsShades(matrices.peek().getModel(), lightColor, darkColor);
+    private void drawTabsShades(PoseStack matrices, int lightColor, int darkColor) {
+        drawTabsShades(matrices.last().pose(), lightColor, darkColor);
     }
     
     private void drawTabsShades(Matrix4f matrix, int lightColor, int darkColor) {
@@ -307,20 +307,20 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         RenderSystem.disableAlphaTest();
         RenderSystem.shadeModel(7425);
         RenderSystem.disableTexture();
-        Tessellator tessellator = Tessellator.getInstance();
-        BufferBuilder buffer = tessellator.getBuffer();
-        buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-        buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMinY() + 4, 0.0F).texture(0, 1f).color(0, 0, 0, lightColor).next();
-        buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMinY() + 4, 0.0F).texture(1f, 1f).color(0, 0, 0, lightColor).next();
-        buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMinY(), 0.0F).texture(1f, 0).color(0, 0, 0, darkColor).next();
-        buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMinY(), 0.0F).texture(0, 0).color(0, 0, 0, darkColor).next();
-        tessellator.draw();
-        buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-        buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMaxY(), 0.0F).texture(0, 1f).color(0, 0, 0, darkColor).next();
-        buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMaxY(), 0.0F).texture(1f, 1f).color(0, 0, 0, darkColor).next();
-        buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMaxY() - 4, 0.0F).texture(1f, 0).color(0, 0, 0, lightColor).next();
-        buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMaxY() - 4, 0.0F).texture(0, 0).color(0, 0, 0, lightColor).next();
-        tessellator.draw();
+        Tesselator tessellator = Tesselator.getInstance();
+        BufferBuilder buffer = tessellator.getBuilder();
+        buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+        buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMinY() + 4, 0.0F).uv(0, 1f).color(0, 0, 0, lightColor).endVertex();
+        buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMinY() + 4, 0.0F).uv(1f, 1f).color(0, 0, 0, lightColor).endVertex();
+        buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMinY(), 0.0F).uv(1f, 0).color(0, 0, 0, darkColor).endVertex();
+        buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMinY(), 0.0F).uv(0, 0).color(0, 0, 0, darkColor).endVertex();
+        tessellator.end();
+        buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+        buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMaxY(), 0.0F).uv(0, 1f).color(0, 0, 0, darkColor).endVertex();
+        buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMaxY(), 0.0F).uv(1f, 1f).color(0, 0, 0, darkColor).endVertex();
+        buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMaxY() - 4, 0.0F).uv(1f, 0).color(0, 0, 0, lightColor).endVertex();
+        buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMaxY() - 4, 0.0F).uv(0, 0).color(0, 0, 0, lightColor).endVertex();
+        tessellator.end();
         RenderSystem.enableTexture();
         RenderSystem.shadeModel(7424);
         RenderSystem.enableAlphaTest();
@@ -338,7 +338,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
     }
     
     public static class ListWidget<R extends DynamicElementListWidget.ElementEntry<R>> extends DynamicElementListWidget<R> {
-        private AbstractConfigScreen screen;
+        private final AbstractConfigScreen screen;
         private boolean hasCurrent;
         private double currentX;
         private double currentY;
@@ -350,7 +350,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         public long start;
         public long duration;
         
-        public ListWidget(AbstractConfigScreen screen, MinecraftClient client, int width, int height, int top, int bottom, Identifier backgroundLocation) {
+        public ListWidget(AbstractConfigScreen screen, Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) {
             super(client, width, height, top, bottom, backgroundLocation);
             setRenderSelection(false);
             this.screen = screen;
@@ -367,18 +367,18 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         }
         
         @Override
-        protected void renderItem(MatrixStack matrices, R item, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
+        protected void renderItem(PoseStack matrices, R item, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
             if (item instanceof AbstractConfigEntry)
                 ((AbstractConfigEntry) item).updateSelected(getFocused() == item);
             super.renderItem(matrices, item, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isSelected, delta);
         }
         
         @Override
-        protected void renderList(MatrixStack matrices, int startX, int startY, int int_3, int int_4, float delta) {
+        protected void renderList(PoseStack matrices, int startX, int startY, int int_3, int int_4, float delta) {
             thisTimeTarget = null;
             if (hasCurrent) {
                 long timePast = System.currentTimeMillis() - lastTouch;
-                int alpha = timePast <= 200 ? 255 : MathHelper.ceil(255 - Math.min(timePast - 200, 500F) / 500F * 255.0);
+                int alpha = timePast <= 200 ? 255 : Mth.ceil(255 - Math.min(timePast - 200, 500F) / 500F * 255.0);
                 alpha = (alpha * 36 / 255) << 24;
                 fillGradient(matrices, currentX, currentY, currentX + currentWidth, currentY + currentHeight, 0xFFFFFF | alpha, 0xFFFFFF | alpha);
             }
@@ -406,17 +406,17 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
             }
         }
         
-        protected void fillGradient(MatrixStack matrices, double xStart, double yStart, double xEnd, double yEnd, int colorStart, int colorEnd) {
+        protected void fillGradient(PoseStack matrices, double xStart, double yStart, double xEnd, double yEnd, int colorStart, int colorEnd) {
             RenderSystem.disableTexture();
             RenderSystem.enableBlend();
             RenderSystem.disableAlphaTest();
             RenderSystem.defaultBlendFunc();
             RenderSystem.shadeModel(7425);
-            Tessellator tessellator = Tessellator.getInstance();
-            BufferBuilder bufferBuilder = tessellator.getBuffer();
-            bufferBuilder.begin(7, VertexFormats.POSITION_COLOR);
-            fillGradient(matrices.peek().getModel(), bufferBuilder, xStart, yStart, xEnd, yEnd, this.getZOffset(), colorStart, colorEnd);
-            tessellator.draw();
+            Tesselator tessellator = Tesselator.getInstance();
+            BufferBuilder bufferBuilder = tessellator.getBuilder();
+            bufferBuilder.begin(7, DefaultVertexFormat.POSITION_COLOR);
+            fillGradient(matrices.last().pose(), bufferBuilder, xStart, yStart, xEnd, yEnd, this.getBlitOffset(), colorStart, colorEnd);
+            tessellator.end();
             RenderSystem.shadeModel(7424);
             RenderSystem.disableBlend();
             RenderSystem.enableAlphaTest();
@@ -432,10 +432,10 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
             float n = (float) (k >> 16 & 255) / 255.0F;
             float o = (float) (k >> 8 & 255) / 255.0F;
             float p = (float) (k & 255) / 255.0F;
-            bufferBuilder.vertex(matrix4f, (float) xEnd, (float) yStart, (float) i).color(g, h, l, f).next();
-            bufferBuilder.vertex(matrix4f, (float) xStart, (float) yStart, (float) i).color(g, h, l, f).next();
-            bufferBuilder.vertex(matrix4f, (float) xStart, (float) yEnd, (float) i).color(n, o, p, m).next();
-            bufferBuilder.vertex(matrix4f, (float) xEnd, (float) yEnd, (float) i).color(n, o, p, m).next();
+            bufferBuilder.vertex(matrix4f, (float) xEnd, (float) yStart, (float) i).color(g, h, l, f).endVertex();
+            bufferBuilder.vertex(matrix4f, (float) xStart, (float) yStart, (float) i).color(g, h, l, f).endVertex();
+            bufferBuilder.vertex(matrix4f, (float) xStart, (float) yEnd, (float) i).color(n, o, p, m).endVertex();
+            bufferBuilder.vertex(matrix4f, (float) xEnd, (float) yEnd, (float) i).color(n, o, p, m).endVertex();
         }
         
         @Override
@@ -461,7 +461,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         }
         
         @Override
-        protected void renderBackBackground(MatrixStack matrices, BufferBuilder buffer, Tessellator tessellator) {
+        protected void renderBackBackground(PoseStack matrices, BufferBuilder buffer, Tesselator tessellator) {
             if (!screen.isTransparentBackground())
                 super.renderBackBackground(matrices, buffer, tessellator);
             else {
@@ -470,7 +470,7 @@ public class ClothConfigScreen extends AbstractTabbedConfigScreen {
         }
         
         @Override
-        protected void renderHoleBackground(MatrixStack matrices, int y1, int y2, int alpha1, int alpha2) {
+        protected void renderHoleBackground(PoseStack matrices, int y1, int y2, int alpha1, int alpha2) {
             if (!screen.isTransparentBackground())
                 super.renderHoleBackground(matrices, y1, y2, alpha1, alpha2);
         }

+ 13 - 14
src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigTabButton.java → common/src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigTabButton.java

@@ -4,32 +4,31 @@ import me.shedaniel.clothconfig2.api.Tooltip;
 import me.shedaniel.math.Point;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.StringRenderable;
-import net.minecraft.text.Text;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.AbstractButton;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.FormattedText;
 import org.jetbrains.annotations.Nullable;
-
+import com.mojang.blaze3d.vertex.PoseStack;
 import java.util.Optional;
 import java.util.function.Supplier;
 
 @Environment(EnvType.CLIENT)
-public class ClothConfigTabButton extends AbstractPressableButtonWidget {
+public class ClothConfigTabButton extends AbstractButton {
     
     private final int index;
     private final ClothConfigScreen screen;
     @Nullable 
-    private final Supplier<Optional<StringRenderable[]>> descriptionSupplier;
+    private final Supplier<Optional<FormattedText[]>> descriptionSupplier;
     
-    public ClothConfigTabButton(ClothConfigScreen screen, int index, int int_1, int int_2, int int_3, int int_4, Text string_1, Supplier<Optional<StringRenderable[]>> descriptionSupplier) {
+    public ClothConfigTabButton(ClothConfigScreen screen, int index, int int_1, int int_2, int int_3, int int_4, Component string_1, Supplier<Optional<FormattedText[]>> descriptionSupplier) {
         super(int_1, int_2, int_3, int_4, string_1);
         this.index = index;
         this.screen = screen;
         this.descriptionSupplier = descriptionSupplier;
     }
 
-    public ClothConfigTabButton(ClothConfigScreen screen, int index, int int_1, int int_2, int int_3, int int_4, Text string_1) {
+    public ClothConfigTabButton(ClothConfigScreen screen, int index, int int_1, int int_2, int int_3, int int_4, Component string_1) {
         this(screen, index, int_1, int_2, int_3, int_4, string_1, null);
     }
     
@@ -37,16 +36,16 @@ public class ClothConfigTabButton extends AbstractPressableButtonWidget {
     public void onPress() {
         if (index != -1)
             screen.selectedCategoryIndex = index;
-        screen.init(MinecraftClient.getInstance(), screen.width, screen.height);
+        screen.init(Minecraft.getInstance(), screen.width, screen.height);
     }
     
     @Override
-    public void render(MatrixStack matrices, int int_1, int int_2, float float_1) {
+    public void render(PoseStack matrices, int int_1, int int_2, float float_1) {
         active = index != screen.selectedCategoryIndex;
         super.render(matrices, int_1, int_2, float_1);
 
         if (isMouseOver(int_1, int_2)) {
-            Optional<StringRenderable[]> tooltip = getTooltip();
+            Optional<FormattedText[]> tooltip = getTooltip();
             if (tooltip.isPresent() && tooltip.get().length > 0)
                 screen.addTooltip(Tooltip.of(new Point(int_1, int_2), tooltip.get()));
         }
@@ -62,7 +61,7 @@ public class ClothConfigTabButton extends AbstractPressableButtonWidget {
         return this.visible && double_1 >= this.x && double_2 >= this.y && double_1 < this.x + this.width && double_2 < this.y + this.height && double_1 >= 20 && double_1 < screen.width - 20;
     }
 
-    public Optional<StringRenderable[]> getTooltip() {
+    public Optional<FormattedText[]> getTooltip() {
         if (descriptionSupplier != null)
             return descriptionSupplier.get();
         return Optional.empty();

+ 20 - 0
common/src/main/java/me/shedaniel/clothconfig2/gui/ClothRequiresRestartScreen.java

@@ -0,0 +1,20 @@
+package me.shedaniel.clothconfig2.gui;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.screens.ConfirmScreen;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.TranslatableComponent;
+
+@Environment(EnvType.CLIENT)
+public class ClothRequiresRestartScreen extends ConfirmScreen {
+    public ClothRequiresRestartScreen(Screen parent) {
+        super(t -> {
+            if (t)
+                Minecraft.getInstance().stop();
+            else
+                Minecraft.getInstance().setScreen(parent);
+        }, new TranslatableComponent("text.cloth-config.restart_required"), new TranslatableComponent("text.cloth-config.restart_required_sub"), new TranslatableComponent("text.cloth-config.exit_minecraft"), new TranslatableComponent("text.cloth-config.ignore_restart"));
+    }
+}

+ 106 - 106
src/main/java/me/shedaniel/clothconfig2/gui/GlobalizedClothConfigScreen.java → common/src/main/java/me/shedaniel/clothconfig2/gui/GlobalizedClothConfigScreen.java

@@ -3,32 +3,32 @@ package me.shedaniel.clothconfig2.gui;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.blaze3d.vertex.Tesselator;
+import com.mojang.math.Matrix4f;
 import me.shedaniel.clothconfig2.ClothConfigInitializer;
 import me.shedaniel.clothconfig2.api.*;
 import me.shedaniel.math.Rectangle;
-import net.minecraft.class_5481;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.widget.AbstractButtonWidget;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexConsumerProvider;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.sound.PositionedSoundInstance;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.sound.SoundEvents;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
-import net.minecraft.util.Formatting;
-import net.minecraft.util.Identifier;
-import net.minecraft.util.Pair;
-import net.minecraft.util.math.MathHelper;
-import net.minecraft.util.math.Matrix4f;
+import net.minecraft.ChatFormatting;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.renderer.MultiBufferSource;
+import net.minecraft.client.resources.sounds.SimpleSoundInstance;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.sounds.SoundEvents;
+import net.minecraft.util.FormattedCharSequence;
+import net.minecraft.util.Mth;
+import net.minecraft.util.Tuple;
 import org.apache.commons.lang3.StringUtils;
 import org.jetbrains.annotations.ApiStatus;
 
@@ -36,8 +36,8 @@ import java.util.*;
 
 public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements ReferenceBuildingConfigScreen, Expandable {
     public ClothConfigScreen.ListWidget<AbstractConfigEntry<AbstractConfigEntry<?>>> listWidget;
-    private AbstractButtonWidget cancelButton, exitButton;
-    private final LinkedHashMap<Text, List<AbstractConfigEntry<?>>> categorizedEntries = Maps.newLinkedHashMap();
+    private AbstractWidget cancelButton, exitButton;
+    private final LinkedHashMap<Component, List<AbstractConfigEntry<?>>> categorizedEntries = Maps.newLinkedHashMap();
     private final ScrollingContainer sideScroller = new ScrollingContainer() {
         @Override
         public Rectangle getBounds() {
@@ -49,14 +49,14 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
             int i = 0;
             for (Reference reference : references) {
                 if (i != 0) i += 3 * reference.getScale();
-                i += textRenderer.fontHeight * reference.getScale();
+                i += font.lineHeight * reference.getScale();
             }
             return i;
         }
     };
     private Reference lastHoveredReference = null;
     private final ScrollingContainer sideSlider = new ScrollingContainer() {
-        private Rectangle empty = new Rectangle();
+        private final Rectangle empty = new Rectangle();
         
         @Override
         public Rectangle getBounds() {
@@ -72,8 +72,8 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
     private final LazyResettable<Integer> sideExpandLimit = new LazyResettable<>(() -> {
         int max = 0;
         for (Reference reference : references) {
-            Text referenceText = reference.getText();
-            int width = textRenderer.getWidth(new LiteralText(StringUtils.repeat("  ", reference.getIndent()) + "- ").append(referenceText));
+            Component referenceText = reference.getText();
+            int width = font.width(new TextComponent(StringUtils.repeat("  ", reference.getIndent()) + "- ").append(referenceText));
             if (width > max) max = width;
         }
         return Math.min(max + 8, width / 4);
@@ -81,14 +81,14 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
     private boolean requestingReferenceRebuilding = false;
     
     @ApiStatus.Internal
-    public GlobalizedClothConfigScreen(Screen parent, Text title, Map<Text, ConfigCategory> categoryMap, Identifier backgroundLocation) {
+    public GlobalizedClothConfigScreen(Screen parent, Component title, Map<Component, ConfigCategory> categoryMap, ResourceLocation backgroundLocation) {
         super(parent, title, backgroundLocation);
         categoryMap.forEach((categoryName, category) -> {
             List<AbstractConfigEntry<?>> entries = Lists.newArrayList();
             for (Object object : category.getEntries()) {
                 AbstractConfigListEntry<?> entry;
-                if (object instanceof Pair<?, ?>) {
-                    entry = (AbstractConfigListEntry<?>) ((Pair<?, ?>) object).getRight();
+                if (object instanceof Tuple<?, ?>) {
+                    entry = (AbstractConfigListEntry<?>) ((Tuple<?, ?>) object).getB();
                 } else {
                     entry = (AbstractConfigListEntry<?>) object;
                 }
@@ -106,7 +106,7 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
     }
     
     @Override
-    public Map<Text, List<AbstractConfigEntry<?>>> getCategorizedEntries() {
+    public Map<Component, List<AbstractConfigEntry<?>>> getCategorizedEntries() {
         return this.categorizedEntries;
     }
     
@@ -117,21 +117,21 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
         this.sideExpandLimit.reset();
         this.references.clear();
         buildReferences();
-        this.children.add(listWidget = new ClothConfigScreen.ListWidget<>(this, client, width - 14, height, 30, height - 32, getBackgroundLocation()));
+        this.children.add(listWidget = new ClothConfigScreen.ListWidget<>(this, minecraft, width - 14, height, 30, height - 32, getBackgroundLocation()));
         this.listWidget.setLeftPos(14);
         this.categorizedEntries.forEach((category, entries) -> {
             if (!listWidget.children().isEmpty())
                 this.listWidget.children().add((AbstractConfigEntry) new EmptyEntry(5));
             this.listWidget.children().add((AbstractConfigEntry) new EmptyEntry(4));
-            this.listWidget.children().add((AbstractConfigEntry) new CategoryTextEntry(category, category.shallowCopy().formatted(Formatting.BOLD)));
+            this.listWidget.children().add((AbstractConfigEntry) new CategoryTextEntry(category, category.copy().withStyle(ChatFormatting.BOLD)));
             this.listWidget.children().add((AbstractConfigEntry) new EmptyEntry(4));
             this.listWidget.children().addAll((List) entries);
         });
         int buttonWidths = Math.min(200, (width - 50 - 12) / 3);
-        addButton(cancelButton = new ButtonWidget(0, height - 26, buttonWidths, 20, isEdited() ? new TranslatableText("text.cloth-config.cancel_discard") : new TranslatableText("gui.cancel"), widget -> quit()));
-        addButton(exitButton = new ButtonWidget(0, height - 26, buttonWidths, 20, NarratorManager.EMPTY, button -> saveAll(true)) {
+        addButton(cancelButton = new Button(0, height - 26, buttonWidths, 20, isEdited() ? new TranslatableComponent("text.cloth-config.cancel_discard") : new TranslatableComponent("gui.cancel"), widget -> quit()));
+        addButton(exitButton = new Button(0, height - 26, buttonWidths, 20, NarratorChatListener.NO_TITLE, button -> saveAll(true)) {
             @Override
-            public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+            public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
                 boolean hasErrors = false;
                 label:
                 for (List<AbstractConfigEntry<?>> entries : categorizedEntries.values()) {
@@ -143,7 +143,7 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
                     }
                 }
                 active = isEdited() && !hasErrors;
-                setMessage(hasErrors ? new TranslatableText("text.cloth-config.error_cannot_save") : new TranslatableText("text.cloth-config.save_and_done"));
+                setMessage(hasErrors ? new TranslatableComponent("text.cloth-config.error_cannot_save") : new TranslatableComponent("text.cloth-config.save_and_done"));
                 super.render(matrices, mouseX, mouseY, delta);
             }
         });
@@ -169,7 +169,7 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
     
     @SuppressWarnings("deprecation")
     @Override
-    public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
         this.lastHoveredReference = null;
         if (requestingReferenceRebuilding) {
             this.references.clear();
@@ -181,7 +181,7 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
         if (isTransparentBackground()) {
             fillGradient(matrices, 14, 0, width, height, -1072689136, -804253680);
         } else {
-            renderBackgroundTexture(0);
+            renderDirtBackground(0);
             overlayBackground(matrices, new Rectangle(14, 0, width, height), 64, 64, 64, 255, 255);
         }
         listWidget.width = width - sliderPosition;
@@ -191,7 +191,7 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
         for (AbstractConfigEntry<?> child : listWidget.children())
             child.lateRender(matrices, mouseX, mouseY, delta);
         ScissorsHandler.INSTANCE.removeLastScissor();
-        textRenderer.drawWithShadow(matrices, title.method_30937(), sliderPosition + (width - sliderPosition) / 2f - textRenderer.getWidth(title) / 2f, 12, -1);
+        font.drawShadow(matrices, title.getVisualOrderText(), sliderPosition + (width - sliderPosition) / 2f - font.width(title) / 2f, 12, -1);
         ScissorsHandler.INSTANCE.removeLastScissor();
         cancelButton.x = sliderPosition + (width - sliderPosition) / 2 - cancelButton.getWidth() - 3;
         exitButton.x = sliderPosition + (width - sliderPosition) / 2 + 3;
@@ -202,48 +202,48 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
             fillGradient(matrices, 0, 0, sliderPosition, height, -1240461296, -972025840);
             fillGradient(matrices, 0, 0, sliderPosition - 14, height, 1744830464, 1744830464);
         } else {
-            Tessellator tessellator = Tessellator.getInstance();
-            BufferBuilder buffer = tessellator.getBuffer();
-            client.getTextureManager().bindTexture(getBackgroundLocation());
+            Tesselator tessellator = Tesselator.getInstance();
+            BufferBuilder buffer = tessellator.getBuilder();
+            minecraft.getTextureManager().bind(getBackgroundLocation());
             RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
             float f = 32.0F;
-            buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-            buffer.vertex(sliderPosition - 14, height, 0.0D).texture(0, height / 32.0F).color(68, 68, 68, 255).next();
-            buffer.vertex(sliderPosition, height, 0.0D).texture(14 / 32.0F, height / 32.0F).color(68, 68, 68, 255).next();
-            buffer.vertex(sliderPosition, 0, 0.0D).texture(14 / 32.0F, 0).color(68, 68, 68, 255).next();
-            buffer.vertex(sliderPosition - 14, 0, 0.0D).texture(0, 0).color(68, 68, 68, 255).next();
-            tessellator.draw();
+            buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+            buffer.vertex(sliderPosition - 14, height, 0.0D).uv(0, height / 32.0F).color(68, 68, 68, 255).endVertex();
+            buffer.vertex(sliderPosition, height, 0.0D).uv(14 / 32.0F, height / 32.0F).color(68, 68, 68, 255).endVertex();
+            buffer.vertex(sliderPosition, 0, 0.0D).uv(14 / 32.0F, 0).color(68, 68, 68, 255).endVertex();
+            buffer.vertex(sliderPosition - 14, 0, 0.0D).uv(0, 0).color(68, 68, 68, 255).endVertex();
+            tessellator.end();
             
-            buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-            buffer.vertex(0, height, 0.0D).texture(0, (height + (int) sideScroller.scrollAmount) / 32.0F).color(32, 32, 32, 255).next();
-            buffer.vertex(sliderPosition - 14, height, 0.0D).texture((sliderPosition - 14) / 32.0F, (height + (int) sideScroller.scrollAmount) / 32.0F).color(32, 32, 32, 255).next();
-            buffer.vertex(sliderPosition - 14, 0, 0.0D).texture((sliderPosition - 14) / 32.0F, ((int) sideScroller.scrollAmount) / 32.0F).color(32, 32, 32, 255).next();
-            buffer.vertex(0, 0, 0.0D).texture(0, ((int) sideScroller.scrollAmount) / 32.0F).color(32, 32, 32, 255).next();
-            tessellator.draw();
+            buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+            buffer.vertex(0, height, 0.0D).uv(0, (height + (int) sideScroller.scrollAmount) / 32.0F).color(32, 32, 32, 255).endVertex();
+            buffer.vertex(sliderPosition - 14, height, 0.0D).uv((sliderPosition - 14) / 32.0F, (height + (int) sideScroller.scrollAmount) / 32.0F).color(32, 32, 32, 255).endVertex();
+            buffer.vertex(sliderPosition - 14, 0, 0.0D).uv((sliderPosition - 14) / 32.0F, ((int) sideScroller.scrollAmount) / 32.0F).color(32, 32, 32, 255).endVertex();
+            buffer.vertex(0, 0, 0.0D).uv(0, ((int) sideScroller.scrollAmount) / 32.0F).color(32, 32, 32, 255).endVertex();
+            tessellator.end();
         }
         {
-            Matrix4f matrix = matrices.peek().getModel();
+            Matrix4f matrix = matrices.last().pose();
             RenderSystem.disableTexture();
             RenderSystem.enableBlend();
             RenderSystem.disableAlphaTest();
             RenderSystem.defaultBlendFunc();
             RenderSystem.shadeModel(7425);
-            Tessellator tessellator = Tessellator.getInstance();
-            BufferBuilder buffer = tessellator.getBuffer();
+            Tesselator tessellator = Tesselator.getInstance();
+            BufferBuilder buffer = tessellator.getBuilder();
             int shadeColor = isTransparentBackground() ? 120 : 160;
-            buffer.begin(7, VertexFormats.POSITION_COLOR);
-            buffer.vertex(matrix, sliderPosition + 4, 0, 100.0F).color(0, 0, 0, 0).next();
-            buffer.vertex(matrix, sliderPosition, 0, 100.0F).color(0, 0, 0, shadeColor).next();
-            buffer.vertex(matrix, sliderPosition, height, 100.0F).color(0, 0, 0, shadeColor).next();
-            buffer.vertex(matrix, sliderPosition + 4, height, 100.0F).color(0, 0, 0, 0).next();
-            tessellator.draw();
+            buffer.begin(7, DefaultVertexFormat.POSITION_COLOR);
+            buffer.vertex(matrix, sliderPosition + 4, 0, 100.0F).color(0, 0, 0, 0).endVertex();
+            buffer.vertex(matrix, sliderPosition, 0, 100.0F).color(0, 0, 0, shadeColor).endVertex();
+            buffer.vertex(matrix, sliderPosition, height, 100.0F).color(0, 0, 0, shadeColor).endVertex();
+            buffer.vertex(matrix, sliderPosition + 4, height, 100.0F).color(0, 0, 0, 0).endVertex();
+            tessellator.end();
             shadeColor /= 2;
-            buffer.begin(7, VertexFormats.POSITION_COLOR);
-            buffer.vertex(matrix, sliderPosition - 14, 0, 100.0F).color(0, 0, 0, shadeColor).next();
-            buffer.vertex(matrix, sliderPosition - 14 - 4, 0, 100.0F).color(0, 0, 0, 0).next();
-            buffer.vertex(matrix, sliderPosition - 14 - 4, height, 100.0F).color(0, 0, 0, 0).next();
-            buffer.vertex(matrix, sliderPosition - 14, height, 100.0F).color(0, 0, 0, shadeColor).next();
-            tessellator.draw();
+            buffer.begin(7, DefaultVertexFormat.POSITION_COLOR);
+            buffer.vertex(matrix, sliderPosition - 14, 0, 100.0F).color(0, 0, 0, shadeColor).endVertex();
+            buffer.vertex(matrix, sliderPosition - 14 - 4, 0, 100.0F).color(0, 0, 0, 0).endVertex();
+            buffer.vertex(matrix, sliderPosition - 14 - 4, height, 100.0F).color(0, 0, 0, 0).endVertex();
+            buffer.vertex(matrix, sliderPosition - 14, height, 100.0F).color(0, 0, 0, shadeColor).endVertex();
+            tessellator.end();
             RenderSystem.shadeModel(7424);
             RenderSystem.disableBlend();
             RenderSystem.enableAlphaTest();
@@ -252,24 +252,24 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
         Rectangle slideArrowBounds = new Rectangle(sliderPosition - 14, 0, 14, height);
         {
             RenderSystem.enableAlphaTest();
-            VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
-            textRenderer.drawLayer(">", sliderPosition - 7 - textRenderer.getStringWidth(">") / 2f, height / 2, (slideArrowBounds.contains(mouseX, mouseY) ? 16777120 : 16777215) | MathHelper.clamp(MathHelper.ceil((1 - sideSlider.scrollAmount) * 255.0F), 0, 255) << 24, false, matrices.peek().getModel(), immediate, false, 0, 15728880);
-            textRenderer.drawLayer("<", sliderPosition - 7 - textRenderer.getStringWidth("<") / 2f, height / 2, (slideArrowBounds.contains(mouseX, mouseY) ? 16777120 : 16777215) | MathHelper.clamp(MathHelper.ceil(sideSlider.scrollAmount * 255.0F), 0, 255) << 24, false, matrices.peek().getModel(), immediate, false, 0, 15728880);
-            immediate.draw();
+            MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
+            font.renderText(">", sliderPosition - 7 - font.width(">") / 2f, height / 2, (slideArrowBounds.contains(mouseX, mouseY) ? 16777120 : 16777215) | Mth.clamp(Mth.ceil((1 - sideSlider.scrollAmount) * 255.0F), 0, 255) << 24, false, matrices.last().pose(), immediate, false, 0, 15728880);
+            font.renderText("<", sliderPosition - 7 - font.width("<") / 2f, height / 2, (slideArrowBounds.contains(mouseX, mouseY) ? 16777120 : 16777215) | Mth.clamp(Mth.ceil(sideSlider.scrollAmount * 255.0F), 0, 255) << 24, false, matrices.last().pose(), immediate, false, 0, 15728880);
+            immediate.endBatch();
             
             Rectangle scrollerBounds = sideScroller.getBounds();
             if (!scrollerBounds.isEmpty()) {
                 ScissorsHandler.INSTANCE.scissor(new Rectangle(0, 0, sliderPosition - 14, height));
                 int scrollOffset = (int) (scrollerBounds.y - sideScroller.scrollAmount);
                 for (Reference reference : references) {
-                    matrices.push();
+                    matrices.pushPose();
                     matrices.scale(reference.getScale(), reference.getScale(), reference.getScale());
-                    MutableText text = new LiteralText(StringUtils.repeat("  ", reference.getIndent()) + "- ").append(reference.getText());
-                    if (lastHoveredReference == null && new Rectangle(scrollerBounds.x, (int) (scrollOffset - 4 * reference.getScale()), (int) (textRenderer.getWidth(text) * reference.getScale()), (int) ((textRenderer.fontHeight + 4) * reference.getScale())).contains(mouseX, mouseY))
+                    MutableComponent text = new TextComponent(StringUtils.repeat("  ", reference.getIndent()) + "- ").append(reference.getText());
+                    if (lastHoveredReference == null && new Rectangle(scrollerBounds.x, (int) (scrollOffset - 4 * reference.getScale()), (int) (font.width(text) * reference.getScale()), (int) ((font.lineHeight + 4) * reference.getScale())).contains(mouseX, mouseY))
                         lastHoveredReference = reference;
-                    textRenderer.draw(matrices, text.method_30937(), scrollerBounds.x, scrollOffset, lastHoveredReference == reference ? 16769544 : 16777215);
-                    matrices.pop();
-                    scrollOffset += (textRenderer.fontHeight + 3) * reference.getScale();
+                    font.draw(matrices, text.getVisualOrderText(), scrollerBounds.x, scrollOffset, lastHoveredReference == reference ? 16769544 : 16777215);
+                    matrices.popPose();
+                    scrollOffset += (font.lineHeight + 3) * reference.getScale();
                 }
                 ScissorsHandler.INSTANCE.removeLastScissor();
                 sideScroller.renderScrollBar();
@@ -281,14 +281,14 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
     public boolean mouseClicked(double mouseX, double mouseY, int button) {
         Rectangle slideBounds = new Rectangle(0, 0, getSideSliderPosition() - 14, height);
         if (button == 0 && slideBounds.contains(mouseX, mouseY) && lastHoveredReference != null) {
-            client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+            minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
             lastHoveredReference.go();
             return true;
         }
         Rectangle slideArrowBounds = new Rectangle(getSideSliderPosition() - 14, 0, 14, height);
         if (button == 0 && slideArrowBounds.contains(mouseX, mouseY)) {
             setExpanded(!isExpanded());
-            client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+            minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
             return true;
         }
         return super.mouseClicked(mouseX, mouseY, button);
@@ -322,7 +322,7 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
         private final int height;
         
         public EmptyEntry(int height) {
-            super(new LiteralText(UUID.randomUUID().toString()), false);
+            super(new TextComponent(UUID.randomUUID().toString()), false);
             this.height = height;
         }
         
@@ -350,27 +350,27 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
         public void save() {}
         
         @Override
-        public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {}
+        public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {}
         
         @Override
-        public List<? extends Element> children() {
+        public List<? extends GuiEventListener> children() {
             return Collections.emptyList();
         }
     }
     
     private static class CategoryTextEntry extends AbstractConfigListEntry<Object> {
-        private final Text category;
-        private final Text text;
+        private final Component category;
+        private final Component text;
         
-        public CategoryTextEntry(Text category, Text text) {
-            super(new LiteralText(UUID.randomUUID().toString()), false);
+        public CategoryTextEntry(Component category, Component text) {
+            super(new TextComponent(UUID.randomUUID().toString()), false);
             this.category = category;
             this.text = text;
         }
         
         @Override
         public int getItemHeight() {
-            List<class_5481> strings = MinecraftClient.getInstance().textRenderer.wrapStringToWidthAsList(text, getParent().getItemWidth());
+            List<FormattedCharSequence> strings = Minecraft.getInstance().font.split(text, getParent().getItemWidth());
             if (strings.isEmpty())
                 return 0;
             return 4 + strings.size() * 10;
@@ -395,18 +395,18 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
         }
         
         @Override
-        public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+        public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
             super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
             int yy = y + 2;
-            List<class_5481> texts = MinecraftClient.getInstance().textRenderer.wrapStringToWidthAsList(this.text, getParent().getItemWidth());
-            for (class_5481 text : texts) {
-                MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text, x - 4 + entryWidth / 2 - MinecraftClient.getInstance().textRenderer.method_30880(text) / 2, yy, -1);
+            List<FormattedCharSequence> texts = Minecraft.getInstance().font.split(this.text, getParent().getItemWidth());
+            for (FormattedCharSequence text : texts) {
+                Minecraft.getInstance().font.drawShadow(matrices, text, x - 4 + entryWidth / 2 - Minecraft.getInstance().font.width(text) / 2, yy, -1);
                 yy += 10;
             }
         }
         
         @Override
-        public List<? extends Element> children() {
+        public List<? extends GuiEventListener> children() {
             return Collections.emptyList();
         }
     }
@@ -416,7 +416,7 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
             return 0;
         }
         
-        Text getText();
+        Component getText();
         
         float getScale();
         
@@ -424,14 +424,14 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
     }
     
     private class CategoryReference implements Reference {
-        private Text category;
+        private final Component category;
         
-        public CategoryReference(Text category) {
+        public CategoryReference(Component category) {
             this.category = category;
         }
         
         @Override
-        public Text getText() {
+        public Component getText() {
             return category;
         }
         
@@ -454,8 +454,8 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
     }
     
     private class ConfigEntryReference implements Reference {
-        private AbstractConfigEntry<?> entry;
-        private int layer;
+        private final AbstractConfigEntry<?> entry;
+        private final int layer;
         
         public ConfigEntryReference(AbstractConfigEntry<?> entry, int layer) {
             this.entry = entry;
@@ -468,7 +468,7 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
         }
         
         @Override
-        public Text getText() {
+        public Component getText() {
             return entry.getFieldName();
         }
         
@@ -496,9 +496,9 @@ public class GlobalizedClothConfigScreen extends AbstractConfigScreen implements
             i[0] += root.getInitialReferenceOffset();
             boolean expanded = root instanceof Expandable && ((Expandable) root).isExpanded();
             if (root instanceof Expandable) ((Expandable) root).setExpanded(true);
-            List<? extends Element> children = root.children();
+            List<? extends GuiEventListener> children = root.children();
             if (root instanceof Expandable) ((Expandable) root).setExpanded(expanded);
-            for (Element child : children) {
+            for (GuiEventListener child : children) {
                 if (child instanceof ReferenceProvider<?>) {
                     int i1 = i[0];
                     if (goChild(i, expandedParent != null ? expandedParent : root instanceof Expandable && !expanded ? j : null, ((ReferenceProvider<?>) child).provideReferenceEntry())) {

+ 5 - 5
src/main/java/me/shedaniel/clothconfig2/gui/entries/AbstractListListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/AbstractListListEntry.java

@@ -2,7 +2,7 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.Nullable;
 
@@ -26,11 +26,11 @@ import java.util.stream.Collectors;
 public abstract class AbstractListListEntry<T, C extends AbstractListListEntry.AbstractListCell<T, C, SELF>, SELF extends AbstractListListEntry<T, C, SELF>> extends BaseListEntry<T, C, SELF> {
     
     protected final BiFunction<T, SELF, C> createNewCell;
-    protected Function<T, Optional<Text>> cellErrorSupplier;
+    protected Function<T, Optional<Component>> cellErrorSupplier;
     protected List<T> original;
     
     @ApiStatus.Internal
-    public AbstractListListEntry(Text fieldName, List<T> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<T>> saveConsumer, Supplier<List<T>> defaultValue, Text resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront, BiFunction<T, SELF, C> createNewCell) {
+    public AbstractListListEntry(Component fieldName, List<T> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<T>> saveConsumer, Supplier<List<T>> defaultValue, Component resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront, BiFunction<T, SELF, C> createNewCell) {
         super(fieldName, tooltipSupplier, defaultValue, abstractListListEntry -> createNewCell.apply(null, abstractListListEntry), saveConsumer, resetButtonKey, requiresRestart, deleteButtonEnabled, insertInFront);
         this.createNewCell = createNewCell;
         this.original = new ArrayList<T>(value);
@@ -40,11 +40,11 @@ public abstract class AbstractListListEntry<T, C extends AbstractListListEntry.A
         setExpanded(defaultExpanded);
     }
     
-    public Function<T, Optional<Text>> getCellErrorSupplier() {
+    public Function<T, Optional<Component>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
     
-    public void setCellErrorSupplier(Function<T, Optional<Text>> cellErrorSupplier) {
+    public void setCellErrorSupplier(Function<T, Optional<Component>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
     }
     

+ 19 - 20
src/main/java/me/shedaniel/clothconfig2/gui/entries/AbstractTextFieldListListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/AbstractTextFieldListListEntry.java

@@ -2,16 +2,15 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-
+import com.mojang.blaze3d.vertex.PoseStack;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
@@ -21,7 +20,7 @@ import java.util.function.Consumer;
 import java.util.function.Supplier;
 
 /**
- * This class represents config entry lists that use one {@link TextFieldWidget} per entry.
+ * This class represents config entry lists that use one {@link EditBox} per entry.
  *
  * @param <T>    the configuration object type
  * @param <C>    the cell type
@@ -32,7 +31,7 @@ import java.util.function.Supplier;
 public abstract class AbstractTextFieldListListEntry<T, C extends AbstractTextFieldListListEntry.AbstractTextFieldListCell<T, C, SELF>, SELF extends AbstractTextFieldListListEntry<T, C, SELF>> extends AbstractListListEntry<T, C, SELF> {
     
     @ApiStatus.Internal
-    public AbstractTextFieldListListEntry(Text fieldName, List<T> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<T>> saveConsumer, Supplier<List<T>> defaultValue, Text resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront, BiFunction<T, SELF, C> createNewCell) {
+    public AbstractTextFieldListListEntry(Component fieldName, List<T> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<T>> saveConsumer, Supplier<List<T>> defaultValue, Component resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront, BiFunction<T, SELF, C> createNewCell) {
         super(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, deleteButtonEnabled, insertInFront, createNewCell);
     }
     
@@ -45,7 +44,7 @@ public abstract class AbstractTextFieldListListEntry<T, C extends AbstractTextFi
     @ApiStatus.Internal
     public static abstract class AbstractTextFieldListCell<T, SELF extends AbstractTextFieldListCell<T, SELF, OUTER_SELF>, OUTER_SELF extends AbstractTextFieldListListEntry<T, SELF, OUTER_SELF>> extends AbstractListListEntry.AbstractListCell<T, SELF, OUTER_SELF> {
         
-        protected TextFieldWidget widget;
+        protected EditBox widget;
         private boolean isSelected;
         
         public AbstractTextFieldListCell(@Nullable T value, OUTER_SELF listListEntry) {
@@ -53,20 +52,20 @@ public abstract class AbstractTextFieldListListEntry<T, C extends AbstractTextFi
             
             final T finalValue = substituteDefault(value);
             
-            widget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 0, 0, 100, 18, NarratorManager.EMPTY) {
+            widget = new EditBox(Minecraft.getInstance().font, 0, 0, 100, 18, NarratorChatListener.NO_TITLE) {
                 @Override
-                public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+                public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
                     setFocused(isSelected);
                     super.render(matrices, mouseX, mouseY, delta);
                 }
             };
-            widget.setTextPredicate(this::isValidText);
+            widget.setFilter(this::isValidText);
             widget.setMaxLength(Integer.MAX_VALUE);
-            widget.setHasBorder(false);
-            widget.setText(Objects.toString(finalValue));
-            widget.setCursorToStart();
-            widget.setChangedListener(s -> {
-                widget.setEditableColor(getPreferredTextColor());
+            widget.setBordered(false);
+            widget.setValue(Objects.toString(finalValue));
+            widget.moveCursorToStart();
+            widget.setResponder(s -> {
+                widget.setTextColor(getPreferredTextColor());
             });
         }
         
@@ -98,7 +97,7 @@ public abstract class AbstractTextFieldListListEntry<T, C extends AbstractTextFi
         }
         
         @Override
-        public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
+        public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
             widget.setWidth(entryWidth - 12);
             widget.x = x;
             widget.y = y + 1;
@@ -109,7 +108,7 @@ public abstract class AbstractTextFieldListListEntry<T, C extends AbstractTextFi
         }
         
         @Override
-        public List<? extends Element> children() {
+        public List<? extends GuiEventListener> children() {
             return Collections.singletonList(widget);
         }
     }

+ 9 - 10
src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListCell.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListCell.java

@@ -2,36 +2,35 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.AbstractParentElement;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
-
+import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
+import net.minecraft.network.chat.Component;
+import com.mojang.blaze3d.vertex.PoseStack;
 import java.util.Optional;
 import java.util.function.Supplier;
 
 @Environment(EnvType.CLIENT)
-public abstract class BaseListCell extends AbstractParentElement {
-    private Supplier<Optional<Text>> errorSupplier;
+public abstract class BaseListCell extends AbstractContainerEventHandler {
+    private Supplier<Optional<Component>> errorSupplier;
     
     public final int getPreferredTextColor() {
         return getConfigError().isPresent() ? 16733525 : 14737632;
     }
     
-    public final Optional<Text> getConfigError() {
+    public final Optional<Component> getConfigError() {
         if (errorSupplier != null && errorSupplier.get().isPresent())
             return errorSupplier.get();
         return getError();
     }
     
-    public void setErrorSupplier(Supplier<Optional<Text>> errorSupplier) {
+    public void setErrorSupplier(Supplier<Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
     }
     
-    public abstract Optional<Text> getError();
+    public abstract Optional<Component> getError();
     
     public abstract int getCellHeight();
     
-    public abstract void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta);
+    public abstract void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta);
     
     public void updateSelected(boolean isSelected) {}
     

+ 44 - 45
src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java

@@ -1,22 +1,22 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Lighting;
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.PoseStack;
 import me.shedaniel.clothconfig2.api.Expandable;
 import me.shedaniel.math.Rectangle;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.AbstractButtonWidget;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.render.DiffuseLighting;
-import net.minecraft.client.sound.PositionedSoundInstance;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.sound.SoundEvents;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.resources.sounds.SimpleSoundInstance;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.sounds.SoundEvents;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -39,39 +39,39 @@ import java.util.stream.Collectors;
 @Environment(EnvType.CLIENT)
 public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends BaseListEntry<T, C, SELF>> extends TooltipListEntry<List<T>> implements Expandable {
     
-    protected static final Identifier CONFIG_TEX = new Identifier("cloth-config2", "textures/gui/cloth_config.png");
+    protected static final ResourceLocation CONFIG_TEX = new ResourceLocation("cloth-config2", "textures/gui/cloth_config.png");
     @NotNull protected final List<C> cells;
-    @NotNull protected final List<Element> widgets;
+    @NotNull protected final List<GuiEventListener> widgets;
     protected boolean expanded;
     protected boolean deleteButtonEnabled;
     protected boolean insertInFront;
     @Nullable protected Consumer<List<T>> saveConsumer;
     protected ListLabelWidget labelWidget;
-    protected AbstractButtonWidget resetWidget;
+    protected AbstractWidget resetWidget;
     @NotNull protected Function<SELF, C> createNewInstance;
     @NotNull protected Supplier<List<T>> defaultValue;
     @Nullable
-    protected Text addTooltip = new TranslatableText("text.cloth-config.list.add"), removeTooltip = new TranslatableText("text.cloth-config.list.remove");
+    protected Component addTooltip = new TranslatableComponent("text.cloth-config.list.add"), removeTooltip = new TranslatableComponent("text.cloth-config.list.remove");
     
     @ApiStatus.Internal
-    public BaseListEntry(@NotNull Text fieldName, @Nullable Supplier<Optional<Text[]>> tooltipSupplier, @Nullable Supplier<List<T>> defaultValue, @NotNull Function<SELF, C> createNewInstance, @Nullable Consumer<List<T>> saveConsumer, Text resetButtonKey) {
+    public BaseListEntry(@NotNull Component fieldName, @Nullable Supplier<Optional<Component[]>> tooltipSupplier, @Nullable Supplier<List<T>> defaultValue, @NotNull Function<SELF, C> createNewInstance, @Nullable Consumer<List<T>> saveConsumer, Component resetButtonKey) {
         this(fieldName, tooltipSupplier, defaultValue, createNewInstance, saveConsumer, resetButtonKey, false);
     }
     
     @ApiStatus.Internal
-    public BaseListEntry(@NotNull Text fieldName, @Nullable Supplier<Optional<Text[]>> tooltipSupplier, @Nullable Supplier<List<T>> defaultValue, @NotNull Function<SELF, C> createNewInstance, @Nullable Consumer<List<T>> saveConsumer, Text resetButtonKey, boolean requiresRestart) {
+    public BaseListEntry(@NotNull Component fieldName, @Nullable Supplier<Optional<Component[]>> tooltipSupplier, @Nullable Supplier<List<T>> defaultValue, @NotNull Function<SELF, C> createNewInstance, @Nullable Consumer<List<T>> saveConsumer, Component resetButtonKey, boolean requiresRestart) {
         this(fieldName, tooltipSupplier, defaultValue, createNewInstance, saveConsumer, resetButtonKey, requiresRestart, true, true);
     }
     
     @ApiStatus.Internal
-    public BaseListEntry(@NotNull Text fieldName, @Nullable Supplier<Optional<Text[]>> tooltipSupplier, @Nullable Supplier<List<T>> defaultValue, @NotNull Function<SELF, C> createNewInstance, @Nullable Consumer<List<T>> saveConsumer, Text resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
+    public BaseListEntry(@NotNull Component fieldName, @Nullable Supplier<Optional<Component[]>> tooltipSupplier, @Nullable Supplier<List<T>> defaultValue, @NotNull Function<SELF, C> createNewInstance, @Nullable Consumer<List<T>> saveConsumer, Component resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
         super(fieldName, tooltipSupplier, requiresRestart);
         this.deleteButtonEnabled = deleteButtonEnabled;
         this.insertInFront = insertInFront;
         this.cells = Lists.newArrayList();
         this.labelWidget = new ListLabelWidget();
         this.widgets = Lists.newArrayList(labelWidget);
-        this.resetWidget = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
+        this.resetWidget = new Button(0, 0, Minecraft.getInstance().font.width(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
             widgets.removeAll(cells);
             for (C cell : cells) {
                 cell.onDelete();
@@ -102,8 +102,7 @@ public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends Base
     @Override
     public boolean isEdited() {
         if (super.isEdited()) return true;
-        if (cells.stream().anyMatch(BaseListCell::isEdited)) return true;
-        return false;
+        return cells.stream().anyMatch(BaseListCell::isEdited);
     }
     
     public boolean isMatchDefault() {
@@ -148,20 +147,20 @@ public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends Base
     }
     
     @Nullable
-    public Text getAddTooltip() {
+    public Component getAddTooltip() {
         return addTooltip;
     }
     
-    public void setAddTooltip(@Nullable Text addTooltip) {
+    public void setAddTooltip(@Nullable Component addTooltip) {
         this.addTooltip = addTooltip;
     }
     
     @Nullable
-    public Text getRemoveTooltip() {
+    public Component getRemoveTooltip() {
         return removeTooltip;
     }
     
-    public void setRemoveTooltip(@Nullable Text removeTooltip) {
+    public void setRemoveTooltip(@Nullable Component removeTooltip) {
         this.removeTooltip = removeTooltip;
     }
     
@@ -186,9 +185,9 @@ public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends Base
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         if (!expanded) {
-            List<Element> elements = new ArrayList<>(widgets);
+            List<GuiEventListener> elements = new ArrayList<>(widgets);
             elements.removeAll(cells);
             return elements;
         }
@@ -196,11 +195,11 @@ public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends Base
     }
     
     @Override
-    public Optional<Text> getError() {
-        List<Text> errors = cells.stream().map(C::getConfigError).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
+    public Optional<Component> getError() {
+        List<Component> errors = cells.stream().map(C::getConfigError).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
         
         if (errors.size() > 1)
-            return Optional.of(new TranslatableText("text.cloth-config.multi_error"));
+            return Optional.of(new TranslatableComponent("text.cloth-config.multi_error"));
         else
             return errors.stream().findFirst();
     }
@@ -229,34 +228,34 @@ public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends Base
     }
     
     @Override
-    public Optional<Text[]> getTooltip(int mouseX, int mouseY) {
+    public Optional<Component[]> getTooltip(int mouseX, int mouseY) {
         if (addTooltip != null && isInsideCreateNew(mouseX, mouseY))
-            return Optional.of(new Text[]{addTooltip});
+            return Optional.of(new Component[]{addTooltip});
         if (removeTooltip != null && isInsideDelete(mouseX, mouseY))
-            return Optional.of(new Text[]{removeTooltip});
+            return Optional.of(new Component[]{removeTooltip});
         if (getTooltipSupplier() != null)
             return getTooltipSupplier().get();
         return Optional.empty();
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        MinecraftClient.getInstance().getTextureManager().bindTexture(CONFIG_TEX);
-        DiffuseLighting.disable();
+        Minecraft.getInstance().getTextureManager().bind(CONFIG_TEX);
+        Lighting.turnOff();
         RenderSystem.color4f(1, 1, 1, 1);
         BaseListCell focused = !expanded || getFocused() == null || !(getFocused() instanceof BaseListCell) ? null : (BaseListCell) getFocused();
         boolean insideCreateNew = isInsideCreateNew(mouseX, mouseY);
         boolean insideDelete = isInsideDelete(mouseX, mouseY);
-        drawTexture(matrices, x - 15, y + 5, 24 + 9, (labelWidget.rectangle.contains(mouseX, mouseY) && !insideCreateNew && !insideDelete ? 18 : 0) + (expanded ? 9 : 0), 9, 9);
-        drawTexture(matrices, x - 15 + 13, y + 5, 24 + 18, insideCreateNew ? 9 : 0, 9, 9);
+        blit(matrices, x - 15, y + 5, 24 + 9, (labelWidget.rectangle.contains(mouseX, mouseY) && !insideCreateNew && !insideDelete ? 18 : 0) + (expanded ? 9 : 0), 9, 9);
+        blit(matrices, x - 15 + 13, y + 5, 24 + 18, insideCreateNew ? 9 : 0, 9, 9);
         if (isDeleteButtonEnabled())
-            drawTexture(matrices, x - 15 + 26, y + 5, 24 + 27, focused == null ? 0 : insideDelete ? 18 : 9, 9, 9);
+            blit(matrices, x - 15 + 26, y + 5, 24 + 27, focused == null ? 0 : insideDelete ? 18 : 9, 9, 9);
         resetWidget.x = x + entryWidth - resetWidget.getWidth();
         resetWidget.y = y;
         resetWidget.active = isEditable() && getDefaultValue().isPresent() && !isMatchDefault();
         resetWidget.render(matrices, mouseX, mouseY, delta);
-        MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, getDisplayedFieldName().method_30937(), isDeleteButtonEnabled() ? x + 24 : x + 24 - 9, y + 6, labelWidget.rectangle.contains(mouseX, mouseY) && !resetWidget.isMouseOver(mouseX, mouseY) && !insideDelete && !insideCreateNew ? 0xffe6fe16 : getPreferredTextColor());
+        Minecraft.getInstance().font.drawShadow(matrices, getDisplayedFieldName().getVisualOrderText(), isDeleteButtonEnabled() ? x + 24 : x + 24 - 9, y + 6, labelWidget.rectangle.contains(mouseX, mouseY) && !resetWidget.isMouseOver(mouseX, mouseY) && !insideDelete && !insideCreateNew ? 0xffe6fe16 : getPreferredTextColor());
         if (expanded) {
             int yy = y + 24;
             for (BaseListCell cell : cells) {
@@ -282,7 +281,7 @@ public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends Base
         return insertInFront;
     }
     
-    public class ListLabelWidget implements Element {
+    public class ListLabelWidget implements GuiEventListener {
         protected Rectangle rectangle = new Rectangle();
         
         @Override
@@ -300,21 +299,21 @@ public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends Base
                     widgets.add(cell);
                 }
                 cell.onAdd();
-                MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+                Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
                 return true;
             } else if (isDeleteButtonEnabled() && isInsideDelete(double_1, double_2)) {
-                Element focused = getFocused();
+                GuiEventListener focused = getFocused();
                 if (expanded && focused instanceof BaseListCell) {
                     ((BaseListCell) focused).onDelete();
                     //noinspection SuspiciousMethodCalls
                     cells.remove(focused);
                     widgets.remove(focused);
-                    MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+                    Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
                 }
                 return true;
             } else if (rectangle.contains(double_1, double_2)) {
                 expanded = !expanded;
-                MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+                Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
                 return true;
             }
             return false;

+ 25 - 25
src/main/java/me/shedaniel/clothconfig2/gui/entries/BooleanListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BooleanListEntry.java

@@ -1,16 +1,16 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Window;
+import com.mojang.blaze3d.vertex.PoseStack;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.Window;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.List;
@@ -24,35 +24,35 @@ public class BooleanListEntry extends TooltipListEntry<Boolean> {
     
     private final AtomicBoolean bool;
     private final boolean original;
-    private final ButtonWidget buttonWidget;
-    private final ButtonWidget resetButton;
+    private final Button buttonWidget;
+    private final Button resetButton;
     private final Consumer<Boolean> saveConsumer;
     private final Supplier<Boolean> defaultValue;
-    private final List<Element> widgets;
+    private final List<GuiEventListener> widgets;
     
     @ApiStatus.Internal
     @Deprecated
-    public BooleanListEntry(Text fieldName, boolean bool, Text resetButtonKey, Supplier<Boolean> defaultValue, Consumer<Boolean> saveConsumer) {
+    public BooleanListEntry(Component fieldName, boolean bool, Component resetButtonKey, Supplier<Boolean> defaultValue, Consumer<Boolean> saveConsumer) {
         this(fieldName, bool, resetButtonKey, defaultValue, saveConsumer, null);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public BooleanListEntry(Text fieldName, boolean bool, Text resetButtonKey, Supplier<Boolean> defaultValue, Consumer<Boolean> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public BooleanListEntry(Component fieldName, boolean bool, Component resetButtonKey, Supplier<Boolean> defaultValue, Consumer<Boolean> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, bool, resetButtonKey, defaultValue, saveConsumer, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public BooleanListEntry(Text fieldName, boolean bool, Text resetButtonKey, Supplier<Boolean> defaultValue, Consumer<Boolean> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public BooleanListEntry(Component fieldName, boolean bool, Component resetButtonKey, Supplier<Boolean> defaultValue, Consumer<Boolean> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, requiresRestart);
         this.defaultValue = defaultValue;
         this.original = bool;
         this.bool = new AtomicBoolean(bool);
-        this.buttonWidget = new ButtonWidget(0, 0, 150, 20, NarratorManager.EMPTY, widget -> {
+        this.buttonWidget = new Button(0, 0, 150, 20, NarratorChatListener.NO_TITLE, widget -> {
             BooleanListEntry.this.bool.set(!BooleanListEntry.this.bool.get());
         });
-        this.resetButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
+        this.resetButton = new Button(0, 0, Minecraft.getInstance().font.width(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
             BooleanListEntry.this.bool.set(defaultValue.get());
         });
         this.saveConsumer = saveConsumer;
@@ -81,21 +81,21 @@ public class BooleanListEntry extends TooltipListEntry<Boolean> {
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        Window window = MinecraftClient.getInstance().getWindow();
+        Window window = Minecraft.getInstance().getWindow();
         this.resetButton.active = isEditable() && getDefaultValue().isPresent() && defaultValue.get() != bool.get();
         this.resetButton.y = y;
         this.buttonWidget.active = isEditable();
         this.buttonWidget.y = y;
         this.buttonWidget.setMessage(getYesNoText(bool.get()));
-        Text displayedFieldName = getDisplayedFieldName();
-        if (MinecraftClient.getInstance().textRenderer.isRightToLeft()) {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), window.getScaledWidth() - x - MinecraftClient.getInstance().textRenderer.getWidth(displayedFieldName), y + 6, 16777215);
+        Component displayedFieldName = getDisplayedFieldName();
+        if (Minecraft.getInstance().font.isBidirectional()) {
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), window.getGuiScaledWidth() - x - Minecraft.getInstance().font.width(displayedFieldName), y + 6, 16777215);
             this.resetButton.x = x;
             this.buttonWidget.x = x + resetButton.getWidth() + 2;
         } else {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), x, y + 6, getPreferredTextColor());
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), x, y + 6, getPreferredTextColor());
             this.resetButton.x = x + entryWidth - resetButton.getWidth();
             this.buttonWidget.x = x + entryWidth - 150;
         }
@@ -104,12 +104,12 @@ public class BooleanListEntry extends TooltipListEntry<Boolean> {
         buttonWidget.render(matrices, mouseX, mouseY, delta);
     }
     
-    public Text getYesNoText(boolean bool) {
-        return new TranslatableText("text.cloth-config.boolean.value." + bool);
+    public Component getYesNoText(boolean bool) {
+        return new TranslatableComponent("text.cloth-config.boolean.value." + bool);
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return widgets;
     }
     

+ 26 - 27
src/main/java/me/shedaniel/clothconfig2/gui/entries/ColorEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/ColorEntry.java

@@ -1,15 +1,14 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import me.shedaniel.clothconfig2.gui.widget.ColorDisplayWidget;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.apache.commons.lang3.StringUtils;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.Nullable;
-
+import com.mojang.blaze3d.vertex.PoseStack;
 import java.util.Locale;
 import java.util.Optional;
 import java.util.function.Consumer;
@@ -17,13 +16,13 @@ import java.util.function.Supplier;
 
 public class ColorEntry extends TextFieldListEntry<Integer> {
     
-    private ColorDisplayWidget colorDisplayWidget;
-    private Consumer<Integer> saveConsumer;
+    private final ColorDisplayWidget colorDisplayWidget;
+    private final Consumer<Integer> saveConsumer;
     private boolean alpha;
     
     @ApiStatus.Internal
     @Deprecated
-    public ColorEntry(Text fieldName, int value, Text resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public ColorEntry(Component fieldName, int value, Component resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, 0, resetButtonKey, defaultValue, tooltipSupplier, requiresRestart);
         this.alpha = true;
         ColorValue colorValue = getColorValue(String.valueOf(value));
@@ -32,10 +31,10 @@ public class ColorEntry extends TextFieldListEntry<Integer> {
         this.alpha = false;
         this.saveConsumer = saveConsumer;
         this.original = value;
-        this.textFieldWidget.setText(getHexColorString(value));
-        this.colorDisplayWidget = new ColorDisplayWidget(textFieldWidget, 0, 0, 20, getColorValueColor(textFieldWidget.getText()));
+        this.textFieldWidget.setValue(getHexColorString(value));
+        this.colorDisplayWidget = new ColorDisplayWidget(textFieldWidget, 0, 0, 20, getColorValueColor(textFieldWidget.getValue()));
         this.resetButton.onPress = button -> {
-            this.textFieldWidget.setText(getHexColorString(defaultValue.get()));
+            this.textFieldWidget.setValue(getHexColorString(defaultValue.get()));
         };
     }
     
@@ -46,13 +45,13 @@ public class ColorEntry extends TextFieldListEntry<Integer> {
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
         this.colorDisplayWidget.y = y;
-        ColorValue value = getColorValue(textFieldWidget.getText());
+        ColorValue value = getColorValue(textFieldWidget.getValue());
         if (!value.hasError())
             colorDisplayWidget.setColor(alpha ? value.getColor() : 0xff000000 | value.getColor());
-        if (MinecraftClient.getInstance().textRenderer.isRightToLeft()) {
+        if (Minecraft.getInstance().font.isBidirectional()) {
             this.colorDisplayWidget.x = x + resetButton.getWidth() + textFieldWidget.getWidth();
         } else {
             this.colorDisplayWidget.x = textFieldWidget.x - 23;
@@ -61,11 +60,11 @@ public class ColorEntry extends TextFieldListEntry<Integer> {
     }
     
     @Override
-    protected void textFieldPreRender(TextFieldWidget widget) {
+    protected void textFieldPreRender(EditBox widget) {
         if (!getConfigError().isPresent()) {
-            widget.setEditableColor(14737632);
+            widget.setTextColor(14737632);
         } else {
-            widget.setEditableColor(16733525);
+            widget.setTextColor(16733525);
         }
     }
     
@@ -85,39 +84,39 @@ public class ColorEntry extends TextFieldListEntry<Integer> {
     
     @Override
     public boolean isEdited() {
-        ColorValue colorValue = getColorValue(textFieldWidget.getText());
+        ColorValue colorValue = getColorValue(textFieldWidget.getValue());
         return colorValue.hasError() || colorValue.color != original;
     }
     
     @Override
     public Integer getValue() {
-        return getColorValueColor(textFieldWidget.getText());
+        return getColorValueColor(textFieldWidget.getValue());
     }
     
     @Deprecated
     public void setValue(int color) {
-        textFieldWidget.setText(getHexColorString(color));
+        textFieldWidget.setValue(getHexColorString(color));
     }
     
     @Override
-    public Optional<Text> getError() {
-        ColorValue colorValue = getColorValue(this.textFieldWidget.getText());
+    public Optional<Component> getError() {
+        ColorValue colorValue = getColorValue(this.textFieldWidget.getValue());
         if (colorValue.hasError())
-            return Optional.of(new TranslatableText("text.cloth-config.error.color." + colorValue.getError().name().toLowerCase(Locale.ROOT)));
+            return Optional.of(new TranslatableComponent("text.cloth-config.error.color." + colorValue.getError().name().toLowerCase(Locale.ROOT)));
         return super.getError();
     }
     
     public void withAlpha() {
         if (!alpha) {
             this.alpha = true;
-            textFieldWidget.setText(getHexColorString(original));
+            textFieldWidget.setValue(getHexColorString(original));
         }
     }
     
     public void withoutAlpha() {
         if (alpha) {
             alpha = false;
-            textFieldWidget.setText(getHexColorString(original));
+            textFieldWidget.setValue(getHexColorString(original));
         }
     }
     
@@ -178,7 +177,7 @@ public class ColorEntry extends TextFieldListEntry<Integer> {
         INVALID_BLUE,
         INVALID_COLOR;
         
-        private ColorValue value;
+        private final ColorValue value;
         
         ColorError() {
             this.value = new ColorValue(this);

+ 19 - 19
src/main/java/me/shedaniel/clothconfig2/gui/entries/DoubleListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DoubleListEntry.java

@@ -2,9 +2,9 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.Optional;
@@ -15,7 +15,7 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class DoubleListEntry extends TextFieldListEntry<Double> {
     
-    private static Function<String, String> stripCharacters = s -> {
+    private static final Function<String, String> stripCharacters = s -> {
         StringBuilder stringBuilder_1 = new StringBuilder();
         char[] var2 = s.toCharArray();
         int var3 = var2.length;
@@ -27,11 +27,11 @@ public class DoubleListEntry extends TextFieldListEntry<Double> {
         return stringBuilder_1.toString();
     };
     private double minimum, maximum;
-    private Consumer<Double> saveConsumer;
+    private final Consumer<Double> saveConsumer;
     
     @ApiStatus.Internal
     @Deprecated
-    public DoubleListEntry(Text fieldName, Double value, Text resetButtonKey, Supplier<Double> defaultValue, Consumer<Double> saveConsumer) {
+    public DoubleListEntry(Component fieldName, Double value, Component resetButtonKey, Supplier<Double> defaultValue, Consumer<Double> saveConsumer) {
         super(fieldName, value, resetButtonKey, defaultValue);
         this.minimum = -Double.MAX_VALUE;
         this.maximum = Double.MAX_VALUE;
@@ -40,13 +40,13 @@ public class DoubleListEntry extends TextFieldListEntry<Double> {
     
     @ApiStatus.Internal
     @Deprecated
-    public DoubleListEntry(Text fieldName, Double value, Text resetButtonKey, Supplier<Double> defaultValue, Consumer<Double> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public DoubleListEntry(Component fieldName, Double value, Component resetButtonKey, Supplier<Double> defaultValue, Consumer<Double> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, value, resetButtonKey, defaultValue, saveConsumer, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public DoubleListEntry(Text fieldName, Double value, Text resetButtonKey, Supplier<Double> defaultValue, Consumer<Double> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public DoubleListEntry(Component fieldName, Double value, Component resetButtonKey, Supplier<Double> defaultValue, Consumer<Double> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, value, resetButtonKey, defaultValue, tooltipSupplier, requiresRestart);
         this.minimum = -Double.MAX_VALUE;
         this.maximum = Double.MAX_VALUE;
@@ -59,15 +59,15 @@ public class DoubleListEntry extends TextFieldListEntry<Double> {
     }
     
     @Override
-    protected void textFieldPreRender(TextFieldWidget widget) {
+    protected void textFieldPreRender(EditBox widget) {
         try {
-            double i = Double.parseDouble(textFieldWidget.getText());
+            double i = Double.parseDouble(textFieldWidget.getValue());
             if (i < minimum || i > maximum)
-                widget.setEditableColor(16733525);
+                widget.setTextColor(16733525);
             else
-                widget.setEditableColor(14737632);
+                widget.setTextColor(14737632);
         } catch (NumberFormatException ex) {
-            widget.setEditableColor(16733525);
+            widget.setTextColor(16733525);
         }
     }
     
@@ -95,22 +95,22 @@ public class DoubleListEntry extends TextFieldListEntry<Double> {
     @Override
     public Double getValue() {
         try {
-            return Double.valueOf(textFieldWidget.getText());
+            return Double.valueOf(textFieldWidget.getValue());
         } catch (Exception e) {
             return 0d;
         }
     }
     
     @Override
-    public Optional<Text> getError() {
+    public Optional<Component> getError() {
         try {
-            double i = Double.parseDouble(textFieldWidget.getText());
+            double i = Double.parseDouble(textFieldWidget.getValue());
             if (i > maximum)
-                return Optional.of(new TranslatableText("text.cloth-config.error.too_large", maximum));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.too_large", maximum));
             else if (i < minimum)
-                return Optional.of(new TranslatableText("text.cloth-config.error.too_small", minimum));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.too_small", minimum));
         } catch (NumberFormatException ex) {
-            return Optional.of(new TranslatableText("text.cloth-config.error.not_valid_number_double"));
+            return Optional.of(new TranslatableComponent("text.cloth-config.error.not_valid_number_double"));
         }
         return super.getError();
     }

+ 11 - 11
src/main/java/me/shedaniel/clothconfig2/gui/entries/DoubleListListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DoubleListListEntry.java

@@ -2,8 +2,8 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -20,19 +20,19 @@ public class DoubleListListEntry extends AbstractTextFieldListListEntry<Double,
     
     @ApiStatus.Internal
     @Deprecated
-    public DoubleListListEntry(Text fieldName, List<Double> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Double>> saveConsumer, Supplier<List<Double>> defaultValue, Text resetButtonKey) {
+    public DoubleListListEntry(Component fieldName, List<Double> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Double>> saveConsumer, Supplier<List<Double>> defaultValue, Component resetButtonKey) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public DoubleListListEntry(Text fieldName, List<Double> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Double>> saveConsumer, Supplier<List<Double>> defaultValue, Text resetButtonKey, boolean requiresRestart) {
+    public DoubleListListEntry(Component fieldName, List<Double> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Double>> saveConsumer, Supplier<List<Double>> defaultValue, Component resetButtonKey, boolean requiresRestart) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, true, true);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public DoubleListListEntry(Text fieldName, List<Double> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Double>> saveConsumer, Supplier<List<Double>> defaultValue, Text resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
+    public DoubleListListEntry(Component fieldName, List<Double> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Double>> saveConsumer, Supplier<List<Double>> defaultValue, Component resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
         super(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, deleteButtonEnabled, insertInFront, DoubleListCell::new);
         this.minimum = Double.NEGATIVE_INFINITY;
         this.maximum = Double.POSITIVE_INFINITY;
@@ -75,22 +75,22 @@ public class DoubleListListEntry extends AbstractTextFieldListListEntry<Double,
         
         public Double getValue() {
             try {
-                return Double.valueOf(widget.getText());
+                return Double.valueOf(widget.getValue());
             } catch (NumberFormatException e) {
                 return 0d;
             }
         }
         
         @Override
-        public Optional<Text> getError() {
+        public Optional<Component> getError() {
             try {
-                double i = Double.parseDouble(widget.getText());
+                double i = Double.parseDouble(widget.getValue());
                 if (i > listListEntry.maximum)
-                    return Optional.of(new TranslatableText("text.cloth-config.error.too_large", listListEntry.maximum));
+                    return Optional.of(new TranslatableComponent("text.cloth-config.error.too_large", listListEntry.maximum));
                 else if (i < listListEntry.minimum)
-                    return Optional.of(new TranslatableText("text.cloth-config.error.too_small", listListEntry.minimum));
+                    return Optional.of(new TranslatableComponent("text.cloth-config.error.too_small", listListEntry.minimum));
             } catch (NumberFormatException ex) {
-                return Optional.of(new TranslatableText("text.cloth-config.error.not_valid_number_double"));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.not_valid_number_double"));
             }
             return Optional.empty();
         }

+ 99 - 99
src/main/java/me/shedaniel/clothconfig2/gui/entries/DropdownBoxEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DropdownBoxEntry.java

@@ -2,7 +2,12 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Window;
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.blaze3d.vertex.Tesselator;
 import me.shedaniel.clothconfig2.ClothConfigInitializer;
 import me.shedaniel.clothconfig2.api.ScissorsHandler;
 import me.shedaniel.clothconfig2.api.ScrollingContainer;
@@ -10,23 +15,18 @@ import me.shedaniel.math.Rectangle;
 import me.shedaniel.math.impl.PointHelper;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.font.TextRenderer;
-import net.minecraft.client.gui.AbstractParentElement;
-import net.minecraft.client.gui.Drawable;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.Window;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
-import net.minecraft.util.math.MathHelper;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.client.gui.components.Widget;
+import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.util.Mth;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -42,39 +42,39 @@ import static me.shedaniel.clothconfig2.api.ScrollingContainer.handleScrollingPo
 @Environment(EnvType.CLIENT)
 public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
     
-    protected ButtonWidget resetButton;
+    protected Button resetButton;
     protected SelectionElement<T> selectionElement;
-    @NotNull private Supplier<T> defaultValue;
-    @Nullable private Consumer<T> saveConsumer;
+    @NotNull private final Supplier<T> defaultValue;
+    @Nullable private final Consumer<T> saveConsumer;
     private boolean suggestionMode = true;
     
     @ApiStatus.Internal
     @Deprecated
-    public DropdownBoxEntry(Text fieldName, @NotNull Text resetButtonKey, @Nullable Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart, @Nullable Supplier<T> defaultValue, @Nullable Consumer<T> saveConsumer, @Nullable Iterable<T> selections, @NotNull SelectionTopCellElement<T> topRenderer, @NotNull SelectionCellCreator<T> cellCreator) {
+    public DropdownBoxEntry(Component fieldName, @NotNull Component resetButtonKey, @Nullable Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart, @Nullable Supplier<T> defaultValue, @Nullable Consumer<T> saveConsumer, @Nullable Iterable<T> selections, @NotNull SelectionTopCellElement<T> topRenderer, @NotNull SelectionCellCreator<T> cellCreator) {
         super(fieldName, tooltipSupplier, requiresRestart);
         this.defaultValue = defaultValue;
         this.saveConsumer = saveConsumer;
-        this.resetButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
+        this.resetButton = new Button(0, 0, Minecraft.getInstance().font.width(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
             selectionElement.topRenderer.setValue(defaultValue.get());
         });
         this.selectionElement = new SelectionElement<>(this, new Rectangle(0, 0, 150, 20), new DefaultDropdownMenuElement<>(selections == null ? ImmutableList.of() : ImmutableList.copyOf(selections)), topRenderer, cellCreator);
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        Window window = MinecraftClient.getInstance().getWindow();
+        Window window = Minecraft.getInstance().getWindow();
         this.resetButton.active = isEditable() && getDefaultValue().isPresent() && (!defaultValue.get().equals(getValue()) || getConfigError().isPresent());
         this.resetButton.y = y;
         this.selectionElement.active = isEditable();
         this.selectionElement.bounds.y = y;
-        Text displayedFieldName = getDisplayedFieldName();
-        if (MinecraftClient.getInstance().textRenderer.isRightToLeft()) {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), window.getScaledWidth() - x - MinecraftClient.getInstance().textRenderer.getWidth(displayedFieldName), y + 6, getPreferredTextColor());
+        Component displayedFieldName = getDisplayedFieldName();
+        if (Minecraft.getInstance().font.isBidirectional()) {
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), window.getGuiScaledWidth() - x - Minecraft.getInstance().font.width(displayedFieldName), y + 6, getPreferredTextColor());
             this.resetButton.x = x;
             this.selectionElement.bounds.x = x + resetButton.getWidth() + 1;
         } else {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), x, y + 6, getPreferredTextColor());
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), x, y + 6, getPreferredTextColor());
             this.resetButton.x = x + entryWidth - resetButton.getWidth();
             this.selectionElement.bounds.x = x + entryWidth - 150 + 1;
         }
@@ -129,17 +129,17 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return Lists.newArrayList(selectionElement, resetButton);
     }
     
     @Override
-    public Optional<Text> getError() {
+    public Optional<Component> getError() {
         return selectionElement.topRenderer.getError();
     }
     
     @Override
-    public void lateRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
         selectionElement.lateRender(matrices, mouseX, mouseY, delta);
     }
     
@@ -153,7 +153,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         return selectionElement.mouseScrolled(double_1, double_2, double_3);
     }
     
-    public static class SelectionElement<R> extends AbstractParentElement implements Drawable {
+    public static class SelectionElement<R> extends AbstractContainerEventHandler implements Widget {
         protected Rectangle bounds;
         protected boolean active;
         protected SelectionTopCellElement<R> topRenderer;
@@ -173,7 +173,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
         
         @Override
-        public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+        public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
             fill(matrices, bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, topRenderer.isSelected ? -1 : -6250336);
             fill(matrices, bounds.x + 1, bounds.y + 1, bounds.x + bounds.width - 1, bounds.y + bounds.height - 1, -16777216);
             topRenderer.render(matrices, mouseX, mouseY, bounds.x, bounds.y, bounds.width, bounds.height, delta);
@@ -193,7 +193,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
             return false;
         }
         
-        public void lateRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+        public void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
             if (menu.isExpanded())
                 menu.lateRender(matrices, mouseX, mouseY, delta);
         }
@@ -209,7 +209,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
         
         @Override
-        public List<? extends Element> children() {
+        public List<? extends GuiEventListener> children() {
             return Lists.newArrayList(topRenderer, menu);
         }
         
@@ -225,7 +225,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
     }
     
-    public static abstract class DropdownMenuElement<R> extends AbstractParentElement {
+    public static abstract class DropdownMenuElement<R> extends AbstractContainerEventHandler {
         @Deprecated @NotNull private SelectionCellCreator<R> cellCreator;
         @Deprecated @NotNull private DropdownBoxEntry<R> entry;
         private boolean isSelected;
@@ -245,9 +245,9 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         
         public abstract void initCells();
         
-        public abstract void render(MatrixStack matrices, int mouseX, int mouseY, Rectangle rectangle, float delta);
+        public abstract void render(PoseStack matrices, int mouseX, int mouseY, Rectangle rectangle, float delta);
         
-        public abstract void lateRender(MatrixStack matrices, int mouseX, int mouseY, float delta);
+        public abstract void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta);
         
         public abstract int getHeight();
         
@@ -267,7 +267,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         @NotNull protected ImmutableList<R> selections;
         @NotNull protected List<SelectionCellElement<R>> cells;
         @NotNull protected List<SelectionCellElement<R>> currentElements;
-        protected Text lastSearchKeyword = NarratorManager.EMPTY;
+        protected Component lastSearchKeyword = NarratorChatListener.NO_TITLE;
         protected Rectangle lastRectangle;
         protected boolean scrolling;
         protected double scroll, target;
@@ -310,7 +310,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
                 currentElements.clear();
                 String keyword = this.lastSearchKeyword.getString().toLowerCase();
                 for (SelectionCellElement<R> cell : cells) {
-                    Text key = cell.getSearchKey();
+                    Component key = cell.getSearchKey();
                     if (key == null || key.getString().toLowerCase().contains(keyword))
                         currentElements.add(cell);
                 }
@@ -365,7 +365,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
         
         @Override
-        public void render(MatrixStack matrices, int mouseX, int mouseY, Rectangle rectangle, float delta) {
+        public void render(PoseStack matrices, int mouseX, int mouseY, Rectangle rectangle, float delta) {
             if (!getEntry().selectionElement.topRenderer.getSearchTerm().equals(lastSearchKeyword)) {
                 lastSearchKeyword = getEntry().selectionElement.topRenderer.getSearchTerm();
                 search();
@@ -382,7 +382,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
         
         @Override
-        public void lateRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+        public void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
             int last10Height = getHeight();
             int cWidth = getCellCreator().getCellWidth();
             fill(matrices, lastRectangle.x, lastRectangle.y + lastRectangle.height, lastRectangle.x + cWidth, lastRectangle.y + lastRectangle.height + last10Height + 1, isExpanded() ? -1 : -6250336);
@@ -402,9 +402,9 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
             ScissorsHandler.INSTANCE.removeLastScissor();
             
             if (currentElements.isEmpty()) {
-                TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
-                Text text = new TranslatableText("text.cloth-config.dropdown.value.unknown");
-                textRenderer.drawWithShadow(matrices, text.method_30937(), lastRectangle.x + getCellCreator().getCellWidth() / 2f - textRenderer.getWidth(text) / 2f, lastRectangle.y + lastRectangle.height + 3, -1);
+                Font textRenderer = Minecraft.getInstance().font;
+                Component text = new TranslatableComponent("text.cloth-config.dropdown.value.unknown");
+                textRenderer.drawShadow(matrices, text.getVisualOrderText(), lastRectangle.x + getCellCreator().getCellWidth() / 2f - textRenderer.width(text) / 2f, lastRectangle.y + lastRectangle.height + 3, -1);
             }
             
             if (getMaxScrollPosition() > 6) {
@@ -412,7 +412,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
                 int scrollbarPositionMinX = lastRectangle.x + getCellCreator().getCellWidth() - 6;
                 int scrollbarPositionMaxX = scrollbarPositionMinX + 6;
                 int height = (int) (((last10Height) * (last10Height)) / this.getMaxScrollPosition());
-                height = MathHelper.clamp(height, 32, last10Height - 8);
+                height = Mth.clamp(height, 32, last10Height - 8);
                 height -= Math.min((scroll < 0 ? (int) -scroll : scroll > getMaxScrollPosition() ? (int) scroll - getMaxScrollPosition() : 0), height * .95);
                 height = Math.max(10, height);
                 int minY = (int) Math.min(Math.max((int) scroll * (last10Height - height) / getMaxScrollPosition() + (lastRectangle.y + lastRectangle.height + 1), (lastRectangle.y + lastRectangle.height + 1)), (lastRectangle.y + lastRectangle.height + 1 + last10Height) - height);
@@ -420,24 +420,24 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
                 int bottomc = new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height).contains(PointHelper.ofMouse()) ? 168 : 128;
                 int topc = new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height).contains(PointHelper.ofMouse()) ? 222 : 172;
                 
-                Tessellator tessellator = Tessellator.getInstance();
-                BufferBuilder buffer = tessellator.getBuffer();
+                Tesselator tessellator = Tesselator.getInstance();
+                BufferBuilder buffer = tessellator.getBuilder();
                 
                 // Bottom
-                buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-                buffer.vertex(scrollbarPositionMinX, minY + height, 0.0D).texture(0, 1).color(bottomc, bottomc, bottomc, 255).next();
-                buffer.vertex(scrollbarPositionMaxX, minY + height, 0.0D).texture(1, 1).color(bottomc, bottomc, bottomc, 255).next();
-                buffer.vertex(scrollbarPositionMaxX, minY, 0.0D).texture(1, 0).color(bottomc, bottomc, bottomc, 255).next();
-                buffer.vertex(scrollbarPositionMinX, minY, 0.0D).texture(0, 0).color(bottomc, bottomc, bottomc, 255).next();
-                tessellator.draw();
+                buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+                buffer.vertex(scrollbarPositionMinX, minY + height, 0.0D).uv(0, 1).color(bottomc, bottomc, bottomc, 255).endVertex();
+                buffer.vertex(scrollbarPositionMaxX, minY + height, 0.0D).uv(1, 1).color(bottomc, bottomc, bottomc, 255).endVertex();
+                buffer.vertex(scrollbarPositionMaxX, minY, 0.0D).uv(1, 0).color(bottomc, bottomc, bottomc, 255).endVertex();
+                buffer.vertex(scrollbarPositionMinX, minY, 0.0D).uv(0, 0).color(bottomc, bottomc, bottomc, 255).endVertex();
+                tessellator.end();
                 
                 // Top
-                buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-                buffer.vertex(scrollbarPositionMinX, (minY + height - 1), 0.0D).texture(0, 1).color(topc, topc, topc, 255).next();
-                buffer.vertex((scrollbarPositionMaxX - 1), (minY + height - 1), 0.0D).texture(1, 1).color(topc, topc, topc, 255).next();
-                buffer.vertex((scrollbarPositionMaxX - 1), minY, 0.0D).texture(1, 0).color(topc, topc, topc, 255).next();
-                buffer.vertex(scrollbarPositionMinX, minY, 0.0D).texture(0, 0).color(topc, topc, topc, 255).next();
-                tessellator.draw();
+                buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+                buffer.vertex(scrollbarPositionMinX, (minY + height - 1), 0.0D).uv(0, 1).color(topc, topc, topc, 255).endVertex();
+                buffer.vertex((scrollbarPositionMaxX - 1), (minY + height - 1), 0.0D).uv(1, 1).color(topc, topc, topc, 255).endVertex();
+                buffer.vertex((scrollbarPositionMaxX - 1), minY, 0.0D).uv(1, 0).color(topc, topc, topc, 255).endVertex();
+                buffer.vertex(scrollbarPositionMinX, minY, 0.0D).uv(0, 0).color(topc, topc, topc, 255).endVertex();
+                tessellator.end();
                 RenderSystem.enableTexture();
             }
             RenderSystem.translatef(0, 0, -300f);
@@ -466,11 +466,11 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
                 } else {
                     double double_5 = Math.max(1, this.getMaxScrollPosition());
                     int int_2 = getHeight();
-                    int int_3 = MathHelper.clamp((int) ((float) (int_2 * int_2) / (float) this.getMaxScrollPosition()), 32, int_2 - 8);
+                    int int_3 = Mth.clamp((int) ((float) (int_2 * int_2) / (float) this.getMaxScrollPosition()), 32, int_2 - 8);
                     double double_6 = Math.max(1.0D, double_5 / (double) (int_2 - int_3));
                     this.offset(double_4 * double_6, false);
                 }
-                target = MathHelper.clamp(target, 0, getMaxScrollPosition());
+                target = Mth.clamp(target, 0, getMaxScrollPosition());
                 return true;
             }
             return false;
@@ -534,14 +534,14 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
     }
     
     public static class DefaultSelectionCellCreator<R> extends SelectionCellCreator<R> {
-        protected Function<R, Text> toTextFunction;
+        protected Function<R, Component> toTextFunction;
         
-        public DefaultSelectionCellCreator(Function<R, Text> toTextFunction) {
+        public DefaultSelectionCellCreator(Function<R, Component> toTextFunction) {
             this.toTextFunction = toTextFunction;
         }
         
         public DefaultSelectionCellCreator() {
-            this(r -> new LiteralText(r.toString()));
+            this(r -> new TextComponent(r.toString()));
         }
         
         @Override
@@ -560,7 +560,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
     }
     
-    public static abstract class SelectionCellElement<R> extends AbstractParentElement {
+    public static abstract class SelectionCellElement<R> extends AbstractContainerEventHandler {
         @SuppressWarnings("NotNullFieldNotInitialized") @Deprecated @NotNull private DropdownBoxEntry<R> entry;
         
         @NotNull
@@ -568,12 +568,12 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
             return entry;
         }
         
-        public abstract void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta);
+        public abstract void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta);
         
-        public abstract void dontRender(MatrixStack matrices, float delta);
+        public abstract void dontRender(PoseStack matrices, float delta);
         
         @Nullable
-        public abstract Text getSearchKey();
+        public abstract Component getSearchKey();
         
         @Nullable
         public abstract R getSelection();
@@ -586,15 +586,15 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         protected int width;
         protected int height;
         protected boolean rendering;
-        protected Function<R, Text> toTextFunction;
+        protected Function<R, Component> toTextFunction;
         
-        public DefaultSelectionCellElement(R r, Function<R, Text> toTextFunction) {
+        public DefaultSelectionCellElement(R r, Function<R, Component> toTextFunction) {
             this.r = r;
             this.toTextFunction = toTextFunction;
         }
         
         @Override
-        public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+        public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
             rendering = true;
             this.x = x;
             this.y = y;
@@ -603,17 +603,17 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
             boolean b = mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
             if (b)
                 fill(matrices, x + 1, y + 1, x + width - 1, y + height - 1, -15132391);
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, toTextFunction.apply(r).method_30937(), x + 6, y + 3, b ? 16777215 : 8947848);
+            Minecraft.getInstance().font.drawShadow(matrices, toTextFunction.apply(r).getVisualOrderText(), x + 6, y + 3, b ? 16777215 : 8947848);
         }
         
         @Override
-        public void dontRender(MatrixStack matrices, float delta) {
+        public void dontRender(PoseStack matrices, float delta) {
             rendering = false;
         }
         
         @Nullable
         @Override
-        public Text getSearchKey() {
+        public Component getSearchKey() {
             return toTextFunction.apply(r);
         }
         
@@ -624,7 +624,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
         
         @Override
-        public List<? extends Element> children() {
+        public List<? extends GuiEventListener> children() {
             return Collections.emptyList();
         }
         
@@ -641,7 +641,7 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
     }
     
-    public static abstract class SelectionTopCellElement<R> extends AbstractParentElement {
+    public static abstract class SelectionTopCellElement<R> extends AbstractContainerEventHandler {
         @Deprecated private DropdownBoxEntry<R> entry;
         protected boolean isSelected = false;
         
@@ -649,15 +649,15 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         
         public abstract void setValue(R value);
         
-        public abstract Text getSearchTerm();
+        public abstract Component getSearchTerm();
         
         public boolean isEdited() {
             return getConfigError().isPresent();
         }
         
-        public abstract Optional<Text> getError();
+        public abstract Optional<Component> getError();
         
-        public final Optional<Text> getConfigError() {
+        public final Optional<Component> getConfigError() {
             return entry.getConfigError();
         }
         
@@ -692,24 +692,24 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
             }
         }
         
-        public abstract void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta);
+        public abstract void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta);
     }
     
     public static class DefaultSelectionTopCellElement<R> extends SelectionTopCellElement<R> {
-        protected TextFieldWidget textFieldWidget;
+        protected EditBox textFieldWidget;
         protected Function<String, R> toObjectFunction;
-        protected Function<R, Text> toTextFunction;
+        protected Function<R, Component> toTextFunction;
         protected final R original;
         protected R value;
         
-        public DefaultSelectionTopCellElement(R value, Function<String, R> toObjectFunction, Function<R, Text> toTextFunction) {
+        public DefaultSelectionTopCellElement(R value, Function<String, R> toObjectFunction, Function<R, Component> toTextFunction) {
             this.original = Objects.requireNonNull(value);
             this.value = Objects.requireNonNull(value);
             this.toObjectFunction = Objects.requireNonNull(toObjectFunction);
             this.toTextFunction = Objects.requireNonNull(toTextFunction);
-            textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 0, 0, 148, 18, NarratorManager.EMPTY) {
+            textFieldWidget = new EditBox(Minecraft.getInstance().font, 0, 0, 148, 18, NarratorChatListener.NO_TITLE) {
                 @Override
-                public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+                public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
                     setFocused(isSuggestionMode() && isSelected && DefaultSelectionTopCellElement.this.getParent().getFocused() == DefaultSelectionTopCellElement.this.getParent().selectionElement && DefaultSelectionTopCellElement.this.getParent().selectionElement.getFocused() == DefaultSelectionTopCellElement.this && DefaultSelectionTopCellElement.this.getFocused() == this);
                     super.render(matrices, mouseX, mouseY, delta);
                 }
@@ -728,9 +728,9 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
                     return isSuggestionMode() && super.charTyped(chr, keyCode);
                 }
             };
-            textFieldWidget.setHasBorder(false);
+            textFieldWidget.setBordered(false);
             textFieldWidget.setMaxLength(999999);
-            textFieldWidget.setText(toTextFunction.apply(value).getString());
+            textFieldWidget.setValue(toTextFunction.apply(value).getString());
         }
         
         @Override
@@ -739,12 +739,12 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         }
         
         @Override
-        public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+        public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
             textFieldWidget.x = x + 4;
             textFieldWidget.y = y + 6;
             textFieldWidget.setWidth(width - 8);
             textFieldWidget.setEditable(getParent().isEditable());
-            textFieldWidget.setEditableColor(getPreferredTextColor());
+            textFieldWidget.setTextColor(getPreferredTextColor());
             textFieldWidget.render(matrices, mouseX, mouseY, delta);
         }
         
@@ -752,29 +752,29 @@ public class DropdownBoxEntry<T> extends TooltipListEntry<T> {
         public R getValue() {
             if (hasError())
                 return value;
-            return toObjectFunction.apply(textFieldWidget.getText());
+            return toObjectFunction.apply(textFieldWidget.getValue());
         }
         
         @Override
         public void setValue(R value) {
-            textFieldWidget.setText(toTextFunction.apply(value).getString());
-            textFieldWidget.setCursor(0);
+            textFieldWidget.setValue(toTextFunction.apply(value).getString());
+            textFieldWidget.moveCursorTo(0);
         }
         
         @Override
-        public Text getSearchTerm() {
-            return new LiteralText(textFieldWidget.getText());
+        public Component getSearchTerm() {
+            return new TextComponent(textFieldWidget.getValue());
         }
         
         @Override
-        public Optional<Text> getError() {
-            if (toObjectFunction.apply(textFieldWidget.getText()) != null)
+        public Optional<Component> getError() {
+            if (toObjectFunction.apply(textFieldWidget.getValue()) != null)
                 return Optional.empty();
-            return Optional.of(new LiteralText("Invalid Value!"));
+            return Optional.of(new TextComponent("Invalid Value!"));
         }
         
         @Override
-        public List<? extends Element> children() {
+        public List<? extends GuiEventListener> children() {
             return Collections.singletonList(textFieldWidget);
         }
     }

+ 7 - 7
src/main/java/me/shedaniel/clothconfig2/gui/entries/EnumListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/EnumListEntry.java

@@ -2,8 +2,8 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.Optional;
@@ -14,29 +14,29 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class EnumListEntry<T extends Enum<?>> extends SelectionListEntry<T> {
     
-    public static final Function<Enum, Text> DEFAULT_NAME_PROVIDER = t -> new TranslatableText(t instanceof Translatable ? ((Translatable) t).getKey() : t.toString());
+    public static final Function<Enum, Component> DEFAULT_NAME_PROVIDER = t -> new TranslatableComponent(t instanceof Translatable ? ((Translatable) t).getKey() : t.toString());
     
     @ApiStatus.Internal
     @Deprecated
-    public EnumListEntry(Text fieldName, Class<T> clazz, T value, Text resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer) {
+    public EnumListEntry(Component fieldName, Class<T> clazz, T value, Component resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer) {
         super(fieldName, clazz.getEnumConstants(), value, resetButtonKey, defaultValue, saveConsumer, DEFAULT_NAME_PROVIDER::apply);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public EnumListEntry(Text fieldName, Class<T> clazz, T value, Text resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<Enum, Text> enumNameProvider) {
+    public EnumListEntry(Component fieldName, Class<T> clazz, T value, Component resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<Enum, Component> enumNameProvider) {
         super(fieldName, clazz.getEnumConstants(), value, resetButtonKey, defaultValue, saveConsumer, enumNameProvider::apply, null);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public EnumListEntry(Text fieldName, Class<T> clazz, T value, Text resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<Enum, Text> enumNameProvider, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public EnumListEntry(Component fieldName, Class<T> clazz, T value, Component resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<Enum, Component> enumNameProvider, Supplier<Optional<Component[]>> tooltipSupplier) {
         super(fieldName, clazz.getEnumConstants(), value, resetButtonKey, defaultValue, saveConsumer, enumNameProvider::apply, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public EnumListEntry(Text fieldName, Class<T> clazz, T value, Text resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<Enum, Text> enumNameProvider, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public EnumListEntry(Component fieldName, Class<T> clazz, T value, Component resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<Enum, Component> enumNameProvider, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, clazz.getEnumConstants(), value, resetButtonKey, defaultValue, saveConsumer, enumNameProvider::apply, tooltipSupplier, requiresRestart);
     }
     

+ 19 - 19
src/main/java/me/shedaniel/clothconfig2/gui/entries/FloatListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/FloatListEntry.java

@@ -2,9 +2,9 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.Optional;
@@ -15,7 +15,7 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class FloatListEntry extends TextFieldListEntry<Float> {
     
-    private static Function<String, String> stripCharacters = s -> {
+    private static final Function<String, String> stripCharacters = s -> {
         StringBuilder stringBuilder_1 = new StringBuilder();
         char[] var2 = s.toCharArray();
         int var3 = var2.length;
@@ -27,11 +27,11 @@ public class FloatListEntry extends TextFieldListEntry<Float> {
         return stringBuilder_1.toString();
     };
     private float minimum, maximum;
-    private Consumer<Float> saveConsumer;
+    private final Consumer<Float> saveConsumer;
     
     @ApiStatus.Internal
     @Deprecated
-    public FloatListEntry(Text fieldName, Float value, Text resetButtonKey, Supplier<Float> defaultValue, Consumer<Float> saveConsumer) {
+    public FloatListEntry(Component fieldName, Float value, Component resetButtonKey, Supplier<Float> defaultValue, Consumer<Float> saveConsumer) {
         super(fieldName, value, resetButtonKey, defaultValue);
         this.minimum = -Float.MAX_VALUE;
         this.maximum = Float.MAX_VALUE;
@@ -40,13 +40,13 @@ public class FloatListEntry extends TextFieldListEntry<Float> {
     
     @ApiStatus.Internal
     @Deprecated
-    public FloatListEntry(Text fieldName, Float value, Text resetButtonKey, Supplier<Float> defaultValue, Consumer<Float> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public FloatListEntry(Component fieldName, Float value, Component resetButtonKey, Supplier<Float> defaultValue, Consumer<Float> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, value, resetButtonKey, defaultValue, saveConsumer, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public FloatListEntry(Text fieldName, Float value, Text resetButtonKey, Supplier<Float> defaultValue, Consumer<Float> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public FloatListEntry(Component fieldName, Float value, Component resetButtonKey, Supplier<Float> defaultValue, Consumer<Float> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, value, resetButtonKey, defaultValue, tooltipSupplier, requiresRestart);
         this.minimum = -Float.MAX_VALUE;
         this.maximum = Float.MAX_VALUE;
@@ -59,15 +59,15 @@ public class FloatListEntry extends TextFieldListEntry<Float> {
     }
     
     @Override
-    protected void textFieldPreRender(TextFieldWidget widget) {
+    protected void textFieldPreRender(EditBox widget) {
         try {
-            double i = Float.parseFloat(textFieldWidget.getText());
+            double i = Float.parseFloat(textFieldWidget.getValue());
             if (i < minimum || i > maximum)
-                widget.setEditableColor(16733525);
+                widget.setTextColor(16733525);
             else
-                widget.setEditableColor(14737632);
+                widget.setTextColor(14737632);
         } catch (NumberFormatException ex) {
-            widget.setEditableColor(16733525);
+            widget.setTextColor(16733525);
         }
     }
     
@@ -95,22 +95,22 @@ public class FloatListEntry extends TextFieldListEntry<Float> {
     @Override
     public Float getValue() {
         try {
-            return Float.valueOf(textFieldWidget.getText());
+            return Float.valueOf(textFieldWidget.getValue());
         } catch (Exception e) {
             return 0f;
         }
     }
     
     @Override
-    public Optional<Text> getError() {
+    public Optional<Component> getError() {
         try {
-            float i = Float.parseFloat(textFieldWidget.getText());
+            float i = Float.parseFloat(textFieldWidget.getValue());
             if (i > maximum)
-                return Optional.of(new TranslatableText("text.cloth-config.error.too_large", maximum));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.too_large", maximum));
             else if (i < minimum)
-                return Optional.of(new TranslatableText("text.cloth-config.error.too_small", minimum));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.too_small", minimum));
         } catch (NumberFormatException ex) {
-            return Optional.of(new TranslatableText("text.cloth-config.error.not_valid_number_float"));
+            return Optional.of(new TranslatableComponent("text.cloth-config.error.not_valid_number_float"));
         }
         return super.getError();
     }

+ 11 - 11
src/main/java/me/shedaniel/clothconfig2/gui/entries/FloatListListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/FloatListListEntry.java

@@ -2,8 +2,8 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -20,19 +20,19 @@ public class FloatListListEntry extends AbstractTextFieldListListEntry<Float, Fl
     
     @ApiStatus.Internal
     @Deprecated
-    public FloatListListEntry(Text fieldName, List<Float> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Float>> saveConsumer, Supplier<List<Float>> defaultValue, Text resetButtonKey) {
+    public FloatListListEntry(Component fieldName, List<Float> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Float>> saveConsumer, Supplier<List<Float>> defaultValue, Component resetButtonKey) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public FloatListListEntry(Text fieldName, List<Float> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Float>> saveConsumer, Supplier<List<Float>> defaultValue, Text resetButtonKey, boolean requiresRestart) {
+    public FloatListListEntry(Component fieldName, List<Float> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Float>> saveConsumer, Supplier<List<Float>> defaultValue, Component resetButtonKey, boolean requiresRestart) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, true, true);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public FloatListListEntry(Text fieldName, List<Float> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Float>> saveConsumer, Supplier<List<Float>> defaultValue, Text resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
+    public FloatListListEntry(Component fieldName, List<Float> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Float>> saveConsumer, Supplier<List<Float>> defaultValue, Component resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
         super(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, deleteButtonEnabled, insertInFront, FloatListCell::new);
         this.minimum = Float.NEGATIVE_INFINITY;
         this.maximum = Float.POSITIVE_INFINITY;
@@ -75,22 +75,22 @@ public class FloatListListEntry extends AbstractTextFieldListListEntry<Float, Fl
         
         public Float getValue() {
             try {
-                return Float.valueOf(widget.getText());
+                return Float.valueOf(widget.getValue());
             } catch (NumberFormatException e) {
                 return 0f;
             }
         }
         
         @Override
-        public Optional<Text> getError() {
+        public Optional<Component> getError() {
             try {
-                float i = Float.parseFloat(widget.getText());
+                float i = Float.parseFloat(widget.getValue());
                 if (i > listListEntry.maximum)
-                    return Optional.of(new TranslatableText("text.cloth-config.error.too_large", listListEntry.maximum));
+                    return Optional.of(new TranslatableComponent("text.cloth-config.error.too_large", listListEntry.maximum));
                 else if (i < listListEntry.minimum)
-                    return Optional.of(new TranslatableText("text.cloth-config.error.too_small", listListEntry.minimum));
+                    return Optional.of(new TranslatableComponent("text.cloth-config.error.too_small", listListEntry.minimum));
             } catch (NumberFormatException ex) {
-                return Optional.of(new TranslatableText("text.cloth-config.error.not_valid_number_float"));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.not_valid_number_float"));
             }
             return Optional.empty();
         }

+ 19 - 19
src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerListEntry.java

@@ -2,9 +2,9 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.Optional;
@@ -15,7 +15,7 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class IntegerListEntry extends TextFieldListEntry<Integer> {
     
-    private static Function<String, String> stripCharacters = s -> {
+    private static final Function<String, String> stripCharacters = s -> {
         StringBuilder builder = new StringBuilder();
         char[] var2 = s.toCharArray();
         int var3 = var2.length;
@@ -27,11 +27,11 @@ public class IntegerListEntry extends TextFieldListEntry<Integer> {
         return builder.toString();
     };
     private int minimum, maximum;
-    private Consumer<Integer> saveConsumer;
+    private final Consumer<Integer> saveConsumer;
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerListEntry(Text fieldName, Integer value, Text resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer) {
+    public IntegerListEntry(Component fieldName, Integer value, Component resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer) {
         super(fieldName, value, resetButtonKey, defaultValue);
         this.minimum = -Integer.MAX_VALUE;
         this.maximum = Integer.MAX_VALUE;
@@ -40,13 +40,13 @@ public class IntegerListEntry extends TextFieldListEntry<Integer> {
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerListEntry(Text fieldName, Integer value, Text resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public IntegerListEntry(Component fieldName, Integer value, Component resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, value, resetButtonKey, defaultValue, saveConsumer, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerListEntry(Text fieldName, Integer value, Text resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public IntegerListEntry(Component fieldName, Integer value, Component resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, value, resetButtonKey, defaultValue, tooltipSupplier, requiresRestart);
         this.minimum = -Integer.MAX_VALUE;
         this.maximum = Integer.MAX_VALUE;
@@ -59,15 +59,15 @@ public class IntegerListEntry extends TextFieldListEntry<Integer> {
     }
     
     @Override
-    protected void textFieldPreRender(TextFieldWidget widget) {
+    protected void textFieldPreRender(EditBox widget) {
         try {
-            double i = Integer.parseInt(textFieldWidget.getText());
+            double i = Integer.parseInt(textFieldWidget.getValue());
             if (i < minimum || i > maximum)
-                widget.setEditableColor(16733525);
+                widget.setTextColor(16733525);
             else
-                widget.setEditableColor(14737632);
+                widget.setTextColor(14737632);
         } catch (NumberFormatException ex) {
-            widget.setEditableColor(16733525);
+            widget.setTextColor(16733525);
         }
     }
     
@@ -95,22 +95,22 @@ public class IntegerListEntry extends TextFieldListEntry<Integer> {
     @Override
     public Integer getValue() {
         try {
-            return Integer.valueOf(textFieldWidget.getText());
+            return Integer.valueOf(textFieldWidget.getValue());
         } catch (Exception e) {
             return 0;
         }
     }
     
     @Override
-    public Optional<Text> getError() {
+    public Optional<Component> getError() {
         try {
-            int i = Integer.parseInt(textFieldWidget.getText());
+            int i = Integer.parseInt(textFieldWidget.getValue());
             if (i > maximum)
-                return Optional.of(new TranslatableText("text.cloth-config.error.too_large", maximum));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.too_large", maximum));
             else if (i < minimum)
-                return Optional.of(new TranslatableText("text.cloth-config.error.too_small", minimum));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.too_small", minimum));
         } catch (NumberFormatException ex) {
-            return Optional.of(new TranslatableText("text.cloth-config.error.not_valid_number_int"));
+            return Optional.of(new TranslatableComponent("text.cloth-config.error.not_valid_number_int"));
         }
         return super.getError();
     }

+ 11 - 11
src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerListListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerListListEntry.java

@@ -2,8 +2,8 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -20,19 +20,19 @@ public class IntegerListListEntry extends AbstractTextFieldListListEntry<Integer
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerListListEntry(Text fieldName, List<Integer> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Integer>> saveConsumer, Supplier<List<Integer>> defaultValue, Text resetButtonKey) {
+    public IntegerListListEntry(Component fieldName, List<Integer> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Integer>> saveConsumer, Supplier<List<Integer>> defaultValue, Component resetButtonKey) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerListListEntry(Text fieldName, List<Integer> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Integer>> saveConsumer, Supplier<List<Integer>> defaultValue, Text resetButtonKey, boolean requiresRestart) {
+    public IntegerListListEntry(Component fieldName, List<Integer> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Integer>> saveConsumer, Supplier<List<Integer>> defaultValue, Component resetButtonKey, boolean requiresRestart) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, true, true);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerListListEntry(Text fieldName, List<Integer> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Integer>> saveConsumer, Supplier<List<Integer>> defaultValue, Text resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
+    public IntegerListListEntry(Component fieldName, List<Integer> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Integer>> saveConsumer, Supplier<List<Integer>> defaultValue, Component resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
         super(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, deleteButtonEnabled, insertInFront, IntegerListCell::new);
         this.minimum = Integer.MIN_VALUE;
         this.maximum = Integer.MAX_VALUE;
@@ -75,22 +75,22 @@ public class IntegerListListEntry extends AbstractTextFieldListListEntry<Integer
         
         public Integer getValue() {
             try {
-                return Integer.valueOf(widget.getText());
+                return Integer.valueOf(widget.getValue());
             } catch (NumberFormatException e) {
                 return 0;
             }
         }
         
         @Override
-        public Optional<Text> getError() {
+        public Optional<Component> getError() {
             try {
-                int i = Integer.parseInt(widget.getText());
+                int i = Integer.parseInt(widget.getValue());
                 if (i > listListEntry.maximum)
-                    return Optional.of(new TranslatableText("text.cloth-config.error.too_large", listListEntry.maximum));
+                    return Optional.of(new TranslatableComponent("text.cloth-config.error.too_large", listListEntry.maximum));
                 else if (i < listListEntry.minimum)
-                    return Optional.of(new TranslatableText("text.cloth-config.error.too_small", listListEntry.minimum));
+                    return Optional.of(new TranslatableComponent("text.cloth-config.error.too_small", listListEntry.minimum));
             } catch (NumberFormatException ex) {
-                return Optional.of(new TranslatableText("text.cloth-config.error.not_valid_number_int"));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.not_valid_number_int"));
             }
             return Optional.empty();
         }

+ 31 - 31
src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerSliderEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerSliderEntry.java

@@ -1,18 +1,18 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Window;
+import com.mojang.blaze3d.vertex.PoseStack;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.gui.widget.SliderWidget;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.Window;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.Text;
-import net.minecraft.util.math.MathHelper;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.AbstractSliderButton;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.util.Mth;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.List;
@@ -26,30 +26,30 @@ import java.util.function.Supplier;
 public class IntegerSliderEntry extends TooltipListEntry<Integer> {
     
     protected Slider sliderWidget;
-    protected ButtonWidget resetButton;
+    protected Button resetButton;
     protected AtomicInteger value;
     protected final long orginial;
     private int minimum, maximum;
-    private Consumer<Integer> saveConsumer;
-    private Supplier<Integer> defaultValue;
-    private Function<Integer, Text> textGetter = integer -> new LiteralText(String.format("Value: %d", integer));
-    private List<Element> widgets;
+    private final Consumer<Integer> saveConsumer;
+    private final Supplier<Integer> defaultValue;
+    private Function<Integer, Component> textGetter = integer -> new TextComponent(String.format("Value: %d", integer));
+    private final List<GuiEventListener> widgets;
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerSliderEntry(Text fieldName, int minimum, int maximum, int value, Text resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer) {
+    public IntegerSliderEntry(Component fieldName, int minimum, int maximum, int value, Component resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer) {
         this(fieldName, minimum, maximum, value, resetButtonKey, defaultValue, saveConsumer, null);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerSliderEntry(Text fieldName, int minimum, int maximum, int value, Text resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public IntegerSliderEntry(Component fieldName, int minimum, int maximum, int value, Component resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, minimum, maximum, value, resetButtonKey, defaultValue, saveConsumer, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public IntegerSliderEntry(Text fieldName, int minimum, int maximum, int value, Text resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public IntegerSliderEntry(Component fieldName, int minimum, int maximum, int value, Component resetButtonKey, Supplier<Integer> defaultValue, Consumer<Integer> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, requiresRestart);
         this.orginial = value;
         this.defaultValue = defaultValue;
@@ -58,7 +58,7 @@ public class IntegerSliderEntry extends TooltipListEntry<Integer> {
         this.maximum = maximum;
         this.minimum = minimum;
         this.sliderWidget = new Slider(0, 0, 152, 20, ((double) this.value.get() - minimum) / Math.abs(maximum - minimum));
-        this.resetButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
+        this.resetButton = new Button(0, 0, Minecraft.getInstance().font.width(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
             setValue(defaultValue.get());
         });
         this.sliderWidget.setMessage(textGetter.apply(IntegerSliderEntry.this.value.get()));
@@ -71,11 +71,11 @@ public class IntegerSliderEntry extends TooltipListEntry<Integer> {
             saveConsumer.accept(getValue());
     }
     
-    public Function<Integer, Text> getTextGetter() {
+    public Function<Integer, Component> getTextGetter() {
         return textGetter;
     }
     
-    public IntegerSliderEntry setTextGetter(Function<Integer, Text> textGetter) {
+    public IntegerSliderEntry setTextGetter(Function<Integer, Component> textGetter) {
         this.textGetter = textGetter;
         this.sliderWidget.setMessage(textGetter.apply(IntegerSliderEntry.this.value.get()));
         return this;
@@ -88,7 +88,7 @@ public class IntegerSliderEntry extends TooltipListEntry<Integer> {
     
     @Deprecated
     public void setValue(int value) {
-        sliderWidget.setValue((MathHelper.clamp(value, minimum, maximum) - minimum) / (double) Math.abs(maximum - minimum));
+        sliderWidget.setValue((Mth.clamp(value, minimum, maximum) - minimum) / (double) Math.abs(maximum - minimum));
         this.value.set(Math.min(Math.max(value, minimum), maximum));
         sliderWidget.updateMessage();
     }
@@ -104,7 +104,7 @@ public class IntegerSliderEntry extends TooltipListEntry<Integer> {
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return widgets;
     }
     
@@ -119,20 +119,20 @@ public class IntegerSliderEntry extends TooltipListEntry<Integer> {
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        Window window = MinecraftClient.getInstance().getWindow();
+        Window window = Minecraft.getInstance().getWindow();
         this.resetButton.active = isEditable() && getDefaultValue().isPresent() && defaultValue.get() != value.get();
         this.resetButton.y = y;
         this.sliderWidget.active = isEditable();
         this.sliderWidget.y = y;
-        Text displayedFieldName = getDisplayedFieldName();
-        if (MinecraftClient.getInstance().textRenderer.isRightToLeft()) {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), window.getScaledWidth() - x - MinecraftClient.getInstance().textRenderer.getWidth(displayedFieldName), y + 6, getPreferredTextColor());
+        Component displayedFieldName = getDisplayedFieldName();
+        if (Minecraft.getInstance().font.isBidirectional()) {
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), window.getGuiScaledWidth() - x - Minecraft.getInstance().font.width(displayedFieldName), y + 6, getPreferredTextColor());
             this.resetButton.x = x;
             this.sliderWidget.x = x + resetButton.getWidth() + 1;
         } else {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), x, y + 6, getPreferredTextColor());
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), x, y + 6, getPreferredTextColor());
             this.resetButton.x = x + entryWidth - resetButton.getWidth();
             this.sliderWidget.x = x + entryWidth - 150;
         }
@@ -141,9 +141,9 @@ public class IntegerSliderEntry extends TooltipListEntry<Integer> {
         sliderWidget.render(matrices, mouseX, mouseY, delta);
     }
     
-    private class Slider extends SliderWidget {
+    private class Slider extends AbstractSliderButton {
         protected Slider(int int_1, int int_2, int int_3, int int_4, double double_1) {
-            super(int_1, int_2, int_3, int_4, NarratorManager.EMPTY, double_1);
+            super(int_1, int_2, int_3, int_4, NarratorChatListener.NO_TITLE, double_1);
         }
         
         @Override

+ 27 - 26
src/main/java/me/shedaniel/clothconfig2/gui/entries/KeyCodeEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/KeyCodeEntry.java

@@ -1,18 +1,18 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Window;
+import com.mojang.blaze3d.vertex.PoseStack;
 import me.shedaniel.clothconfig2.api.ModifierKeyCode;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.Window;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
+import net.minecraft.ChatFormatting;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextComponent;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.List;
@@ -25,24 +25,25 @@ import java.util.function.Supplier;
 public class KeyCodeEntry extends TooltipListEntry<ModifierKeyCode> {
     
     private ModifierKeyCode value;
-    private ModifierKeyCode original;
-    private ButtonWidget buttonWidget, resetButton;
-    private Consumer<ModifierKeyCode> saveConsumer;
-    private Supplier<ModifierKeyCode> defaultValue;
-    private List<Element> widgets;
+    private final ModifierKeyCode original;
+    private final Button buttonWidget;
+    private final Button resetButton;
+    private final Consumer<ModifierKeyCode> saveConsumer;
+    private final Supplier<ModifierKeyCode> defaultValue;
+    private final List<GuiEventListener> widgets;
     private boolean allowMouse = true, allowKey = true, allowModifiers = true;
     
     @ApiStatus.Internal
     @Deprecated
-    public KeyCodeEntry(Text fieldName, ModifierKeyCode value, Text resetButtonKey, Supplier<ModifierKeyCode> defaultValue, Consumer<ModifierKeyCode> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public KeyCodeEntry(Component fieldName, ModifierKeyCode value, Component resetButtonKey, Supplier<ModifierKeyCode> defaultValue, Consumer<ModifierKeyCode> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, requiresRestart);
         this.defaultValue = defaultValue;
         this.value = value.copy();
         this.original = value.copy();
-        this.buttonWidget = new ButtonWidget(0, 0, 150, 20, NarratorManager.EMPTY, widget -> {
+        this.buttonWidget = new Button(0, 0, 150, 20, NarratorChatListener.NO_TITLE, widget -> {
             getConfigScreen().setFocusedBinding(this);
         });
-        this.resetButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
+        this.resetButton = new Button(0, 0, Minecraft.getInstance().font.width(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
             KeyCodeEntry.this.value = getDefaultValue().orElse(null).copy();
             getConfigScreen().setFocusedBinding(null);
         });
@@ -99,28 +100,28 @@ public class KeyCodeEntry extends TooltipListEntry<ModifierKeyCode> {
         return Optional.ofNullable(defaultValue).map(Supplier::get).map(ModifierKeyCode::copy);
     }
     
-    private Text getLocalizedName() {
+    private Component getLocalizedName() {
         return this.value.getLocalizedName();
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        Window window = MinecraftClient.getInstance().getWindow();
+        Window window = Minecraft.getInstance().getWindow();
         this.resetButton.active = isEditable() && getDefaultValue().isPresent() && !getDefaultValue().get().equals(getValue());
         this.resetButton.y = y;
         this.buttonWidget.active = isEditable();
         this.buttonWidget.y = y;
         this.buttonWidget.setMessage(getLocalizedName());
         if (getConfigScreen().getFocusedBinding() == this)
-            this.buttonWidget.setMessage(new LiteralText("> ").formatted(Formatting.WHITE).append(this.buttonWidget.getMessage().copy().formatted(Formatting.YELLOW)).append(new LiteralText(" <").formatted(Formatting.WHITE)));
-        Text displayedFieldName = getDisplayedFieldName();
-        if (MinecraftClient.getInstance().textRenderer.isRightToLeft()) {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), window.getScaledWidth() - x - MinecraftClient.getInstance().textRenderer.getWidth(displayedFieldName), y + 6, 16777215);
+            this.buttonWidget.setMessage(new TextComponent("> ").withStyle(ChatFormatting.WHITE).append(this.buttonWidget.getMessage().plainCopy().withStyle(ChatFormatting.YELLOW)).append(new TextComponent(" <").withStyle(ChatFormatting.WHITE)));
+        Component displayedFieldName = getDisplayedFieldName();
+        if (Minecraft.getInstance().font.isBidirectional()) {
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), window.getGuiScaledWidth() - x - Minecraft.getInstance().font.width(displayedFieldName), y + 6, 16777215);
             this.resetButton.x = x;
             this.buttonWidget.x = x + resetButton.getWidth() + 2;
         } else {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), x, y + 6, getPreferredTextColor());
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), x, y + 6, getPreferredTextColor());
             this.resetButton.x = x + entryWidth - resetButton.getWidth();
             this.buttonWidget.x = x + entryWidth - 150;
         }
@@ -130,7 +131,7 @@ public class KeyCodeEntry extends TooltipListEntry<ModifierKeyCode> {
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return widgets;
     }
     

+ 19 - 19
src/main/java/me/shedaniel/clothconfig2/gui/entries/LongListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/LongListEntry.java

@@ -2,9 +2,9 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.Optional;
@@ -15,7 +15,7 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class LongListEntry extends TextFieldListEntry<Long> {
     
-    private static Function<String, String> stripCharacters = s -> {
+    private static final Function<String, String> stripCharacters = s -> {
         StringBuilder stringBuilder_1 = new StringBuilder();
         char[] var2 = s.toCharArray();
         int var3 = var2.length;
@@ -27,11 +27,11 @@ public class LongListEntry extends TextFieldListEntry<Long> {
         return stringBuilder_1.toString();
     };
     private long minimum, maximum;
-    private Consumer<Long> saveConsumer;
+    private final Consumer<Long> saveConsumer;
     
     @ApiStatus.Internal
     @Deprecated
-    public LongListEntry(Text fieldName, Long value, Text resetButtonKey, Supplier<Long> defaultValue, Consumer<Long> saveConsumer) {
+    public LongListEntry(Component fieldName, Long value, Component resetButtonKey, Supplier<Long> defaultValue, Consumer<Long> saveConsumer) {
         super(fieldName, value, resetButtonKey, defaultValue);
         this.minimum = -Long.MAX_VALUE;
         this.maximum = Long.MAX_VALUE;
@@ -40,13 +40,13 @@ public class LongListEntry extends TextFieldListEntry<Long> {
     
     @ApiStatus.Internal
     @Deprecated
-    public LongListEntry(Text fieldName, Long value, Text resetButtonKey, Supplier<Long> defaultValue, Consumer<Long> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public LongListEntry(Component fieldName, Long value, Component resetButtonKey, Supplier<Long> defaultValue, Consumer<Long> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, value, resetButtonKey, defaultValue, saveConsumer, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public LongListEntry(Text fieldName, Long value, Text resetButtonKey, Supplier<Long> defaultValue, Consumer<Long> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public LongListEntry(Component fieldName, Long value, Component resetButtonKey, Supplier<Long> defaultValue, Consumer<Long> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, value, resetButtonKey, defaultValue, tooltipSupplier, requiresRestart);
         this.minimum = -Long.MAX_VALUE;
         this.maximum = Long.MAX_VALUE;
@@ -59,15 +59,15 @@ public class LongListEntry extends TextFieldListEntry<Long> {
     }
     
     @Override
-    protected void textFieldPreRender(TextFieldWidget widget) {
+    protected void textFieldPreRender(EditBox widget) {
         try {
-            double i = Long.parseLong(textFieldWidget.getText());
+            double i = Long.parseLong(textFieldWidget.getValue());
             if (i < minimum || i > maximum)
-                widget.setEditableColor(16733525);
+                widget.setTextColor(16733525);
             else
-                widget.setEditableColor(14737632);
+                widget.setTextColor(14737632);
         } catch (NumberFormatException ex) {
-            widget.setEditableColor(16733525);
+            widget.setTextColor(16733525);
         }
     }
     
@@ -95,22 +95,22 @@ public class LongListEntry extends TextFieldListEntry<Long> {
     @Override
     public Long getValue() {
         try {
-            return Long.valueOf(textFieldWidget.getText());
+            return Long.valueOf(textFieldWidget.getValue());
         } catch (Exception e) {
             return 0L;
         }
     }
     
     @Override
-    public Optional<Text> getError() {
+    public Optional<Component> getError() {
         try {
-            long i = Long.parseLong(textFieldWidget.getText());
+            long i = Long.parseLong(textFieldWidget.getValue());
             if (i > maximum)
-                return Optional.of(new TranslatableText("text.cloth-config.error.too_large", maximum));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.too_large", maximum));
             else if (i < minimum)
-                return Optional.of(new TranslatableText("text.cloth-config.error.too_small", minimum));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.too_small", minimum));
         } catch (NumberFormatException ex) {
-            return Optional.of(new TranslatableText("text.cloth-config.error.not_valid_number_long"));
+            return Optional.of(new TranslatableComponent("text.cloth-config.error.not_valid_number_long"));
         }
         return super.getError();
     }

+ 11 - 11
src/main/java/me/shedaniel/clothconfig2/gui/entries/LongListListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/LongListListEntry.java

@@ -2,8 +2,8 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -20,19 +20,19 @@ public class LongListListEntry extends AbstractTextFieldListListEntry<Long, Long
     
     @ApiStatus.Internal
     @Deprecated
-    public LongListListEntry(Text fieldName, List<Long> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Long>> saveConsumer, Supplier<List<Long>> defaultValue, Text resetButtonKey) {
+    public LongListListEntry(Component fieldName, List<Long> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Long>> saveConsumer, Supplier<List<Long>> defaultValue, Component resetButtonKey) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public LongListListEntry(Text fieldName, List<Long> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Long>> saveConsumer, Supplier<List<Long>> defaultValue, Text resetButtonKey, boolean requiresRestart) {
+    public LongListListEntry(Component fieldName, List<Long> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Long>> saveConsumer, Supplier<List<Long>> defaultValue, Component resetButtonKey, boolean requiresRestart) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, true, true);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public LongListListEntry(Text fieldName, List<Long> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<Long>> saveConsumer, Supplier<List<Long>> defaultValue, Text resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
+    public LongListListEntry(Component fieldName, List<Long> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<Long>> saveConsumer, Supplier<List<Long>> defaultValue, Component resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
         super(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, deleteButtonEnabled, insertInFront, LongListCell::new);
         this.minimum = Long.MIN_VALUE;
         this.maximum = Long.MAX_VALUE;
@@ -75,22 +75,22 @@ public class LongListListEntry extends AbstractTextFieldListListEntry<Long, Long
         
         public Long getValue() {
             try {
-                return Long.valueOf(widget.getText());
+                return Long.valueOf(widget.getValue());
             } catch (NumberFormatException e) {
                 return 0L;
             }
         }
         
         @Override
-        public Optional<Text> getError() {
+        public Optional<Component> getError() {
             try {
-                long l = Long.parseLong(widget.getText());
+                long l = Long.parseLong(widget.getValue());
                 if (l > listListEntry.maximum)
-                    return Optional.of(new TranslatableText("text.cloth-config.error.too_large", listListEntry.maximum));
+                    return Optional.of(new TranslatableComponent("text.cloth-config.error.too_large", listListEntry.maximum));
                 else if (l < listListEntry.minimum)
-                    return Optional.of(new TranslatableText("text.cloth-config.error.too_small", listListEntry.minimum));
+                    return Optional.of(new TranslatableComponent("text.cloth-config.error.too_small", listListEntry.minimum));
             } catch (NumberFormatException ex) {
-                return Optional.of(new TranslatableText("text.cloth-config.error.not_valid_number_long"));
+                return Optional.of(new TranslatableComponent("text.cloth-config.error.not_valid_number_long"));
             }
             return Optional.empty();
         }

+ 31 - 31
src/main/java/me/shedaniel/clothconfig2/gui/entries/LongSliderEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/LongSliderEntry.java

@@ -1,18 +1,18 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Window;
+import com.mojang.blaze3d.vertex.PoseStack;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.gui.widget.SliderWidget;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.Window;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.Text;
-import net.minecraft.util.math.MathHelper;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.AbstractSliderButton;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.util.Mth;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.List;
@@ -26,30 +26,30 @@ import java.util.function.Supplier;
 public class LongSliderEntry extends TooltipListEntry<Long> {
     
     protected Slider sliderWidget;
-    protected ButtonWidget resetButton;
+    protected Button resetButton;
     protected AtomicLong value;
     protected final long orginial;
     private long minimum, maximum;
-    private Consumer<Long> saveConsumer;
-    private Supplier<Long> defaultValue;
-    private Function<Long, Text> textGetter = value -> new LiteralText(String.format("Value: %d", value));
-    private List<Element> widgets;
+    private final Consumer<Long> saveConsumer;
+    private final Supplier<Long> defaultValue;
+    private Function<Long, Component> textGetter = value -> new TextComponent(String.format("Value: %d", value));
+    private final List<GuiEventListener> widgets;
     
     @ApiStatus.Internal
     @Deprecated
-    public LongSliderEntry(Text fieldName, long minimum, long maximum, long value, Consumer<Long> saveConsumer, Text resetButtonKey, Supplier<Long> defaultValue) {
+    public LongSliderEntry(Component fieldName, long minimum, long maximum, long value, Consumer<Long> saveConsumer, Component resetButtonKey, Supplier<Long> defaultValue) {
         this(fieldName, minimum, maximum, value, saveConsumer, resetButtonKey, defaultValue, null);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public LongSliderEntry(Text fieldName, long minimum, long maximum, long value, Consumer<Long> saveConsumer, Text resetButtonKey, Supplier<Long> defaultValue, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public LongSliderEntry(Component fieldName, long minimum, long maximum, long value, Consumer<Long> saveConsumer, Component resetButtonKey, Supplier<Long> defaultValue, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, minimum, maximum, value, saveConsumer, resetButtonKey, defaultValue, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public LongSliderEntry(Text fieldName, long minimum, long maximum, long value, Consumer<Long> saveConsumer, Text resetButtonKey, Supplier<Long> defaultValue, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public LongSliderEntry(Component fieldName, long minimum, long maximum, long value, Consumer<Long> saveConsumer, Component resetButtonKey, Supplier<Long> defaultValue, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, requiresRestart);
         this.orginial = value;
         this.defaultValue = defaultValue;
@@ -58,7 +58,7 @@ public class LongSliderEntry extends TooltipListEntry<Long> {
         this.maximum = maximum;
         this.minimum = minimum;
         this.sliderWidget = new Slider(0, 0, 152, 20, ((double) LongSliderEntry.this.value.get() - minimum) / Math.abs(maximum - minimum));
-        this.resetButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
+        this.resetButton = new Button(0, 0, Minecraft.getInstance().font.width(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
             setValue(defaultValue.get());
         });
         this.sliderWidget.setMessage(textGetter.apply(LongSliderEntry.this.value.get()));
@@ -71,11 +71,11 @@ public class LongSliderEntry extends TooltipListEntry<Long> {
             saveConsumer.accept(getValue());
     }
     
-    public Function<Long, Text> getTextGetter() {
+    public Function<Long, Component> getTextGetter() {
         return textGetter;
     }
     
-    public LongSliderEntry setTextGetter(Function<Long, Text> textGetter) {
+    public LongSliderEntry setTextGetter(Function<Long, Component> textGetter) {
         this.textGetter = textGetter;
         this.sliderWidget.setMessage(textGetter.apply(LongSliderEntry.this.value.get()));
         return this;
@@ -88,7 +88,7 @@ public class LongSliderEntry extends TooltipListEntry<Long> {
     
     @Deprecated
     public void setValue(long value) {
-        sliderWidget.setValue((MathHelper.clamp(value, minimum, maximum) - minimum) / (double) Math.abs(maximum - minimum));
+        sliderWidget.setValue((Mth.clamp(value, minimum, maximum) - minimum) / (double) Math.abs(maximum - minimum));
         this.value.set(Math.min(Math.max(value, minimum), maximum));
         sliderWidget.updateMessage();
     }
@@ -99,7 +99,7 @@ public class LongSliderEntry extends TooltipListEntry<Long> {
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return widgets;
     }
     
@@ -119,20 +119,20 @@ public class LongSliderEntry extends TooltipListEntry<Long> {
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        Window window = MinecraftClient.getInstance().getWindow();
+        Window window = Minecraft.getInstance().getWindow();
         this.resetButton.active = isEditable() && getDefaultValue().isPresent() && defaultValue.get() != value.get();
         this.resetButton.y = y;
         this.sliderWidget.active = isEditable();
         this.sliderWidget.y = y;
-        Text displayedFieldName = getDisplayedFieldName();
-        if (MinecraftClient.getInstance().textRenderer.isRightToLeft()) {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), window.getScaledWidth() - x - MinecraftClient.getInstance().textRenderer.getWidth(displayedFieldName), y + 6, getPreferredTextColor());
+        Component displayedFieldName = getDisplayedFieldName();
+        if (Minecraft.getInstance().font.isBidirectional()) {
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), window.getGuiScaledWidth() - x - Minecraft.getInstance().font.width(displayedFieldName), y + 6, getPreferredTextColor());
             this.resetButton.x = x;
             this.sliderWidget.x = x + resetButton.getWidth() + 1;
         } else {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), x, y + 6, getPreferredTextColor());
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), x, y + 6, getPreferredTextColor());
             this.resetButton.x = x + entryWidth - resetButton.getWidth();
             this.sliderWidget.x = x + entryWidth - 150;
         }
@@ -141,9 +141,9 @@ public class LongSliderEntry extends TooltipListEntry<Long> {
         sliderWidget.render(matrices, mouseX, mouseY, delta);
     }
     
-    private class Slider extends SliderWidget {
+    private class Slider extends AbstractSliderButton {
         protected Slider(int int_1, int int_2, int int_3, int int_4, double double_1) {
-            super(int_1, int_2, int_3, int_4, NarratorManager.EMPTY, double_1);
+            super(int_1, int_2, int_3, int_4, NarratorChatListener.NO_TITLE, double_1);
         }
         
         @Override

+ 28 - 28
src/main/java/me/shedaniel/clothconfig2/gui/entries/MultiElementListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/MultiElementListEntry.java

@@ -1,21 +1,21 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Lighting;
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.PoseStack;
 import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
 import me.shedaniel.clothconfig2.api.Expandable;
 import me.shedaniel.math.Rectangle;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.render.DiffuseLighting;
-import net.minecraft.client.sound.PositionedSoundInstance;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.sound.SoundEvents;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.resources.sounds.SimpleSoundInstance;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.sounds.SoundEvents;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.ArrayList;
@@ -27,15 +27,15 @@ import java.util.stream.Collectors;
 @Environment(EnvType.CLIENT)
 public class MultiElementListEntry<T> extends TooltipListEntry<T> implements Expandable {
     
-    private static final Identifier CONFIG_TEX = new Identifier("cloth-config2", "textures/gui/cloth_config.png");
+    private static final ResourceLocation CONFIG_TEX = new ResourceLocation("cloth-config2", "textures/gui/cloth_config.png");
     private final T object;
-    private List<AbstractConfigListEntry<?>> entries;
-    private MultiElementListEntry<T>.CategoryLabelWidget widget;
-    private List<Element> children;
+    private final List<AbstractConfigListEntry<?>> entries;
+    private final MultiElementListEntry<T>.CategoryLabelWidget widget;
+    private final List<GuiEventListener> children;
     private boolean expanded;
     
     @ApiStatus.Internal
-    public MultiElementListEntry(Text categoryName, T object, List<AbstractConfigListEntry<?>> entries, boolean defaultExpanded) {
+    public MultiElementListEntry(Component categoryName, T object, List<AbstractConfigListEntry<?>> entries, boolean defaultExpanded) {
         super(categoryName, null);
         this.object = object;
         this.entries = entries;
@@ -74,7 +74,7 @@ public class MultiElementListEntry<T> extends TooltipListEntry<T> implements Exp
         return super.mouseClicked(mouseX, mouseY, button);
     }
     
-    public Text getCategoryName() {
+    public Component getCategoryName() {
         return getFieldName();
     }
     
@@ -89,13 +89,13 @@ public class MultiElementListEntry<T> extends TooltipListEntry<T> implements Exp
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        MinecraftClient.getInstance().getTextureManager().bindTexture(CONFIG_TEX);
-        DiffuseLighting.disable();
+        Minecraft.getInstance().getTextureManager().bind(CONFIG_TEX);
+        Lighting.turnOff();
         RenderSystem.color4f(1, 1, 1, 1);
-        drawTexture(matrices, x - 15, y + 5, 24, (widget.rectangle.contains(mouseX, mouseY) ? 18 : 0) + (expanded ? 9 : 0), 9, 9);
-        MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, getDisplayedFieldName().method_30937(), x, y + 6, widget.rectangle.contains(mouseX, mouseY) ? 0xffe6fe16 : -1);
+        blit(matrices, x - 15, y + 5, 24, (widget.rectangle.contains(mouseX, mouseY) ? 18 : 0) + (expanded ? 9 : 0), 9, 9);
+        Minecraft.getInstance().font.drawShadow(matrices, getDisplayedFieldName().getVisualOrderText(), x, y + 6, widget.rectangle.contains(mouseX, mouseY) ? 0xffe6fe16 : -1);
         for (AbstractConfigListEntry entry : entries) {
             entry.setParent(getParent());
             entry.setScreen(getConfigScreen());
@@ -143,7 +143,7 @@ public class MultiElementListEntry<T> extends TooltipListEntry<T> implements Exp
     }
     
     @Override
-    public void lateRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
         if (expanded) {
             for (AbstractConfigListEntry<?> entry : entries) {
                 entry.lateRender(matrices, mouseX, mouseY, delta);
@@ -168,7 +168,7 @@ public class MultiElementListEntry<T> extends TooltipListEntry<T> implements Exp
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return expanded ? children : Collections.singletonList(widget);
     }
     
@@ -178,11 +178,11 @@ public class MultiElementListEntry<T> extends TooltipListEntry<T> implements Exp
     }
     
     @Override
-    public Optional<Text> getError() {
-        List<Text> errors = entries.stream().map(AbstractConfigListEntry::getConfigError).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
+    public Optional<Component> getError() {
+        List<Component> errors = entries.stream().map(AbstractConfigListEntry::getConfigError).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
         
         if (errors.size() > 1)
-            return Optional.of(new TranslatableText("text.cloth-config.multi_error"));
+            return Optional.of(new TranslatableComponent("text.cloth-config.multi_error"));
         else
             return errors.stream().findFirst();
     }
@@ -197,14 +197,14 @@ public class MultiElementListEntry<T> extends TooltipListEntry<T> implements Exp
         this.expanded = expanded;
     }
     
-    public class CategoryLabelWidget implements Element {
-        private Rectangle rectangle = new Rectangle();
+    public class CategoryLabelWidget implements GuiEventListener {
+        private final Rectangle rectangle = new Rectangle();
         
         @Override
         public boolean mouseClicked(double double_1, double double_2, int int_1) {
             if (rectangle.contains(double_1, double_2)) {
                 expanded = !expanded;
-                MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+                Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
                 return true;
             }
             return false;

+ 7 - 7
src/main/java/me/shedaniel/clothconfig2/gui/entries/NestedListListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/NestedListListEntry.java

@@ -1,6 +1,7 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.vertex.PoseStack;
 import me.shedaniel.clothconfig2.api.AbstractConfigEntry;
 import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
 import me.shedaniel.clothconfig2.api.ReferenceProvider;
@@ -8,9 +9,8 @@ import me.shedaniel.clothconfig2.gui.entries.NestedListListEntry.NestedListCell;
 import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -31,7 +31,7 @@ public final class NestedListListEntry<T, INNER extends AbstractConfigListEntry<
     private final List<ReferenceProvider<?>> referencableEntries = Lists.newArrayList();
     
     @ApiStatus.Internal
-    public NestedListListEntry(Text fieldName, List<T> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<T>> saveConsumer, Supplier<List<T>> defaultValue, Text resetButtonKey, boolean deleteButtonEnabled, boolean insertInFront, BiFunction<T, NestedListListEntry<T, INNER>, INNER> createNewCell) {
+    public NestedListListEntry(Component fieldName, List<T> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<T>> saveConsumer, Supplier<List<T>> defaultValue, Component resetButtonKey, boolean deleteButtonEnabled, boolean insertInFront, BiFunction<T, NestedListListEntry<T, INNER>, INNER> createNewCell) {
         super(fieldName, value, defaultExpanded, null, null, defaultValue, resetButtonKey, false, deleteButtonEnabled, insertInFront, (t, nestedListListEntry) -> new NestedListCell<>(t, nestedListListEntry, createNewCell.apply(t, nestedListListEntry)));
         for (NestedListCell<T, INNER> cell : cells) {
             referencableEntries.add(cell.nestedEntry);
@@ -69,7 +69,7 @@ public final class NestedListListEntry<T, INNER extends AbstractConfigListEntry<
         }
         
         @Override
-        public Optional<Text> getError() {
+        public Optional<Component> getError() {
             return nestedEntry.getError();
         }
         
@@ -79,14 +79,14 @@ public final class NestedListListEntry<T, INNER extends AbstractConfigListEntry<
         }
         
         @Override
-        public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
+        public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
             nestedEntry.setParent((DynamicEntryListWidget) listListEntry.getParent());
             nestedEntry.setScreen(listListEntry.getConfigScreen());
             nestedEntry.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isSelected, delta);
         }
         
         @Override
-        public List<? extends Element> children() {
+        public List<? extends GuiEventListener> children() {
             return Collections.singletonList(nestedEntry);
         }
         

+ 30 - 29
src/main/java/me/shedaniel/clothconfig2/gui/entries/SelectionListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/SelectionListEntry.java

@@ -2,16 +2,16 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Window;
+import com.mojang.blaze3d.vertex.PoseStack;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.Window;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
@@ -26,36 +26,37 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class SelectionListEntry<T> extends TooltipListEntry<T> {
     
-    private ImmutableList<T> values;
-    private AtomicInteger index;
+    private final ImmutableList<T> values;
+    private final AtomicInteger index;
     private final int original;
-    private ButtonWidget buttonWidget, resetButton;
-    private Consumer<T> saveConsumer;
-    private Supplier<T> defaultValue;
-    private List<Element> widgets;
-    private Function<T, Text> nameProvider;
+    private final Button buttonWidget;
+    private final Button resetButton;
+    private final Consumer<T> saveConsumer;
+    private final Supplier<T> defaultValue;
+    private final List<GuiEventListener> widgets;
+    private final Function<T, Component> nameProvider;
     
     @ApiStatus.Internal
     @Deprecated
-    public SelectionListEntry(Text fieldName, T[] valuesArray, T value, Text resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer) {
+    public SelectionListEntry(Component fieldName, T[] valuesArray, T value, Component resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer) {
         this(fieldName, valuesArray, value, resetButtonKey, defaultValue, saveConsumer, null);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public SelectionListEntry(Text fieldName, T[] valuesArray, T value, Text resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<T, Text> nameProvider) {
+    public SelectionListEntry(Component fieldName, T[] valuesArray, T value, Component resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<T, Component> nameProvider) {
         this(fieldName, valuesArray, value, resetButtonKey, defaultValue, saveConsumer, nameProvider, null);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public SelectionListEntry(Text fieldName, T[] valuesArray, T value, Text resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<T, Text> nameProvider, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public SelectionListEntry(Component fieldName, T[] valuesArray, T value, Component resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<T, Component> nameProvider, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, valuesArray, value, resetButtonKey, defaultValue, saveConsumer, nameProvider, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public SelectionListEntry(Text fieldName, T[] valuesArray, T value, Text resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<T, Text> nameProvider, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public SelectionListEntry(Component fieldName, T[] valuesArray, T value, Component resetButtonKey, Supplier<T> defaultValue, Consumer<T> saveConsumer, Function<T, Component> nameProvider, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, requiresRestart);
         if (valuesArray != null)
             this.values = ImmutableList.copyOf(valuesArray);
@@ -65,16 +66,16 @@ public class SelectionListEntry<T> extends TooltipListEntry<T> {
         this.index = new AtomicInteger(this.values.indexOf(value));
         this.index.compareAndSet(-1, 0);
         this.original = this.values.indexOf(value);
-        this.buttonWidget = new ButtonWidget(0, 0, 150, 20, NarratorManager.EMPTY, widget -> {
+        this.buttonWidget = new Button(0, 0, 150, 20, NarratorChatListener.NO_TITLE, widget -> {
             SelectionListEntry.this.index.incrementAndGet();
             SelectionListEntry.this.index.compareAndSet(SelectionListEntry.this.values.size(), 0);
         });
-        this.resetButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
+        this.resetButton = new Button(0, 0, Minecraft.getInstance().font.width(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
             SelectionListEntry.this.index.set(getDefaultIndex());
         });
         this.saveConsumer = saveConsumer;
         this.widgets = Lists.newArrayList(buttonWidget, resetButton);
-        this.nameProvider = nameProvider == null ? (t -> new TranslatableText(t instanceof Translatable ? ((Translatable) t).getKey() : t.toString())) : nameProvider;
+        this.nameProvider = nameProvider == null ? (t -> new TranslatableComponent(t instanceof Translatable ? ((Translatable) t).getKey() : t.toString())) : nameProvider;
     }
     
     @Override
@@ -99,21 +100,21 @@ public class SelectionListEntry<T> extends TooltipListEntry<T> {
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        Window window = MinecraftClient.getInstance().getWindow();
+        Window window = Minecraft.getInstance().getWindow();
         this.resetButton.active = isEditable() && getDefaultValue().isPresent() && getDefaultIndex() != this.index.get();
         this.resetButton.y = y;
         this.buttonWidget.active = isEditable();
         this.buttonWidget.y = y;
         this.buttonWidget.setMessage(nameProvider.apply(getValue()));
-        Text displayedFieldName = getDisplayedFieldName();
-        if (MinecraftClient.getInstance().textRenderer.isRightToLeft()) {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), window.getScaledWidth() - x - MinecraftClient.getInstance().textRenderer.getWidth(displayedFieldName), y + 6, getPreferredTextColor());
+        Component displayedFieldName = getDisplayedFieldName();
+        if (Minecraft.getInstance().font.isBidirectional()) {
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), window.getGuiScaledWidth() - x - Minecraft.getInstance().font.width(displayedFieldName), y + 6, getPreferredTextColor());
             this.resetButton.x = x;
             this.buttonWidget.x = x + resetButton.getWidth() + 2;
         } else {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), x, y + 6, getPreferredTextColor());
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), x, y + 6, getPreferredTextColor());
             this.resetButton.x = x + entryWidth - resetButton.getWidth();
             this.buttonWidget.x = x + entryWidth - 150;
         }
@@ -127,7 +128,7 @@ public class SelectionListEntry<T> extends TooltipListEntry<T> {
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return widgets;
     }
     

+ 6 - 6
src/main/java/me/shedaniel/clothconfig2/gui/entries/StringListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/StringListEntry.java

@@ -2,7 +2,7 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.Optional;
@@ -12,31 +12,31 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class StringListEntry extends TextFieldListEntry<String> {
     
-    private Consumer<String> saveConsumer;
+    private final Consumer<String> saveConsumer;
     
     @ApiStatus.Internal
     @Deprecated
-    public StringListEntry(Text fieldName, String value, Text resetButtonKey, Supplier<String> defaultValue, Consumer<String> saveConsumer) {
+    public StringListEntry(Component fieldName, String value, Component resetButtonKey, Supplier<String> defaultValue, Consumer<String> saveConsumer) {
         super(fieldName, value, resetButtonKey, defaultValue);
         this.saveConsumer = saveConsumer;
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public StringListEntry(Text fieldName, String value, Text resetButtonKey, Supplier<String> defaultValue, Consumer<String> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public StringListEntry(Component fieldName, String value, Component resetButtonKey, Supplier<String> defaultValue, Consumer<String> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, value, resetButtonKey, defaultValue, saveConsumer, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public StringListEntry(Text fieldName, String value, Text resetButtonKey, Supplier<String> defaultValue, Consumer<String> saveConsumer, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public StringListEntry(Component fieldName, String value, Component resetButtonKey, Supplier<String> defaultValue, Consumer<String> saveConsumer, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, value, resetButtonKey, defaultValue, tooltipSupplier, requiresRestart);
         this.saveConsumer = saveConsumer;
     }
     
     @Override
     public String getValue() {
-        return textFieldWidget.getText();
+        return textFieldWidget.getValue();
     }
     
     @Override

+ 6 - 6
src/main/java/me/shedaniel/clothconfig2/gui/entries/StringListListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/StringListListEntry.java

@@ -2,7 +2,7 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -17,19 +17,19 @@ public class StringListListEntry extends AbstractTextFieldListListEntry<String,
     
     @ApiStatus.Internal
     @Deprecated
-    public StringListListEntry(Text fieldName, List<String> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<String>> saveConsumer, Supplier<List<String>> defaultValue, Text resetButtonKey) {
+    public StringListListEntry(Component fieldName, List<String> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<String>> saveConsumer, Supplier<List<String>> defaultValue, Component resetButtonKey) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public StringListListEntry(Text fieldName, List<String> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<String>> saveConsumer, Supplier<List<String>> defaultValue, Text resetButtonKey, boolean requiresRestart) {
+    public StringListListEntry(Component fieldName, List<String> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<String>> saveConsumer, Supplier<List<String>> defaultValue, Component resetButtonKey, boolean requiresRestart) {
         this(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, true, true);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public StringListListEntry(Text fieldName, List<String> value, boolean defaultExpanded, Supplier<Optional<Text[]>> tooltipSupplier, Consumer<List<String>> saveConsumer, Supplier<List<String>> defaultValue, Text resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
+    public StringListListEntry(Component fieldName, List<String> value, boolean defaultExpanded, Supplier<Optional<Component[]>> tooltipSupplier, Consumer<List<String>> saveConsumer, Supplier<List<String>> defaultValue, Component resetButtonKey, boolean requiresRestart, boolean deleteButtonEnabled, boolean insertInFront) {
         super(fieldName, value, defaultExpanded, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, requiresRestart, deleteButtonEnabled, insertInFront, StringListCell::new);
     }
     
@@ -60,11 +60,11 @@ public class StringListListEntry extends AbstractTextFieldListListEntry<String,
         
         @Override
         public String getValue() {
-            return widget.getText();
+            return widget.getValue();
         }
         
         @Override
-        public Optional<Text> getError() {
+        public Optional<Component> getError() {
             return Optional.empty();
         }
         

+ 29 - 30
src/main/java/me/shedaniel/clothconfig2/gui/entries/SubCategoryListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/SubCategoryListEntry.java

@@ -1,23 +1,22 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Lighting;
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.PoseStack;
 import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
 import me.shedaniel.clothconfig2.api.Expandable;
 import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget;
 import me.shedaniel.math.Rectangle;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.render.DiffuseLighting;
-import net.minecraft.client.sound.PositionedSoundInstance;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.sound.SoundEvents;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
-import net.minecraft.util.Identifier;
-
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.resources.sounds.SimpleSoundInstance;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.sounds.SoundEvents;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -26,14 +25,14 @@ import java.util.Optional;
 @Environment(EnvType.CLIENT)
 public class SubCategoryListEntry extends TooltipListEntry<List<AbstractConfigListEntry>> implements Expandable {
     
-    private static final Identifier CONFIG_TEX = new Identifier("cloth-config2", "textures/gui/cloth_config.png");
-    private List<AbstractConfigListEntry> entries;
-    private CategoryLabelWidget widget;
-    private List<Element> children;
+    private static final ResourceLocation CONFIG_TEX = new ResourceLocation("cloth-config2", "textures/gui/cloth_config.png");
+    private final List<AbstractConfigListEntry> entries;
+    private final CategoryLabelWidget widget;
+    private final List<GuiEventListener> children;
     private boolean expanded;
     
     @Deprecated
-    public SubCategoryListEntry(Text categoryName, List<AbstractConfigListEntry> entries, boolean defaultExpanded) {
+    public SubCategoryListEntry(Component categoryName, List<AbstractConfigListEntry> entries, boolean defaultExpanded) {
         super(categoryName, null);
         this.entries = entries;
         this.expanded = defaultExpanded;
@@ -66,7 +65,7 @@ public class SubCategoryListEntry extends TooltipListEntry<List<AbstractConfigLi
         
     }
     
-    public Text getCategoryName() {
+    public Component getCategoryName() {
         return getFieldName();
     }
     
@@ -81,13 +80,13 @@ public class SubCategoryListEntry extends TooltipListEntry<List<AbstractConfigLi
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        MinecraftClient.getInstance().getTextureManager().bindTexture(CONFIG_TEX);
-        DiffuseLighting.disable();
+        Minecraft.getInstance().getTextureManager().bind(CONFIG_TEX);
+        Lighting.turnOff();
         RenderSystem.color4f(1, 1, 1, 1);
-        drawTexture(matrices, x - 15, y + 5, 24, (widget.rectangle.contains(mouseX, mouseY) ? 18 : 0) + (expanded ? 9 : 0), 9, 9);
-        MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, getDisplayedFieldName().method_30937(), x, y + 6, widget.rectangle.contains(mouseX, mouseY) ? 0xffe6fe16 : -1);
+        blit(matrices, x - 15, y + 5, 24, (widget.rectangle.contains(mouseX, mouseY) ? 18 : 0) + (expanded ? 9 : 0), 9, 9);
+        Minecraft.getInstance().font.drawShadow(matrices, getDisplayedFieldName().getVisualOrderText(), x, y + 6, widget.rectangle.contains(mouseX, mouseY) ? 0xffe6fe16 : -1);
         for (AbstractConfigListEntry<?> entry : entries) {
             entry.setParent((DynamicEntryListWidget) getParent());
             entry.setScreen(getConfigScreen());
@@ -119,7 +118,7 @@ public class SubCategoryListEntry extends TooltipListEntry<List<AbstractConfigLi
     }
     
     @Override
-    public void lateRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
         if (expanded) {
             for (AbstractConfigListEntry<?> entry : entries) {
                 entry.lateRender(matrices, mouseX, mouseY, delta);
@@ -169,7 +168,7 @@ public class SubCategoryListEntry extends TooltipListEntry<List<AbstractConfigLi
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return expanded ? children : Collections.singletonList(widget);
     }
     
@@ -179,27 +178,27 @@ public class SubCategoryListEntry extends TooltipListEntry<List<AbstractConfigLi
     }
     
     @Override
-    public Optional<Text> getError() {
-        Text error = null;
+    public Optional<Component> getError() {
+        Component error = null;
         for (AbstractConfigListEntry<?> entry : entries) {
-            Optional<Text> configError = entry.getConfigError();
+            Optional<Component> configError = entry.getConfigError();
             if (configError.isPresent()) {
                 if (error != null)
-                    return Optional.ofNullable(new TranslatableText("text.cloth-config.multi_error"));
+                    return Optional.ofNullable(new TranslatableComponent("text.cloth-config.multi_error"));
                 return configError;
             }
         }
         return Optional.ofNullable(error);
     }
     
-    public class CategoryLabelWidget implements Element {
-        private Rectangle rectangle = new Rectangle();
+    public class CategoryLabelWidget implements GuiEventListener {
+        private final Rectangle rectangle = new Rectangle();
         
         @Override
         public boolean mouseClicked(double double_1, double double_2, int int_1) {
             if (rectangle.contains(double_1, double_2)) {
                 expanded = !expanded;
-                MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+                Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
                 return true;
             }
             return false;

+ 33 - 33
src/main/java/me/shedaniel/clothconfig2/gui/entries/TextFieldListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/TextFieldListEntry.java

@@ -1,16 +1,16 @@
 package me.shedaniel.clothconfig2.gui.entries;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Window;
+import com.mojang.blaze3d.vertex.PoseStack;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.Window;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.List;
@@ -20,75 +20,75 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public abstract class TextFieldListEntry<T> extends TooltipListEntry<T> {
     
-    protected TextFieldWidget textFieldWidget;
-    protected ButtonWidget resetButton;
+    protected EditBox textFieldWidget;
+    protected Button resetButton;
     protected Supplier<T> defaultValue;
     protected T original;
-    protected List<Element> widgets;
+    protected List<GuiEventListener> widgets;
     private boolean isSelected = false;
     
     @ApiStatus.Internal
     @Deprecated
-    protected TextFieldListEntry(Text fieldName, T original, Text resetButtonKey, Supplier<T> defaultValue) {
+    protected TextFieldListEntry(Component fieldName, T original, Component resetButtonKey, Supplier<T> defaultValue) {
         this(fieldName, original, resetButtonKey, defaultValue, null);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    protected TextFieldListEntry(Text fieldName, T original, Text resetButtonKey, Supplier<T> defaultValue, Supplier<Optional<Text[]>> tooltipSupplier) {
+    protected TextFieldListEntry(Component fieldName, T original, Component resetButtonKey, Supplier<T> defaultValue, Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, original, resetButtonKey, defaultValue, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    protected TextFieldListEntry(Text fieldName, T original, Text resetButtonKey, Supplier<T> defaultValue, Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    protected TextFieldListEntry(Component fieldName, T original, Component resetButtonKey, Supplier<T> defaultValue, Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, requiresRestart);
         this.defaultValue = defaultValue;
         this.original = original;
-        this.textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 0, 0, 148, 18, NarratorManager.EMPTY) {
+        this.textFieldWidget = new EditBox(Minecraft.getInstance().font, 0, 0, 148, 18, NarratorChatListener.NO_TITLE) {
             @Override
-            public void render(MatrixStack matrices, int int_1, int int_2, float float_1) {
+            public void render(PoseStack matrices, int int_1, int int_2, float float_1) {
                 setFocused(isSelected && TextFieldListEntry.this.getFocused() == this);
                 textFieldPreRender(this);
                 super.render(matrices, int_1, int_2, float_1);
             }
             
             @Override
-            public void write(String string_1) {
-                super.write(stripAddText(string_1));
+            public void insertText(String string_1) {
+                super.insertText(stripAddText(string_1));
             }
         };
         textFieldWidget.setMaxLength(999999);
-        textFieldWidget.setText(String.valueOf(original));
-        this.resetButton = new ButtonWidget(0, 0, MinecraftClient.getInstance().textRenderer.getWidth(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
-            TextFieldListEntry.this.textFieldWidget.setText(String.valueOf(defaultValue.get()));
+        textFieldWidget.setValue(String.valueOf(original));
+        this.resetButton = new Button(0, 0, Minecraft.getInstance().font.width(resetButtonKey) + 6, 20, resetButtonKey, widget -> {
+            TextFieldListEntry.this.textFieldWidget.setValue(String.valueOf(defaultValue.get()));
         });
         this.widgets = Lists.newArrayList(textFieldWidget, resetButton);
     }
     
     @Override
     public boolean isEdited() {
-        return isChanged(original, textFieldWidget.getText());
+        return isChanged(original, textFieldWidget.getValue());
     }
     
     protected boolean isChanged(T original, String s) {
         return !String.valueOf(original).equals(s);
     }
     
-    protected static void setTextFieldWidth(TextFieldWidget widget, int width) {
+    protected static void setTextFieldWidth(EditBox widget, int width) {
         widget.setWidth(width);
     }
     
     @Deprecated
     public void setValue(String s) {
-        textFieldWidget.setText(String.valueOf(s));
+        textFieldWidget.setValue(String.valueOf(s));
     }
     
     protected String stripAddText(String s) {
         return s;
     }
     
-    protected void textFieldPreRender(TextFieldWidget widget) {
+    protected void textFieldPreRender(EditBox widget) {
         
     }
     
@@ -98,20 +98,20 @@ public abstract class TextFieldListEntry<T> extends TooltipListEntry<T> {
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
-        Window window = MinecraftClient.getInstance().getWindow();
-        this.resetButton.active = isEditable() && getDefaultValue().isPresent() && !isMatchDefault(textFieldWidget.getText());
+        Window window = Minecraft.getInstance().getWindow();
+        this.resetButton.active = isEditable() && getDefaultValue().isPresent() && !isMatchDefault(textFieldWidget.getValue());
         this.resetButton.y = y;
         this.textFieldWidget.setEditable(isEditable());
         this.textFieldWidget.y = y + 1;
-        Text displayedFieldName = getDisplayedFieldName();
-        if (MinecraftClient.getInstance().textRenderer.isRightToLeft()) {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), window.getScaledWidth() - x - MinecraftClient.getInstance().textRenderer.getWidth(displayedFieldName), y + 6, getPreferredTextColor());
+        Component displayedFieldName = getDisplayedFieldName();
+        if (Minecraft.getInstance().font.isBidirectional()) {
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), window.getGuiScaledWidth() - x - Minecraft.getInstance().font.width(displayedFieldName), y + 6, getPreferredTextColor());
             this.resetButton.x = x;
             this.textFieldWidget.x = x + resetButton.getWidth();
         } else {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, displayedFieldName.method_30937(), x, y + 6, getPreferredTextColor());
+            Minecraft.getInstance().font.drawShadow(matrices, displayedFieldName.getVisualOrderText(), x, y + 6, getPreferredTextColor());
             this.resetButton.x = x + entryWidth - resetButton.getWidth();
             this.textFieldWidget.x = x + entryWidth - 148;
         }
@@ -128,7 +128,7 @@ public abstract class TextFieldListEntry<T> extends TooltipListEntry<T> {
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return widgets;
     }
     

+ 17 - 18
src/main/java/me/shedaniel/clothconfig2/gui/entries/TextListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/TextListEntry.java

@@ -2,13 +2,12 @@ package me.shedaniel.clothconfig2.gui.entries;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.class_5481;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+import net.minecraft.util.FormattedCharSequence;
 import org.jetbrains.annotations.ApiStatus;
-
+import com.mojang.blaze3d.vertex.PoseStack;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
@@ -18,38 +17,38 @@ import java.util.function.Supplier;
 public class TextListEntry extends TooltipListEntry<Object> {
     
     private int savedWidth = -1;
-    private int color;
-    private Text text;
+    private final int color;
+    private final Component text;
     
     @ApiStatus.Internal
     @Deprecated
-    public TextListEntry(Text fieldName, Text text) {
+    public TextListEntry(Component fieldName, Component text) {
         this(fieldName, text, -1);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public TextListEntry(Text fieldName, Text text, int color) {
+    public TextListEntry(Component fieldName, Component text, int color) {
         this(fieldName, text, color, null);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public TextListEntry(Text fieldName, Text text, int color, Supplier<Optional<Text[]>> tooltipSupplier) {
+    public TextListEntry(Component fieldName, Component text, int color, Supplier<Optional<Component[]>> tooltipSupplier) {
         super(fieldName, tooltipSupplier);
         this.text = text;
         this.color = color;
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
         this.savedWidth = entryWidth;
         int yy = y + 4;
-        List<class_5481> strings = MinecraftClient.getInstance().textRenderer.wrapStringToWidthAsList(text, savedWidth);
-        for (class_5481 string : strings) {
-            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, string, x, yy, color);
-            yy += MinecraftClient.getInstance().textRenderer.fontHeight + 3;
+        List<FormattedCharSequence> strings = Minecraft.getInstance().font.split(text, savedWidth);
+        for (FormattedCharSequence string : strings) {
+            Minecraft.getInstance().font.drawShadow(matrices, string, x, yy, color);
+            yy += Minecraft.getInstance().font.lineHeight + 3;
         }
     }
     
@@ -57,7 +56,7 @@ public class TextListEntry extends TooltipListEntry<Object> {
     public int getItemHeight() {
         if (savedWidth == -1)
             return 12;
-        List<class_5481> strings = MinecraftClient.getInstance().textRenderer.wrapStringToWidthAsList(text, savedWidth);
+        List<FormattedCharSequence> strings = Minecraft.getInstance().font.split(text, savedWidth);
         if (strings.isEmpty())
             return 0;
         return 15 + strings.size() * 12;
@@ -79,7 +78,7 @@ public class TextListEntry extends TooltipListEntry<Object> {
     }
     
     @Override
-    public List<? extends Element> children() {
+    public List<? extends GuiEventListener> children() {
         return Collections.emptyList();
     }
     

+ 11 - 12
src/main/java/me/shedaniel/clothconfig2/gui/entries/TooltipListEntry.java → common/src/main/java/me/shedaniel/clothconfig2/gui/entries/TooltipListEntry.java

@@ -5,58 +5,57 @@ import me.shedaniel.clothconfig2.api.Tooltip;
 import me.shedaniel.math.Point;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.Nullable;
-
+import com.mojang.blaze3d.vertex.PoseStack;
 import java.util.Optional;
 import java.util.function.Supplier;
 
 @Environment(EnvType.CLIENT)
 public abstract class TooltipListEntry<T> extends AbstractConfigListEntry<T> {
     
-    @Nullable private Supplier<Optional<Text[]>> tooltipSupplier;
+    @Nullable private Supplier<Optional<Component[]>> tooltipSupplier;
     
     @ApiStatus.Internal
     @Deprecated
-    public TooltipListEntry(Text fieldName, @Nullable Supplier<Optional<Text[]>> tooltipSupplier) {
+    public TooltipListEntry(Component fieldName, @Nullable Supplier<Optional<Component[]>> tooltipSupplier) {
         this(fieldName, tooltipSupplier, false);
     }
     
     @ApiStatus.Internal
     @Deprecated
-    public TooltipListEntry(Text fieldName, @Nullable Supplier<Optional<Text[]>> tooltipSupplier, boolean requiresRestart) {
+    public TooltipListEntry(Component fieldName, @Nullable Supplier<Optional<Component[]>> tooltipSupplier, boolean requiresRestart) {
         super(fieldName, requiresRestart);
         this.tooltipSupplier = tooltipSupplier;
     }
     
     @Override
-    public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
+    public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta) {
         super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isHovered, delta);
         if (isMouseInside(mouseX, mouseY, x, y, entryWidth, entryHeight)) {
-            Optional<Text[]> tooltip = getTooltip(mouseX, mouseY);
+            Optional<Component[]> tooltip = getTooltip(mouseX, mouseY);
             if (tooltip.isPresent() && tooltip.get().length > 0)
                 addTooltip(Tooltip.of(new Point(mouseX, mouseY), tooltip.get()));
         }
     }
     
-    public Optional<Text[]> getTooltip() {
+    public Optional<Component[]> getTooltip() {
         if (tooltipSupplier != null)
             return tooltipSupplier.get();
         return Optional.empty();
     }
     
-    public Optional<Text[]> getTooltip(int mouseX, int mouseY) {
+    public Optional<Component[]> getTooltip(int mouseX, int mouseY) {
         return getTooltip();
     }
     
     @Nullable
-    public Supplier<Optional<Text[]>> getTooltipSupplier() {
+    public Supplier<Optional<Component[]>> getTooltipSupplier() {
         return tooltipSupplier;
     }
     
-    public void setTooltipSupplier(@Nullable Supplier<Optional<Text[]>> tooltipSupplier) {
+    public void setTooltipSupplier(@Nullable Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
     }
     

+ 9 - 9
src/main/java/me/shedaniel/clothconfig2/gui/widget/ColorDisplayWidget.java → common/src/main/java/me/shedaniel/clothconfig2/gui/widget/ColorDisplayWidget.java

@@ -1,25 +1,25 @@
 package me.shedaniel.clothconfig2.gui.widget;
 
-import net.minecraft.client.gui.widget.AbstractButtonWidget;
-import net.minecraft.client.gui.widget.TextFieldWidget;
-import net.minecraft.client.util.NarratorManager;
-import net.minecraft.client.util.math.MatrixStack;
+import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.client.gui.chat.NarratorChatListener;
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.components.EditBox;
 
-public class ColorDisplayWidget extends AbstractButtonWidget {
+public class ColorDisplayWidget extends AbstractWidget {
     
-    protected TextFieldWidget textFieldWidget;
+    protected EditBox textFieldWidget;
     protected int color;
     protected int size;
     
-    public ColorDisplayWidget(TextFieldWidget textFieldWidget, int x, int y, int size, int color) {
-        super(x, y, size, size, NarratorManager.EMPTY);
+    public ColorDisplayWidget(EditBox textFieldWidget, int x, int y, int size, int color) {
+        super(x, y, size, size, NarratorChatListener.NO_TITLE);
         this.textFieldWidget = textFieldWidget;
         this.color = color;
         this.size = size;
     }
     
     @Override
-    public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
         fillGradient(matrices, this.x, this.y, this.x + size, this.y + size, textFieldWidget.isFocused() ? -1 : -6250336, textFieldWidget.isFocused() ? -1 : -6250336);
         fillGradient(matrices, this.x + 1, this.y + 1, this.x + size - 1, this.y + size - 1, 0xffffffff, 0xffffffff);
         fillGradient(matrices, this.x + 1, this.y + 1, this.x + size - 1, this.y + size - 1, color, color);

+ 9 - 9
src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicElementListWidget.java → common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicElementListWidget.java

@@ -2,15 +2,15 @@ package me.shedaniel.clothconfig2.gui.widget;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.ParentElement;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.events.ContainerEventHandler;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.resources.ResourceLocation;
 
 @Environment(EnvType.CLIENT)
 public abstract class DynamicElementListWidget<E extends DynamicElementListWidget.ElementEntry<E>> extends DynamicNewSmoothScrollingEntryListWidget<E> {
     
-    public DynamicElementListWidget(MinecraftClient client, int width, int height, int top, int bottom, Identifier backgroundLocation) {
+    public DynamicElementListWidget(Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) {
         super(client, width, height, top, bottom, backgroundLocation);
     }
     
@@ -26,8 +26,8 @@ public abstract class DynamicElementListWidget<E extends DynamicElementListWidge
     }
     
     @Environment(EnvType.CLIENT)
-    public abstract static class ElementEntry<E extends ElementEntry<E>> extends Entry<E> implements ParentElement {
-        private Element focused;
+    public abstract static class ElementEntry<E extends ElementEntry<E>> extends Entry<E> implements ContainerEventHandler {
+        private GuiEventListener focused;
         private boolean dragging;
         
         public ElementEntry() {
@@ -41,11 +41,11 @@ public abstract class DynamicElementListWidget<E extends DynamicElementListWidge
             this.dragging = boolean_1;
         }
         
-        public Element getFocused() {
+        public GuiEventListener getFocused() {
             return this.focused;
         }
         
-        public void setFocused(Element element_1) {
+        public void setFocused(GuiEventListener element_1) {
             this.focused = element_1;
         }
     }

+ 101 - 100
src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicEntryListWidget.java → common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicEntryListWidget.java

@@ -1,24 +1,25 @@
 package me.shedaniel.clothconfig2.gui.widget;
 
 import com.google.common.collect.Lists;
+import com.mojang.blaze3d.platform.Lighting;
 import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.blaze3d.vertex.Tesselator;
+import com.mojang.math.Matrix4f;
 import me.shedaniel.clothconfig2.api.ScissorsHandler;
+import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget.Entries;
 import me.shedaniel.math.Rectangle;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.AbstractParentElement;
-import net.minecraft.client.gui.Drawable;
-import net.minecraft.client.gui.DrawableHelper;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.DiffuseLighting;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.util.Identifier;
-import net.minecraft.util.math.MathHelper;
-import net.minecraft.util.math.Matrix4f;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.components.Widget;
+import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.util.Mth;
 import org.jetbrains.annotations.ApiStatus;
 
 import java.util.AbstractList;
@@ -27,9 +28,9 @@ import java.util.List;
 import java.util.Objects;
 
 @Environment(EnvType.CLIENT)
-public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.Entry<E>> extends AbstractParentElement implements Drawable {
+public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.Entry<E>> extends AbstractContainerEventHandler implements Widget {
     protected static final int DRAG_OUTSIDE = -2;
-    protected final MinecraftClient client;
+    protected final Minecraft client;
     private final List<E> entries = new Entries();
     public int width;
     public int height;
@@ -45,9 +46,9 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
     protected double scroll;
     protected boolean scrolling;
     protected E selectedItem;
-    protected Identifier backgroundLocation;
+    protected ResourceLocation backgroundLocation;
     
-    public DynamicEntryListWidget(MinecraftClient client, int width, int height, int top, int bottom, Identifier backgroundLocation) {
+    public DynamicEntryListWidget(Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) {
         this.client = client;
         this.width = width;
         this.height = height;
@@ -114,7 +115,7 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
         int listMiddleX = this.left + this.width / 2;
         int minX = listMiddleX - this.getItemWidth() / 2;
         int maxX = listMiddleX + this.getItemWidth() / 2;
-        int currentY = MathHelper.floor(mouseY - (double) this.top) - this.headerHeight + (int) this.getScroll() - 4;
+        int currentY = Mth.floor(mouseY - (double) this.top) - this.headerHeight + (int) this.getScroll() - 4;
         int itemY = 0;
         int itemIndex = -1;
         for (int i = 0; i < entries.size(); i++) {
@@ -158,39 +159,39 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
     protected void clickedHeader(int int_1, int int_2) {
     }
     
-    protected void renderHeader(MatrixStack matrices, int rowLeft, int startY, Tessellator tessellator) {
+    protected void renderHeader(PoseStack matrices, int rowLeft, int startY, Tesselator tessellator) {
     }
     
     protected void drawBackground() {
     }
     
-    protected void renderDecorations(MatrixStack matrices, int mouseX, int mouseY) {
+    protected void renderDecorations(PoseStack matrices, int mouseX, int mouseY) {
     }
     
     @Deprecated
-    protected void renderBackBackground(MatrixStack matrices, BufferBuilder buffer, Tessellator tessellator) {
-        this.client.getTextureManager().bindTexture(backgroundLocation);
+    protected void renderBackBackground(PoseStack matrices, BufferBuilder buffer, Tesselator tessellator) {
+        this.client.getTextureManager().bind(backgroundLocation);
         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
-        Matrix4f matrix = matrices.peek().getModel();
+        Matrix4f matrix = matrices.last().pose();
         float float_2 = 32.0F;
-        buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-        buffer.vertex(matrix, this.left, this.bottom, 0.0F).texture(this.left / 32.0F, ((this.bottom + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).next();
-        buffer.vertex(matrix, this.right, this.bottom, 0.0F).texture(this.right / 32.0F, ((this.bottom + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).next();
-        buffer.vertex(matrix, this.right, this.top, 0.0F).texture(this.right / 32.0F, ((this.top + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).next();
-        buffer.vertex(matrix, this.left, this.top, 0.0F).texture(this.left / 32.0F, ((this.top + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).next();
-        tessellator.draw();
+        buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+        buffer.vertex(matrix, this.left, this.bottom, 0.0F).uv(this.left / 32.0F, ((this.bottom + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).endVertex();
+        buffer.vertex(matrix, this.right, this.bottom, 0.0F).uv(this.right / 32.0F, ((this.bottom + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).endVertex();
+        buffer.vertex(matrix, this.right, this.top, 0.0F).uv(this.right / 32.0F, ((this.top + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).endVertex();
+        buffer.vertex(matrix, this.left, this.top, 0.0F).uv(this.left / 32.0F, ((this.top + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).endVertex();
+        tessellator.end();
     }
     
     @SuppressWarnings("deprecation")
     @Override
-    public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
         this.drawBackground();
         int scrollbarPosition = this.getScrollbarPosition();
         int int_4 = scrollbarPosition + 6;
         RenderSystem.disableLighting();
         RenderSystem.disableFog();
-        Tessellator tessellator = Tessellator.getInstance();
-        BufferBuilder buffer = tessellator.getBuffer();
+        Tesselator tessellator = Tesselator.getInstance();
+        BufferBuilder buffer = tessellator.getBuilder();
         renderBackBackground(matrices, buffer, tessellator);
         int rowLeft = this.getRowLeft();
         int startY = this.top + 4 - (int) this.getScroll();
@@ -207,19 +208,19 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
         RenderSystem.disableAlphaTest();
         RenderSystem.shadeModel(7425);
         RenderSystem.disableTexture();
-        Matrix4f matrix = matrices.peek().getModel();
-        buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-        buffer.vertex(matrix, this.left, this.top + 4, 0.0F).texture(0, 1).color(0, 0, 0, 0).next();
-        buffer.vertex(matrix, this.right, this.top + 4, 0.0F).texture(1, 1).color(0, 0, 0, 0).next();
-        buffer.vertex(matrix, this.right, this.top, 0.0F).texture(1, 0).color(0, 0, 0, 255).next();
-        buffer.vertex(matrix, this.left, this.top, 0.0F).texture(0, 0).color(0, 0, 0, 255).next();
-        tessellator.draw();
-        buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-        buffer.vertex(matrix, this.left, this.bottom, 0.0F).texture(0, 1).color(0, 0, 0, 255).next();
-        buffer.vertex(matrix, this.right, this.bottom, 0.0F).texture(1, 1).color(0, 0, 0, 255).next();
-        buffer.vertex(matrix, this.right, this.bottom - 4, 0.0F).texture(1, 0).color(0, 0, 0, 0).next();
-        buffer.vertex(matrix, this.left, this.bottom - 4, 0.0F).texture(0, 0).color(0, 0, 0, 0).next();
-        tessellator.draw();
+        Matrix4f matrix = matrices.last().pose();
+        buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+        buffer.vertex(matrix, this.left, this.top + 4, 0.0F).uv(0, 1).color(0, 0, 0, 0).endVertex();
+        buffer.vertex(matrix, this.right, this.top + 4, 0.0F).uv(1, 1).color(0, 0, 0, 0).endVertex();
+        buffer.vertex(matrix, this.right, this.top, 0.0F).uv(1, 0).color(0, 0, 0, 255).endVertex();
+        buffer.vertex(matrix, this.left, this.top, 0.0F).uv(0, 0).color(0, 0, 0, 255).endVertex();
+        tessellator.end();
+        buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+        buffer.vertex(matrix, this.left, this.bottom, 0.0F).uv(0, 1).color(0, 0, 0, 255).endVertex();
+        buffer.vertex(matrix, this.right, this.bottom, 0.0F).uv(1, 1).color(0, 0, 0, 255).endVertex();
+        buffer.vertex(matrix, this.right, this.bottom - 4, 0.0F).uv(1, 0).color(0, 0, 0, 0).endVertex();
+        buffer.vertex(matrix, this.left, this.bottom - 4, 0.0F).uv(0, 0).color(0, 0, 0, 0).endVertex();
+        tessellator.end();
         int maxScroll = this.getMaxScroll();
         renderScrollBar(matrices, tessellator, buffer, maxScroll, scrollbarPosition, int_4);
         
@@ -231,34 +232,34 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
     }
     
     @SuppressWarnings("deprecation")
-    protected void renderScrollBar(MatrixStack matrices, Tessellator tessellator, BufferBuilder buffer, int maxScroll, int scrollbarPositionMinX, int scrollbarPositionMaxX) {
+    protected void renderScrollBar(PoseStack matrices, Tesselator tessellator, BufferBuilder buffer, int maxScroll, int scrollbarPositionMinX, int scrollbarPositionMaxX) {
         if (maxScroll > 0) {
             int int_9 = ((this.bottom - this.top) * (this.bottom - this.top)) / this.getMaxScrollPosition();
-            int_9 = MathHelper.clamp(int_9, 32, this.bottom - this.top - 8);
+            int_9 = Mth.clamp(int_9, 32, this.bottom - this.top - 8);
             int int_10 = (int) this.getScroll() * (this.bottom - this.top - int_9) / maxScroll + this.top;
             if (int_10 < this.top) {
                 int_10 = this.top;
             }
             
-            Matrix4f matrix = matrices.peek().getModel();
-            buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-            buffer.vertex(matrix, scrollbarPositionMinX, this.bottom, 0.0F).texture(0, 1).color(0, 0, 0, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMaxX, this.bottom, 0.0F).texture(1, 1).color(0, 0, 0, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMaxX, this.top, 0.0F).texture(1, 0).color(0, 0, 0, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMinX, this.top, 0.0F).texture(0, 0).color(0, 0, 0, 255).next();
-            tessellator.draw();
-            buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-            buffer.vertex(matrix, scrollbarPositionMinX, int_10 + int_9, 0.0F).texture(0, 1).color(128, 128, 128, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMaxX, int_10 + int_9, 0.0F).texture(1, 1).color(128, 128, 128, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMaxX, int_10, 0.0F).texture(1, 0).color(128, 128, 128, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMinX, int_10, 0.0F).texture(0, 0).color(128, 128, 128, 255).next();
-            tessellator.draw();
-            buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-            buffer.vertex(scrollbarPositionMinX, (int_10 + int_9 - 1), 0.0F).texture(0, 1).color(192, 192, 192, 255).next();
-            buffer.vertex((scrollbarPositionMaxX - 1), (int_10 + int_9 - 1), 0.0F).texture(1, 1).color(192, 192, 192, 255).next();
-            buffer.vertex((scrollbarPositionMaxX - 1), int_10, 0.0F).texture(1, 0).color(192, 192, 192, 255).next();
-            buffer.vertex(scrollbarPositionMinX, int_10, 0.0F).texture(0, 0).color(192, 192, 192, 255).next();
-            tessellator.draw();
+            Matrix4f matrix = matrices.last().pose();
+            buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+            buffer.vertex(matrix, scrollbarPositionMinX, this.bottom, 0.0F).uv(0, 1).color(0, 0, 0, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMaxX, this.bottom, 0.0F).uv(1, 1).color(0, 0, 0, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMaxX, this.top, 0.0F).uv(1, 0).color(0, 0, 0, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMinX, this.top, 0.0F).uv(0, 0).color(0, 0, 0, 255).endVertex();
+            tessellator.end();
+            buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+            buffer.vertex(matrix, scrollbarPositionMinX, int_10 + int_9, 0.0F).uv(0, 1).color(128, 128, 128, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMaxX, int_10 + int_9, 0.0F).uv(1, 1).color(128, 128, 128, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMaxX, int_10, 0.0F).uv(1, 0).color(128, 128, 128, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMinX, int_10, 0.0F).uv(0, 0).color(128, 128, 128, 255).endVertex();
+            tessellator.end();
+            buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+            buffer.vertex(scrollbarPositionMinX, (int_10 + int_9 - 1), 0.0F).uv(0, 1).color(192, 192, 192, 255).endVertex();
+            buffer.vertex((scrollbarPositionMaxX - 1), (int_10 + int_9 - 1), 0.0F).uv(1, 1).color(192, 192, 192, 255).endVertex();
+            buffer.vertex((scrollbarPositionMaxX - 1), int_10, 0.0F).uv(1, 0).color(192, 192, 192, 255).endVertex();
+            buffer.vertex(scrollbarPositionMinX, int_10, 0.0F).uv(0, 0).color(192, 192, 192, 255).endVertex();
+            tessellator.end();
         }
     }
     
@@ -289,7 +290,7 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
     }
     
     public void capYPosition(double double_1) {
-        this.scroll = MathHelper.clamp(double_1, 0.0F, this.getMaxScroll());
+        this.scroll = Mth.clamp(double_1, 0.0F, this.getMaxScroll());
     }
     
     protected int getMaxScroll() {
@@ -348,7 +349,7 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
             } else {
                 double double_5 = Math.max(1, this.getMaxScroll());
                 int int_2 = this.bottom - this.top;
-                int int_3 = MathHelper.clamp((int) ((float) (int_2 * int_2) / (float) this.getMaxScrollPosition()), 32, int_2 - 8);
+                int int_3 = Mth.clamp((int) ((float) (int_2 * int_2) / (float) this.getMaxScrollPosition()), 32, int_2 - 8);
                 double double_6 = Math.max(1.0D, double_5 / (double) (int_2 - int_3));
                 this.capYPosition(this.getScroll() + deltaY * double_6);
             }
@@ -386,7 +387,7 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
     protected void moveSelection(int int_1) {
         if (!this.children().isEmpty()) {
             int int_2 = this.children().indexOf(this.getSelectedItem());
-            int int_3 = MathHelper.clamp(int_2 + int_1, 0, this.getItemCount() - 1);
+            int int_3 = Mth.clamp(int_2 + int_1, 0, this.getItemCount() - 1);
             E itemListWidget$Item_1 = this.children().get(int_3);
             this.selectItem(itemListWidget$Item_1);
             this.ensureVisible(itemListWidget$Item_1);
@@ -398,10 +399,10 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
         return double_2 >= (double) this.top && double_2 <= (double) this.bottom && double_1 >= (double) this.left && double_1 <= (double) this.right;
     }
     
-    protected void renderList(MatrixStack matrices, int startX, int startY, int int_3, int int_4, float float_1) {
+    protected void renderList(PoseStack matrices, int startX, int startY, int int_3, int int_4, float float_1) {
         int itemCount = this.getItemCount();
-        Tessellator tessellator = Tessellator.getInstance();
-        BufferBuilder buffer = tessellator.getBuffer();
+        Tesselator tessellator = Tesselator.getInstance();
+        BufferBuilder buffer = tessellator.getBuilder();
         
         for (int renderIndex = 0; renderIndex < itemCount; ++renderIndex) {
             E item = this.getItem(renderIndex);
@@ -416,32 +417,32 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
                 itemMaxX = itemMinX + itemWidth;
                 RenderSystem.disableTexture();
                 float float_2 = this.isFocused() ? 1.0F : 0.5F;
-                Matrix4f matrix = matrices.peek().getModel();
+                Matrix4f matrix = matrices.last().pose();
                 RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
-                buffer.begin(7, VertexFormats.POSITION_COLOR);
-                buffer.vertex(matrix, itemMinX, itemY + itemHeight + 2, 0.0F).color(float_2, float_2, float_2, 1.0F).next();
-                buffer.vertex(matrix, itemMaxX, itemY + itemHeight + 2, 0.0F).color(float_2, float_2, float_2, 1.0F).next();
-                buffer.vertex(matrix, itemMaxX, itemY - 2, 0.0F).color(float_2, float_2, float_2, 1.0F).next();
-                buffer.vertex(matrix, itemMinX, itemY - 2, 0.0F).color(float_2, float_2, float_2, 1.0F).next();
-                tessellator.draw();
-                buffer.begin(7, VertexFormats.POSITION_COLOR);
-                buffer.vertex(matrix, itemMinX + 1, itemY + itemHeight + 1, 0.0F).color(0.0F, 0.0F, 0.0F, 1.0F).next();
-                buffer.vertex(matrix, itemMaxX - 1, itemY + itemHeight + 1, 0.0F).color(0.0F, 0.0F, 0.0F, 1.0F).next();
-                buffer.vertex(matrix, itemMaxX - 1, itemY - 1, 0.0F).color(0.0F, 0.0F, 0.0F, 1.0F).next();
-                buffer.vertex(matrix, itemMinX + 1, itemY - 1, 0.0F).color(0.0F, 0.0F, 0.0F, 1.0F).next();
-                tessellator.draw();
+                buffer.begin(7, DefaultVertexFormat.POSITION_COLOR);
+                buffer.vertex(matrix, itemMinX, itemY + itemHeight + 2, 0.0F).color(float_2, float_2, float_2, 1.0F).endVertex();
+                buffer.vertex(matrix, itemMaxX, itemY + itemHeight + 2, 0.0F).color(float_2, float_2, float_2, 1.0F).endVertex();
+                buffer.vertex(matrix, itemMaxX, itemY - 2, 0.0F).color(float_2, float_2, float_2, 1.0F).endVertex();
+                buffer.vertex(matrix, itemMinX, itemY - 2, 0.0F).color(float_2, float_2, float_2, 1.0F).endVertex();
+                tessellator.end();
+                buffer.begin(7, DefaultVertexFormat.POSITION_COLOR);
+                buffer.vertex(matrix, itemMinX + 1, itemY + itemHeight + 1, 0.0F).color(0.0F, 0.0F, 0.0F, 1.0F).endVertex();
+                buffer.vertex(matrix, itemMaxX - 1, itemY + itemHeight + 1, 0.0F).color(0.0F, 0.0F, 0.0F, 1.0F).endVertex();
+                buffer.vertex(matrix, itemMaxX - 1, itemY - 1, 0.0F).color(0.0F, 0.0F, 0.0F, 1.0F).endVertex();
+                buffer.vertex(matrix, itemMinX + 1, itemY - 1, 0.0F).color(0.0F, 0.0F, 0.0F, 1.0F).endVertex();
+                tessellator.end();
                 RenderSystem.enableTexture();
             }
             
             int y = this.getRowTop(renderIndex);
             int x = this.getRowLeft();
-            DiffuseLighting.disable();
+            Lighting.turnOff();
             renderItem(matrices, item, renderIndex, y, x, itemWidth, itemHeight, int_3, int_4, this.isMouseOver(int_3, int_4) && Objects.equals(this.getItemAtPosition(int_3, int_4), item), float_1);
         }
         
     }
     
-    protected void renderItem(MatrixStack matrices, E item, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
+    protected void renderItem(PoseStack matrices, E item, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
         item.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, isSelected, delta);
     }
     
@@ -461,19 +462,19 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
     }
     
     @SuppressWarnings("deprecation")
-    protected void renderHoleBackground(MatrixStack matrices, int y1, int y2, int alpha1, int alpha2) {
-        Tessellator tessellator = Tessellator.getInstance();
-        BufferBuilder buffer = tessellator.getBuffer();
-        this.client.getTextureManager().bindTexture(backgroundLocation);
-        Matrix4f matrix = matrices.peek().getModel();
+    protected void renderHoleBackground(PoseStack matrices, int y1, int y2, int alpha1, int alpha2) {
+        Tesselator tessellator = Tesselator.getInstance();
+        BufferBuilder buffer = tessellator.getBuilder();
+        this.client.getTextureManager().bind(backgroundLocation);
+        Matrix4f matrix = matrices.last().pose();
         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
         float float_1 = 32.0F;
-        buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-        buffer.vertex(matrix, this.left, y2, 0.0F).texture(0, ((float) y2 / 32.0F)).color(64, 64, 64, alpha2).next();
-        buffer.vertex(matrix, this.left + this.width, y2, 0.0F).texture(((float) this.width / 32.0F), ((float) y2 / 32.0F)).color(64, 64, 64, alpha2).next();
-        buffer.vertex(matrix, this.left + this.width, y1, 0.0F).texture(((float) this.width / 32.0F), ((float) y1 / 32.0F)).color(64, 64, 64, alpha1).next();
-        buffer.vertex(matrix, this.left, y1, 0.0F).texture(0, ((float) y1 / 32.0F)).color(64, 64, 64, alpha1).next();
-        tessellator.draw();
+        buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+        buffer.vertex(matrix, this.left, y2, 0.0F).uv(0, ((float) y2 / 32.0F)).color(64, 64, 64, alpha2).endVertex();
+        buffer.vertex(matrix, this.left + this.width, y2, 0.0F).uv(((float) this.width / 32.0F), ((float) y2 / 32.0F)).color(64, 64, 64, alpha2).endVertex();
+        buffer.vertex(matrix, this.left + this.width, y1, 0.0F).uv(((float) this.width / 32.0F), ((float) y1 / 32.0F)).color(64, 64, 64, alpha1).endVertex();
+        buffer.vertex(matrix, this.left, y1, 0.0F).uv(0, ((float) y1 / 32.0F)).color(64, 64, 64, alpha1).endVertex();
+        tessellator.end();
     }
     
     protected E remove(int int_1) {
@@ -497,13 +498,13 @@ public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.En
     }
     
     @Environment(EnvType.CLIENT)
-    public abstract static class Entry<E extends Entry<E>> extends DrawableHelper implements Element {
+    public abstract static class Entry<E extends Entry<E>> extends GuiComponent implements GuiEventListener {
         @Deprecated DynamicEntryListWidget<E> parent;
         
         public Entry() {
         }
         
-        public abstract void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta);
+        public abstract void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float delta);
         
         public boolean isMouseOver(double double_1, double double_2) {
             return Objects.equals(this.parent.getItemAtPosition(double_1, double_2), this);

+ 36 - 35
src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicNewSmoothScrollingEntryListWidget.java → common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicNewSmoothScrollingEntryListWidget.java

@@ -29,18 +29,19 @@ import me.shedaniel.math.Rectangle;
 import me.shedaniel.math.impl.PointHelper;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.BufferBuilder;
-import net.minecraft.client.render.Tessellator;
-import net.minecraft.client.render.VertexFormats;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.util.Identifier;
-import net.minecraft.util.math.MathHelper;
-import net.minecraft.util.math.Matrix4f;
+import net.minecraft.client.Minecraft;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.util.Mth;
 
 import static me.shedaniel.clothconfig2.api.ScrollingContainer.clampExtension;
 import static me.shedaniel.clothconfig2.api.ScrollingContainer.handleScrollingPosition;
 
+import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.blaze3d.vertex.Tesselator;
+import com.mojang.math.Matrix4f;
+
 @Environment(EnvType.CLIENT)
 public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends DynamicEntryListWidget.Entry<E>> extends DynamicEntryListWidget<E> {
     
@@ -49,7 +50,7 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
     protected long start;
     protected long duration;
     
-    public DynamicNewSmoothScrollingEntryListWidget(MinecraftClient client, int width, int height, int top, int bottom, Identifier backgroundLocation) {
+    public DynamicNewSmoothScrollingEntryListWidget(Minecraft client, int width, int height, int top, int bottom, ResourceLocation backgroundLocation) {
         super(client, width, height, top, bottom, backgroundLocation);
     }
     
@@ -64,7 +65,7 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
     @Override
     public void capYPosition(double double_1) {
         if (!smoothScrolling)
-            this.scroll = MathHelper.clamp(double_1, 0.0D, this.getMaxScroll());
+            this.scroll = Mth.clamp(double_1, 0.0D, this.getMaxScroll());
         else {
             scroll = clampExtension(double_1, getMaxScroll());
             target = clampExtension(double_1, getMaxScroll());
@@ -85,9 +86,9 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
             } else {
                 double double_5 = Math.max(1, this.getMaxScroll());
                 int int_2 = this.bottom - this.top;
-                int int_3 = MathHelper.clamp((int) ((float) (int_2 * int_2) / (float) this.getMaxScrollPosition()), 32, int_2 - 8);
+                int int_3 = Mth.clamp((int) ((float) (int_2 * int_2) / (float) this.getMaxScrollPosition()), 32, int_2 - 8);
                 double double_6 = Math.max(1.0D, double_5 / (double) (int_2 - int_3));
-                this.capYPosition(MathHelper.clamp(this.getScroll() + deltaY * double_6, 0, getMaxScroll()));
+                this.capYPosition(Mth.clamp(this.getScroll() + deltaY * double_6, 0, getMaxScroll()));
             }
             return true;
         }
@@ -103,7 +104,7 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
         }
         if (!smoothScrolling) {
             scroll += 16 * -amount;
-            this.scroll = MathHelper.clamp(amount, 0.0D, this.getMaxScroll());
+            this.scroll = Mth.clamp(amount, 0.0D, this.getMaxScroll());
             return true;
         }
         offset(ClothConfigInitializer.getScrollStep() * -amount, true);
@@ -129,7 +130,7 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
     }
     
     @Override
-    public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+    public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
         double[] target = {this.target};
         scroll = handleScrollingPosition(target, scroll, getMaxScroll(), delta, start, duration);
         this.target = target[0];
@@ -138,12 +139,12 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
     
     @SuppressWarnings("deprecation")
     @Override
-    protected void renderScrollBar(MatrixStack matrices, Tessellator tessellator, BufferBuilder buffer, int maxScroll, int scrollbarPositionMinX, int scrollbarPositionMaxX) {
+    protected void renderScrollBar(PoseStack matrices, Tesselator tessellator, BufferBuilder buffer, int maxScroll, int scrollbarPositionMinX, int scrollbarPositionMaxX) {
         if (!smoothScrolling)
             super.renderScrollBar(matrices, tessellator, buffer, maxScroll, scrollbarPositionMinX, scrollbarPositionMaxX);
         else if (maxScroll > 0) {
             int height = ((this.bottom - this.top) * (this.bottom - this.top)) / this.getMaxScrollPosition();
-            height = MathHelper.clamp(height, 32, this.bottom - this.top - 8);
+            height = Mth.clamp(height, 32, this.bottom - this.top - 8);
             height -= Math.min((scroll < 0 ? (int) -scroll : scroll > getMaxScroll() ? (int) scroll - getMaxScroll() : 0), height * .95);
             height = Math.max(10, height);
             int minY = Math.min(Math.max((int) this.getScroll() * (this.bottom - this.top - height) / maxScroll + this.top, this.top), this.bottom - height);
@@ -151,30 +152,30 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
             int bottomc = new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height).contains(PointHelper.ofMouse()) ? 168 : 128;
             int topc = new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height).contains(PointHelper.ofMouse()) ? 222 : 172;
             
-            Matrix4f matrix = matrices.peek().getModel();
+            Matrix4f matrix = matrices.last().pose();
             // Black Bar
-            buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-            buffer.vertex(matrix, scrollbarPositionMinX, this.bottom, 0.0F).texture(0, 1).color(0, 0, 0, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMaxX, this.bottom, 0.0F).texture(1, 1).color(0, 0, 0, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMaxX, this.top, 0.0F).texture(1, 0).color(0, 0, 0, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMinX, this.top, 0.0F).texture(0, 0).color(0, 0, 0, 255).next();
-            tessellator.draw();
+            buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+            buffer.vertex(matrix, scrollbarPositionMinX, this.bottom, 0.0F).uv(0, 1).color(0, 0, 0, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMaxX, this.bottom, 0.0F).uv(1, 1).color(0, 0, 0, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMaxX, this.top, 0.0F).uv(1, 0).color(0, 0, 0, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMinX, this.top, 0.0F).uv(0, 0).color(0, 0, 0, 255).endVertex();
+            tessellator.end();
             
             // Bottom
-            buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-            buffer.vertex(matrix, scrollbarPositionMinX, minY + height, 0.0F).texture(0, 1).color(bottomc, bottomc, bottomc, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMaxX, minY + height, 0.0F).texture(1, 1).color(bottomc, bottomc, bottomc, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMaxX, minY, 0.0F).texture(1, 0).color(bottomc, bottomc, bottomc, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMinX, minY, 0.0F).texture(0, 0).color(bottomc, bottomc, bottomc, 255).next();
-            tessellator.draw();
+            buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+            buffer.vertex(matrix, scrollbarPositionMinX, minY + height, 0.0F).uv(0, 1).color(bottomc, bottomc, bottomc, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMaxX, minY + height, 0.0F).uv(1, 1).color(bottomc, bottomc, bottomc, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMaxX, minY, 0.0F).uv(1, 0).color(bottomc, bottomc, bottomc, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMinX, minY, 0.0F).uv(0, 0).color(bottomc, bottomc, bottomc, 255).endVertex();
+            tessellator.end();
             
             // Top
-            buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
-            buffer.vertex(matrix, scrollbarPositionMinX, (minY + height - 1), 0.0F).texture(0, 1).color(topc, topc, topc, 255).next();
-            buffer.vertex(matrix, (scrollbarPositionMaxX - 1), (minY + height - 1), 0.0F).texture(1, 1).color(topc, topc, topc, 255).next();
-            buffer.vertex(matrix, (scrollbarPositionMaxX - 1), minY, 0.0F).texture(1, 0).color(topc, topc, topc, 255).next();
-            buffer.vertex(matrix, scrollbarPositionMinX, minY, 0.0F).texture(0, 0).color(topc, topc, topc, 255).next();
-            tessellator.draw();
+            buffer.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR);
+            buffer.vertex(matrix, scrollbarPositionMinX, (minY + height - 1), 0.0F).uv(0, 1).color(topc, topc, topc, 255).endVertex();
+            buffer.vertex(matrix, (scrollbarPositionMaxX - 1), (minY + height - 1), 0.0F).uv(1, 1).color(topc, topc, topc, 255).endVertex();
+            buffer.vertex(matrix, (scrollbarPositionMaxX - 1), minY, 0.0F).uv(1, 0).color(topc, topc, topc, 255).endVertex();
+            buffer.vertex(matrix, scrollbarPositionMinX, minY, 0.0F).uv(0, 0).color(topc, topc, topc, 255).endVertex();
+            tessellator.end();
         }
     }
     

+ 18 - 21
src/main/java/me/shedaniel/clothconfig2/impl/ConfigBuilderImpl.java → common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigBuilderImpl.java

@@ -1,24 +1,21 @@
 package me.shedaniel.clothconfig2.impl;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import me.shedaniel.clothconfig2.api.ConfigBuilder;
 import me.shedaniel.clothconfig2.api.ConfigCategory;
 import me.shedaniel.clothconfig2.api.Expandable;
-import me.shedaniel.clothconfig2.api.TabbedConfigScreen;
 import me.shedaniel.clothconfig2.gui.AbstractConfigScreen;
 import me.shedaniel.clothconfig2.gui.ClothConfigScreen;
 import me.shedaniel.clothconfig2.gui.GlobalizedClothConfigScreen;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.DrawableHelper;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.resources.ResourceLocation;
 import org.jetbrains.annotations.ApiStatus;
 
-import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.function.Consumer;
@@ -28,7 +25,7 @@ import java.util.function.Consumer;
 public class ConfigBuilderImpl implements ConfigBuilder {
     private Runnable savingRunnable;
     private Screen parent;
-    private Text title = new TranslatableText("text.cloth-config.config");
+    private Component title = new TranslatableComponent("text.cloth-config.config");
     private boolean globalized = false;
     private boolean globalizedExpanded = true;
     private boolean editable = true;
@@ -36,10 +33,10 @@ public class ConfigBuilderImpl implements ConfigBuilder {
     private boolean listSmoothScroll = true;
     private boolean doesConfirmSave = true;
     private boolean transparentBackground = false;
-    private Identifier defaultBackground = DrawableHelper.BACKGROUND_TEXTURE;
+    private ResourceLocation defaultBackground = GuiComponent.BACKGROUND_LOCATION;
     private Consumer<Screen> afterInitConsumer = screen -> {};
-    private final Map<Text, ConfigCategory> categoryMap = Maps.newLinkedHashMap();
-    private Text fallbackCategory = null;
+    private final Map<Component, ConfigCategory> categoryMap = Maps.newLinkedHashMap();
+    private Component fallbackCategory = null;
     private boolean alwaysShowTabs = false;
     
     @ApiStatus.Internal
@@ -103,12 +100,12 @@ public class ConfigBuilderImpl implements ConfigBuilder {
     }
     
     @Override
-    public Text getTitle() {
+    public Component getTitle() {
         return title;
     }
     
     @Override
-    public ConfigBuilder setTitle(Text title) {
+    public ConfigBuilder setTitle(Component title) {
         this.title = title;
         return this;
     }
@@ -125,7 +122,7 @@ public class ConfigBuilderImpl implements ConfigBuilder {
     }
     
     @Override
-    public ConfigCategory getOrCreateCategory(Text categoryKey) {
+    public ConfigCategory getOrCreateCategory(Component categoryKey) {
         if (categoryMap.containsKey(categoryKey))
             return categoryMap.get(categoryKey);
         if (fallbackCategory == null)
@@ -134,7 +131,7 @@ public class ConfigBuilderImpl implements ConfigBuilder {
     }
     
     @Override
-    public ConfigBuilder removeCategory(Text category) {
+    public ConfigBuilder removeCategory(Component category) {
         if (categoryMap.containsKey(category) && fallbackCategory.equals(category))
             fallbackCategory = null;
         if (!categoryMap.containsKey(category))
@@ -144,7 +141,7 @@ public class ConfigBuilderImpl implements ConfigBuilder {
     }
     
     @Override
-    public ConfigBuilder removeCategoryIfExists(Text category) {
+    public ConfigBuilder removeCategoryIfExists(Component category) {
         if (categoryMap.containsKey(category) && fallbackCategory.equals(category))
             fallbackCategory = null;
         categoryMap.remove(category);
@@ -152,7 +149,7 @@ public class ConfigBuilderImpl implements ConfigBuilder {
     }
     
     @Override
-    public boolean hasCategory(Text category) {
+    public boolean hasCategory(Component category) {
         return categoryMap.containsKey(category);
     }
     
@@ -190,12 +187,12 @@ public class ConfigBuilderImpl implements ConfigBuilder {
     }
     
     @Override
-    public Identifier getDefaultBackgroundTexture() {
+    public ResourceLocation getDefaultBackgroundTexture() {
         return defaultBackground;
     }
     
     @Override
-    public ConfigBuilder setDefaultBackgroundTexture(Identifier texture) {
+    public ConfigBuilder setDefaultBackgroundTexture(ResourceLocation texture) {
         this.defaultBackground = texture;
         return this;
     }
@@ -219,7 +216,7 @@ public class ConfigBuilderImpl implements ConfigBuilder {
         if (globalized) {
             screen = new GlobalizedClothConfigScreen(parent, title, categoryMap, defaultBackground);
         } else {
-            screen = new ClothConfigScreen(parent, title,  categoryMap, defaultBackground);
+            screen = new ClothConfigScreen(parent, title, categoryMap, defaultBackground);
         }
         screen.setSavingRunnable(savingRunnable);
         screen.setEditable(editable);

+ 13 - 13
src/main/java/me/shedaniel/clothconfig2/impl/ConfigCategoryImpl.java → common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigCategoryImpl.java

@@ -6,9 +6,9 @@ import me.shedaniel.clothconfig2.api.ConfigBuilder;
 import me.shedaniel.clothconfig2.api.ConfigCategory;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.StringRenderable;
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.FormattedText;
+import net.minecraft.resources.ResourceLocation;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.List;
@@ -20,19 +20,19 @@ public class ConfigCategoryImpl implements ConfigCategory {
     private final ConfigBuilder builder;
     private final List<Object> data;
     @Nullable
-    private Identifier background;
-    private final Text categoryKey;
+    private ResourceLocation background;
+    private final Component categoryKey;
     @Nullable
-    private Supplier<Optional<StringRenderable[]>> description = Optional::empty;
+    private Supplier<Optional<FormattedText[]>> description = Optional::empty;
     
-    ConfigCategoryImpl(ConfigBuilder builder, Text categoryKey) {
+    ConfigCategoryImpl(ConfigBuilder builder, Component categoryKey) {
         this.builder = builder;
         this.data = Lists.newArrayList();
         this.categoryKey = categoryKey;
     }
     
     @Override
-    public Text getCategoryKey() {
+    public Component getCategoryKey() {
         return categoryKey;
     }
     
@@ -48,7 +48,7 @@ public class ConfigCategoryImpl implements ConfigCategory {
     }
     
     @Override
-    public ConfigCategory setCategoryBackground(Identifier identifier) {
+    public ConfigCategory setCategoryBackground(ResourceLocation identifier) {
         if (builder.hasTransparentBackground())
             throw new IllegalStateException("Cannot set category background if screen is using transparent background.");
         background = identifier;
@@ -61,24 +61,24 @@ public class ConfigCategoryImpl implements ConfigCategory {
     }
     
     @Override
-    public void setBackground(@Nullable Identifier background) {
+    public void setBackground(@Nullable ResourceLocation background) {
         this.background = background;
     }
     
     @Override
     @Nullable
-    public Identifier getBackground() {
+    public ResourceLocation getBackground() {
         return background;
     }
     
     @Nullable
     @Override
-    public Supplier<Optional<StringRenderable[]>> getDescription() {
+    public Supplier<Optional<FormattedText[]>> getDescription() {
         return description;
     }
     
     @Override
-    public void setDescription(@Nullable Supplier<Optional<StringRenderable[]>> description) {
+    public void setDescription(@Nullable Supplier<Optional<FormattedText[]>> description) {
         this.description = description;
     }
 }

+ 30 - 30
src/main/java/me/shedaniel/clothconfig2/impl/ConfigEntryBuilderImpl.java → common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigEntryBuilderImpl.java

@@ -8,9 +8,9 @@ import me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry.SelectionTopCellEl
 import me.shedaniel.clothconfig2.impl.builders.*;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.network.chat.TranslatableComponent;
 
 import java.util.List;
 import java.util.UUID;
@@ -18,7 +18,7 @@ import java.util.UUID;
 @Environment(EnvType.CLIENT)
 public class ConfigEntryBuilderImpl implements ConfigEntryBuilder {
     
-    private Text resetButtonKey = new TranslatableText("text.cloth-config.reset_value");
+    private Component resetButtonKey = new TranslatableComponent("text.cloth-config.reset_value");
     
     private ConfigEntryBuilderImpl() {
     }
@@ -30,132 +30,132 @@ public class ConfigEntryBuilderImpl implements ConfigEntryBuilder {
     public static ConfigEntryBuilderImpl createImmutable() {
         return new ConfigEntryBuilderImpl() {
             @Override
-            public ConfigEntryBuilder setResetButtonKey(Text resetButtonKey) {
+            public ConfigEntryBuilder setResetButtonKey(Component resetButtonKey) {
                 throw new UnsupportedOperationException("This is an immutable entry builder!");
             }
         };
     }
     
     @Override
-    public Text getResetButtonKey() {
+    public Component getResetButtonKey() {
         return resetButtonKey;
     }
     
     @Override
-    public ConfigEntryBuilder setResetButtonKey(Text resetButtonKey) {
+    public ConfigEntryBuilder setResetButtonKey(Component resetButtonKey) {
         this.resetButtonKey = resetButtonKey;
         return this;
     }
     
     @Override
-    public IntListBuilder startIntList(Text fieldNameKey, List<Integer> value) {
+    public IntListBuilder startIntList(Component fieldNameKey, List<Integer> value) {
         return new IntListBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public LongListBuilder startLongList(Text fieldNameKey, List<Long> value) {
+    public LongListBuilder startLongList(Component fieldNameKey, List<Long> value) {
         return new LongListBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public FloatListBuilder startFloatList(Text fieldNameKey, List<Float> value) {
+    public FloatListBuilder startFloatList(Component fieldNameKey, List<Float> value) {
         return new FloatListBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public DoubleListBuilder startDoubleList(Text fieldNameKey, List<Double> value) {
+    public DoubleListBuilder startDoubleList(Component fieldNameKey, List<Double> value) {
         return new DoubleListBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public StringListBuilder startStrList(Text fieldNameKey, List<String> value) {
+    public StringListBuilder startStrList(Component fieldNameKey, List<String> value) {
         return new StringListBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public SubCategoryBuilder startSubCategory(Text fieldNameKey) {
+    public SubCategoryBuilder startSubCategory(Component fieldNameKey) {
         return new SubCategoryBuilder(resetButtonKey, fieldNameKey);
     }
     
     @Override
-    public SubCategoryBuilder startSubCategory(Text fieldNameKey, List<AbstractConfigListEntry> entries) {
+    public SubCategoryBuilder startSubCategory(Component fieldNameKey, List<AbstractConfigListEntry> entries) {
         SubCategoryBuilder builder = new SubCategoryBuilder(resetButtonKey, fieldNameKey);
         builder.addAll(entries);
         return builder;
     }
     
     @Override
-    public BooleanToggleBuilder startBooleanToggle(Text fieldNameKey, boolean value) {
+    public BooleanToggleBuilder startBooleanToggle(Component fieldNameKey, boolean value) {
         return new BooleanToggleBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public StringFieldBuilder startStrField(Text fieldNameKey, String value) {
+    public StringFieldBuilder startStrField(Component fieldNameKey, String value) {
         return new StringFieldBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public ColorFieldBuilder startColorField(Text fieldNameKey, int value) {
+    public ColorFieldBuilder startColorField(Component fieldNameKey, int value) {
         return new ColorFieldBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public TextFieldBuilder startTextField(Text fieldNameKey, String value) {
+    public TextFieldBuilder startTextField(Component fieldNameKey, String value) {
         return new TextFieldBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public TextDescriptionBuilder startTextDescription(Text value) {
-        return new TextDescriptionBuilder(resetButtonKey, new LiteralText(UUID.randomUUID().toString()), value);
+    public TextDescriptionBuilder startTextDescription(Component value) {
+        return new TextDescriptionBuilder(resetButtonKey, new TextComponent(UUID.randomUUID().toString()), value);
     }
     
     @Override
-    public <T extends Enum<?>> EnumSelectorBuilder<T> startEnumSelector(Text fieldNameKey, Class<T> clazz, T value) {
+    public <T extends Enum<?>> EnumSelectorBuilder<T> startEnumSelector(Component fieldNameKey, Class<T> clazz, T value) {
         return new EnumSelectorBuilder<>(resetButtonKey, fieldNameKey, clazz, value);
     }
     
     @Override
-    public <T> SelectorBuilder<T> startSelector(Text fieldNameKey, T[] valuesArray, T value) {
+    public <T> SelectorBuilder<T> startSelector(Component fieldNameKey, T[] valuesArray, T value) {
         return new SelectorBuilder<>(resetButtonKey, fieldNameKey, valuesArray, value);
     }
     
     @Override
-    public IntFieldBuilder startIntField(Text fieldNameKey, int value) {
+    public IntFieldBuilder startIntField(Component fieldNameKey, int value) {
         return new IntFieldBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public LongFieldBuilder startLongField(Text fieldNameKey, long value) {
+    public LongFieldBuilder startLongField(Component fieldNameKey, long value) {
         return new LongFieldBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public FloatFieldBuilder startFloatField(Text fieldNameKey, float value) {
+    public FloatFieldBuilder startFloatField(Component fieldNameKey, float value) {
         return new FloatFieldBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public DoubleFieldBuilder startDoubleField(Text fieldNameKey, double value) {
+    public DoubleFieldBuilder startDoubleField(Component fieldNameKey, double value) {
         return new DoubleFieldBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public IntSliderBuilder startIntSlider(Text fieldNameKey, int value, int min, int max) {
+    public IntSliderBuilder startIntSlider(Component fieldNameKey, int value, int min, int max) {
         return new IntSliderBuilder(resetButtonKey, fieldNameKey, value, min, max);
     }
     
     @Override
-    public LongSliderBuilder startLongSlider(Text fieldNameKey, long value, long min, long max) {
+    public LongSliderBuilder startLongSlider(Component fieldNameKey, long value, long min, long max) {
         return new LongSliderBuilder(resetButtonKey, fieldNameKey, value, min, max);
     }
     
     @Override
-    public KeyCodeBuilder startModifierKeyCodeField(Text fieldNameKey, ModifierKeyCode value) {
+    public KeyCodeBuilder startModifierKeyCodeField(Component fieldNameKey, ModifierKeyCode value) {
         return new KeyCodeBuilder(resetButtonKey, fieldNameKey, value);
     }
     
     @Override
-    public <T> DropdownMenuBuilder<T> startDropdownMenu(Text fieldNameKey, SelectionTopCellElement<T> topCellElement, SelectionCellCreator<T> cellCreator) {
+    public <T> DropdownMenuBuilder<T> startDropdownMenu(Component fieldNameKey, SelectionTopCellElement<T> topCellElement, SelectionCellCreator<T> cellCreator) {
         return new DropdownMenuBuilder<>(resetButtonKey, fieldNameKey, topCellElement, cellCreator);
     }
     

+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/impl/EasingMethod.java → common/src/main/java/me/shedaniel/clothconfig2/impl/EasingMethod.java


+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/impl/EasingMethods.java → common/src/main/java/me/shedaniel/clothconfig2/impl/EasingMethods.java


+ 2 - 2
src/main/java/me/shedaniel/clothconfig2/impl/GameOptionsHooks.java → common/src/main/java/me/shedaniel/clothconfig2/impl/GameOptionsHooks.java

@@ -2,9 +2,9 @@ package me.shedaniel.clothconfig2.impl;
 
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.options.KeyBinding;
+import net.minecraft.client.KeyMapping;
 
 @Environment(EnvType.CLIENT)
 public interface GameOptionsHooks {
-    void cloth_setKeysAll(KeyBinding[] all);
+    void cloth_setKeysAll(KeyMapping[] all);
 }

+ 0 - 0
src/main/java/me/shedaniel/clothconfig2/impl/KeyBindingHooks.java → common/src/main/java/me/shedaniel/clothconfig2/impl/KeyBindingHooks.java


+ 13 - 13
src/main/java/me/shedaniel/clothconfig2/impl/ModifierKeyCodeImpl.java → common/src/main/java/me/shedaniel/clothconfig2/impl/ModifierKeyCodeImpl.java

@@ -1,23 +1,23 @@
 package me.shedaniel.clothconfig2.impl;
 
+import com.mojang.blaze3d.platform.InputConstants;
 import me.shedaniel.clothconfig2.api.Modifier;
 import me.shedaniel.clothconfig2.api.ModifierKeyCode;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.util.InputUtil;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 
 @Environment(EnvType.CLIENT)
 public class ModifierKeyCodeImpl implements ModifierKeyCode {
-    private InputUtil.KeyCode keyCode;
+    private InputConstants.Key keyCode;
     private Modifier modifier;
     
     public ModifierKeyCodeImpl() {
     }
     
     @Override
-    public InputUtil.KeyCode getKeyCode() {
+    public InputConstants.Key getKeyCode() {
         return keyCode;
     }
     
@@ -27,9 +27,9 @@ public class ModifierKeyCodeImpl implements ModifierKeyCode {
     }
     
     @Override
-    public ModifierKeyCode setKeyCode(InputUtil.KeyCode keyCode) {
-        this.keyCode = keyCode.getCategory().createFromCode(keyCode.getKeyCode());
-        if (keyCode.equals(InputUtil.UNKNOWN_KEYCODE))
+    public ModifierKeyCode setKeyCode(InputConstants.Key keyCode) {
+        this.keyCode = keyCode.getType().getOrCreate(keyCode.getValue());
+        if (keyCode.equals(InputConstants.UNKNOWN))
             setModifier(Modifier.none());
         return this;
     }
@@ -46,14 +46,14 @@ public class ModifierKeyCodeImpl implements ModifierKeyCode {
     }
     
     @Override
-    public Text getLocalizedName() {
-        Text base = this.keyCode.getLocalizedText();
+    public Component getLocalizedName() {
+        Component base = this.keyCode.getDisplayName();
         if (modifier.hasShift())
-            base = new TranslatableText("modifier.cloth-config.shift", base);
+            base = new TranslatableComponent("modifier.cloth-config.shift", base);
         if (modifier.hasControl())
-            base = new TranslatableText("modifier.cloth-config.ctrl", base);
+            base = new TranslatableComponent("modifier.cloth-config.ctrl", base);
         if (modifier.hasAlt())
-            base = new TranslatableText("modifier.cloth-config.alt", base);
+            base = new TranslatableComponent("modifier.cloth-config.alt", base);
         return base;
     }
     

+ 12 - 14
src/main/java/me/shedaniel/clothconfig2/impl/ScissorsHandlerImpl.java → common/src/main/java/me/shedaniel/clothconfig2/impl/ScissorsHandlerImpl.java

@@ -1,16 +1,13 @@
 package me.shedaniel.clothconfig2.impl;
 
 import com.google.common.collect.Lists;
-import me.shedaniel.clothconfig2.ClothConfigInitializer;
+import com.mojang.blaze3d.platform.Window;
 import me.shedaniel.clothconfig2.api.ScissorsHandler;
 import me.shedaniel.clothconfig2.api.ScissorsScreen;
 import me.shedaniel.math.Rectangle;
-import me.shedaniel.math.api.Executor;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.fabricmc.loader.api.FabricLoader;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.util.Window;
+import net.minecraft.client.Minecraft;
 import org.jetbrains.annotations.ApiStatus;
 import org.lwjgl.opengl.GL11;
 
@@ -23,7 +20,8 @@ public final class ScissorsHandlerImpl implements ScissorsHandler {
     @ApiStatus.Internal
     public static final ScissorsHandler INSTANCE = new ScissorsHandlerImpl();
     
-    static {
+    // TODO: should this be reimplemented?
+    /*static {
         Executor.runIf(() -> FabricLoader.getInstance().isModLoaded("notenoughcrashes"), () -> () -> {
             try {
                 Class.forName("fudge.notenoughcrashes.api.NotEnoughCrashesApi").getDeclaredMethod("onEveryCrash", Runnable.class).invoke(null, (Runnable) () -> {
@@ -37,7 +35,7 @@ public final class ScissorsHandlerImpl implements ScissorsHandler {
                 throwable.printStackTrace();
             }
         });
-    }
+    }*/
     
     private final List<Rectangle> scissorsAreas;
     
@@ -77,22 +75,22 @@ public final class ScissorsHandlerImpl implements ScissorsHandler {
                 r.setBounds(r.intersection(scissorsAreas.get(i)));
             }
             r.setBounds(Math.min(r.x, r.x + r.width), Math.min(r.y, r.y + r.height), Math.abs(r.width), Math.abs(r.height));
-            if (MinecraftClient.getInstance().currentScreen instanceof ScissorsScreen)
-                _applyScissor(((ScissorsScreen) MinecraftClient.getInstance().currentScreen).handleScissor(r));
+            if (Minecraft.getInstance().screen instanceof ScissorsScreen)
+                _applyScissor(((ScissorsScreen) Minecraft.getInstance().screen).handleScissor(r));
             else _applyScissor(r);
         } else {
-            if (MinecraftClient.getInstance().currentScreen instanceof ScissorsScreen)
-                _applyScissor(((ScissorsScreen) MinecraftClient.getInstance().currentScreen).handleScissor(null));
+            if (Minecraft.getInstance().screen instanceof ScissorsScreen)
+                _applyScissor(((ScissorsScreen) Minecraft.getInstance().screen).handleScissor(null));
             else _applyScissor(null);
         }
     }
     
     public void _applyScissor(Rectangle r) {
         if (r != null && !r.isEmpty()) {
-            Window window = MinecraftClient.getInstance().getWindow();
-            double scaleFactor = window.getScaleFactor();
+            Window window = Minecraft.getInstance().getWindow();
+            double scaleFactor = window.getGuiScale();
             GL11.glEnable(GL11.GL_SCISSOR_TEST);
-            GL11.glScissor((int) (r.x * scaleFactor), (int) ((window.getScaledHeight() - r.height - r.y) * scaleFactor), (int) (r.width * scaleFactor), (int) (r.height * scaleFactor));
+            GL11.glScissor((int) (r.x * scaleFactor), (int) ((window.getGuiScaledHeight() - r.height - r.y) * scaleFactor), (int) (r.width * scaleFactor), (int) (r.height * scaleFactor));
         } else
             GL11.glDisable(GL11.GL_SCISSOR_TEST);
     }

+ 12 - 12
src/main/java/me/shedaniel/clothconfig2/impl/builders/BooleanToggleBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/BooleanToggleBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.BooleanListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -16,16 +16,16 @@ import java.util.function.Supplier;
 public class BooleanToggleBuilder extends FieldBuilder<Boolean, BooleanListEntry> {
     
     @Nullable private Consumer<Boolean> saveConsumer = null;
-    @NotNull private Function<Boolean, Optional<Text[]>> tooltipSupplier = bool -> Optional.empty();
+    @NotNull private Function<Boolean, Optional<Component[]>> tooltipSupplier = bool -> Optional.empty();
     private final boolean value;
-    @Nullable private Function<Boolean, Text> yesNoTextSupplier = null;
+    @Nullable private Function<Boolean, Component> yesNoTextSupplier = null;
     
-    public BooleanToggleBuilder(Text resetButtonKey, Text fieldNameKey, boolean value) {
+    public BooleanToggleBuilder(Component resetButtonKey, Component fieldNameKey, boolean value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public BooleanToggleBuilder setErrorSupplier(@Nullable Function<Boolean, Optional<Text>> errorSupplier) {
+    public BooleanToggleBuilder setErrorSupplier(@Nullable Function<Boolean, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -50,32 +50,32 @@ public class BooleanToggleBuilder extends FieldBuilder<Boolean, BooleanListEntry
         return this;
     }
     
-    public BooleanToggleBuilder setTooltipSupplier(@NotNull Function<Boolean, Optional<Text[]>> tooltipSupplier) {
+    public BooleanToggleBuilder setTooltipSupplier(@NotNull Function<Boolean, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public BooleanToggleBuilder setTooltipSupplier(@NotNull Supplier<Optional<Text[]>> tooltipSupplier) {
+    public BooleanToggleBuilder setTooltipSupplier(@NotNull Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = bool -> tooltipSupplier.get();
         return this;
     }
     
-    public BooleanToggleBuilder setTooltip(Optional<Text[]> tooltip) {
+    public BooleanToggleBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = bool -> tooltip;
         return this;
     }
     
-    public BooleanToggleBuilder setTooltip(@Nullable Text... tooltip) {
+    public BooleanToggleBuilder setTooltip(@Nullable Component... tooltip) {
         this.tooltipSupplier = bool -> Optional.ofNullable(tooltip);
         return this;
     }
     
     @Nullable
-    public Function<Boolean, Text> getYesNoTextSupplier() {
+    public Function<Boolean, Component> getYesNoTextSupplier() {
         return yesNoTextSupplier;
     }
     
-    public BooleanToggleBuilder setYesNoTextSupplier(@Nullable Function<Boolean, Text> yesNoTextSupplier) {
+    public BooleanToggleBuilder setYesNoTextSupplier(@Nullable Function<Boolean, Component> yesNoTextSupplier) {
         this.yesNoTextSupplier = yesNoTextSupplier;
         return this;
     }
@@ -85,7 +85,7 @@ public class BooleanToggleBuilder extends FieldBuilder<Boolean, BooleanListEntry
     public BooleanListEntry build() {
         BooleanListEntry entry = new BooleanListEntry(getFieldNameKey(), value, getResetButtonKey(), defaultValue, saveConsumer, null, isRequireRestart()) {
             @Override
-            public Text getYesNoText(boolean bool) {
+            public Component getYesNoText(boolean bool) {
                 if (yesNoTextSupplier == null)
                     return super.getYesNoText(bool);
                 return yesNoTextSupplier.apply(bool);

+ 12 - 12
src/main/java/me/shedaniel/clothconfig2/impl/builders/ColorFieldBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/ColorFieldBuilder.java

@@ -4,8 +4,8 @@ import me.shedaniel.clothconfig2.gui.entries.ColorEntry;
 import me.shedaniel.math.Color;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
-import net.minecraft.text.TextColor;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextColor;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Objects;
@@ -18,18 +18,18 @@ import java.util.function.Supplier;
 public class ColorFieldBuilder extends FieldBuilder<String, ColorEntry> {
     
     private Consumer<Integer> saveConsumer = null;
-    private Function<Integer, Optional<Text>> errorSupplier;
-    private Function<Integer, Optional<Text[]>> tooltipSupplier = str -> Optional.empty();
+    private Function<Integer, Optional<Component>> errorSupplier;
+    private Function<Integer, Optional<Component[]>> tooltipSupplier = str -> Optional.empty();
     private final int value;
     private Supplier<Integer> defaultValue;
     private boolean alpha = false;
     
-    public ColorFieldBuilder(Text resetButtonKey, Text fieldNameKey, int value) {
+    public ColorFieldBuilder(Component resetButtonKey, Component fieldNameKey, int value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public ColorFieldBuilder setErrorSupplier(Function<Integer, Optional<Text>> errorSupplier) {
+    public ColorFieldBuilder setErrorSupplier(Function<Integer, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -65,7 +65,7 @@ public class ColorFieldBuilder extends FieldBuilder<String, ColorEntry> {
     }
     
     public ColorFieldBuilder setDefaultValue3(Supplier<TextColor> defaultValue) {
-        this.defaultValue = () -> defaultValue.get().getRgb();
+        this.defaultValue = () -> defaultValue.get().getValue();
         return this;
     }
     
@@ -80,26 +80,26 @@ public class ColorFieldBuilder extends FieldBuilder<String, ColorEntry> {
     }
     
     public ColorFieldBuilder setDefaultValue(TextColor defaultValue) {
-        this.defaultValue = () -> Objects.requireNonNull(defaultValue).getRgb();
+        this.defaultValue = () -> Objects.requireNonNull(defaultValue).getValue();
         return this;
     }
     
-    public ColorFieldBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public ColorFieldBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = str -> tooltipSupplier.get();
         return this;
     }
     
-    public ColorFieldBuilder setTooltipSupplier(Function<Integer, Optional<Text[]>> tooltipSupplier) {
+    public ColorFieldBuilder setTooltipSupplier(Function<Integer, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public ColorFieldBuilder setTooltip(Optional<Text[]> tooltip) {
+    public ColorFieldBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = str -> tooltip;
         return this;
     }
     
-    public ColorFieldBuilder setTooltip(Text... tooltip) {
+    public ColorFieldBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = str -> Optional.ofNullable(tooltip);
         return this;
     }

+ 8 - 8
src/main/java/me/shedaniel/clothconfig2/impl/builders/DoubleFieldBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DoubleFieldBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.DoubleListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Optional;
@@ -15,16 +15,16 @@ import java.util.function.Supplier;
 public class DoubleFieldBuilder extends FieldBuilder<Double, DoubleListEntry> {
     
     private Consumer<Double> saveConsumer = null;
-    private Function<Double, Optional<Text[]>> tooltipSupplier = d -> Optional.empty();
+    private Function<Double, Optional<Component[]>> tooltipSupplier = d -> Optional.empty();
     private final double value;
     private Double min = null, max = null;
     
-    public DoubleFieldBuilder(Text resetButtonKey, Text fieldNameKey, double value) {
+    public DoubleFieldBuilder(Component resetButtonKey, Component fieldNameKey, double value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public DoubleFieldBuilder setErrorSupplier(Function<Double, Optional<Text>> errorSupplier) {
+    public DoubleFieldBuilder setErrorSupplier(Function<Double, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -69,22 +69,22 @@ public class DoubleFieldBuilder extends FieldBuilder<Double, DoubleListEntry> {
         return this;
     }
     
-    public DoubleFieldBuilder setTooltipSupplier(Function<Double, Optional<Text[]>> tooltipSupplier) {
+    public DoubleFieldBuilder setTooltipSupplier(Function<Double, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public DoubleFieldBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public DoubleFieldBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = d -> tooltipSupplier.get();
         return this;
     }
     
-    public DoubleFieldBuilder setTooltip(Optional<Text[]> tooltip) {
+    public DoubleFieldBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = d -> tooltip;
         return this;
     }
     
-    public DoubleFieldBuilder setTooltip(Text... tooltip) {
+    public DoubleFieldBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = d -> Optional.ofNullable(tooltip);
         return this;
     }

+ 15 - 16
src/main/java/me/shedaniel/clothconfig2/impl/builders/DoubleListBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DoubleListBuilder.java

@@ -3,9 +3,8 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.DoubleListListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.resource.language.I18n;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
@@ -18,31 +17,31 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class DoubleListBuilder extends FieldBuilder<List<Double>, DoubleListListEntry> {
     
-    protected Function<Double, Optional<Text>> cellErrorSupplier;
+    protected Function<Double, Optional<Component>> cellErrorSupplier;
     private Consumer<List<Double>> saveConsumer = null;
-    private Function<List<Double>, Optional<Text[]>> tooltipSupplier = list -> Optional.empty();
+    private Function<List<Double>, Optional<Component[]>> tooltipSupplier = list -> Optional.empty();
     private final List<Double> value;
     private boolean expanded = false;
     private Double min = null, max = null;
     private Function<DoubleListListEntry, DoubleListListEntry.DoubleListCell> createNewInstance;
-    private Text addTooltip = new TranslatableText("text.cloth-config.list.add"), removeTooltip = new TranslatableText("text.cloth-config.list.remove");
+    private Component addTooltip = new TranslatableComponent("text.cloth-config.list.add"), removeTooltip = new TranslatableComponent("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
     
-    public DoubleListBuilder(Text resetButtonKey, Text fieldNameKey, List<Double> value) {
+    public DoubleListBuilder(Component resetButtonKey, Component fieldNameKey, List<Double> value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public Function<Double, Optional<Text>> getCellErrorSupplier() {
+    public Function<Double, Optional<Component>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
     
-    public DoubleListBuilder setCellErrorSupplier(Function<Double, Optional<Text>> cellErrorSupplier) {
+    public DoubleListBuilder setCellErrorSupplier(Function<Double, Optional<Component>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
         return this;
     }
     
-    public DoubleListBuilder setErrorSupplier(Function<List<Double>, Optional<Text>> errorSupplier) {
+    public DoubleListBuilder setErrorSupplier(Function<List<Double>, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -57,12 +56,12 @@ public class DoubleListBuilder extends FieldBuilder<List<Double>, DoubleListList
         return this;
     }
     
-    public DoubleListBuilder setAddButtonTooltip(Text addTooltip) {
+    public DoubleListBuilder setAddButtonTooltip(Component addTooltip) {
         this.addTooltip = addTooltip;
         return this;
     }
     
-    public DoubleListBuilder setRemoveButtonTooltip(Text removeTooltip) {
+    public DoubleListBuilder setRemoveButtonTooltip(Component removeTooltip) {
         this.removeTooltip = removeTooltip;
         return this;
     }
@@ -123,22 +122,22 @@ public class DoubleListBuilder extends FieldBuilder<List<Double>, DoubleListList
         return this;
     }
     
-    public DoubleListBuilder setTooltipSupplier(Function<List<Double>, Optional<Text[]>> tooltipSupplier) {
+    public DoubleListBuilder setTooltipSupplier(Function<List<Double>, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public DoubleListBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public DoubleListBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
     
-    public DoubleListBuilder setTooltip(Optional<Text[]> tooltip) {
+    public DoubleListBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
     
-    public DoubleListBuilder setTooltip(Text... tooltip) {
+    public DoubleListBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }

+ 87 - 88
src/main/java/me/shedaniel/clothconfig2/impl/builders/DropdownMenuBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DropdownMenuBuilder.java

@@ -7,19 +7,18 @@ import me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry.SelectionCellCreat
 import me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry.SelectionTopCellElement;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.block.Block;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.item.ItemRenderer;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.item.Items;
-import net.minecraft.text.LiteralText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
-import net.minecraft.util.registry.Registry;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.entity.ItemRenderer;
+import net.minecraft.core.Registry;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextComponent;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.Items;
+import net.minecraft.world.level.block.Block;
 import org.jetbrains.annotations.NotNull;
-
+import com.mojang.blaze3d.vertex.PoseStack;
 import java.util.Collections;
 import java.util.Objects;
 import java.util.Optional;
@@ -31,12 +30,12 @@ import java.util.function.Supplier;
 public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>> {
     protected SelectionTopCellElement<T> topCellElement;
     protected SelectionCellCreator<T> cellCreator;
-    protected Function<T, Optional<Text[]>> tooltipSupplier = str -> Optional.empty();
+    protected Function<T, Optional<Component[]>> tooltipSupplier = str -> Optional.empty();
     protected Consumer<T> saveConsumer = null;
     protected Iterable<T> selections = Collections.emptyList();
     protected boolean suggestionMode = true;
     
-    public DropdownMenuBuilder(Text resetButtonKey, Text fieldNameKey, SelectionTopCellElement<T> topCellElement, SelectionCellCreator<T> cellCreator) {
+    public DropdownMenuBuilder(Component resetButtonKey, Component fieldNameKey, SelectionTopCellElement<T> topCellElement, SelectionCellCreator<T> cellCreator) {
         super(resetButtonKey, fieldNameKey);
         this.topCellElement = Objects.requireNonNull(topCellElement);
         this.cellCreator = Objects.requireNonNull(cellCreator);
@@ -62,22 +61,22 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
         return this;
     }
     
-    public DropdownMenuBuilder<T> setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public DropdownMenuBuilder<T> setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = str -> tooltipSupplier.get();
         return this;
     }
     
-    public DropdownMenuBuilder<T> setTooltipSupplier(Function<T, Optional<Text[]>> tooltipSupplier) {
+    public DropdownMenuBuilder<T> setTooltipSupplier(Function<T, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public DropdownMenuBuilder<T> setTooltip(Optional<Text[]> tooltip) {
+    public DropdownMenuBuilder<T> setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = str -> tooltip;
         return this;
     }
     
-    public DropdownMenuBuilder<T> setTooltip(Text... tooltip) {
+    public DropdownMenuBuilder<T> setTooltip(Component... tooltip) {
         this.tooltipSupplier = str -> Optional.ofNullable(tooltip);
         return this;
     }
@@ -87,7 +86,7 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
         return this;
     }
     
-    public DropdownMenuBuilder<T> setErrorSupplier(Function<T, Optional<Text>> errorSupplier) {
+    public DropdownMenuBuilder<T> setErrorSupplier(Function<T, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -113,26 +112,26 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
     }
     
     public static class TopCellElementBuilder {
-        public static final Function<String, Identifier> IDENTIFIER_FUNCTION = str -> {
+        public static final Function<String, ResourceLocation> IDENTIFIER_FUNCTION = str -> {
             try {
-                return new Identifier(str);
+                return new ResourceLocation(str);
             } catch (NumberFormatException e) {
                 return null;
             }
         };
-        public static final Function<String, Identifier> ITEM_IDENTIFIER_FUNCTION = str -> {
+        public static final Function<String, ResourceLocation> ITEM_IDENTIFIER_FUNCTION = str -> {
             try {
-                Identifier identifier = new Identifier(str);
-                if (Registry.ITEM.getOrEmpty(identifier).isPresent())
+                ResourceLocation identifier = new ResourceLocation(str);
+                if (Registry.ITEM.getOptional(identifier).isPresent())
                     return identifier;
             } catch (Exception ignored) {
             }
             return null;
         };
-        public static final Function<String, Identifier> BLOCK_IDENTIFIER_FUNCTION = str -> {
+        public static final Function<String, ResourceLocation> BLOCK_IDENTIFIER_FUNCTION = str -> {
             try {
-                Identifier identifier = new Identifier(str);
-                if (Registry.BLOCK.getOrEmpty(identifier).isPresent())
+                ResourceLocation identifier = new ResourceLocation(str);
+                if (Registry.BLOCK.getOptional(identifier).isPresent())
                     return identifier;
             } catch (Exception ignored) {
             }
@@ -140,14 +139,14 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
         };
         public static final Function<String, Item> ITEM_FUNCTION = str -> {
             try {
-                return Registry.ITEM.getOrEmpty(new Identifier(str)).orElse(null);
+                return Registry.ITEM.getOptional(new ResourceLocation(str)).orElse(null);
             } catch (Exception ignored) {
             }
             return null;
         };
         public static final Function<String, Block> BLOCK_FUNCTION = str -> {
             try {
-                return Registry.BLOCK.getOrEmpty(new Identifier(str)).orElse(null);
+                return Registry.BLOCK.getOptional(new ResourceLocation(str)).orElse(null);
             } catch (Exception ignored) {
             }
             return null;
@@ -155,77 +154,77 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
         private static final ItemStack BARRIER = new ItemStack(Items.BARRIER);
         
         public static <T> SelectionTopCellElement<T> of(T value, Function<String, T> toObjectFunction) {
-            return of(value, toObjectFunction, t -> new LiteralText(t.toString()));
+            return of(value, toObjectFunction, t -> new TextComponent(t.toString()));
         }
         
-        public static <T> SelectionTopCellElement<T> of(T value, Function<String, T> toObjectFunction, Function<T, Text> toTextFunction) {
+        public static <T> SelectionTopCellElement<T> of(T value, Function<String, T> toObjectFunction, Function<T, Component> toTextFunction) {
             return new DefaultSelectionTopCellElement<>(value, toObjectFunction, toTextFunction);
         }
         
-        public static SelectionTopCellElement<Identifier> ofItemIdentifier(Item item) {
-            return new DefaultSelectionTopCellElement<Identifier>(Registry.ITEM.getId(item), ITEM_IDENTIFIER_FUNCTION, identifier -> new LiteralText(identifier.toString())) {
+        public static SelectionTopCellElement<ResourceLocation> ofItemIdentifier(Item item) {
+            return new DefaultSelectionTopCellElement<ResourceLocation>(Registry.ITEM.getKey(item), ITEM_IDENTIFIER_FUNCTION, identifier -> new TextComponent(identifier.toString())) {
                 @Override
-                public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+                public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
                     textFieldWidget.x = x + 4;
                     textFieldWidget.y = y + 6;
                     textFieldWidget.setWidth(width - 4 - 20);
                     textFieldWidget.setEditable(getParent().isEditable());
-                    textFieldWidget.setEditableColor(getPreferredTextColor());
+                    textFieldWidget.setTextColor(getPreferredTextColor());
                     textFieldWidget.render(matrices, mouseX, mouseY, delta);
-                    ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
+                    ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
                     ItemStack stack = hasConfigError() ? BARRIER : new ItemStack(Registry.ITEM.get(getValue()));
-                    itemRenderer.renderGuiItemIcon(stack, x + width - 18, y + 2);
+                    itemRenderer.renderGuiItem(stack, x + width - 18, y + 2);
                 }
             };
         }
         
-        public static SelectionTopCellElement<Identifier> ofBlockIdentifier(Block block) {
-            return new DefaultSelectionTopCellElement<Identifier>(Registry.BLOCK.getId(block), BLOCK_IDENTIFIER_FUNCTION, identifier -> new LiteralText(identifier.toString())) {
+        public static SelectionTopCellElement<ResourceLocation> ofBlockIdentifier(Block block) {
+            return new DefaultSelectionTopCellElement<ResourceLocation>(Registry.BLOCK.getKey(block), BLOCK_IDENTIFIER_FUNCTION, identifier -> new TextComponent(identifier.toString())) {
                 @Override
-                public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+                public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
                     textFieldWidget.x = x + 4;
                     textFieldWidget.y = y + 6;
                     textFieldWidget.setWidth(width - 4 - 20);
                     textFieldWidget.setEditable(getParent().isEditable());
-                    textFieldWidget.setEditableColor(getPreferredTextColor());
+                    textFieldWidget.setTextColor(getPreferredTextColor());
                     textFieldWidget.render(matrices, mouseX, mouseY, delta);
-                    ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
+                    ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
                     ItemStack stack = hasConfigError() ? BARRIER : new ItemStack(Registry.BLOCK.get(getValue()));
-                    itemRenderer.renderGuiItemIcon(stack, x + width - 18, y + 2);
+                    itemRenderer.renderGuiItem(stack, x + width - 18, y + 2);
                 }
             };
         }
         
         public static SelectionTopCellElement<Item> ofItemObject(Item item) {
-            return new DefaultSelectionTopCellElement<Item>(item, ITEM_FUNCTION, i -> new LiteralText(Registry.ITEM.getId(i).toString())) {
+            return new DefaultSelectionTopCellElement<Item>(item, ITEM_FUNCTION, i -> new TextComponent(Registry.ITEM.getKey(i).toString())) {
                 @Override
-                public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+                public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
                     textFieldWidget.x = x + 4;
                     textFieldWidget.y = y + 6;
                     textFieldWidget.setWidth(width - 4 - 20);
                     textFieldWidget.setEditable(getParent().isEditable());
-                    textFieldWidget.setEditableColor(getPreferredTextColor());
+                    textFieldWidget.setTextColor(getPreferredTextColor());
                     textFieldWidget.render(matrices, mouseX, mouseY, delta);
-                    ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
+                    ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
                     ItemStack stack = hasConfigError() ? BARRIER : new ItemStack(getValue());
-                    itemRenderer.renderGuiItemIcon(stack, x + width - 18, y + 2);
+                    itemRenderer.renderGuiItem(stack, x + width - 18, y + 2);
                 }
             };
         }
         
         public static SelectionTopCellElement<Block> ofBlockObject(Block block) {
-            return new DefaultSelectionTopCellElement<Block>(block, BLOCK_FUNCTION, i -> new LiteralText(Registry.BLOCK.getId(i).toString())) {
+            return new DefaultSelectionTopCellElement<Block>(block, BLOCK_FUNCTION, i -> new TextComponent(Registry.BLOCK.getKey(i).toString())) {
                 @Override
-                public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+                public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
                     textFieldWidget.x = x + 4;
                     textFieldWidget.y = y + 6;
                     textFieldWidget.setWidth(width - 4 - 20);
                     textFieldWidget.setEditable(getParent().isEditable());
-                    textFieldWidget.setEditableColor(getPreferredTextColor());
+                    textFieldWidget.setTextColor(getPreferredTextColor());
                     textFieldWidget.render(matrices, mouseX, mouseY, delta);
-                    ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
+                    ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
                     ItemStack stack = hasConfigError() ? BARRIER : new ItemStack(getValue());
-                    itemRenderer.renderGuiItemIcon(stack, x + width - 18, y + 2);
+                    itemRenderer.renderGuiItem(stack, x + width - 18, y + 2);
                 }
             };
         }
@@ -236,7 +235,7 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
             return new DefaultSelectionCellCreator<>();
         }
         
-        public static <T> SelectionCellCreator<T> of(Function<T, Text> toTextFunction) {
+        public static <T> SelectionCellCreator<T> of(Function<T, Component> toTextFunction) {
             return new DefaultSelectionCellCreator<>(toTextFunction);
         }
         
@@ -249,7 +248,7 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
             };
         }
         
-        public static <T> SelectionCellCreator<T> ofWidth(int cellWidth, Function<T, Text> toTextFunction) {
+        public static <T> SelectionCellCreator<T> ofWidth(int cellWidth, Function<T, Component> toTextFunction) {
             return new DefaultSelectionCellCreator<T>(toTextFunction) {
                 @Override
                 public int getCellWidth() {
@@ -267,7 +266,7 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
             };
         }
         
-        public static <T> SelectionCellCreator<T> ofCellCount(int maxItems, Function<T, Text> toTextFunction) {
+        public static <T> SelectionCellCreator<T> ofCellCount(int maxItems, Function<T, Component> toTextFunction) {
             return new DefaultSelectionCellCreator<T>(toTextFunction) {
                 @Override
                 public int getDropBoxMaxHeight() {
@@ -290,7 +289,7 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
             };
         }
         
-        public static <T> SelectionCellCreator<T> of(int cellWidth, int maxItems, Function<T, Text> toTextFunction) {
+        public static <T> SelectionCellCreator<T> of(int cellWidth, int maxItems, Function<T, Component> toTextFunction) {
             return new DefaultSelectionCellCreator<T>(toTextFunction) {
                 @Override
                 public int getCellWidth() {
@@ -323,7 +322,7 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
             };
         }
         
-        public static <T> SelectionCellCreator<T> of(int cellHeight, int cellWidth, int maxItems, Function<T, Text> toTextFunction) {
+        public static <T> SelectionCellCreator<T> of(int cellHeight, int cellWidth, int maxItems, Function<T, Component> toTextFunction) {
             return new DefaultSelectionCellCreator<T>(toTextFunction) {
                 @Override
                 public int getCellHeight() {
@@ -342,22 +341,22 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
             };
         }
         
-        public static SelectionCellCreator<Identifier> ofItemIdentifier() {
+        public static SelectionCellCreator<ResourceLocation> ofItemIdentifier() {
             return ofItemIdentifier(20, 146, 7);
         }
         
-        public static SelectionCellCreator<Identifier> ofItemIdentifier(int maxItems) {
+        public static SelectionCellCreator<ResourceLocation> ofItemIdentifier(int maxItems) {
             return ofItemIdentifier(20, 146, maxItems);
         }
         
-        public static SelectionCellCreator<Identifier> ofItemIdentifier(int cellHeight, int cellWidth, int maxItems) {
-            return new DefaultSelectionCellCreator<Identifier>() {
+        public static SelectionCellCreator<ResourceLocation> ofItemIdentifier(int cellHeight, int cellWidth, int maxItems) {
+            return new DefaultSelectionCellCreator<ResourceLocation>() {
                 @Override
-                public DropdownBoxEntry.SelectionCellElement<Identifier> create(Identifier selection) {
+                public DropdownBoxEntry.SelectionCellElement<ResourceLocation> create(ResourceLocation selection) {
                     ItemStack s = new ItemStack(Registry.ITEM.get(selection));
-                    return new DropdownBoxEntry.DefaultSelectionCellElement<Identifier>(selection, toTextFunction) {
+                    return new DropdownBoxEntry.DefaultSelectionCellElement<ResourceLocation>(selection, toTextFunction) {
                         @Override
-                        public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+                        public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
                             rendering = true;
                             this.x = x;
                             this.y = y;
@@ -366,9 +365,9 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
                             boolean b = mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
                             if (b)
                                 fill(matrices, x + 1, y + 1, x + width - 1, y + height - 1, -15132391);
-                            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, toTextFunction.apply(r).method_30937(), x + 6 + 18, y + 6, b ? 16777215 : 8947848);
-                            ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
-                            itemRenderer.renderGuiItemIcon(s, x + 4, y + 2);
+                            Minecraft.getInstance().font.drawShadow(matrices, toTextFunction.apply(r).getVisualOrderText(), x + 6 + 18, y + 6, b ? 16777215 : 8947848);
+                            ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
+                            itemRenderer.renderGuiItem(s, x + 4, y + 2);
                         }
                     };
                 }
@@ -391,22 +390,22 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
         }
         
         
-        public static SelectionCellCreator<Identifier> ofBlockIdentifier() {
+        public static SelectionCellCreator<ResourceLocation> ofBlockIdentifier() {
             return ofBlockIdentifier(20, 146, 7);
         }
         
-        public static SelectionCellCreator<Identifier> ofBlockIdentifier(int maxItems) {
+        public static SelectionCellCreator<ResourceLocation> ofBlockIdentifier(int maxItems) {
             return ofBlockIdentifier(20, 146, maxItems);
         }
         
-        public static SelectionCellCreator<Identifier> ofBlockIdentifier(int cellHeight, int cellWidth, int maxItems) {
-            return new DefaultSelectionCellCreator<Identifier>() {
+        public static SelectionCellCreator<ResourceLocation> ofBlockIdentifier(int cellHeight, int cellWidth, int maxItems) {
+            return new DefaultSelectionCellCreator<ResourceLocation>() {
                 @Override
-                public DropdownBoxEntry.SelectionCellElement<Identifier> create(Identifier selection) {
+                public DropdownBoxEntry.SelectionCellElement<ResourceLocation> create(ResourceLocation selection) {
                     ItemStack s = new ItemStack(Registry.BLOCK.get(selection));
-                    return new DropdownBoxEntry.DefaultSelectionCellElement<Identifier>(selection, toTextFunction) {
+                    return new DropdownBoxEntry.DefaultSelectionCellElement<ResourceLocation>(selection, toTextFunction) {
                         @Override
-                        public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+                        public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
                             rendering = true;
                             this.x = x;
                             this.y = y;
@@ -415,9 +414,9 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
                             boolean b = mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
                             if (b)
                                 fill(matrices, x + 1, y + 1, x + width - 1, y + height - 1, -15132391);
-                            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, toTextFunction.apply(r).method_30937(), x + 6 + 18, y + 6, b ? 16777215 : 8947848);
-                            ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
-                            itemRenderer.renderGuiItemIcon(s, x + 4, y + 2);
+                            Minecraft.getInstance().font.drawShadow(matrices, toTextFunction.apply(r).getVisualOrderText(), x + 6 + 18, y + 6, b ? 16777215 : 8947848);
+                            ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
+                            itemRenderer.renderGuiItem(s, x + 4, y + 2);
                         }
                     };
                 }
@@ -448,13 +447,13 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
         }
         
         public static SelectionCellCreator<Item> ofItemObject(int cellHeight, int cellWidth, int maxItems) {
-            return new DefaultSelectionCellCreator<Item>(i -> new LiteralText(Registry.ITEM.getId(i).toString())) {
+            return new DefaultSelectionCellCreator<Item>(i -> new TextComponent(Registry.ITEM.getKey(i).toString())) {
                 @Override
                 public DropdownBoxEntry.SelectionCellElement<Item> create(Item selection) {
                     ItemStack s = new ItemStack(selection);
                     return new DropdownBoxEntry.DefaultSelectionCellElement<Item>(selection, toTextFunction) {
                         @Override
-                        public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+                        public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
                             rendering = true;
                             this.x = x;
                             this.y = y;
@@ -463,9 +462,9 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
                             boolean b = mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
                             if (b)
                                 fill(matrices, x + 1, y + 1, x + width - 1, y + height - 1, -15132391);
-                            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, toTextFunction.apply(r).method_30937(), x + 6 + 18, y + 6, b ? 16777215 : 8947848);
-                            ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
-                            itemRenderer.renderGuiItemIcon(s, x + 4, y + 2);
+                            Minecraft.getInstance().font.drawShadow(matrices, toTextFunction.apply(r).getVisualOrderText(), x + 6 + 18, y + 6, b ? 16777215 : 8947848);
+                            ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
+                            itemRenderer.renderGuiItem(s, x + 4, y + 2);
                         }
                     };
                 }
@@ -496,13 +495,13 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
         }
         
         public static SelectionCellCreator<Block> ofBlockObject(int cellHeight, int cellWidth, int maxItems) {
-            return new DefaultSelectionCellCreator<Block>(i -> new LiteralText(Registry.BLOCK.getId(i).toString())) {
+            return new DefaultSelectionCellCreator<Block>(i -> new TextComponent(Registry.BLOCK.getKey(i).toString())) {
                 @Override
                 public DropdownBoxEntry.SelectionCellElement<Block> create(Block selection) {
                     ItemStack s = new ItemStack(selection);
                     return new DropdownBoxEntry.DefaultSelectionCellElement<Block>(selection, toTextFunction) {
                         @Override
-                        public void render(MatrixStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
+                        public void render(PoseStack matrices, int mouseX, int mouseY, int x, int y, int width, int height, float delta) {
                             rendering = true;
                             this.x = x;
                             this.y = y;
@@ -511,9 +510,9 @@ public class DropdownMenuBuilder<T> extends FieldBuilder<T, DropdownBoxEntry<T>>
                             boolean b = mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
                             if (b)
                                 fill(matrices, x + 1, y + 1, x + width - 1, y + height - 1, -15132391);
-                            MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, toTextFunction.apply(r).method_30937(), x + 6 + 18, y + 6, b ? 16777215 : 8947848);
-                            ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
-                            itemRenderer.renderGuiItemIcon(s, x + 4, y + 2);
+                            Minecraft.getInstance().font.drawShadow(matrices, toTextFunction.apply(r).getVisualOrderText(), x + 6 + 18, y + 6, b ? 16777215 : 8947848);
+                            ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
+                            itemRenderer.renderGuiItem(s, x + 4, y + 2);
                         }
                     };
                 }

+ 10 - 10
src/main/java/me/shedaniel/clothconfig2/impl/builders/EnumSelectorBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/EnumSelectorBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.EnumListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Objects;
@@ -16,12 +16,12 @@ import java.util.function.Supplier;
 public class EnumSelectorBuilder<T extends Enum<?>> extends FieldBuilder<T, EnumListEntry<T>> {
     
     private Consumer<T> saveConsumer = null;
-    private Function<T, Optional<Text[]>> tooltipSupplier = e -> Optional.empty();
+    private Function<T, Optional<Component[]>> tooltipSupplier = e -> Optional.empty();
     private final T value;
     private final Class<T> clazz;
-    private Function<Enum, Text> enumNameProvider = EnumListEntry.DEFAULT_NAME_PROVIDER;
+    private Function<Enum, Component> enumNameProvider = EnumListEntry.DEFAULT_NAME_PROVIDER;
     
-    public EnumSelectorBuilder(Text resetButtonKey, Text fieldNameKey, Class<T> clazz, T value) {
+    public EnumSelectorBuilder(Component resetButtonKey, Component fieldNameKey, Class<T> clazz, T value) {
         super(resetButtonKey, fieldNameKey);
         Objects.requireNonNull(clazz);
         Objects.requireNonNull(value);
@@ -29,7 +29,7 @@ public class EnumSelectorBuilder<T extends Enum<?>> extends FieldBuilder<T, Enum
         this.clazz = clazz;
     }
     
-    public EnumSelectorBuilder<T> setErrorSupplier(Function<T, Optional<Text>> errorSupplier) {
+    public EnumSelectorBuilder<T> setErrorSupplier(Function<T, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -55,27 +55,27 @@ public class EnumSelectorBuilder<T extends Enum<?>> extends FieldBuilder<T, Enum
         return this;
     }
     
-    public EnumSelectorBuilder<T> setTooltipSupplier(Function<T, Optional<Text[]>> tooltipSupplier) {
+    public EnumSelectorBuilder<T> setTooltipSupplier(Function<T, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public EnumSelectorBuilder<T> setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public EnumSelectorBuilder<T> setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = e -> tooltipSupplier.get();
         return this;
     }
     
-    public EnumSelectorBuilder<T> setTooltip(Optional<Text[]> tooltip) {
+    public EnumSelectorBuilder<T> setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = e -> tooltip;
         return this;
     }
     
-    public EnumSelectorBuilder<T> setTooltip(Text... tooltip) {
+    public EnumSelectorBuilder<T> setTooltip(Component... tooltip) {
         this.tooltipSupplier = e -> Optional.ofNullable(tooltip);
         return this;
     }
     
-    public EnumSelectorBuilder<T> setEnumNameProvider(Function<Enum, Text> enumNameProvider) {
+    public EnumSelectorBuilder<T> setEnumNameProvider(Function<Enum, Component> enumNameProvider) {
         Objects.requireNonNull(enumNameProvider);
         this.enumNameProvider = enumNameProvider;
         return this;

+ 7 - 7
src/main/java/me/shedaniel/clothconfig2/impl/builders/FieldBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/FieldBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -14,13 +14,13 @@ import java.util.function.Supplier;
 
 @Environment(EnvType.CLIENT)
 public abstract class FieldBuilder<T, A extends AbstractConfigListEntry> {
-    @NotNull private final Text fieldNameKey;
-    @NotNull private final Text resetButtonKey;
+    @NotNull private final Component fieldNameKey;
+    @NotNull private final Component resetButtonKey;
     protected boolean requireRestart = false;
     @Nullable protected Supplier<T> defaultValue = null;
-    @Nullable protected Function<T, Optional<Text>> errorSupplier;
+    @Nullable protected Function<T, Optional<Component>> errorSupplier;
     
-    protected FieldBuilder(Text resetButtonKey, Text fieldNameKey) {
+    protected FieldBuilder(Component resetButtonKey, Component fieldNameKey) {
         this.resetButtonKey = Objects.requireNonNull(resetButtonKey);
         this.fieldNameKey = Objects.requireNonNull(fieldNameKey);
     }
@@ -40,12 +40,12 @@ public abstract class FieldBuilder<T, A extends AbstractConfigListEntry> {
     public abstract A build();
     
     @NotNull
-    public final Text getFieldNameKey() {
+    public final Component getFieldNameKey() {
         return fieldNameKey;
     }
     
     @NotNull
-    public final Text getResetButtonKey() {
+    public final Component getResetButtonKey() {
         return resetButtonKey;
     }
     

+ 8 - 8
src/main/java/me/shedaniel/clothconfig2/impl/builders/FloatFieldBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/FloatFieldBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.FloatListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Optional;
@@ -15,16 +15,16 @@ import java.util.function.Supplier;
 public class FloatFieldBuilder extends FieldBuilder<Float, FloatListEntry> {
     
     private Consumer<Float> saveConsumer = null;
-    private Function<Float, Optional<Text[]>> tooltipSupplier = f -> Optional.empty();
+    private Function<Float, Optional<Component[]>> tooltipSupplier = f -> Optional.empty();
     private final float value;
     private Float min = null, max = null;
     
-    public FloatFieldBuilder(Text resetButtonKey, Text fieldNameKey, float value) {
+    public FloatFieldBuilder(Component resetButtonKey, Component fieldNameKey, float value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public FloatFieldBuilder setErrorSupplier(Function<Float, Optional<Text>> errorSupplier) {
+    public FloatFieldBuilder setErrorSupplier(Function<Float, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -49,22 +49,22 @@ public class FloatFieldBuilder extends FieldBuilder<Float, FloatListEntry> {
         return this;
     }
     
-    public FloatFieldBuilder setTooltipSupplier(Function<Float, Optional<Text[]>> tooltipSupplier) {
+    public FloatFieldBuilder setTooltipSupplier(Function<Float, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public FloatFieldBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public FloatFieldBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = f -> tooltipSupplier.get();
         return this;
     }
     
-    public FloatFieldBuilder setTooltip(Optional<Text[]> tooltip) {
+    public FloatFieldBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = f -> tooltip;
         return this;
     }
     
-    public FloatFieldBuilder setTooltip(Text... tooltip) {
+    public FloatFieldBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = f -> Optional.ofNullable(tooltip);
         return this;
     }

+ 15 - 16
src/main/java/me/shedaniel/clothconfig2/impl/builders/FloatListBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/FloatListBuilder.java

@@ -3,9 +3,8 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.FloatListListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.resource.language.I18n;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
@@ -18,26 +17,26 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class FloatListBuilder extends FieldBuilder<List<Float>, FloatListListEntry> {
     
-    protected Function<Float, Optional<Text>> cellErrorSupplier;
+    protected Function<Float, Optional<Component>> cellErrorSupplier;
     private Consumer<List<Float>> saveConsumer = null;
-    private Function<List<Float>, Optional<Text[]>> tooltipSupplier = list -> Optional.empty();
+    private Function<List<Float>, Optional<Component[]>> tooltipSupplier = list -> Optional.empty();
     private final List<Float> value;
     private boolean expanded = false;
     private Float min = null, max = null;
     private Function<FloatListListEntry, FloatListListEntry.FloatListCell> createNewInstance;
-    private Text addTooltip = new TranslatableText("text.cloth-config.list.add"), removeTooltip = new TranslatableText("text.cloth-config.list.remove");
+    private Component addTooltip = new TranslatableComponent("text.cloth-config.list.add"), removeTooltip = new TranslatableComponent("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
     
-    public FloatListBuilder(Text resetButtonKey, Text fieldNameKey, List<Float> value) {
+    public FloatListBuilder(Component resetButtonKey, Component fieldNameKey, List<Float> value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public Function<Float, Optional<Text>> getCellErrorSupplier() {
+    public Function<Float, Optional<Component>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
     
-    public FloatListBuilder setCellErrorSupplier(Function<Float, Optional<Text>> cellErrorSupplier) {
+    public FloatListBuilder setCellErrorSupplier(Function<Float, Optional<Component>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
         return this;
     }
@@ -47,7 +46,7 @@ public class FloatListBuilder extends FieldBuilder<List<Float>, FloatListListEnt
         return this;
     }
     
-    public FloatListBuilder setErrorSupplier(Function<List<Float>, Optional<Text>> errorSupplier) {
+    public FloatListBuilder setErrorSupplier(Function<List<Float>, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -57,12 +56,12 @@ public class FloatListBuilder extends FieldBuilder<List<Float>, FloatListListEnt
         return this;
     }
     
-    public FloatListBuilder setAddButtonTooltip(Text addTooltip) {
+    public FloatListBuilder setAddButtonTooltip(Component addTooltip) {
         this.addTooltip = addTooltip;
         return this;
     }
     
-    public FloatListBuilder setRemoveButtonTooltip(Text removeTooltip) {
+    public FloatListBuilder setRemoveButtonTooltip(Component removeTooltip) {
         this.removeTooltip = removeTooltip;
         return this;
     }
@@ -123,22 +122,22 @@ public class FloatListBuilder extends FieldBuilder<List<Float>, FloatListListEnt
         return this;
     }
     
-    public FloatListBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public FloatListBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
     
-    public FloatListBuilder setTooltipSupplier(Function<List<Float>, Optional<Text[]>> tooltipSupplier) {
+    public FloatListBuilder setTooltipSupplier(Function<List<Float>, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public FloatListBuilder setTooltip(Optional<Text[]> tooltip) {
+    public FloatListBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
     
-    public FloatListBuilder setTooltip(Text... tooltip) {
+    public FloatListBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }

+ 8 - 8
src/main/java/me/shedaniel/clothconfig2/impl/builders/IntFieldBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/IntFieldBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.IntegerListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Optional;
@@ -15,11 +15,11 @@ import java.util.function.Supplier;
 public class IntFieldBuilder extends FieldBuilder<Integer, IntegerListEntry> {
     
     private Consumer<Integer> saveConsumer = null;
-    private Function<Integer, Optional<Text[]>> tooltipSupplier = i -> Optional.empty();
+    private Function<Integer, Optional<Component[]>> tooltipSupplier = i -> Optional.empty();
     private final int value;
     private Integer min = null, max = null;
     
-    public IntFieldBuilder(Text resetButtonKey, Text fieldNameKey, int value) {
+    public IntFieldBuilder(Component resetButtonKey, Component fieldNameKey, int value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
@@ -29,7 +29,7 @@ public class IntFieldBuilder extends FieldBuilder<Integer, IntegerListEntry> {
         return this;
     }
     
-    public IntFieldBuilder setErrorSupplier(Function<Integer, Optional<Text>> errorSupplier) {
+    public IntFieldBuilder setErrorSupplier(Function<Integer, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -49,22 +49,22 @@ public class IntFieldBuilder extends FieldBuilder<Integer, IntegerListEntry> {
         return this;
     }
     
-    public IntFieldBuilder setTooltipSupplier(Function<Integer, Optional<Text[]>> tooltipSupplier) {
+    public IntFieldBuilder setTooltipSupplier(Function<Integer, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public IntFieldBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public IntFieldBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = i -> tooltipSupplier.get();
         return this;
     }
     
-    public IntFieldBuilder setTooltip(Optional<Text[]> tooltip) {
+    public IntFieldBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = i -> tooltip;
         return this;
     }
     
-    public IntFieldBuilder setTooltip(Text... tooltip) {
+    public IntFieldBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = i -> Optional.ofNullable(tooltip);
         return this;
     }

+ 15 - 15
src/main/java/me/shedaniel/clothconfig2/impl/builders/IntListBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/IntListBuilder.java

@@ -3,8 +3,8 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.IntegerListListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
@@ -17,31 +17,31 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class IntListBuilder extends FieldBuilder<List<Integer>, IntegerListListEntry> {
     
-    protected Function<Integer, Optional<Text>> cellErrorSupplier;
+    protected Function<Integer, Optional<Component>> cellErrorSupplier;
     private Consumer<List<Integer>> saveConsumer = null;
-    private Function<List<Integer>, Optional<Text[]>> tooltipSupplier = list -> Optional.empty();
+    private Function<List<Integer>, Optional<Component[]>> tooltipSupplier = list -> Optional.empty();
     private final List<Integer> value;
     private boolean expanded = false;
     private Integer min = null, max = null;
     private Function<IntegerListListEntry, IntegerListListEntry.IntegerListCell> createNewInstance;
-    private Text addTooltip = new TranslatableText("text.cloth-config.list.add"), removeTooltip = new TranslatableText("text.cloth-config.list.remove");
+    private Component addTooltip = new TranslatableComponent("text.cloth-config.list.add"), removeTooltip = new TranslatableComponent("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
     
-    public IntListBuilder(Text resetButtonKey, Text fieldNameKey, List<Integer> value) {
+    public IntListBuilder(Component resetButtonKey, Component fieldNameKey, List<Integer> value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public Function<Integer, Optional<Text>> getCellErrorSupplier() {
+    public Function<Integer, Optional<Component>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
     
-    public IntListBuilder setCellErrorSupplier(Function<Integer, Optional<Text>> cellErrorSupplier) {
+    public IntListBuilder setCellErrorSupplier(Function<Integer, Optional<Component>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
         return this;
     }
     
-    public IntListBuilder setErrorSupplier(Function<List<Integer>, Optional<Text>> errorSupplier) {
+    public IntListBuilder setErrorSupplier(Function<List<Integer>, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -56,12 +56,12 @@ public class IntListBuilder extends FieldBuilder<List<Integer>, IntegerListListE
         return this;
     }
     
-    public IntListBuilder setAddButtonTooltip(Text addTooltip) {
+    public IntListBuilder setAddButtonTooltip(Component addTooltip) {
         this.addTooltip = addTooltip;
         return this;
     }
     
-    public IntListBuilder setRemoveButtonTooltip(Text removeTooltip) {
+    public IntListBuilder setRemoveButtonTooltip(Component removeTooltip) {
         this.removeTooltip = removeTooltip;
         return this;
     }
@@ -122,22 +122,22 @@ public class IntListBuilder extends FieldBuilder<List<Integer>, IntegerListListE
         return this;
     }
     
-    public IntListBuilder setTooltipSupplier(Function<List<Integer>, Optional<Text[]>> tooltipSupplier) {
+    public IntListBuilder setTooltipSupplier(Function<List<Integer>, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public IntListBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public IntListBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
     
-    public IntListBuilder setTooltip(Optional<Text[]> tooltip) {
+    public IntListBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
     
-    public IntListBuilder setTooltip(Text... tooltip) {
+    public IntListBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }

+ 10 - 10
src/main/java/me/shedaniel/clothconfig2/impl/builders/IntSliderBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/IntSliderBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.IntegerSliderEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Optional;
@@ -15,20 +15,20 @@ import java.util.function.Supplier;
 public class IntSliderBuilder extends FieldBuilder<Integer, IntegerSliderEntry> {
     
     private Consumer<Integer> saveConsumer = null;
-    private Function<Integer, Optional<Text[]>> tooltipSupplier = i -> Optional.empty();
+    private Function<Integer, Optional<Component[]>> tooltipSupplier = i -> Optional.empty();
     private final int value;
     private int max;
     private int min;
-    private Function<Integer, Text> textGetter = null;
+    private Function<Integer, Component> textGetter = null;
     
-    public IntSliderBuilder(Text resetButtonKey, Text fieldNameKey, int value, int min, int max) {
+    public IntSliderBuilder(Component resetButtonKey, Component fieldNameKey, int value, int min, int max) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
         this.max = max;
         this.min = min;
     }
     
-    public IntSliderBuilder setErrorSupplier(Function<Integer, Optional<Text>> errorSupplier) {
+    public IntSliderBuilder setErrorSupplier(Function<Integer, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -38,7 +38,7 @@ public class IntSliderBuilder extends FieldBuilder<Integer, IntegerSliderEntry>
         return this;
     }
     
-    public IntSliderBuilder setTextGetter(Function<Integer, Text> textGetter) {
+    public IntSliderBuilder setTextGetter(Function<Integer, Component> textGetter) {
         this.textGetter = textGetter;
         return this;
     }
@@ -58,22 +58,22 @@ public class IntSliderBuilder extends FieldBuilder<Integer, IntegerSliderEntry>
         return this;
     }
     
-    public IntSliderBuilder setTooltipSupplier(Function<Integer, Optional<Text[]>> tooltipSupplier) {
+    public IntSliderBuilder setTooltipSupplier(Function<Integer, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public IntSliderBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public IntSliderBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = i -> tooltipSupplier.get();
         return this;
     }
     
-    public IntSliderBuilder setTooltip(Optional<Text[]> tooltip) {
+    public IntSliderBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = i -> tooltip;
         return this;
     }
     
-    public IntSliderBuilder setTooltip(Text... tooltip) {
+    public IntSliderBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = i -> Optional.ofNullable(tooltip);
         return this;
     }

+ 14 - 15
src/main/java/me/shedaniel/clothconfig2/impl/builders/KeyCodeBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/KeyCodeBuilder.java

@@ -5,11 +5,10 @@ import me.shedaniel.clothconfig2.api.ModifierKeyCode;
 import me.shedaniel.clothconfig2.gui.entries.KeyCodeEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.util.InputUtil;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-
+import com.mojang.blaze3d.platform.InputConstants;
 import java.util.Optional;
 import java.util.function.Consumer;
 import java.util.function.Function;
@@ -19,11 +18,11 @@ import java.util.function.Supplier;
 public class KeyCodeBuilder extends FieldBuilder<ModifierKeyCode, KeyCodeEntry> {
     
     @Nullable private Consumer<ModifierKeyCode> saveConsumer = null;
-    @NotNull private Function<ModifierKeyCode, Optional<Text[]>> tooltipSupplier = bool -> Optional.empty();
+    @NotNull private Function<ModifierKeyCode, Optional<Component[]>> tooltipSupplier = bool -> Optional.empty();
     private final ModifierKeyCode value;
     private boolean allowKey = true, allowMouse = true, allowModifiers = true;
     
-    public KeyCodeBuilder(Text resetButtonKey, Text fieldNameKey, ModifierKeyCode value) {
+    public KeyCodeBuilder(Component resetButtonKey, Component fieldNameKey, ModifierKeyCode value) {
         super(resetButtonKey, fieldNameKey);
         this.value = ModifierKeyCode.copyOf(value);
     }
@@ -49,11 +48,11 @@ public class KeyCodeBuilder extends FieldBuilder<ModifierKeyCode, KeyCodeEntry>
         return this;
     }
     
-    public KeyCodeBuilder setErrorSupplier(@Nullable Function<InputUtil.KeyCode, Optional<Text>> errorSupplier) {
+    public KeyCodeBuilder setErrorSupplier(@Nullable Function<InputConstants.Key, Optional<Component>> errorSupplier) {
         return setModifierErrorSupplier(keyCode -> errorSupplier.apply(keyCode.getKeyCode()));
     }
     
-    public KeyCodeBuilder setModifierErrorSupplier(@Nullable Function<ModifierKeyCode, Optional<Text>> errorSupplier) {
+    public KeyCodeBuilder setModifierErrorSupplier(@Nullable Function<ModifierKeyCode, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -63,11 +62,11 @@ public class KeyCodeBuilder extends FieldBuilder<ModifierKeyCode, KeyCodeEntry>
         return this;
     }
     
-    public KeyCodeBuilder setSaveConsumer(Consumer<InputUtil.KeyCode> saveConsumer) {
+    public KeyCodeBuilder setSaveConsumer(Consumer<InputConstants.Key> saveConsumer) {
         return setModifierSaveConsumer(keyCode -> saveConsumer.accept(keyCode.getKeyCode()));
     }
     
-    public KeyCodeBuilder setDefaultValue(Supplier<InputUtil.KeyCode> defaultValue) {
+    public KeyCodeBuilder setDefaultValue(Supplier<InputConstants.Key> defaultValue) {
         return setModifierDefaultValue(() -> ModifierKeyCode.of(defaultValue.get(), Modifier.none()));
     }
     
@@ -81,7 +80,7 @@ public class KeyCodeBuilder extends FieldBuilder<ModifierKeyCode, KeyCodeEntry>
         return this;
     }
     
-    public KeyCodeBuilder setDefaultValue(InputUtil.KeyCode defaultValue) {
+    public KeyCodeBuilder setDefaultValue(InputConstants.Key defaultValue) {
         return setDefaultValue(ModifierKeyCode.of(defaultValue, Modifier.none()));
     }
     
@@ -90,26 +89,26 @@ public class KeyCodeBuilder extends FieldBuilder<ModifierKeyCode, KeyCodeEntry>
         return this;
     }
     
-    public KeyCodeBuilder setTooltipSupplier(@NotNull Function<InputUtil.KeyCode, Optional<Text[]>> tooltipSupplier) {
+    public KeyCodeBuilder setTooltipSupplier(@NotNull Function<InputConstants.Key, Optional<Component[]>> tooltipSupplier) {
         return setModifierTooltipSupplier(keyCode -> tooltipSupplier.apply(keyCode.getKeyCode()));
     }
     
-    public KeyCodeBuilder setModifierTooltipSupplier(@NotNull Function<ModifierKeyCode, Optional<Text[]>> tooltipSupplier) {
+    public KeyCodeBuilder setModifierTooltipSupplier(@NotNull Function<ModifierKeyCode, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public KeyCodeBuilder setTooltipSupplier(@NotNull Supplier<Optional<Text[]>> tooltipSupplier) {
+    public KeyCodeBuilder setTooltipSupplier(@NotNull Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = bool -> tooltipSupplier.get();
         return this;
     }
     
-    public KeyCodeBuilder setTooltip(Optional<Text[]> tooltip) {
+    public KeyCodeBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = bool -> tooltip;
         return this;
     }
     
-    public KeyCodeBuilder setTooltip(@Nullable Text... tooltip) {
+    public KeyCodeBuilder setTooltip(@Nullable Component... tooltip) {
         this.tooltipSupplier = bool -> Optional.ofNullable(tooltip);
         return this;
     }

+ 8 - 8
src/main/java/me/shedaniel/clothconfig2/impl/builders/LongFieldBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/LongFieldBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.LongListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Optional;
@@ -15,16 +15,16 @@ import java.util.function.Supplier;
 public class LongFieldBuilder extends FieldBuilder<Long, LongListEntry> {
     
     private Consumer<Long> saveConsumer = null;
-    private Function<Long, Optional<Text[]>> tooltipSupplier = l -> Optional.empty();
+    private Function<Long, Optional<Component[]>> tooltipSupplier = l -> Optional.empty();
     private final long value;
     private Long min = null, max = null;
     
-    public LongFieldBuilder(Text resetButtonKey, Text fieldNameKey, long value) {
+    public LongFieldBuilder(Component resetButtonKey, Component fieldNameKey, long value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public LongFieldBuilder setErrorSupplier(Function<Long, Optional<Text>> errorSupplier) {
+    public LongFieldBuilder setErrorSupplier(Function<Long, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -49,22 +49,22 @@ public class LongFieldBuilder extends FieldBuilder<Long, LongListEntry> {
         return this;
     }
     
-    public LongFieldBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public LongFieldBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = l -> tooltipSupplier.get();
         return this;
     }
     
-    public LongFieldBuilder setTooltipSupplier(Function<Long, Optional<Text[]>> tooltipSupplier) {
+    public LongFieldBuilder setTooltipSupplier(Function<Long, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public LongFieldBuilder setTooltip(Optional<Text[]> tooltip) {
+    public LongFieldBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = l -> tooltip;
         return this;
     }
     
-    public LongFieldBuilder setTooltip(Text... tooltip) {
+    public LongFieldBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = l -> Optional.ofNullable(tooltip);
         return this;
     }

+ 15 - 15
src/main/java/me/shedaniel/clothconfig2/impl/builders/LongListBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/LongListBuilder.java

@@ -3,8 +3,8 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.LongListListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
@@ -17,31 +17,31 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class LongListBuilder extends FieldBuilder<List<Long>, LongListListEntry> {
     
-    protected Function<Long, Optional<Text>> cellErrorSupplier;
+    protected Function<Long, Optional<Component>> cellErrorSupplier;
     private Consumer<List<Long>> saveConsumer = null;
-    private Function<List<Long>, Optional<Text[]>> tooltipSupplier = list -> Optional.empty();
+    private Function<List<Long>, Optional<Component[]>> tooltipSupplier = list -> Optional.empty();
     private final List<Long> value;
     private boolean expanded = false;
     private Long min = null, max = null;
     private Function<LongListListEntry, LongListListEntry.LongListCell> createNewInstance;
-    private Text addTooltip = new TranslatableText("text.cloth-config.list.add"), removeTooltip = new TranslatableText("text.cloth-config.list.remove");
+    private Component addTooltip = new TranslatableComponent("text.cloth-config.list.add"), removeTooltip = new TranslatableComponent("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
     
-    public LongListBuilder(Text resetButtonKey, Text fieldNameKey, List<Long> value) {
+    public LongListBuilder(Component resetButtonKey, Component fieldNameKey, List<Long> value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public Function<Long, Optional<Text>> getCellErrorSupplier() {
+    public Function<Long, Optional<Component>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
     
-    public LongListBuilder setCellErrorSupplier(Function<Long, Optional<Text>> cellErrorSupplier) {
+    public LongListBuilder setCellErrorSupplier(Function<Long, Optional<Component>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
         return this;
     }
     
-    public LongListBuilder setErrorSupplier(Function<List<Long>, Optional<Text>> errorSupplier) {
+    public LongListBuilder setErrorSupplier(Function<List<Long>, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -56,12 +56,12 @@ public class LongListBuilder extends FieldBuilder<List<Long>, LongListListEntry>
         return this;
     }
     
-    public LongListBuilder setAddButtonTooltip(Text addTooltip) {
+    public LongListBuilder setAddButtonTooltip(Component addTooltip) {
         this.addTooltip = addTooltip;
         return this;
     }
     
-    public LongListBuilder setRemoveButtonTooltip(Text removeTooltip) {
+    public LongListBuilder setRemoveButtonTooltip(Component removeTooltip) {
         this.removeTooltip = removeTooltip;
         return this;
     }
@@ -122,22 +122,22 @@ public class LongListBuilder extends FieldBuilder<List<Long>, LongListListEntry>
         return this;
     }
     
-    public LongListBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public LongListBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
     
-    public LongListBuilder setTooltipSupplier(Function<List<Long>, Optional<Text[]>> tooltipSupplier) {
+    public LongListBuilder setTooltipSupplier(Function<List<Long>, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public LongListBuilder setTooltip(Optional<Text[]> tooltip) {
+    public LongListBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
     
-    public LongListBuilder setTooltip(Text... tooltip) {
+    public LongListBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }

+ 10 - 10
src/main/java/me/shedaniel/clothconfig2/impl/builders/LongSliderBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/LongSliderBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.LongSliderEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Optional;
@@ -15,20 +15,20 @@ import java.util.function.Supplier;
 public class LongSliderBuilder extends FieldBuilder<Long, LongSliderEntry> {
     
     private Consumer<Long> saveConsumer = null;
-    private Function<Long, Optional<Text[]>> tooltipSupplier = l -> Optional.empty();
+    private Function<Long, Optional<Component[]>> tooltipSupplier = l -> Optional.empty();
     private final long value;
     private final long max;
     private final long min;
-    private Function<Long, Text> textGetter = null;
+    private Function<Long, Component> textGetter = null;
     
-    public LongSliderBuilder(Text resetButtonKey, Text fieldNameKey, long value, long min, long max) {
+    public LongSliderBuilder(Component resetButtonKey, Component fieldNameKey, long value, long min, long max) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
         this.max = max;
         this.min = min;
     }
     
-    public LongSliderBuilder setErrorSupplier(Function<Long, Optional<Text>> errorSupplier) {
+    public LongSliderBuilder setErrorSupplier(Function<Long, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -38,7 +38,7 @@ public class LongSliderBuilder extends FieldBuilder<Long, LongSliderEntry> {
         return this;
     }
     
-    public LongSliderBuilder setTextGetter(Function<Long, Text> textGetter) {
+    public LongSliderBuilder setTextGetter(Function<Long, Component> textGetter) {
         this.textGetter = textGetter;
         return this;
     }
@@ -58,22 +58,22 @@ public class LongSliderBuilder extends FieldBuilder<Long, LongSliderEntry> {
         return this;
     }
     
-    public LongSliderBuilder setTooltipSupplier(Function<Long, Optional<Text[]>> tooltipSupplier) {
+    public LongSliderBuilder setTooltipSupplier(Function<Long, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public LongSliderBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public LongSliderBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = i -> tooltipSupplier.get();
         return this;
     }
     
-    public LongSliderBuilder setTooltip(Optional<Text[]> tooltip) {
+    public LongSliderBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = i -> tooltip;
         return this;
     }
     
-    public LongSliderBuilder setTooltip(Text... tooltip) {
+    public LongSliderBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = i -> Optional.ofNullable(tooltip);
         return this;
     }

+ 10 - 10
src/main/java/me/shedaniel/clothconfig2/impl/builders/SelectorBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/SelectorBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Objects;
@@ -16,19 +16,19 @@ import java.util.function.Supplier;
 public class SelectorBuilder<T> extends FieldBuilder<T, SelectionListEntry<T>> {
     
     private Consumer<T> saveConsumer = null;
-    private Function<T, Optional<Text[]>> tooltipSupplier = e -> Optional.empty();
+    private Function<T, Optional<Component[]>> tooltipSupplier = e -> Optional.empty();
     private final T value;
     private final T[] valuesArray;
-    private Function<T, Text> nameProvider = null;
+    private Function<T, Component> nameProvider = null;
     
-    public SelectorBuilder(Text resetButtonKey, Text fieldNameKey, T[] valuesArray, T value) {
+    public SelectorBuilder(Component resetButtonKey, Component fieldNameKey, T[] valuesArray, T value) {
         super(resetButtonKey, fieldNameKey);
         Objects.requireNonNull(value);
         this.valuesArray = valuesArray;
         this.value = value;
     }
     
-    public SelectorBuilder<T> setErrorSupplier(Function<T, Optional<Text>> errorSupplier) {
+    public SelectorBuilder<T> setErrorSupplier(Function<T, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -54,27 +54,27 @@ public class SelectorBuilder<T> extends FieldBuilder<T, SelectionListEntry<T>> {
         return this;
     }
     
-    public SelectorBuilder<T> setTooltipSupplier(Function<T, Optional<Text[]>> tooltipSupplier) {
+    public SelectorBuilder<T> setTooltipSupplier(Function<T, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public SelectorBuilder<T> setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public SelectorBuilder<T> setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = e -> tooltipSupplier.get();
         return this;
     }
     
-    public SelectorBuilder<T> setTooltip(Optional<Text[]> tooltip) {
+    public SelectorBuilder<T> setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = e -> tooltip;
         return this;
     }
     
-    public SelectorBuilder<T> setTooltip(Text... tooltip) {
+    public SelectorBuilder<T> setTooltip(Component... tooltip) {
         this.tooltipSupplier = e -> Optional.ofNullable(tooltip);
         return this;
     }
     
-    public SelectorBuilder<T> setNameProvider(Function<T, Text> enumNameProvider) {
+    public SelectorBuilder<T> setNameProvider(Function<T, Component> enumNameProvider) {
         this.nameProvider = enumNameProvider;
         return this;
     }

+ 8 - 8
src/main/java/me/shedaniel/clothconfig2/impl/builders/StringFieldBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/StringFieldBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.StringListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Objects;
@@ -16,16 +16,16 @@ import java.util.function.Supplier;
 public class StringFieldBuilder extends FieldBuilder<String, StringListEntry> {
     
     private Consumer<String> saveConsumer = null;
-    private Function<String, Optional<Text[]>> tooltipSupplier = str -> Optional.empty();
+    private Function<String, Optional<Component[]>> tooltipSupplier = str -> Optional.empty();
     private final String value;
     
-    public StringFieldBuilder(Text resetButtonKey, Text fieldNameKey, String value) {
+    public StringFieldBuilder(Component resetButtonKey, Component fieldNameKey, String value) {
         super(resetButtonKey, fieldNameKey);
         Objects.requireNonNull(value);
         this.value = value;
     }
     
-    public StringFieldBuilder setErrorSupplier(Function<String, Optional<Text>> errorSupplier) {
+    public StringFieldBuilder setErrorSupplier(Function<String, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -50,22 +50,22 @@ public class StringFieldBuilder extends FieldBuilder<String, StringListEntry> {
         return this;
     }
     
-    public StringFieldBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public StringFieldBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = str -> tooltipSupplier.get();
         return this;
     }
     
-    public StringFieldBuilder setTooltipSupplier(Function<String, Optional<Text[]>> tooltipSupplier) {
+    public StringFieldBuilder setTooltipSupplier(Function<String, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public StringFieldBuilder setTooltip(Optional<Text[]> tooltip) {
+    public StringFieldBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = str -> tooltip;
         return this;
     }
     
-    public StringFieldBuilder setTooltip(Text... tooltip) {
+    public StringFieldBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = str -> Optional.ofNullable(tooltip);
         return this;
     }

+ 15 - 16
src/main/java/me/shedaniel/clothconfig2/impl/builders/StringListBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/StringListBuilder.java

@@ -3,9 +3,8 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.StringListListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.resource.language.I18n;
-import net.minecraft.text.Text;
-import net.minecraft.text.TranslatableText;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
@@ -18,30 +17,30 @@ import java.util.function.Supplier;
 @Environment(EnvType.CLIENT)
 public class StringListBuilder extends FieldBuilder<List<String>, StringListListEntry> {
     
-    private Function<String, Optional<Text>> cellErrorSupplier;
+    private Function<String, Optional<Component>> cellErrorSupplier;
     private Consumer<List<String>> saveConsumer = null;
-    private Function<List<String>, Optional<Text[]>> tooltipSupplier = list -> Optional.empty();
+    private Function<List<String>, Optional<Component[]>> tooltipSupplier = list -> Optional.empty();
     private final List<String> value;
     private boolean expanded = false;
     private Function<StringListListEntry, StringListListEntry.StringListCell> createNewInstance;
-    private Text addTooltip = new TranslatableText("text.cloth-config.list.add"), removeTooltip = new TranslatableText("text.cloth-config.list.remove");
+    private Component addTooltip = new TranslatableComponent("text.cloth-config.list.add"), removeTooltip = new TranslatableComponent("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
     
-    public StringListBuilder(Text resetButtonKey, Text fieldNameKey, List<String> value) {
+    public StringListBuilder(Component resetButtonKey, Component fieldNameKey, List<String> value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
     
-    public Function<String, Optional<Text>> getCellErrorSupplier() {
+    public Function<String, Optional<Component>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
     
-    public StringListBuilder setCellErrorSupplier(Function<String, Optional<Text>> cellErrorSupplier) {
+    public StringListBuilder setCellErrorSupplier(Function<String, Optional<Component>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
         return this;
     }
     
-    public StringListBuilder setErrorSupplier(Function<List<String>, Optional<Text>> errorSupplier) {
+    public StringListBuilder setErrorSupplier(Function<List<String>, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -56,12 +55,12 @@ public class StringListBuilder extends FieldBuilder<List<String>, StringListList
         return this;
     }
     
-    public StringListBuilder setAddButtonTooltip(Text addTooltip) {
+    public StringListBuilder setAddButtonTooltip(Component addTooltip) {
         this.addTooltip = addTooltip;
         return this;
     }
     
-    public StringListBuilder setRemoveButtonTooltip(Text removeTooltip) {
+    public StringListBuilder setRemoveButtonTooltip(Component removeTooltip) {
         this.removeTooltip = removeTooltip;
         return this;
     }
@@ -102,22 +101,22 @@ public class StringListBuilder extends FieldBuilder<List<String>, StringListList
         return this;
     }
     
-    public StringListBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public StringListBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
     
-    public StringListBuilder setTooltipSupplier(Function<List<String>, Optional<Text[]>> tooltipSupplier) {
+    public StringListBuilder setTooltipSupplier(Function<List<String>, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public StringListBuilder setTooltip(Optional<Text[]> tooltip) {
+    public StringListBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
     
-    public StringListBuilder setTooltip(Text... tooltip) {
+    public StringListBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }

+ 7 - 7
src/main/java/me/shedaniel/clothconfig2/impl/builders/SubCategoryBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/SubCategoryBuilder.java

@@ -5,7 +5,7 @@ import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
 import me.shedaniel.clothconfig2.gui.entries.SubCategoryListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
@@ -17,10 +17,10 @@ import java.util.function.Supplier;
 public class SubCategoryBuilder extends FieldBuilder<Object, SubCategoryListEntry> implements List<AbstractConfigListEntry> {
     
     private final List<AbstractConfigListEntry> entries;
-    private Function<List<AbstractConfigListEntry>, Optional<Text[]>> tooltipSupplier = list -> Optional.empty();
+    private Function<List<AbstractConfigListEntry>, Optional<Component[]>> tooltipSupplier = list -> Optional.empty();
     private boolean expanded = false;
     
-    public SubCategoryBuilder(Text resetButtonKey, Text fieldNameKey) {
+    public SubCategoryBuilder(Component resetButtonKey, Component fieldNameKey) {
         super(resetButtonKey, fieldNameKey);
         this.entries = Lists.newArrayList();
     }
@@ -30,22 +30,22 @@ public class SubCategoryBuilder extends FieldBuilder<Object, SubCategoryListEntr
         throw new UnsupportedOperationException();
     }
     
-    public SubCategoryBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public SubCategoryBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
     
-    public SubCategoryBuilder setTooltipSupplier(Function<List<AbstractConfigListEntry>, Optional<Text[]>> tooltipSupplier) {
+    public SubCategoryBuilder setTooltipSupplier(Function<List<AbstractConfigListEntry>, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public SubCategoryBuilder setTooltip(Optional<Text[]> tooltip) {
+    public SubCategoryBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
     
-    public SubCategoryBuilder setTooltip(Text... tooltip) {
+    public SubCategoryBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }

+ 8 - 8
src/main/java/me/shedaniel/clothconfig2/impl/builders/TextDescriptionBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/TextDescriptionBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.TextListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -11,13 +11,13 @@ import java.util.Optional;
 import java.util.function.Supplier;
 
 @Environment(EnvType.CLIENT)
-public class TextDescriptionBuilder extends FieldBuilder<Text, TextListEntry> {
+public class TextDescriptionBuilder extends FieldBuilder<Component, TextListEntry> {
     
     private int color = -1;
-    @Nullable private Supplier<Optional<Text[]>> tooltipSupplier = null;
-    private final Text value;
+    @Nullable private Supplier<Optional<Component[]>> tooltipSupplier = null;
+    private final Component value;
     
-    public TextDescriptionBuilder(Text resetButtonKey, Text fieldNameKey, Text value) {
+    public TextDescriptionBuilder(Component resetButtonKey, Component fieldNameKey, Component value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
@@ -27,17 +27,17 @@ public class TextDescriptionBuilder extends FieldBuilder<Text, TextListEntry> {
         throw new UnsupportedOperationException();
     }
     
-    public TextDescriptionBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public TextDescriptionBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public TextDescriptionBuilder setTooltip(Optional<Text[]> tooltip) {
+    public TextDescriptionBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = () -> tooltip;
         return this;
     }
     
-    public TextDescriptionBuilder setTooltip(Text... tooltip) {
+    public TextDescriptionBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = () -> Optional.ofNullable(tooltip);
         return this;
     }

+ 8 - 8
src/main/java/me/shedaniel/clothconfig2/impl/builders/TextFieldBuilder.java → common/src/main/java/me/shedaniel/clothconfig2/impl/builders/TextFieldBuilder.java

@@ -3,7 +3,7 @@ package me.shedaniel.clothconfig2.impl.builders;
 import me.shedaniel.clothconfig2.gui.entries.StringListEntry;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Objects;
@@ -16,16 +16,16 @@ import java.util.function.Supplier;
 public class TextFieldBuilder extends FieldBuilder<String, StringListEntry> {
     
     private Consumer<String> saveConsumer = null;
-    private Function<String, Optional<Text[]>> tooltipSupplier = str -> Optional.empty();
+    private Function<String, Optional<Component[]>> tooltipSupplier = str -> Optional.empty();
     private final String value;
     
-    public TextFieldBuilder(Text resetButtonKey, Text fieldNameKey, String value) {
+    public TextFieldBuilder(Component resetButtonKey, Component fieldNameKey, String value) {
         super(resetButtonKey, fieldNameKey);
         Objects.requireNonNull(value);
         this.value = value;
     }
     
-    public TextFieldBuilder setErrorSupplier(Function<String, Optional<Text>> errorSupplier) {
+    public TextFieldBuilder setErrorSupplier(Function<String, Optional<Component>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
@@ -50,22 +50,22 @@ public class TextFieldBuilder extends FieldBuilder<String, StringListEntry> {
         return this;
     }
     
-    public TextFieldBuilder setTooltipSupplier(Supplier<Optional<Text[]>> tooltipSupplier) {
+    public TextFieldBuilder setTooltipSupplier(Supplier<Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = str -> tooltipSupplier.get();
         return this;
     }
     
-    public TextFieldBuilder setTooltipSupplier(Function<String, Optional<Text[]>> tooltipSupplier) {
+    public TextFieldBuilder setTooltipSupplier(Function<String, Optional<Component[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
     
-    public TextFieldBuilder setTooltip(Optional<Text[]> tooltip) {
+    public TextFieldBuilder setTooltip(Optional<Component[]> tooltip) {
         this.tooltipSupplier = str -> tooltip;
         return this;
     }
     
-    public TextFieldBuilder setTooltip(Text... tooltip) {
+    public TextFieldBuilder setTooltip(Component... tooltip) {
         this.tooltipSupplier = str -> Optional.ofNullable(tooltip);
         return this;
     }

+ 0 - 0
src/main/java/me/shedaniel/math/api/Executor.java → common/src/main/java/me/shedaniel/math/api/Executor.java


+ 4 - 4
src/main/java/me/shedaniel/math/impl/PointHelper.java → common/src/main/java/me/shedaniel/math/impl/PointHelper.java

@@ -3,14 +3,14 @@ package me.shedaniel.math.impl;
 import me.shedaniel.math.Point;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.Minecraft;
 
 @Environment(EnvType.CLIENT)
 public class PointHelper {
     public static Point ofMouse() {
-        MinecraftClient client = MinecraftClient.getInstance();
-        double mx = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
-        double my = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
+        Minecraft client = Minecraft.getInstance();
+        double mx = client.mouseHandler.xpos() * (double) client.getWindow().getGuiScaledWidth() / (double) client.getWindow().getScreenWidth();
+        double my = client.mouseHandler.ypos() * (double) client.getWindow().getGuiScaledHeight() / (double) client.getWindow().getScreenHeight();
         return new Point(mx, my);
     }
     

Some files were not shown because too many files changed in this diff